在keras/keras/engine/training.py
def standardize_input_data(data, names, shapes=None,
check_batch_dim=True,
exception_prefix=''):
...
# check shapes compatibility
if shapes:
for i in range(len(names)):
...
for j, (dim, ref_dim) in enumerate(zip(array.shape, shapes[i])):
if not j and not check_batch_dim:
# skip the first axis
continue
if ref_dim:
if ref_dim != dim:
raise Exception('Error when checking ' + exception_prefix +
': expected ' + names[i] +
' to have shape ' + str(shapes[i]) +
' but got array with shape ' +
str(array.shape))
与错误比较
Error when checking : expected input_1 to have shape (None, 192) but got array with shape (192, 1)
所以它正在比较(None, 192) 和(192, 1),并跳过第一个轴;这是比较192 和1。如果array 的形状为(n, 192),它可能会通过。
所以基本上,是什么生成了(192,1) 形状,而不是(1,192) 或可广播的(192,) 导致错误。
我将keras 添加到标签中,猜测这是问题模块。
搜索其他keras 标记的 SO 问题:
Exception: Error when checking model target: expected dense_3 to have shape (None, 1000) but got array with shape (32, 2)
Error: Error when checking model input: expected dense_input_6 to have shape (None, 784) but got array with shape (784L, 1L)
Dimensions not matching in keras LSTM model
Getting shape dimension errors with a simple regression using Keras
Deep autoencoder in Keras converting one dimension to another i
我对@987654340@ 的了解不够多,无法理解答案,但不仅仅是简单地重塑您的输入数组。