[英]Why deleting one dimension in tensor causes InvalidArgumentError: Matrix size-incompatible?
Part of my codes: 我的部分代码:
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)
I got the following error: 我收到以下错误:
InvalidArgumentError: Matrix size-incompatible: In[0]: [2,63], In[1]: [42,1024].
But if 但是如果
drop_out = Lambda(lambda x:x[0:2, :, :], output_shape=(2, 21, 1), name='projection')(reshape_out)
is removed, everything is OK. 被删除,一切正常。 Why? 为什么?
First axis is the batch axis and it seems you are mistakenly slicing it instead of the second axis: 第一个轴是批处理轴,似乎您在错误地切片而不是第二个轴:
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.