Hi,
For my model, output.grad is zero right from the first iteration. My model is as follows -
import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
import torch
from torch.autograd.variable import Variable
from torchvision import datasets, models, transforms

class ResnetCombinedFull2(nn.Module):
    def __init__(self,LOAD_VIS_URL=None):
        print('Using MSE Version')
        super(ResnetCombinedFull2, self).__init__()
        
        model = models.resnet18(pretrained = True)
        ct = 0
        for child in model.children():
            for childdd in child.children():
                if ct < 6 :
                    for param in childdd.parameters():
                        param.requires_grad = False
                ct += 1
        
        self.vismodel = nn.Sequential(*list(model.children())[:-1])
        self.projective = nn.Linear(512,400)
        self.nonlinearity = nn.ReLU(inplace=True)
        self.projective2 = nn.Linear(400,300)
    
    def forward(self,x):
        x = self.vismodel(x)
        x = torch.squeeze(x)
        x = self.projective(x)
        x = self.nonlinearity(x)
        x = self.projective2(x)
        x = x/x.norm(2, 1).clamp(min=1e-12).expand_as(x)
        return x

Can someone help me out with this?
Thanks!