I am using grid_sample function, that

```
torch.nn.functional.grid_sample(input, grid, mode='bilinear', padding_mode='zeros')
```

I want to construct a random grid and it trained with the network. The scrip likes

```
class Network(nn.Module):
def __init__(self):
self.rnd_grid_tensor = ... (required_grad=True)
def forward(self,input):
output = torch.nn.functional.grid_sample(input, self.rnd_grid_tensor, mode='bilinear', padding_mode='zeros')
return output
```

How to generate the rnd_grid_tensor so that the value in the grid followed by gaussian distribution. Thanks

This is my solution but I am not sure is it correct or not

```
from torch.autograd import Variable
def gaussian(ins, is_training, mean, stddev):
if is_training:
noise = Variable(ins.data.new(ins.size()).normal_(mean, stddev))
return ins + noise
return ins
grid = torch.rand((1,2,16,16), requires_grad=True)
grid = gaussian (grid, True, 1, 0.1)
```