Tensorflow.js tf.layers.upSampling2d() Function Last Updated : 24 Apr, 2022 Comments Improve Suggest changes Like Article Like Report 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.layers.upSampling2d() function is used to repeat the rows and columns of the data by size[0] and size[1] respectively. upSampling2d is the Up-Sampling layer for 2D inputs. Syntax: tf.layers.upSampling2d( args ) Parameters: args: It accepts the object with the following fields:size: It is an array of numbers. It is the upSampling factor for rows and columns.dataFormat: It is the format of the data, which determines the ordering of the dimension in the inputs.interpolation: It defines the interpolation mechanism. It should be 'nearest' or bilinear'. Default value is 'nearest'.inputShape: It should be an array of numbers. This field is used to create an input layer which is used to be inserted before this layer.batchInputShape: It should be an array of numbers. This field will be used in place of inputShape for creating the input layer which is used to insert before this layer.batchSize: It should be a number. In the absence of batchInputShape this field is used to create batchInputShape with inputShape. batchInputShape : [ batchSize , ...inputShape].dtype: If this layer is used as the input layer, then this field is used as data-type for this layer.name: It should be a string type. this field defines the name for this layer.trainable: It should be boolean. This field defines whether the weights of this layer are trainable with fit or not.weights: This should be a tensor that defines the initial weight value for this layer.inputDType: This is a data type that is used for Legacy support. Parameters: It returns UpSampling2D. Example 1: JavaScript // Import the header file import * as tf from "@tensorflow/tfjs" // Creating upSampling2d layer const upSampling = tf.layers.upSampling2d({ size: [2, 1], batchInputShape: [2, 3, 5, 5] }); // Create an input with 2 time steps. const input = tf.input({shape: [2, 3, 3]}); const output = upSampling.apply(input); // Printing the Shape of file console.log(JSON.stringify(output.shape)); Output: [null, 4, 3, 3] Example 2: JavaScript // Import Header file import * as tf from "@tensorflow/tfjs" // Creating input layer const inputShape = [1, 1, 1, 2]; const input = tf.ones(inputShape); // Creating upSampling layer const layer = tf.layers.upSampling2d({size: [1,2]}); // Printing tensor const output = layer.apply(input); output.print(); Output: Tensor [[[[1, 1], [1, 1]]]] Reference: https://js.tensorflow.org/api/latest/#layers.upSampling2d Comment More infoAdvertise with us Next Article Tensorflow.js tf.layers.upSampling2d() Function S satyam00so Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.layers.zeroPadding2d() Function 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.zeroPadding2d( ) function is used for adding rows and columns for zeros at the top, bottom, left, and right side of and 3 min read Tensorflow.js tf.layers.elu() Function 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 Node.js. The tf.lay 2 min read Tensorflow.js tf.layers.dot() Function 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.layers.dot() function is used to apply the dot product between the two tensors provided. Syntax:Â tf.layers.dot(args) 3 min read Tensorflow.js tf.layers.timeDistributed() Function 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.timeDistributed() function is used to apply the wrap of a layer to every temporal slice of a specified input. The given 3 min read Tensorflow.js tf.layers.dense() Function The tf.layers.dense() is an inbuilt function of Tensorflow.js library. This function is used to create fully connected layers, in which every output depends on every input. Syntax: tf.layers.dense(args)Parameters: This function takes the args object as a parameter which can have the following proper 3 min read Tensorflow.js tf.layers.conv2d() Function Tensorflow.js is a Google-developed open-source toolkit for executing machine learning models and deep learning neural networks in the browser or on the node platform. It also enables developers to create machine learning models in JavaScript and utilize them directly in the browser or with Node.js. 3 min read Tensorflow.js tf.layers.conv1d() Function Tensorflow.js is a javascript library developed by Google to run and train machine learning models in the browser or in Node.js. Tensorflow.js tf.layers.conv1d() function is used to create convolution layer. It is used to applied 1d convolution to the input data. The convolutional layer is used to m 4 min read Tensorflow.js tf.layers.conv3d() Function Tensorflow.js is a Google-developed open-source toolkit for executing machine learning models and deep learning neural networks in the browser or on the node platform. It also enables developers to create machine learning models in JavaScript and utilize them directly in the browser or with Node.js. 3 min read Tensorflow.js tf.layers.flatten() Function 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.flatten() function is used to flatten the input, without affecting the batch size. A Flatten layer flattens each batch i 2 min read Tensorflow.js tf.layers.reshape() Function Tensorflow.js is an open-source library that is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The tf.layers.reshape() function is used to Reshape an input to a certain shape. Syntax: tf.layers.reshape(args) 2 min read Like