0

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?

today
  • 32,602
  • 8
  • 95
  • 115
BAE
  • 8,550
  • 22
  • 88
  • 171

1 Answers1

0

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)
today
  • 32,602
  • 8
  • 95
  • 115
  • please can you help in this https://stackoverflow.com/questions/68225332/matrix-size-incompatible – user Jul 04 '21 at 13:39