파이토치(3)
-
[pytorch] nn.Upsample
주어진 멀티채널 1D / 2D / 3D 데이터를 업샘플링한다. 인풋데이터는 minibatch x channels x [optional depth] x [optional height] x width 형태로 가정되나, spatial input(2D)은 4D 텐서, volumetric input(3D)은 5D텐서가능한 알고리즘 : nearest neighbor, linear, bilinear, bicubic, 3D이상의 데이터에 대해서는 trilinear parameters size (int/tuple) : output 사이즈 scale_factor(float/tuple) : Depth, Height, Width에 입력받은 정수 만큼 곱해준다. (1,1,2,2) 가 인풋으로 들어오면 (1,1,4,4)가 된다...
2021.06.16 -
[Pytorch] nn.ReflectionPad2d
input tensor를 input boundary의 reflection(반사)를 이용해서 패딩 적용 2차원 아닌 N차원 패딩을 이용하려면 torch.nn.functional.pad()를 사용 padding은 int형이나 tuple형 : 패딩 사이즈. int형이면 모든 바운더리에 같은 패딩을 적용. 4-tuple이면 (padding_left, padding_right, padding_top, padding_bottom)으로 적용 Input: (N, C, H_in, W_in) Output: (N, C, H_out, W_out) W_out = W_in + padding_left + padding_right H_out = H_in + padding_top + padding_bottom https://pyt..
2021.06.16 -
[Pytorch] Initializer (torch.nn.init)
torch.nn.init의 간단한 initializer들을 살펴보겠다 xavier같은 초기화기법들은 따로 다루기 1. torch.nn.init.normal_(tensor, mean=0.0, std=1.0) input tensor을 N(mean, std^2)의 normal distribution(정규분포)에 따라 초기화 2. torch.nn.init.uniform_(tensor, a=0.0, b=1.0) input tensor을 U(a, b)의 uniform distribution에 따라 초기화 * uniform distribution ? [a, b]의 범위에서 모든 값의 확률이 동일한 분포 3. torch.nn.init.constant_(tensor, val) input tensor를 특정 값 val로 ..
2021.06.15