• 카테고리

    질문 & 답변
  • 세부 분야

    딥러닝 · 머신러닝

  • 해결 여부

    미해결

DCGAN 실습 Generator 질문

22.04.08 11:51 작성 조회수 277

0

안녕하세요. DCGAN 실습부분 Generator 부분의 shape가 궁금해서 질문드립니다.

 

아래 코드 부분에 nn.ConvTranspose2d가 어떻게 동작해서 state size가 4x4, 8x8, 16x16이 되는 지 궁금합니다.

(ngf*8) x 4 x 4

(ngf*4) x 8 x 8

(ngf*2) x 16 x 16

class Generator(nn.Module):
def __init__(self):
super(Generator, self).__init__()
self.main = nn.Sequential(
 
# input is Z, going into a convolution
nn.ConvTranspose2d( nz, ngf * 8, 4, 1, 0, bias=False),
nn.BatchNorm2d(ngf * 8),
nn.ReLU(True),
# state size. (ngf*8) x 4 x 4
nn.ConvTranspose2d(ngf * 8, ngf * 4, 4, 2, 1, bias=False),
nn.BatchNorm2d(ngf * 4),
nn.ReLU(True),
# state size. (ngf*4) x 8 x 8
nn.ConvTranspose2d( ngf * 4, ngf * 2, 4, 2, 1, bias=False),
nn.BatchNorm2d(ngf * 2),
nn.ReLU(True),
# state size. (ngf*2) x 16 x 16
nn.ConvTranspose2d( ngf * 2, ngf, 4, 2, 1, bias=False),
nn.BatchNorm2d(ngf),
nn.ReLU(True),
# state size. (ngf) x 32 x 32
nn.ConvTranspose2d( ngf, nc, 4, 2, 1, bias=False),
nn.Tanh()
# state size. (nc) x 64 x 64
)

답변 1

답변을 작성해보세요.

0

안녕하세요. 슈림프님

nn.ConvTranspose2d(ngf * 8, ngf * 4, 4, 2, 1, bias=False),
nn.BatchNorm2d(ngf * 4),

 

위 코드 부분에서 output channer을 ngf * 4로 설정했기 때문에

다음 convolution layer의 input이  ngf * 4가 되는것이며

그 다음 옵션인 filter size 4와 stride 2에 의해 state size가 두배가 됩니다.

conv2d의 작동 방법은 아래 링크를 참고해주시면 감사하겠습니다.

https://d2l.ai/chapter_computer-vision/transposed-conv.html