yusuf
yusuf

Reputation: 3781

how to get data type of a tensor in tensorflow?

Which function is used to get the data type of tensors in tensorflow in python? I need to define dynamic data types according to different tensors.

Upvotes: 10

Views: 11143

Answers (1)

Miriam Farber
Miriam Farber

Reputation: 19634

You can get the type using x.dtype, as follows:

import tensorflow as tf
x=tf.constant([1,2])
x.dtype

This prints tf.int32

Upvotes: 14

Related Questions