【问题标题】:convert image to (None, 224, 224, 3) in tensorflow在张量流中将图像转换为 (None, 224, 224, 3)
【发布时间】:2021-05-11 00:26:58
【问题描述】:

我想将我的图像数据转换为 (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)

【问题讨论】:

  • 该错误似乎与您显示的代码无关。请显示错误实际发生的位置,并描述导致问题的输入的形状和 dtype。找到的形状显然不是 224x224x3

标签: numpy tensorflow tensor


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-30
    • 1970-01-01
    • 2021-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-06
    • 2022-09-30
    相关资源
    最近更新 更多