【发布时间】:2020-03-05 19:30:30
【问题描述】:
我正在尝试将 MNIST 数据集转换为 RGB 格式,每个图像的实际形状是 (28, 28),但我需要 (28, 28, 3)。
import numpy as np
import tensorflow as tf
mnist = tf.keras.datasets.mnist
(x_train, _), (x_test, _) = mnist.load_data()
X = np.concatenate([x_train, x_test])
X = X / 127.5 - 1
X.reshape((70000, 28, 28, 1))
tf.image.grayscale_to_rgb(
X,
name=None
)
但我收到以下错误:
ValueError: Dimension 1 in both shapes must be equal, but are 84 and 3. Shapes are [28,84] and [28,3].
【问题讨论】:
-
总是将完整的错误消息(从单词“Traceback”开始)作为文本(不是屏幕截图)放在有问题的(不是评论)中。还有其他有用的信息。
标签: python numpy tensorflow keras tensorflow-datasets