This is bill的专属博客

仅作研究用途,侵删

[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.

阅读更多
个人分类: 机器学习
上一篇Python 中的几种矩阵乘法 np.dot, np.multiply, *
下一篇[work]TypeError: 'Tensor' object does not support item assignment in TensorFlow
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭