Don’t use the .data attribute, as it might break your code in various ways.
For your use case, you could use the functional API as given in this example:
class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(1, 16, kernel_size=3, stride=2, padding=1)
        self.conv2 = nn.Conv2d(16, 16, kernel_size=3, stride=2, padding=1)
        self.conv3 = nn.Conv2d(16, 10, kernel_size=3, stride=2, padding=1)
        
    def forward(self, x):
        x = F.conv2d(x, torch.sigmoid(self.conv1.weight), self.conv1.bias)
        x = F.relu(x)
        x = F.conv2d(x, torch.sigmoid(self.conv2.weight), self.conv2.bias)
        x = F.relu(x)
        x = F.conv2d(x, torch.sigmoid(self.conv3.weight), self.conv3.bias)
        x = F.relu(x)
        x = F.avg_pool2d(x, 4)
        return x


model = Net()
data = torch.randn(1, 1, 28, 28)
out = model(data)
out.mean().backward()

for name, param in model.named_parameters():
    print(name, param.grad)