1 单通道转3通道
import numpy as np
with tf.Session():
image, label = sess.run(next_batch) # batch_size=1
print(image.shape) # [224, 224, 1]
image = np.concatenate((image, image, image), axis=-1)
print(image.shape) # [224, 224, 3]
# image有三个通道,每个通道都是原始的单通道的复制
2增加矩阵维度 numpy.expand_dims(a, axis)
>>> x = np.array([1,2])
>>> x.shape
(2,)
>>> y = np.expand_dims(x, axis=0)
>>> y
array([[1, 2]])
>>> y.shape
(1, 2)
>>> y = np.expand_dims(x, axis=1) # Equivalent to x[:,newaxis]
>>> y
array([[1],
[2]])
>>> y.shape
(2, 1)
不断更新中......