Tensorflow.js是一個開放源代碼庫,由Google開發,用於在瀏覽器或節點環境中運行機器學習模型以及深度學習神經網絡。
.encodeString()函數用於在給定的編碼方案的幫助下將聲明的字符串編碼為字節。
用法:
tf.encodeString(s, encoding?)
Parameters:
- s:是要編碼的指定字符串。它是字符串類型。
- encoding:這是要使用的編碼方案。並且默認值是utf-8。
返回值:它返回Uint8Array。
範例1:未提供編碼方案時。
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Calling tf.encodeString() method and
// printing output
console.log(tf.util.encodeString("fghi"));
輸出:
102,103,104,105
範例2:提供編碼方案時。
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Definging string and encoding
// scheme
var str = "1234"
var encoding = "utf-8"
// Calling tf.encodeString() method and
// printing output
var x = tf.util.encodeString(str, encoding);
console.log(x);
輸出:
49,50,51,52
相關用法
- PHP imagecreatetruecolor()用法及代碼示例
- p5.js year()用法及代碼示例
- d3.js d3.utcTuesdays()用法及代碼示例
- PHP ImagickDraw getTextAlignment()用法及代碼示例
- PHP Ds\Sequence last()用法及代碼示例
- PHP array_udiff_uassoc()用法及代碼示例
- PHP geoip_continent_code_by_name()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- PHP GmagickPixel setcolor()用法及代碼示例
- PHP opendir()用法及代碼示例
- PHP cal_to_jd()用法及代碼示例
- d3.js d3.bisectLeft()用法及代碼示例
- PHP stream_get_transports()用法及代碼示例
- PHP Ds\Deque pop()用法及代碼示例
- PHP SimpleXMLElement children()用法及代碼示例
- p5.js removeElements()用法及代碼示例
注:本文由純淨天空篩選整理自nidhi1352singh大神的英文原創作品 Tensorflow.js tf.encodeString() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。