Tensorflow.js是Google開發的開源庫,用於在瀏覽器或節點環境中運行機器學習模型和深度學習神經網絡。
tf.spaceToBatchND() 函數用於將指定輸入空間的空間維度拆分為塊的矩陣,其形狀為 blockShape,其中 blockshape 是參數。這裏根據指定的填充數組填充空間維度。
用法:
tf.spaceToBatchND (x, blockShape, paddings)
參數:此函數接受三個參數,如下所示:
- x:N-Dimension 的指定張量,形狀為“[batch] + spatialShape + resumeShape”,其中 spatialShape 具有 M 維。
- blockShape:它是一維數組,必須具有 [M] 的形狀,因為所有值必須大於或等於 1。
- paddings:一個形狀為 [M, 2] 的二維數組,所有值必須大於或等於 0。這裏 padding 等於 [padStart, padEnd]。
返回值:它返回指定輸入空間的拆分版本的張量。
範例1:
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Initializing a Tensor
const x = tf.tensor4d(
[5, 10, 15, 20, 25, 30],
[1, 3, 2, 1]
);
// Initializing blockShape and paddings parameters
const blockShape = [1, 1];
const paddings = [[0, 0], [0, 0]];
// Calling the .spaceToBatchND() funtion over
// the above parameters and Tensor
x.spaceToBatchND(blockShape, paddings).print();
輸出:
Tensor [[[[5 ], [10]], [[15], [20]], [[25], [30]]]]
範例2:
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Initializing a Tensor
const x = tf.tensor4d([2, 4, 6, 8], [1, 2, 2, 1]);
// Using the blockShape and paddings as the
// parameter for the .spaceToBatchND() funtion
x.spaceToBatchND([2, 2], [[0, 0], [0, 0]]).print();
輸出:
Tensor [ [ [[2],]], [ [[4],]], [ [[6],]], [ [[8],]]]
相關用法
- 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.spaceToBatchND() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。