Tensorflow.js tf.maxPool3d() Function
Last Updated :
12 May, 2021
Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment.
The tf.maxPool3d() function is used compute the 3D max pooling.
Syntax:
tf.maxPool3d (x, filterSize, strides, pad,
dimRoundingMode?, dataFormat?)
Parameters: This function accepts a parameter which is illustrated below:
- x: This specifies the input tensor of rank 5 or rank 4.
- filterSize: This specifies filterDepth, filterHeight, filterWidth. If the specified filterSize is a single number, then filterWidth == filterHeight == filterDepth.
- strides: The specifies the strides of the pooling: [strideDepth, strideHeight, strideWidth]. If the specified strides is a single number, then strideWidth == strideHeight ==strideDepth .
- pad: This specifies the type of the padding algorithm.
- dimRoundingMode: This is optional. This specifies a string from: ‘ceil’, ’round’, ‘floor’. If nothing is provided, then it will default its value to truncate.
- dataFormat: This is optional. This specifies the data format of the output and input data.
Return Value: It returns the 3D max pooling of the tensor’s elements.
Example 1:
Javascript
import * as tf from "@tensorflow/tfjs"
let pool = tf.tensor5d([11, 12, 13, 14], [2, 1, 1, 1, 2]);
let output = tf.maxPool3d(pool, 1, 2, 'valid' );
output.print();
|
Output:
Tensor
[ [ [ [[11, 12],]]],
[ [ [[13, 14],]]]]
Example 2:
Javascript
import * as tf from "@tensorflow/tfjs"
let maxPool = tf.tensor5d([51, 52, 53, 54, 55, 56, 57, 58], [1, 2, 2, 2, 1]);
tf.avgPool3d(maxPool, 2, 1, 'valid' ).print();
|
Output:
Tensor
[ [ [ [[54.5],]]]]
Reference:https://js.tensorflow.org/api/3.6.0/#maxPool3d
Share your thoughts in the comments
Please Login to comment...