Tensorflow.js tf.dilation2d() Function Last Updated : 07 Jul, 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 .dilation2d() function is used to evaluate the grayscale dilation upon the stated input tensor. Syntax: tf.dilation2d(x, filter, strides, pad, dilations?, dataFormat?) Parameters: x: The stated input tensor which is either of rank 3 or else rank 4 and of shape: [batch, height, width, inChannels]. Moreover, in case the rank is 3, then the batch of size 1 is presumed. It can be of type tf.Tensor3D, tf.Tensor4D, TypedArray, or Array.filter: The stated filter tensor of rank 3 and shape: [filterHeight, filterWidth, depth]. It can be of type tf.Tensor3D, TypedArray, or Array.strides: The stated strides of the sliding window for each size of the given input tensor of shape: [strideHeight, strideWidth]. In case, stated strides is a single number, then strideHeight == strideWidth. It can be of type [number, number], or number.pad: The stated type of algorithm for padding. It can be of type valid or same.Here, for same and stride 1, the output would have identical size as input, irrespective of the filter size.For, 'valid' the output shall be smaller than the input in case, the filter size is larger than 1*1x1.dilations: The stated dilation rates: [dilationHeight, dilationWidth] in that the input values are sampled over the height as well as width dimensions in favor of atrous morphological dilation. The by default value is [1, 1]. Moreover, in case dilations is a single number, then dilationHeight == dilationWidth. And if its greater than 1, then all the values of the strides should be 1. It is optional and is of type [number, number], number.dataFormat: It specifies the data format of the stated input as well as output data. The by default value is 'NHWC'. Moreover, the data here is stored in the order of: [batch, height, width, channels]. It is optional and is of type 'NHWC'. Return Value: It returns tf.Tensor3D or tf.Tensor4D. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Defining input tensor const x = tf.tensor3d([1, 2, 3, 4], [2, 2, 1]); // Defining filter tensor const y = tf.tensor3d([1, 1, 0, 4], [1, 1, 4]); // Calling dilation2d() method const result = tf.dilation2d(x, y, 2, 'valid'); // Printing output result.print(); Output: Tensor [ [[2],]] Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Calling dilation2d() method with // all its parameters tf.tensor3d([1.1, 2.2, 3.3, 4.4], [2, 2, 1]).dilation2d( tf.tensor3d([1.3, 1.2, null, -4], [1, 1, 4]), 2, 'valid', [3, 2], 'NHWC').print(); Output: Tensor [ [[2.4000001],]] Reference: https://js.tensorflow.org/api/latest/#dilation2d Comment More infoAdvertise with us Next Article Tensorflow.js tf.dilation2d() Function nidhi1352singh Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.atan2() 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 .atan2() function is used to find the arctangent of the stated tensor inputs and is done element wise. Moreov 2 min read Tensorflow.js tf.conv2d() Function Tensorflow.js is a javascript library developed by Google to run and train machine learning models in the browser or in Node.js. The tf.conv2d() function is used to compute 2d convolutions over the given input. In a deep neural network, we use this convolution layer which creates a convolution kern 4 min read Tensorflow.js tf.atan() 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 .atan() function is used to find the atan of the stated tensor input and is done element wise. Syntax :  tf. 2 min read Tensorflow.js tf.asinh() 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 .asinh() function is used to find the inverse hyperbolic sin of the stated tensor input and is done elements 2 min read Tensorflow.js tf.depthwiseConv2d() Function Introduction: 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 .depthwiseConv2d() function is used to determine Depthwise 2D convolution. Moreover, for a given 4D 4 min read Like