I am facing problem with updating a custom defined nn.Parameter(). I tried porting it into GPU/CPU using Adam/SGD but the the self.mu parameter does not update at all over batches/epochs. The code below is written to use a custom weights kernel in F.Conv1d. Below is my network class definition. Also, I found that
print(model.mu.data.grad) gives None. I appreciate any suggestions to debug this. I am new to using NNs and pytorch.
class CNN(nn.Module):
  def __init__(self, h_in, w_in, h_out):
    super(CNN,self).__init__()
    self.filter_dur = 8e-3
    self.srate = 16000

    self.f_max = 6500
    self.C_out = 64

    self.filter_length = int(self.filter_dur*self.srate)-1
    self.K = (self.filter_length,1)
    self.m = torch.arange(0,self.K[0],1)/self.srate

    self.freq_scale = 100
    self.mu = Parameter(torch.rand((self.C_out,1)))
    self.center_freq = (self.freq_scale*self.mu.repeat(1,self.K[0]))
    self.time_grid = self.m.repeat(self.C_out, 1)

    self.dims = (self.C_out, h_in, w_in)  # dimensions of pool layer output
    self.fc_1 = nn.Linear(np.prod(self.dims), h_out)  # flattened pool output

  def forward(self, x):
    torch.pi = torch.acos(torch.zeros(1)).item() * 2
    gauss = torch.exp(-(self.time_grid - self.filter_dur/2)**2/(torch.sigmoid(self.center_freq/self.f_max -0.5)**2)*1000)
    tones = torch.cos(2*(torch.pi)*torch.relu(self.center_freq) * self.time_grid)
    filters = gauss * tones
    filters = filters.reshape(self.C_out,self.K[1],self.K[0])
    x = x.view(x.shape[0],x.shape[2],x.shape[1])
    x = F.conv1d(x, filters, stride=1, padding=self.K[0]//2)
    x = x.view(-1, np.prod(self.dims))  # flatten pooling layer outputs into a vector
    x = torch.relu(self.fc_1(x))  # output of fully connected layer
    return x