Tensorflow.js tf.slice() Function Last Updated : 12 May, 2021 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.slice() function is used to extract a slice from tf.Tensor starting at coordinates 'begin' and is of size 'size'. Syntax: tf.slice (x, begin, size?) Parameters: x: the input tensor to slice form.begin: the coordinates to start the slice from.size: the size of the slice Return Value: It returns tf.Tensor. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" const x = tf.tensor1d([1, 2, 3, 4, 5, 6, 7]); x.slice([0], [4]).print(); Output: Tensor [1, 2, 3, 4] Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" const x = tf.tensor2d([1, 2, 3, 4, 5, 6], [2, 3]); x.slice([1, 0], [1, 2]).print(); Output: Tensor [1,2,3,4] Reference: https://js.tensorflow.org/api/latest/#slice Comment More infoAdvertise with us Next Article Tensorflow.js tf.slice() Function T taran910 Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.split() 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.onesLike() 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.onesLike() function is used to create a tf.Tensor with all elements set to 1 with the same shape as the given tensor. Syntax: t 1 min read Tensorflow.js tf.stridedSlice() 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 .stridedSlice() function is used to pull out a strided section of the stated input tensor. Note:< This function 3 min read Tensorflow.js tf.stack() 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 helps developers to develop ML models in JavaScript, and use ML directly in the browser or in Node.js. The tf.stack() function is u 2 min read Tensorflow.js tf.min() 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.min() function is used to calculate the minimum value from the specified Tensor across its dimension. It reduces the given inpu 2 min read Like