如何在张量流中获得张量的数据类型?

yus*_*suf 4 python tensorflow

哪个函数用于获取python中tensorflow中张量的数据类型?我需要根据不同的张量定义动态数据类型.

Mir*_*ber 9

您可以使用x.dtype以下方式获取类型:

import tensorflow as tf
x=tf.constant([1,2])
x.dtype
Run Code Online (Sandbox Code Playgroud)

这打印 tf.int32