简体   繁体   English

我不断收到此错误“ValueError:检查输入时出错:预期的dense_8_input有2维,但得到的数组形状为(705,66,1)”

[英]I keep getting this error “ValueError: Error when checking input: expected dense_8_input to have 2 dimensions, but got array with shape (705, 66, 1)”

'MLP' 'MLP'

'define and fit model on a training dataset' '在训练数据集上定义和拟合 model'

def fit_model(trainX, trainy, testX, testy):
    'define model'
    model = Sequential()
    model.add(Dense(5, input_dim=2, activation='relu', kernel_initializer='he_uniform'))
    model.add(Dense(5, activation='relu', kernel_initializer='he_uniform'))
    model.add(Dense(3, activation='softmax'))
    'compile model'
    model.compile(loss='categorical_crossentropy', optimizer='sgd', metrics=['acc'])
    'fit model'
    history = model.fit(trainX, trainy, validation_data=(testX, testy), epochs=100, batch_size=66, verbose=0)
    return model, history

# fit model on train dataset
model, history = fit_model(trainX, trainy, testX, testy)
# evaluate model behavior
summarize_model(model, history, trainX, trainy, testX, testy)
# save model to file
model.save('model.h5')

you have to pass them as list, you cant have 4 different arguments你必须将它们作为列表传递,你不能有 4 个不同的 arguments

def fit_model(train, test):

and call fit like this像这样打电话给 fit


fit_model([trainX, trainy], [testX, testy], batch_size=16, epochs=100)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 检查输入时出错:预期density_8_input具有2维 - Error when checking input: expected dense_8_input to have 2 dimensions ValueError:检查输入时出错:预期density_11_input具有3维,但数组的形状为(0,1) - ValueError: Error when checking input: expected dense_11_input to have 3 dimensions, but got array with shape (0, 1) ValueError:检查输入时出错:预期density_6_input具有3维,但数组的形状 - ValueError: Error when checking input: expected dense_6_input to have 3 dimensions, but got array with shape ValueError:检查输入时出错:预期dense_input有2维,但得到形状为(1,1,2)的数组 - ValueError: Error when checking input: expected dense_input to have 2 dimensions, but got array with shape (1, 1, 2) ValueError:检查输入时出错:预期density_151_input具有3维,但数组的形状为(2,2100) - ValueError: Error when checking input: expected dense_151_input to have 3 dimensions, but got array with shape (2, 2100) ValueError:检查输入时出错:预期的dense_input有2维,但得到的数组形状为(1、1、15) - ValueError: Error when checking input: expected dense_input to have 2 dimensions, but got array with shape (1, 1, 15) ValueError:检查时出错:预期density_1_input具有2维,但数组的形状为(1,16,16,512) - ValueError: Error when checking : expected dense_1_input to have 2 dimensions, but got array with shape (1, 16, 16, 512) ValueError:检查输入时出错:预期dense_1_input具有形状(180,)但得到形状为(1,)的数组 - ValueError: Error when checking input: expected dense_1_input to have shape (180,) but got array with shape (1,) ValueError:检查输入时出错:预期dense_39_input 具有形状(6,) 但得到形状为(1,) 的数组 - ValueError: Error when checking input: expected dense_39_input to have shape (6,) but got array with shape (1,) ValueError:检查输入时出错:预期 dense_3_input 的形状为 (33,) 但得到的数组形状为 (34,) - ValueError: Error when checking input: expected dense_3_input to have shape (33,) but got array with shape (34,)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM