Cast a Tensor to another Type in TensorFlow

We can cast a Tensor to another type in tensorflow as below:

Cast a Tensor to another Type in TensorFlow

Code as below:

import tensorflow as tf
# Create a TensorFlow float type Tensor x
x = tf.constant([1.8, 2.2], dtype=tf.float32)
# Cast a Tensor of float type to int Type in TensorFlow
x = tf.dtypes.cast(x, tf.int32)

Neural Network Machine Learning Algorithm From Scratch in Python is a short video course to discuss an overview of the Neural Network Deep Learning Algorithm. In this video different concepts related to Neural Network Algorithm such as Dot Product of Matrix, Sigmoid, Sigmoid Derivative, Forward Propagation, Back Propagation is discussed in detail. Also, the model loss and model weights update is discussed. Finally, the algorithm is implemented, step by step, in Python Programming language using Jupyter

Neural Network Machine Learning Algorithm From Scratch in Python

Leave a Reply