Question
How to assign value to a zero dimensional torch tensor?
z = torch.tensor(1, dtype= torch.int64)
z[:] = 5
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: slice() cannot be applied to a 0-dim tensor.
I'm trying to assign a value to a torch tensor but because it has zero dimensions the slice operator doesn't work. How do I assign a new value then?