r/MachineLearning - [R] Replace VAE dense layer with 1x1x1 Convolutional layer

#artificialintelligence 

I have a Variational autoencoder model created in Keras.Encoder is built with three 3D Convolutional layers Flatten Dense layer. Decoder is built with three 3D Transposed Convolutional layers to reconstruct the input 3D images. My goal is to replace Flatten and Dense layer in Encoder with 1x1x1 Convolutional layer. Any ideas how to do that?