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)
一般是reshape或者resize一下就好了。
不过python的框架太多了,reshape的用法也不一样,你具体用到的是哪个框架,就搜一下该框架下如何reshape。
==================================
你现在生成了一个迭代器,具体应该是用到numpy.reshape(a,(3,200,200)),但是我不太清楚在代码中你是如何调用的。