Tensorflow.js是由Google開發的開源庫,用於在瀏覽器或節點環境中運行機器學習模型以及深度學習神經網絡。
.mirrorPad()函數用於在鏡像填充的幫助下填充指定的張量輸入。而且,該方法對於實現焊盤的反射模式和對稱模式是有益的。
用法:
tf.mirrorPad(x, paddings, mode)
Parameters:
- x:它是要填充的指定張量,可以是tf.Tensor,TypedArray或Array類型。
- paddings:它是一個數組,其長度為R,即所述張量的順序。其中,所有元素形成一個長度為2的元組,即ints [padBefore,padAfter],該整數指定要用指定的張量的每種尺寸填充的程度。此外,在填充的反射模式下,填充部分應排除末端,而在填充的對稱模式下,填充部分不應排除末端。它是數組類型。
- mode:它指定填充的模式,即反射或對稱。它是字符串類型。
注意:
- 首先,如果規定的張量輸入為[4,5,6],填充為[0,1],則在填充和[4,5,5]的反射模式下,輸出為[4,5,6,5]。 [6,6]在對稱填充模式中。
- 其次,如果填充模式為反射模式,則padding [D,0]以及paddings [D,1]不得高於x.shape [D]-1,而如果padding模式為對稱模式,則paddings [D,0]和paddings [D,1]不得高於x.shape [D]。
返回值:它返回tf.Tensor對象。
範例1:
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Defining tensor input
const y = tf.tensor1d([4, 5, 6]);
// Defining paddings and mode of
// padding
const pading = [[0, 1]];
const mode = 'reflect';
// Calling tf.mirrorPad() method
var res = tf.mirrorPad(y, pading, mode);
// Printing output
res.print();
輸出:
Tensor [4, 5, 6, 5]
範例2:
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Calling tf.mirrorPad() method and
// Printing output
tf.mirrorPad(tf.tensor(
[2.4, 6.8, 9.3, 5.3]),
[[0, 2]], 'symmetric').print();
輸出:
Tensor [2.4000001, 6.8000002, 9.3000002, 5.3000002, 5.3000002, 9.3000002]
相關用法
- 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()用法及代碼示例
- PHP Ds\Deque pop()用法及代碼示例
注:本文由純淨天空篩選整理自nidhi1352singh大神的英文原創作品 Tensorflow.js tf.mirrorPad() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。