Hi,
I implemented a autoencoder , and use pretrained model resnet as encoder and the decoder is a series of convTranspose.
Is necessary to apply “init_weights” to autoencoder?
If I use “init_weights” the weights of pretrained model also modified?
You can create a separate class for a decoder and init_weights inside this class. Then import it to autoencoder class.
For examples,
class Encoder(nn.Module):
def __init__(self):
# load pretrained here
def forward(self, x):
# do the thing of encode
class Decoder(nn.Module):
def __init__(self):
# define weigths
# init weight as random
def forward(self, x):
# do the thing to decode
class AutoEncoder(nn.Module):
def __init__(self):
self.enc = Encoder()
self.dec = Decoder()
def forward(self, x):
x = self.enc(x)
return self.dec(x)