Here is my problem, I have a linear layer.
- Everytime I forward, I want to make the linear weight multiply a mask.
linear = nn.Linear(10, 10) ## for example
Now during forward
def forward(inputs):
## which way below is the correct way to use? mask is with all 0 and 1 values/
self.linear.weight = self.linear.weight * torch.from_numpy(self.mask)
self.linear.weight.data= self.linear.weight.data * torch.from_numpy(self.mask)
### In the following code, I will use the updated linear layer to do something and
### want the model to check gradient