1.使用torch.as_tensor(a)时报错:ValueError: some of the strides of a given numpy array are negative. This is currently not supported, but will be added in future releases.
解决方式: torch.as_tensor(a.copy())
2.使用loss.data[0]时报错:IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number.
解决方式: 将loss.data[0]改为loss.item()