Tensorflow.js tf.cast() 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.cast() function is used to cast a specified Tensor to a new data type.
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.
Tensor [2, 1, 5, 0, 1, 0]
Tensor [false, true, true]