Solved by ptrblck in post #2 
              
              
                1 To convert a tensor to a numpy array use a = tensor.numpy(), replace the values, and store it via e.g. np.save. 
2. To convert a numpy array to a tensor use tensor = torch.from_numpy(a).