[03] nn.Module 이해하기
pytorch documentation https://pytorch.org/docs/stable/index.html PyTorch documentation — PyTorch 1.10.1 documentation Shortcuts pytorch.org index select >>> x = torch.randn(3, 4) >>> x tensor([[ 0.1427, 0.0231, -0.5414, -1.0009], [-0.4664, 0.2647, -0.1228, -1.1068], [-1.1734, -0.6571, 0.7230, -0.6004]]) >>> indices = torch.tensor([0, 2]) >>> torch.index_select(x, 0, indices) tensor([[ 0.1427, 0...
[02] Pytorch Basics
Tensor 다차원 Arrays를 표현하는 pytorch 클래스 사실상 numpy의 ndarray와 동일 ( = 텐서프로 Tensor와 동일 ) import numpy as np n_array = np.arange(10) # array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) n_array = n_array.reshape(2,5) print("ndim :", n_array.ndim, "shape :", n_array.shape) #ndim : 2 shape : (2, 5) import torch t_array = torch.FloatTensor(n_array) print("ndim :", t_array.ndim, "shape :", t_array.shape) # ndim : 2 shape..