我正在尝试将MNIST数据集转换为RGB。我使用下面的代码来实现这一点,但是我得到了一个错误,它适用于tensorflow1.12.0,但不适用于tensorflow1.14.0(我的项目基于tensorflow1.14.0)
mnist = tf.keras.datasets.mnist
(x_train, _), (x_test, _) = mnist.load_data()
X = np.concatenate([x_train, x_test])
X = X.reshape((70000, 28, 28, 1))
assert X.shape == (70000, 28, 28, 1)
X = tf.image.grayscale_to_rgb(X, name=None)
assert X.shape == (70000, 28, 28, 3)
我得到的错误是:
Traceback (most recent call last):
File "PGE/redis_ako.py", line 75, in <module>
X2 = tf.image.grayscale_to_rgb(X, name=None)
File "/home/farshad/.virtualenvs/ako_cifar/local/lib/python2.7/site-packages/tensorflow/python/ops/image_ops_impl.py", line 1827, in grayscale_to_rgb
images = _AssertGrayscaleImage(images)
File "/home/farshad/.virtualenvs/ako_cifar/local/lib/python2.7/site-packages/tensorflow/python/ops/image_ops_impl.py", line 263, in _AssertGrayscaleImage
_CheckGrayscaleImage(image, require_static=False), image)
File "/home/farshad/.virtualenvs/ako_cifar/local/lib/python2.7/site-packages/tensorflow/python/ops/image_ops_impl.py", line 282, in _CheckGrayscaleImage
if image.get_shape().ndims is None:
AttributeError: 'numpy.ndarray' object has no attribute 'get_shape'
目前没有回答
相关问题 更多 >
编程相关推荐