Tensorflow.js tf.layers computeOutputShape() Method Last Updated : 22 Apr, 2022 Comments Improve Suggest changes Like Article Like Report Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .computeOutputShape() function is used to enumerate the output shape of the stated layer. And it presumes that the layer will be created in order to match the supplied input shape. Syntax: computeOutputShape(inputShape) Parameters: inputShape: It is the stated shape i.e. set of integers or a list of sets of shape. Moreover the Shape tuples can contain void in favor of free sizes, in place of an integer. It can of type ((null | number)[]|(null | number)[][]). Return Value: It returns (null | number)[]|(null | number)[][]. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Creating a model const model = tf.sequential(); // Adding a layer model.add(tf.layers.dense({units: 1, inputShape: [3]})); // Defining inputShape const inputShape = [6, 2, 6]; // Calling computeOutputShape() method with its // parameter const val = model.layers[0].computeOutputShape(inputShape); // Printing output console.log(val); Output: 6,2,1 Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Creating a model const model = tf.sequential(); // Adding layers model.add(tf.layers.dense({units: 1, inputShape: [3]})); model.add(tf.layers.dense({units: 5})); // Defining inputShape const inputShape1 = [6, 2, 6, null]; const inputShape2 = [6.5, 2.6, 9.1, NaN]; // Calling computeOutputShape() method with its // parameter const val1 = model.layers[0].computeOutputShape(inputShape1); const val2 = model.layers[1].computeOutputShape(inputShape2); // Printing output console.log(val1); console.log(val2); Output: 6,2,6,1 6.5,2.6,9.1,5 Reference: https://js.tensorflow.org/api/latest/#tf.layers.Layer.computeOutputShape Comment More infoAdvertise with us Next Article Tensorflow.js tf.layers computeOutputShape() Method nidhi1352singh Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js TensorFlow.js-Classes TensorFlow.js-layers +1 More Similar Reads Tensorflow.js tf.layers apply() Method 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.layers apply() method is used to execute the Layers computation and return Tensor(s) when we call it with the tf.Tensor(s). If 1 min read Tensorflow.js tf.layers getWeights() Method 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. It also helps the developers to develop ML models in JavaScript language and can use ML directly in the browser or in Node.js. The tf. 2 min read Tensorflow.js tf.layers addLoss() Method Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .addLoss() function is used to attach losses to the stated layer. Moreover, the loss might be probably conditional 2 min read Tensorflow.js tf.layers build() Method Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .build() function is used to create the weights of the layer stated. This method should be applied on every layers 2 min read Tensorflow.js tf.LayersModel Class .evaluate() Method Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .evaluate() function is used to find the measure of loss and the values of metrics in favor of the prototype in tes 3 min read Tensorflow.js tf.LayersModel class .getLayer() Method Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .getLayer() function is used to fetch a layer that is based upon either its name (which must be unique) or else an 2 min read Tensorflow.js tf.LayersModel class .evaluateDataset() Method Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .evaluateDataset() function is used to evaluate the stated model by means of a stated dataset object. Note: This me 3 min read Tensorflow.js tf.LayersModel Class 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. Tensorflow. js tf.LayerModel class is used to training, interface and evaluation of model. It have many method for training, evaluatio 2 min read Tensorflow.js tf.layers.inputLayer() Function Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The tf.layers.inputLayer() function is an inlet point towards a tf.LayersModel. It is produced spontaneously in favor o 2 min read Tensorflow.js tf.LayersModel class .predict() Method Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .predict() function is used to produce the output estimates for the given input instances. Moreover, the calculatio 2 min read Like