【发布时间】:2017-01-18 13:44:18
【问题描述】:
我有条件:
if tf.shape(n_spec)[0] < tf.shape(s_spec)[0]:
n_spec = tf.concat(0, [tf.zeros([empty_cols, n_spec.get_shape()[1]], tf.int32), n_spec])
其中 n_spec 和 s_spec 是两个张量(二维数组),如果一个在 0 维中小于另一个,我想执行该连接。当我尝试这个时,tensorflow 会抛出一个错误:
TypeError: Using a `tf.Tensor` as a Python `bool` is not allowed. Use `if t is not None:` instead of `if t:` to test if a tensor is defined, and use TensorFlow ops such as tf.cond to execute subgraphs conditioned on the value of a tensor.
如何重新表述上述内容?
【问题讨论】:
标签: if-statement boolean tensorflow