Это просто вопрос обеспечения правильности формы ввода.Я предполагаю, что вы используете керас.
from tensorflow.keras.layers import Dense, Flatten, Conv2D, Reshape
# Add a convolution to the network (previous layer called some_input)
c1 = Conv2D(32, (3, 3), activation='relu', name='first_conv')(some_input)
# Now reshape using 'Flatten'
f1 = Flatten(name='flat_c1')(c1)
# Now add a dense layer with 10 nodes
dense1 = Dense(10, activation='relu', name='dense1')(f1)
# Now add a dense layer, making sure it has the right number of nodes for my next conreshape8v layer.
dense2 = Dense(784, activation='relu', name='dense2')(dense1)
reshape2 = Reshape((7, 7, 16), name='reshape2')(dense2)
#Now back to convolutions (up or down)
c2 = Conv2D(16, kernel_size=(3, 3), activation='relu',
name='conv2')(reshape2)