Tensorflow.js tf.separableConv2d() Function Last Updated : 30 Sep, 2021 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 .separableConv2d() function is used to determine a 2D complication along with filters that are separable. It executes a depthwise complication which works distinctly on channels pursued by means of a pointwise complexity which is helpful in mixing channels. Moreover, it specifies separability within [1, 2] and 3 dimensions, absolutely not structural separability within 1 and 2 dimensions. Syntax: tf.separableConv2d(x, depthwiseFilter, pointwiseFilter, strides, pad, dilation?, 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.depthwiseFilter: The stated depthwise filter tensor of rank 4 and shape: [filterHeight, filterWidth, inChannels, channelMultiplier]. However, it is utilized in the initial stage. It can be of type tf.Tensor4D, TypedArray, or Array.pointwiseFilter: The stated pointwise filter tensor of rank 4 and shape: [1, 1, inChannels * channelMultiplier, outChannels]. However, it is utilized in the second stage of the operation. It can be of type tf.Tensor4D, TypedArray, or Array.strides: The stated strides of the complication of shape: [strideHeight, strideWidth]. In case, the stated strides is a singular 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’ along with stride 1, the output would have an 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 greater than 1*1×1.dilation: The stated dilation. It is optional and is of type [number, number], or number.dataFormat: The stated elective string from “NHWC”, or “NCHW”. It specifies the data shape of the stated input as well as output data. The by default value is ‘NHWC’. Moreover, the data here is saved in the following order: [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.tensor4d([1, 2, 3, 4], [1, 1, 2, 2]); // Defining depthwise filter tensor const y = tf.tensor4d([1, 1, 0, 4], [1, 1, 2, 2]); // Defining pointwise filter tensor const z = tf.tensor4d([1, 1, 0, 4], [1, 1, 4, 1]); // Calling separableConv2d() method const result = tf.separableConv2d(x, y, z, 2, 'valid'); // Printing output result.print(); Output: Tensor [ [ [[34],]]] Example 2: Javascript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Calling separableConv2d() method tf.separableConv2d( tf.tensor4d([1.1, 2.2, 3.3, 4.4], [1, 1, 2, 2]), tf.tensor4d([1.2, 1.1, 0.3, 4.5], [1, 1, 2, 2]), tf.tensor4d([1.4, 1.6, 0.5, 4.8], [1, 1, 4, 1]), 1, 'same', 1, 'NHWC').print(); Output: Tensor [[[[51.6340065 ], [107.0520096]]]] Reference: https://js.tensorflow.org/api/latest/#separableConv2d Comment More infoAdvertise with us Next Article Tensorflow.js tf.scatterND() Function nidhi1352singh Follow Improve Article Tags : JavaScript Web Technologies Similar Reads Tensorflow.js tf.layers.separableConv2d() 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 in Node.js. The tf. 4 min read Tensorflow.js tf.prod() 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.prod() function is used to calculate product of the elements of a specified Tensor across its dimension. It reduces the given i 2 min read Tensorflow.js tf.pad() 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 in Node.js. The tf. 2 min read Tensorflow.js tf.scatterND() 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 .scatterND() function is used to form a different tensor by utilizing scattered updates to the individual slices or 2 min read Tensorflow.js tf.sparseToDense() 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.sparseToDense() function is used to convert a specified sparse representation into a dense Tensor. If the given indices get rep 2 min read Tensorflow.js tf.step() 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.step() function is used to return the step of the input tensor's elements i.e. it returns 1 if the element is greater than 0 el 2 min read Tensorflow.js tf.mean() 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.mean() function is used to calculate the mean value of the specified Tensor across its dimension. It reduces the given input el 2 min read Tensorflow.js tf.square() 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.square() function is used to return the square of the specified tensor's elements. Syntax: tf.square(x) Parameters: This functi 1 min read Tensorflow.js tf.selu() 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 .selu() function is used to find the scaled exponential linear and is done element wise. Syntax: Â tf.selu(x) Where 1 min read Tensorflow.js tf.spaceToBatchND() 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.spaceToBatchND() function is used to split the spatial dimensions of the specified input space into a matrix of blocks having s 2 min read Like