在使用建立 mlp 之后
## building a mlp model
model=Sequential()
model.add(Dense(25,input_shape=(10,),activation='relu'))
model.add(Dense(100,input_shape=(10,),activation='relu'))
model.add(Dense(150,input_shape=(16,),activation='relu'))
model.add(Dense(10,input_shape=(10,),activation='softmax'))
model.compile(loss='categorical_crossentropy',
optimizer='Adam',metrics=['accuracy'])
当我尝试使用以下方法拟合模型时:
model.fit(x_train, y_train, epochs=10,validation_data=(x_test,y_test))`
我收到此错误:
ValueError Traceback (most recent call last) in 1 # 在 2D 数据上训练 MLP ----> 2 model.fit(x_train, y_train, epochs=10,validation_data=(x_test,y_test))
~\anaconda\lib\site-packages\keras\engine\training.py 适合(self,x,y,batch_size,epochs,verbose,callbacks,validation_split,validation_data,shuffle,class_weight,sample_weight,initial_epoch,steps_per_epoch,validation_steps, **kwargs) 950 sample_weight=sample_weight, 951 class_weight=class_weight, --> 952 batch_size=batch_size) 953 # 准备验证数据。第954章
~\anaconda\lib\site-packages\keras\engine\training.py in _standardize_user_data(self, x, y, sample_weight, class_weight, check_array_lengths, batch_size) 749 feed_input_shapes, 750 check_batch_axis=False, # 不强制批量大小. --> 751 exception_prefix='input') 752 753 如果 y 不是 None:
~\anaconda\lib\site-packages\keras\engine\training_utils.py in standardize_input_data(数据,名称,形状,check_batch_axis,exception_prefix)136':预期'+名称[i]+'具有形状'+ 137 str( shape) + ' 但得到了 shape ' + --> 138 str(data_shape)) 139 返回数据 140 的数组
ValueError:检查输入时出错:预期的dense_29_input具有形状(10,)但得到的数组具有形状(3072,)
有人可以帮我找出错误吗?