Python/PyTorch
-
PyTorch contiguous() 함수Python/PyTorch 2020. 1. 21. 16:31
torch.contiguous()에 대해 알아보자. 1. PyTorch documentation Returns a contiguous tensor containing the same data as self tensor. If self tensor is contiguous, this function returns the self tensor. 라는데... 그러면 contiguous tensor가 먼데...? 구글링을 시작했다. 2. Stack overflow 글 There are few operations on Tensor in PyTorch that do not really change the content of the tensor, but only how to convert indices in to t..
-
PyTorch nn.Sequential 알아보기Python/PyTorch 2020. 1. 21. 16:28
PyTorch 코드를 구경하다보면 종종 nn.Sequential 함수가 보인다. 그래서 알아보았다. 1. 그냥 구현 class CNN(nn.Module): def __init__(): super(CNN, self).__init__(): self.conv1 = nn.Conv2d(1, 32, kernel_size=(41, 11), stride=(2, 2), padding=(20, 5)) self.conv2 = nn.Conv2d(32, 32, kernel_size=(21, 11), stride=(2, 1), padding=(10, 5)) self.bn = nn.BatchNorm2d(32) self.act = nn.Hardtanh(0, 20, inplace=True), def forward(self, x): x..