【问题标题】:MNIST with TensorFlow-Inputs to a layer should be tensors具有 TensorFlow 输入的 MNIST 应该是张量
【发布时间】:2023-06-06 16:36:01
【问题描述】:

我正在尝试基于 MNIST 数据库练习 TensorFlow 深度卷积生成对抗网络。为了测试我的编码能力,我直接从那里的网站下载了 MNIST 数据库(而不是tf.keras.datasets.mnist.load_data()),在执行以下行时我遇到了以下问题: 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?

【问题讨论】:

    标签: python tensorflow keras mnist


    【解决方案1】:

    好的,我解决了。 解决方案是将图像标准化为 -1 到 1 范围内的值: train_images = (train_images - 127.5) / 127.5 # 将图像归一化为 [-1, 1]

    【讨论】: