这两者有什么区别呢?
1- tf.reshape(张量,-1)
2- tf.reshape(张量,-1)
我找不到这两者之间的任何区别,但是当我使用-1而没有括号时,当试图将函数映射到TensorSliceDataset时会发生错误。下面是代码的简化版本:
def reshapeME(tensor):
reshaped = tf.reshape(tensor,-1)
return reshaped
new_y_test = y_test.map(reshapeME)这是一个错误:
ValueError: Shape must be rank 1 but is rank 0 for '{{node Reshape}} = Reshape[T=DT_FLOAT, Tshape=DT_INT32](one_hot, Reshape/shape)' with input shapes: [6], [].如果添加括号,则没有错误。此外,当函数通过调用和喂入张量来使用时也没有错误。
https://stackoverflow.com/questions/72856571
复制相似问题