tips
np.ndarray ⇔ torch.tensor の変換
# numpy => torch.tensor
np_array = np.zeros(3)
torch_array = torch.from_numpy(np_array)
# torch.tensor => numpy
torch_array = torch.zeros(3)
np_array = torch_array.numpy()
# numpy => torch.tensor
np_array = np.zeros(3)
torch_array = torch.from_numpy(np_array)
# torch.tensor => numpy
torch_array = torch.zeros(3)
np_array = torch_array.numpy()
コメント