检查目标:预期具有形状(3404,)但具有形状的数组(1705,)

时间:2019-06-19 06:17:28

标签: python-3.x keras

在以下代码中,我收到有关形状的错误。调用fit()函数时无法理解和寻求帮助

import keras
from keras.models import Model, load_model,Sequential
from keras.layers import Activation, Dropout, Flatten, Dense

hidden_layer_len = 300
# X and Y are input and output respectively with shape (3404, 1705)

model = Sequential()
inputLayer = Dense(units= X.shape[0])
hiddenLayer = Dense(units=hidden_layer_len,activation='linear')
outputLayer = Dense(units=Y.shape[0],activation='softmax')

model.add(inputLayer)
model.add(hiddenLayer)
model.add(outputLayer)

model.compile(optimizer='sgd',loss='mean_squared_error')
model.fit(X,Y,epochs=50)

我无法理解为什么会出现此错误。

0 个答案:

没有答案