在张量流中将图像转换为 (None, 224, 224, 3)

时间:2021-02-07 02:25:28

标签: numpy tensorflow tensor

我想将我的图像数据转换为 (None, 224, 224, 3) ,我尝试使用 np.reshape (None, 224,224,3) 输出说 none 不是整数,我该怎么办?提前致谢 这是我的代码

testdata1= cv2.imread("/content/gdrive/My Drive/cnn/widya/p/daging(15).jpg", cv2.COLOR_BGR2RGB)
testdata1=cv2.resize(testdata1, (224, 224),interpolation = cv2.INTER_AREA)
testdata1=np.array(testdata1)
testdata1 = testdata1.astype('float32')
testdata1= np.reshape(testdata1,[224,224,3] )

这是我的错误

 ValueError: Input 0 is incompatible with layer model_4: expected shape=(None, 224, 224, 3), found shape=(32, 224, 3)

1 个答案:

答案 0 :(得分:-2)

使用numpy.expand_dims(data, axis=0)