Tensorflow.js是Google開發的開源庫,用於在瀏覽器或節點環境中運行機器學習模型和深度學習神經網絡。
tf.avgPool3d()函數用於計算3D平均池。
用法:
tf.avgPool3d(x, filterSize, strides, pad,
dimRoundingMode?, dataFormat?)
參數:此函數接受如下所示的參數:
- x:指定的輸入張量為等級5或等級4。
- filterSize:這指定filterDepth,filterHeight,filterWidth。如果指定的filterSize是單個數字,則filterWidth == filterHeight == filterDepth。
- strides:指定池的跨步:[strideDepth,strideHeight,strideWidth]。如果指定的步幅是單個數字,則strideWidth == strideHeight == strideDepth。
- pad:這指定了填充算法的類型。
- dimRoundingMode:這是可選的。這指定了以下字符串:‘ceil’,“ round”,‘floor’。如果未提供任何內容,則它將默認將其值截斷。
- dataFormat:這是可選的。這指定輸出和輸入數據的數據格式。
返回值:它返回張量元素的3D平均合並。
以下示例說明了avgPool3d()函數的用法。
範例1:
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Initializing a tensor of some elements
let geek = tf.tensor5d([10, 11, 12, 13, 14, 15, 16, 17],
[1, 2, 2, 2, 1]);
// Calling the .avgPool3d() function over
// the above tensor as its parameter
let outcome = tf.avgPool3d(geek, 2, 1, 'valid');
//Printing the result.
outcome.print();
輸出:
Tensor [ [ [ [[13.5],]]]]
範例2:
Javascript
// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
// Initializing a tensor of some elements
let geek = tf.tensor5d([51, 52, 53, 54], [2, 1, 1, 1, 2]);
// Calling the .avgPool3d() function and
// printing the result.
tf.avgPool3d(geek, 1, 2, 'valid').print();
輸出:
Tensor [ [ [ [[51, 52],]]], [ [ [[53, 54],]]]]
相關用法
- 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()用法及代碼示例
注:本文由純淨天空篩選整理自thacker_shahid大神的英文原創作品 Tensorflow.js tf.avgPool3d() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。