[work]Cannot convert a partially converted tensor in TensorFlow

Keras Tensor 操作的时候,第一维度是“?”,所以特殊处理,让其batchsize可变


You just need to feed it in as a single example but in the batched shape. So that means adding an extra dimension to the shape e.g.

batch_size = 32 # set this to the actual size of your batch
tf.truncated_normal((batch_size, 784), mean=0.0, stddev=1.0, dtype=tf.float32, seed=None, name=None)

This way it will "fit" into the placeholder.

If you expect batch_size to change you can also use:

tf.truncated_normal(tf.shape(input_tensor), mean=0.0, stddev=1.0, dtype=tf.float32, seed=None, name=None)

Where input_tensor could be a placeholder or just whatever tensor is going to have this noise added to it.

猜你喜欢

转载自blog.csdn.net/Scythe666/article/details/79960371
今日推荐