当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Tensorflow.js tf.localResponseNormalization()用法及代码示例


Tensorflow.js是由Google开发的开源库,用于在浏览器或节点环境中运行机器学习模型以及深度学习神经网络。

.localResponseNormalization() 函数用于标准化通过通道或通道内部与局部邻域连接的刺激。

用法:

tf.localResponseNormalization (x, depthRadius?, bias?, alpha?, beta?)

Parameters: 

  • x:它是规定的输入张量。其中,4D 输入张量被视为参考具有最大尺寸的 1D 向量的 3D 数组。此外,每个向量都是单独标准化的。它可以是 tf.Tensor3D、tf.Tensor4D、TypedArray 或数组类型。
  • depthRadius:它是一维窗口标准化中规定的并排通道数。它是可选的,它是类型号。
  • bias:它是基数的恒定陈述偏差表达式。它是可选的,类型为 number。
  • alpha:规定的比例因子通常为正。它是可选的,类型为 number。
  • beta:它是指定的 index ,它是可选的并且是数字类型。

返回值:它返回 tf.Tensor3D 或 tf.Tensor4D。



范例1:

Javascript


// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
// Defining tf.tensor3d input
const x = tf.tensor3d([1, 2, 3, 4, 6, 6], [1, 2, 3]);
  
// Calling tf.localResponseNormalization() method
// and printing output
x.localResponseNormalization().print();

输出:

Tensor
    [[[0.2581989, 0.5163978, 0.7745967],
      [0.4239992, 0.6359987, 0.6359987]]]

范例2:

Javascript


// Importing the tensorflow.js library
// import * as tf from "@tensorflow/tfjs"
  
// Calling tf.localResponseNormalization() method
// and printing output
tf.localResponseNormalization(
    tf.tensor3d([1.1, 3.2, -3, null, 5, 0], 
    [1, 1, 6]), 4, 3, 2, 1).print();  

输出:

Tensor
     [ [[0.0117146, 0.0340788, -0.0319489, 0, 0.0532481, 0],]]

参考: https://js.tensorflow.org/api/latest/#localResponseNormalization

相关用法


注:本文由纯净天空筛选整理自nidhi1352singh大神的英文原创作品 Tensorflow.js tf.localResponseNormalization() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。