部分代码:
reshape_out = Reshape((3, 21, 1), input_shape=(21*3,), name='reshape_to_3_21')(output3d)
drop_out = Lambda(lambda x:x[0:2, :, :], output_shape=(2, 21, 1), name='projection')(reshape_out)
flatten_out = Flatten()(drop_out)
我遇到以下错误:
InvalidArgumentError: Matrix size-incompatible: In[0]: [2,63], In[1]: [42,1024].
但是如果
drop_out = Lambda(lambda x:x[0:2, :, :], output_shape=(2, 21, 1), name='projection')(reshape_out)
被删除,一切正常。为什么?
答案 0 :(得分:0)
第一个轴是批处理轴,似乎您在错误地切片而不是第二个轴:
def drop_output_shape(shp):
return (shp[0], 2) + shp[2:]
drop_out = Lambda(lambda x: x[:, 0:2, :, :],
output_shape=drop_output_shape, name='projection')(reshape_out)