Tensorflow.js是由Google開發的開源庫,用於在瀏覽器或節點環境中運行機器學習模型以及深度學習神經網絡。
tf.layers.inputLayer() 函數是 tf.LayersModel 的入口點。它是通過定義 inputshape 或 batchInputShape 以支持第一層而自發產生的,以支持 tf.Sequentialmodels。它不能被特別定義。此外,例如,在從其他順序模型層的子集中創建順序模型時,它可以定期使用。
用法:
tf.layers.inputLayer(args)
Parameters:
- args:上述方法可以容納陳述的論點。它是 object 類型,它持有的參數如下所述。
- inputShape:不包括批次軸的所述輸入形狀。它可以是 (null | number)[] 類型。
- batchSize:它是規定的可選輸入批量大小。它可以是整數或空類型。
- batchInputShape:它是包含批軸的規定批輸入形狀。它可以是 (null | number)[] 類型。
- dtype:所述輸入的數據類型。它可以是 float32、int32、bool、complex64 或 string 類型。
- sparse:它說明創建的占位符是否是稀疏的。它是布爾值。
- name:正在使用的圖層的指定名稱。它是字符串類型。
返回值:它返回輸入層。
範例1:
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Defining a model
const model = tf.sequential();
// Calling layers.inputLayer() using add() method
model.add(tf.layers.inputLayer({inputShape:[4]}));
// Printing output
model.predict(tf.ones([1, 4])).print();
輸出:
Tensor [[1, 1, 1, 1],]
範例2:
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Defining a model
const model = tf.sequential();
// Calling layers.inputLayer() method using add() method
model.add(tf.layers.inputLayer({batchInputShape:[4],
dtype:'int32', sparse:false, name:'mlayer'}));
// Printing output
model.summary();
輸出:
_________________________________________________________________ Layer (type) Output shape Param # ================================================================= mlayer (InputLayer) [4] 0 ================================================================= Total params:0 Trainable params:0 Non-trainable params:0 _________________________________________________________________
參考: https://js.tensorflow.org/api/latest/#layers.inputLayer
相關用法
- PHP imagecreatetruecolor()用法及代碼示例
- p5.js year()用法及代碼示例
- d3.js d3.utcTuesdays()用法及代碼示例
- PHP ImagickDraw getTextAlignment()用法及代碼示例
- PHP Ds\Sequence last()用法及代碼示例
- PHP Imagick floodFillPaintImage()用法及代碼示例
- PHP geoip_continent_code_by_name()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- PHP GmagickPixel setcolor()用法及代碼示例
- Tensorflow.js tf.layers.embedding()用法及代碼示例
- PHP opendir()用法及代碼示例
- d3.js d3.bisectLeft()用法及代碼示例
注:本文由純淨天空篩選整理自nidhi1352singh大神的英文原創作品 Tensorflow.js tf.layers.inputLayer() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。