Files
pytorch-for-numpy-users/README.md
T
Kentaro Wada 8ef5e28027 Initial commit
2017-05-21 05:18:32 +09:00

30 lines
1.1 KiB
Markdown

# PyTorch for Numpy users
[PyTorch](https://github.com/pytorch/pytorch.git) version of [_Torch for Numpy users_](https://github.com/torch/torch7/wiki/Torch-for-Numpy-users).
## Types
| Numpy | PyTorch |
|:-------------|:---------------------|
| `np.uint8` | `torch.ByteTensor` |
| `np.int32` | `torch.IntTensor` |
| `np.int64` | `torch.LongTensor` |
| `np.float32` | `torch.FloatTensor` |
| `np.float64` | `torch.DoubleTensor` |
## Constructors
| Numpy | PyTorch |
|:-------------------|:---------------------------------------|
| `np.empty((2, 3))` | `torch.Tensor(2, 3)` |
| `np.empty_like(x)` | `x.new(x.size()).type(x.type())` |
| `np.eye` | `torch.eye` |
| `np.identity` | `torch.eye` |
| `np.ones` | `torch.ones` |
| `np.ones_like` | `torch.ones(x.size()).type(x.type())` |
| `np.zeros` | `torch.zeros` |
| `np.zeros_like` | `torch.zeros(x.size()).type(x.type())` |