在keras/keras/engine/training.pydef 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))
与错误进行比较
^{pr2}$
所以它比较(None, 192)和(192, 1),并跳过第一个轴;即比较192和{}。如果array有形状(n, 192),它可能会通过。在
因此,基本上,生成(192,1)形状,而不是(1,192)或可广播的(192,)是导致错误的原因。在
我将keras添加到标记中,假设这是问题模块。在
搜索其他keras标记为SO的问题:
我对keras的了解还不足以理解答案,但它不仅仅是简单地重塑输入数组。在