-1
$\begingroup$

I'm trying to make a denoise autoencoder wherein the encoder part is vgg16 and decoder is opposite of vgg16(encoder) network. My dataset consists of 5K images in grayscale.

Now while training, the loss and accuracy doesn't changes. I can think of reducing filters in the initial decoder layers but i fear that's going to affect the autoencoder. Here, i'm really clueless about what approach to follow.

$\endgroup$

1 Answer 1

1
$\begingroup$

VGG16 is not trained to be used as an encoder for image reconstruction, it is trained to extract features from an image using which we can do classification task on the image.
This is why, you cannot use VGG16 as the encoder part of your denoise autoencoder.
However, if you want, you can use that architecture of VGG16 as the encoder part of your autoencoder, by just retraining those layers of VGG16,

vggmodel = keras.applications.vgg16.VGG16()
model_encoder = Sequential() 
num = 0
for i, layer in enumerate(vggmodel.layers):
    if i<19:
      model_encoder.add(layer)

model_encoder.summary()
for layer in model_encoder.layers:
  layer.trainable=True # Set encoder to trainable, and your autoencoder should work.

Again, there is a problem with your current architecture of autoencoder -it downsamples too much, leading to a significant loss of data. A smaller architecture would work better. For example:

model = Sequential()
model.add(Input(shape=(224,224,3)))
model.add(Conv2D(64, (3,3), activation='relu', padding='same'))
model.add(Conv2D(64, (3,3), activation='relu', padding='same'))
model.add(MaxPool2D((2,2)))
model.add(Conv2D(128, (3,3), activation='relu', padding='same'))
model.add(Conv2D(128, (3,3), activation='relu', padding='same'))
model.add(MaxPool2D((2,2)))
model.add(Conv2D(256, (3,3), activation='relu', padding='same'))
model.add(Conv2D(256, (3,3), activation='relu', padding='same'))
model.add(Conv2D(256, (3,3), activation='relu', padding='same'))
model.add(UpSampling2D((2,2)))
model.add(Conv2D(128, (3,3), activation='relu', padding='same'))
model.add(Conv2D(128, (3,3), activation='relu', padding='same'))
model.add(UpSampling2D((2,2)))
model.add(Conv2D(64, (3,3), activation='relu', padding='same'))
model.add(Conv2D(64, (3,3), activation='relu', padding='same'))
model.add(Conv2D(3, (3,3), activation='relu', padding='same'))
$\endgroup$
8
  • $\begingroup$ thank you so much for your comment! Just a quick question, if now i go on train my network using vgg16 by obviously training it again would it be a good choice for something to modify/increase performance in denoise autoencoders?? Because my main aim was to increase the accuracy and denoise autoencoders performance. Or there could be any different approach that is thereb which i can follow. $\endgroup$
    – arizona_3
    Apr 28 at 11:45
  • $\begingroup$ I will build a denoise autoencoder by today, and will share a link to the code. $\endgroup$ Apr 28 at 11:52
  • $\begingroup$ thank you! please do let me know...although i have tried making a basic denoise autoencoder the results were good but i'm expecting a better result because of which i jumped to transfer learning using vgg16 $\endgroup$
    – arizona_3
    Apr 28 at 11:57
  • $\begingroup$ @arizona_3 I've made a notebook on this, here is the link: kaggle.com/code/mushfirat/… The explanations may not be so good, so I'll update it if you face any problem understanding it. $\endgroup$ Apr 29 at 12:23
  • $\begingroup$ thanks a ton!! Really appreciate this_/ _ $\endgroup$
    – arizona_3
    Apr 29 at 19:53

Not the answer you're looking for? Browse other questions tagged .