Tensorflow.js是Google開發的開源庫,用於在瀏覽器或節點環境中運行機器學習模型和深度學習神經網絡。它還可以幫助開發人員使用JavaScript語言開發ML模型,並可以直接在瀏覽器或Node.js中使用ML。
tf.initializers.leCunNormal() 函數從以零為中心且 stddev = sqrt(1 /fanIn) 的截斷正態分布中提取樣本。請注意,fanIn 是張量權重中的輸入數量。
用法:
tf.initializers.leCunNormal(arguments).
參數:
- arguments:它是一個包含種子(一個數字)的對象,它是隨機數生成器的種子/數字。
返回值:它返回 tf.initializers.Initializer。
範例1:
Javascript
// Importing the tensorflow.Js library
import * as tf from "@tensorflow/tfjs"
// Initializing the .initializers.leCunNormal() function
const geek = tf.initializers.leCunNormal(3)
// Printing gain
console.log(geek);
console.log('\nIndividual values:\n');
console.log(geek.scale);
console.log(geek.mode);
console.log(geek.distribution);
輸出:
{ "scale":1, "mode":"fanIn", "distribution":"normal" } Individual values: 1 fanIn normal
範例2:
Javascript
// Importing the tensorflow.Js library
import * as tf from "@tensorflow/tfjs"
// Defining the input value
let inputValue = tf.input({ shape:[4] });
// Initializing tf.initializers.leCunNormal()
// function
let funcValue = tf.initializers.leCunNormal(7)
// Creating dense layer 1
let dense_layer_1 = tf.layers.dense({
units:5,
activation:'relu',
kernelInitialize:funcValue
});
// Creating dense layer 2
let dense_layer_2 = tf.layers.dense({
units:7,
activation:'softmax'
});
// Output
let outputValue = dense_layer_2.apply(
dense_layer_1.apply(inputValue)
);
// Creation the model.
let model = tf.model({
inputs:inputValue,
outputs:outputValue
});
// Predicting the output
let finalOutput = model.predict(tf.ones([2, 4]));
finalOutput.print();
輸出:
Tensor [[0.0666204, 0.1171203, 0.2322821, 0.1056982, 0.2149536, 0.1846998, 0.0786256], [0.0666204, 0.1171203, 0.2322821, 0.1056982, 0.2149536, 0.1846998, 0.0786256]]
參考:https://js.tensorflow.org/api/latest/#initializers.leCunNormal
相關用法
- 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()用法及代碼示例
- PHP cal_to_jd()用法及代碼示例
注:本文由純淨天空篩選整理自cyber_psych0大神的英文原創作品 Tensorflow.js tf.initializers.leCunNormal() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。