我正在运行一个keras模型,但是它显示了形状错误,尽管我确实检查了形状并且它是正确的。
predict = model.predict(sequences_matrix)
显示错误:
ValueError: Error when checking input: expected Inputs to have shape (150,) but got array with shape (1,)
当我检查其形状时,显示正确的形状:
sequences_matrix.shape
输出为:
(150,)
答案 0 :(得分:1)
这是因为第一个通道是为批次保留的。如果将sequence_matrix调整为(1,150)
,该函数应该可以正常工作sequence_matrix = sequence_matrix.reshape(1,-1)
然后,模型将批次1分开,并获得(150,)输入到模型。现在,假设您要传递150批次,每批次具有(1,)形状。