I create a model and it’s similar to NTM(neural turing mathine) .

But when it comes to writing module , it got a `inplace operation`

error. The error happens in the following code.

```
w_pattern = self.fc2(pattern[i])
prev_mem = self.mem
erase = self.get_erase(w_pattern) # [1, M]
era_mat = torch.zeros(self.N, self.M)
era_mat[self.num_patterns, :] = erase
add = weight[i] * w_pattern # [1, M]
add_mat = torch.zeros(self.N, self.M)
add_mat[self.num_patterns, :] = add
# this line below got an error
self.mem = (prev_mem * (torch.ones(self.N, self.M) - era_mat) + add_mat)
self.access_order.append(self.num_patterns)
self.num_patterns = self.num_patterns + 1
```

I found this line because I debugged line by line and found that in this line the property self.mem. _version has changed from 1 to 0.

But i don’t know how to solve it ,I’m still trying