如何解决带有 TensorFlow-Inputs 到一个层的 MNIST 应该是张量
我正在尝试使用基于 MNIST 数据库的 TensorFlow 深度卷积生成对抗网络。为了测试我的编码能力,我直接从那里的网站(而不是 tf.keras.datasets.mnist.load_data()
)下载了 MNIST 数据库,并且在执行以下行时遇到以下问题:
real_output = discriminator(images,training=True)
错误:
raise TypeError('Inputs to a layer should be tensors. Got: %s' % (x,))
TypeError: Inputs to a layer should be tensors. Got: pixel0```
What should I do to solve this?
解决方法
好的,我解决了。 解决方案是将图像标准化为 -1 到 1 范围内的值: train_images = (train_images - 127.5) / 127.5 # 将图像归一化为 [-1,1]
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。