tf.reshape报错

TypeError: Failed to convert object of type to Tensor. Contents: [x.shape[0],-1,x.shape[-1]]. Consider casting elements to a supported type.

这是tf.reshape()的时候报错。需要使用.as_list()将获取到的shape转换成list才行。
例如:
tf.reshape(x, [x.shape[0], -1, x.shape[-1]])
改成:
tf.reshape(x, [x.shape.as_list()[0], -1, x.shape.as_list()[-1]])

你可能感兴趣的:(tf.reshape报错)