Use “Flatten” or “Reshape” to get 1D output of unknown input shape in keras
问题 I want to use the keras layer Flatten() or Reshape((-1,)) at the end of my model to output an 1D vector like [0,0,1,0,0, ... ,0,0,1,0] . Sadly there is an problem because of my unknown input shape which is: input_shape=(4, None, 1))) . So typically the input shape is something between [batch_size, 4, 64, 1] and [batch_size, 4, 256, 1] the output should be batch_size x unknown dimension (for the fist example above: [batch_size, 64] and for the secound [batch_size, 256] ). My model looks like: