Check if A Tensor is optimized in Pytorch?

Hi, I have define a model like this:
class Model(torch.nn.Module):
def init(self, args):
super(Model, self).init()

    # Image Processing
    self.conv1 = nn.Conv2d(3, 128, kernel_size=8, stride=4) 
    self.conv2 = nn.Conv2d(128, 64, kernel_size=4, stride=2)
    self.conv3 = nn.Conv2d(64, 64, kernel_size=4, stride=2)

    # Initializing weights

def forward(self, inputs):
    encoder is the Encoder part of a AutoEncoder
    encoder, x = inputs
    #get the auto encoder representation  
    ae_v_emb = encoder.view(encoder.shape[0], -1)
    # Get the image representation
    x = F.relu(self.conv1(x))
    x = F.relu(self.conv2(x))
    x_image_rep = F.relu(self.conv3(x))
    x_emb = x_image_rep.view(1, -1)
    #Concat features
    x_emb =, ae_v_emb), 1)
    return x_emb

I have defined training process like this:
from model import Model
model = Model()
auto_encoder_model = AutoEncoder()
optimizer = optim.SGD(model.parameters(),

#run Auto Encoder
encode = auto_encoder_model.encoder(image)
decode = auto_encoder_model.decoder(encoder)
features = model(encode, image)


I have passed an RGB image and an encoder of an Auto Encoder model into this model. My question is that I don’t define an optimizer for the Auto Encoder model, so can the encoder part of the auto encoder model be optimized through the optimizer of the main model (Model) ?
Thank you very much

You are passing the model parameters into the optimizer. So, the model parameters would be optimized (using SGD) and not the auto_encoder_model parameters. Unless there are pieces of code which are missing here.

Thank you. So, how to optimizer AE parameters along with the Model?