椒盐玛奇朵 2021-03-02 17:11 采纳率: 0%
浏览 105
已结题

flow_from_director生成RGB图像的通道如何从第三维调整为第二维?

flow_from_director生成RGB图像的通道在第三维,而神经网络要求的通道数在第一个维度,请问何如调整

程序:
train_generator = train_datagen.flow_from_directory( 
        target_size=(img_height, img_width),
        batch_size=batch_size,
        class_mode='categorical')   

validation_generator = test_datagen.flow_from_directory(
        validation_data_dir,
        target_size=(img_height, img_width),
        batch_size=batch_size,
        class_mode='categorical')

报错为:ValueError: Error when checking input: expected input_1 to have shape (3, 200, 200) but got array with shape (200, 200, 3)

  • 写回答

1条回答 默认 最新

  • ProfSnail 2021-03-02 17:59
    关注

    一般是reshape或者resize一下就好了。

    不过python的框架太多了,reshape的用法也不一样,你具体用到的是哪个框架,就搜一下该框架下如何reshape。

    ==================================

    你现在生成了一个迭代器,具体应该是用到numpy.reshape(a,(3,200,200)),但是我不太清楚在代码中你是如何调用的。

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable