Neural network “输入”的形状;“展平”;未完全定义(获取(无、无、64)

Neural network “输入”的形状;“展平”;未完全定义(获取(无、无、64),neural-network,deep-learning,keras,conv-neural-network,pre-trained-model,Neural Network,Deep Learning,Keras,Conv Neural Network,Pre Trained Model,我在第一个图像分类应用程序中使用预先训练好的模型GoogleNet。在使用Flatte时,我得到了这个错误- ValueError: The shape of the input to "Flatten" is not fully defined got (None, None, 64). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your

我在第一个图像分类应用程序中使用预先训练好的模型GoogleNet。在使用Flatte时,我得到了这个错误-

ValueError: The shape of the input to "Flatten" is not fully defined got 
(None, None, 64). Make sure to pass a complete "input_shape" or 
"batch_input_shape" argument to the first layer in your model.
我在网上搜索了很多,但没有找到解决方案。如果有人能帮我,我将不胜感激

下面是我的代码

train_datagen=ImageDataGenerator(
旋转范围=40,
宽度\偏移\范围=0.2,
高度\位移\范围=0.2,
重新缩放=1./255,
剪切范围=0.2,
缩放范围=0.2,
水平翻转=真,
填充模式(最近的)
test_datagen=ImageDataGenerator(重缩放=1./255)
train_generator=来自目录的train_datagen.flow_(
“dir_path”,
目标_大小=(500500),
批次大小=批次大小,
class_mode='classifical')
验证\u生成器=来自\u目录的测试\u datagen.flow\u(
“dir_path”,
目标_大小=(500500),
批次大小=批次大小,
class_mode='classifical')
基本模型=接收v3(权重='imagenet',包括顶部=假)
x=基本模型输出
x=Conv2D(32,(3,3),使用_bias=True,activation='relu',输入_shape=
(500500,3))(x)#第2行
x=MaxPoolig2D(池大小=(2,2))(x)
x=Conv2D(64,(3,3),activation='relu')(x)#line3
x=展平()(x)
x=密集(批量大小,激活='relu')(x)#第1行
x=(辍学率(0.5))(x)
预测=密集(num_类,activation='softmax')(x)
模型=模型(输入=基本模型。输入,输出=预测)

您应该将输入形状从第一个Conv2D层移动到基础模型,如下所示:

base\u model=InceptionV3(weights='imagenet',input\u shape=(500500,3),include\u top=False)
x=基本模型输出
x=Conv2D(32,(3,3),使用_bias=True,activation='relu',)(x)
...

我为这个错误挣扎了一整天。你救了我。非常感谢。