Tensorflow.js是Google开发的开源库,用于在浏览器或节点环境中运行机器学习模型和深度学习神经网络。
tf.batchToSpaceND() 函数用于将给定的 “batch” 从零维重构为具有“block-Shape + [batch]”形状的 “M+1” 维,其中 block-Shape 是参数,batch 是指定的张量。这里根据给定的裁剪数组对 in-between 结果进行裁剪。
tf.batchToSpaceND (x, blockShape, crops)
参数:此函数接受三个参数,如下所示:
- x:N-Dimension 的指定批张量,其形状为“[batch] + spatialShape + resumeShape”,其中 spatialShape 为 M 维。
- blockShape:一维数组的形状必须为 [M],因为所有值都必须大于或等于 1。
- crops:[M, 2] 的二维数组形状,其中所有值必须大于或等于 0。这里的crop[i] = [cropStart,cropEnd] 定义了从输入维度 i + 1 裁剪的部分。
返回值:它返回指定批次的重塑版本的张量。
范例1:
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Initializing a 3D Tensor of batch to reshape
const x = tf.tensor3d([5, 10, 15, 20, 25], [5, 1, 1]);
// Initializing blockShape and crops parameter
const blockShape = [1, 1];
const crops = [[0, 0], [0, 0]];
// Calling the .batchToSpaceND() funtion over
// the above parameters and Tensor
x.batchToSpaceND(blockShape, crops).print();
输出:
Tensor [ [[5 ],], [[10],], [[15],], [[20],], [[25],]]
范例2:
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Initializing a 4D Tensor of batch to restructure
const x = tf.tensor4d([0, 2, 4, 6, 8, 10], [6, 1, 1, 1]);
// Using the blockShape and crops as the parameter
// for the .batchToSpaceND() funtion
x.batchToSpaceND([3, 2], [[0, 0], [0, 0]]).print();
输出:
Tensor [[[[0 ], [2 ]], [[4 ], [6 ]], [[8 ], [10]]]]
相关用法
- PHP imagecreatetruecolor()用法及代码示例
- p5.js year()用法及代码示例
- d3.js d3.utcTuesdays()用法及代码示例
- PHP ImagickDraw getTextAlignment()用法及代码示例
- PHP Ds\Sequence last()用法及代码示例
- PHP Imagick floodFillPaintImage()用法及代码示例
- 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()用法及代码示例
注:本文由纯净天空筛选整理自Kanchan_Ray大神的英文原创作品 Tensorflow.js tf.batchToSpaceND() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。