Tensorflow.js tf.cast() 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. The tf.cast() function is used to cast a specified Tensor to a new data type. Syntax: tf.cast (x, dtype) Parameters: This function accepts two parameters which are illustrated below: x: The input tensor which is being casted.dtype: The data type in which input tensor is going to be casted. Return Value: It returns a casted tensor of new data type. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Initializing a tensor of some values const x = tf.tensor1d([2.3, 1.7, 5, 0, 1, 0.5]); // Calling the .cast() function over the // above tensor to cast in "int32" data type tf.cast(x, 'int32').print(); Output: Tensor [2, 1, 5, 0, 1, 0] Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Using a tensor of some values // as the parameter for .cast() function to // cast into bool data type tf.cast(tf.tensor1d([0, 1, -3]), 'bool').print(); Output: Tensor [false, true, true] Reference: https://js.tensorflow.org/api/latest/#cast Comment More infoAdvertise with us Next Article Tensorflow.js tf.cast() Function K Kanchan_Ray Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js TensorFlow.js-Transformations Similar Reads Tensorflow.js tf.cos() Function Tensorflow.js is an open-source library which is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .cos() function is used to find the cosine value of the stated tensor input and is done element wise. Syntax 2 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.asin() 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 .asin() function is used to find the asin of the stated tensor elementwise. Syntax: Â tf.asin(x) Parameters: 2 min read 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.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.acosh() 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 .acosh() function is used to find the inverse hyperbolic cos of the stated tensor element input. Syntax: Â tf 2 min read Tensorflow.js tf.atanh() 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 .atanh() function is used to find the inverse hyperbolic tan of the stated tensor input and is done elements 2 min read Tensorflow.js tf.all() 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. al 1 min read Tensorflow.js tf.any() 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 the JavaScript language so that ML directly can be used in the browser or in Node 1 min read Tensorflow.js tf.broadcastTo() 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 .broadcastTo() function is used to circulate an array to a consistent model of NumPy-style. Note: Here, the shape o 2 min read Like