【发布时间】:2019-02-27 12:19:10
【问题描述】:
占位符在 TensorFlow 中被识别为张量。
isinstance(tf.placeholder("float", []), tf.Tensor) 返回True
有没有办法专门检查张量是否是占位符?比如:
isinstance(tf.placeholder("float", []), tf.Placeholder)
不幸的是,对于我正在构建的 API,tf.Placeholder 不是 TensorFlow 中的实际实例类型。
【问题讨论】:
-
这是我设法做到的一种丑陋的方式:
import tensorflow as tf pl = tf.placeholder("float", []) sess = tf.Session() try: sess.run(pl) except tf.errors.InvalidArgumentError: print(pl.shape)
标签: python tensorflow tensor