Hi, I have model in the model of forward, as follows.

model2 = torchvision.models.video.r3d_18(pretrained=False).to('cuda')

class model1(torch.nn.Module):
    def __init__(self):
        super(model1, self).__init__()
        self.ReLU = ReLU(400, 128, 1)
        self.QoS = nn.Linear(128, 1)

    def forward(self, pixel):
        pixel = model2(pixel.cuda())
        pixel = self.ReLU(pixel)
        pixel = self.QoS(pixel)
        return pixel

Now, I’m training model1 by loss.backward()
However, the model2, located in the model1’s forward, is trained?
If not, How can I train the model 2?
My model 1 train code is as follows.
for idx, (raw_data, len_frame, true_mos) in enumerate(train_module):
            raw_data = raw_data.to(device).float()
            true_mos = true_mos.to(device).float()
            optimizer.zero_grad()
            outputs = model1(raw_data)
            loss = criterion(outputs, true_mos)
            loss.backward()
            optimizer.step()

Thanks.