Tensorflow.js tf.util.sizeFromShape() Function
Tensorflow.js is an open-source library that is being develop by Google for running machine learning models as well as deep learning neural networks in the browser or node environment.
The .util.sizeFromShape() function is used to find the number of elements i.e. the size of the stated tensor input from the stated shape.
Syntax :
tf.util.sizeFromShape(shape)
Parameters:
- shape: It is the stated shape whose size is to be returned. It is of type number[].
Return Value: It returns a number.
Example 1:
Javascript
import * as tf from "@tensorflow/tfjs"
const sh = [5, 8, 1];
const num = tf.util.sizeFromShape(sh);
console.log(num);
|
Output:
40
Example 2:
Javascript
import * as tf from "@tensorflow/tfjs"
console.log(tf.util.sizeFromShape([1.4, 5.6, 9.0]));
|
Output:
70.55999999999999
Reference:https://js.tensorflow.org/api/1.0.0/#sizeFromShape
Last Updated :
02 Jul, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...