Hi!
I took 06_homework_autoencoder_tSNE and tried to avoid using AveragePooling2D and UpSampling2D. Instead I wanted a Dense neuron reduction.
So I changed the Net like so:
from tensorflow.keras.layers import Flatten, Reshape
Net2=Sequential()
Net2.add(Conv2D(20,5,input_shape=(None,None,1),
activation="relu",padding='same'))
Net2.add(AveragePooling2D(pool_size=(3,3),padding='same')) # down
Net2.add(Conv2D(20,5,
activation="relu",padding='same'))
Net2.add(Flatten())
Net2.add(Dense(9,activation='relu'))
Net2.add(Dense(81, activation='relu'))
Net2.add(Reshape(9,9))
Net2.add(Conv2D(20,5,
activation="relu",padding='same'))
Net2.add(UpSampling2D(size=(3,3))) # up
Net2.add(Conv2D(20,5,
activation="relu",padding='same'))
Net2.add(Conv2D(1,3,activation="linear",padding='same'))
Net2.compile(loss='mean_squared_error',
optimizer='adam')
But I got the error:
ValueError: The last dimension of the inputs to `Dense` should be defined. Found `None`.
I know that
Net2.add(Flatten()) has the size (None, None) and the last None is the number of neurons, which is at the moment undefined, but what can I do about this?
Also, why is the
input_shape=(None,None,1)?
None,None are the x and y coordinates of the images and 1 is the number of filters, right? But where is the batchsize in the input_shape?