1

Not Sequential API, but for Keras Functional API, how do I remove the '[]' of my output shape? For example, I don't want [(None,32)] instead, i want (None,32):

i = Input(shape=(32,))
x = Dense(16, activation='softmax')(i)
model = Model(x, y)
model.summary()
 Layer (type)                Output Shape              Param #   
=================================================================
 input_20 (InputLayer)       [(None, 32)]              0         
                                                                 
 dense_47 (Dense)            (None, 16)                528       
                                                                 
=================================================================
Total params: 528
Trainable params: 528
Non-trainable params: 0
Innat
  • 16,113
  • 6
  • 53
  • 101
  • Does this answer your question? [Keras input explanation: input\_shape, units, batch\_size, dim, etc](https://stackoverflow.com/questions/44747343/keras-input-explanation-input-shape-units-batch-size-dim-etc) – roberto tomás Feb 03 '23 at 13:33
  • in your example, the output shape of the input layer is represented as `[(None, 32)]` because the input layer takes a batch of 32-dimensional vectors as input. it is not possible to change the way the shape is represented in the summary so it ignores batching. – roberto tomás Feb 03 '23 at 13:33
  • Keras Functional API has [multiple inputs and multiple output](https://www.tensorflow.org/guide/keras/functional#models_with_multiple_inputs_and_outputs) features where multiple inputs can be handled in the form of a list of tuples inside input layer. Not sure if we can modify this in `model.summary()`. However you can access input shape as tuple using `model.input_shape` explicitly. –  Mar 22 '23 at 17:50

0 Answers0