プリンキピア

第2章準備

2.2.3. Conversion to the Tensor Format2.2.3 テンソル形式への変換

Now that all the entries in inputs and targets are numerical, we can load them into a tensor (recall Section 2.1).
英語のヒント
これでinputsとtargetsの項目はすべて数値になったので、テンソルに読み込める(2.1節を思い出そう)。
import torch

X = torch.tensor(inputs.to_numpy(dtype=float))
y = torch.tensor(targets.to_numpy(dtype=float))
X, y
(tensor([[3., 0., 1.],
         [2., 0., 1.],
         [4., 1., 0.],
         [3., 0., 1.]], dtype=torch.float64),
 tensor([127500., 106000., 178100., 140000.], dtype=torch.float64))