mirror of
https://github.com/wassname/pytorch-for-numpy-users.git
synced 2026-06-27 16:10:21 +08:00
46 lines
1.0 KiB
YAML
46 lines
1.0 KiB
YAML
types:
|
|
- numpy: np.float32
|
|
pytorch: torch.FloatTensor
|
|
- numpy: np.float64
|
|
pytorch: torch.DoubleTensor
|
|
- numpy: np.int8
|
|
pytorch: torch.CharTensor
|
|
- numpy: np.uint8
|
|
pytorch: torch.ByteTensor
|
|
- numpy: np.int16
|
|
pytorch: torch.ShortTensor
|
|
- numpy: np.int32
|
|
pytorch: torch.IntTensor
|
|
- numpy: np.int64
|
|
pytorch: torch.LongTensor
|
|
|
|
constructors:
|
|
- numpy: np.empty((2, 3))
|
|
pytorch: torch.Tensor(2, 3)
|
|
- numpy: np.empty_like(x)
|
|
pytorch: x.new(x.size()).type(x.type())
|
|
- numpy: np.eye
|
|
pytorch: torch.eye
|
|
- numpy: np.identity
|
|
pytorch: torch.eye
|
|
- numpy: np.ones
|
|
pytorch: torch.ones
|
|
- numpy: np.ones_like
|
|
pytorch: torch.ones(x.size()).type(x.type())
|
|
- numpy: np.zeros
|
|
pytorch: torch.zeros
|
|
- numpy: np.zeros_like
|
|
pytorch: torch.zeros(x.size()).type(x.type())
|
|
|
|
# - numpy: x.astype(np.int32)
|
|
# pytorch: x.type(torch.IntTensor)
|
|
#
|
|
# - numpy: y = x.copy()
|
|
# pytorch: y = x.clone()
|
|
#
|
|
# - numpy: x.shape
|
|
# pytorch: x.size()
|
|
#
|
|
# - numpy: x.size
|
|
# pytorch: x.nelement()
|