Tensorflow.js tf.split() Function Last Updated : 10 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.split() function is used to split a tf.tensors into sub tensors. Syntax: tf.split (x, numOrSizeSplits, axis?) Parameters: x: The input tensor to split.numOrSizeSplits: It can be a number indicating the number of splits or can be the array in which sizes are provided for each output tensoraxis: It is an axis of the dimension along which to split. Return Value: It returns tf.Tensor[]. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" const x = tf.tensor2d([10, 20, 50, 60, 30, 40, 70, 80], [2, 4]); // Split the tensor const [gfg, geeks] = tf.split(x, 2, 1); gfg.print(); geeks.print(); Output: Tensor [[10, 20], [30, 40]] Tensor [[50, 60], [70, 80]] Example 2: In this example, making the split with axis as the 2nd parameter as an array. JavaScript const x = tf.tensor2d([10, 30, 50, 70, 20, 40, 60, 80], [2, 4]); const [gfg, gfg1, geeks] = tf.split(x, [1, 2, 1], 1); gfg.print(); gfg1.print(); geeks.print(); Output: Tensor [[10], [20]] Tensor [[30, 50], [40, 60]] Tensor [[70], [80]] Reference: https://js.tensorflow.org/api/latest/#split Comment More infoAdvertise with us Next Article Tensorflow.js tf.split() Function T taran910 Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.slice() 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. 1 min read Tensorflow.js tf.print() 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.print() function is u 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 1 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.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 Like