Skip to content Skip to sidebar Skip to footer

Keras Output Shape Has An Extra Dimension

I have a neural network that takes in an RGB colour image of 500px by 500px and will also output another image of the same dimensions. Here's the structure of my network: Generat

Solution 1:

Whilst speaking to @Dodge in chat he pointed me to the following docs:

https://www.tensorflow.org/api_docs/python/tf/keras/layers/Reshape

which states that the additional None comes from the batch length. I needed to feed the output of the first network into the output of a second which expected not to have the batch dimension so I removed this using a reshape outside of the first network like so:

#Adversierial network which is comprised of a generator network and a discriminator network.
self.model = Sequential([
   Gen_Input, # Generator Network
   Reshape((500, 500, 3), input_shape=(500, 500, 3)),
   discriminative_model.Input # Discriminator Network
        ])

This allowed me to reshape the output from inside the graph.


Post a Comment for "Keras Output Shape Has An Extra Dimension"