inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

[PyTorch] 쉽고 빠르게 배우는 GAN

DCGAN 실습 Generator 질문

477

슈림프

작성한 질문수 2

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
)

dcgan pytorch 인공신경망 딥러닝

답변 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

 

섹션22 퀴즈 질문

0

34

1

DCGAN 실습에 있는 celba 이미지 다운로드 권한 요청

0

382

0

GAN의 베이스코드에 대하여

0

324

0

(Pdata + Pg) / 2 가 왜 Q인가요?

0

258

0

z의 x 변환

0

297

0

cuda 버전 질문입니다!

0

238

0

결과를 다운받는 방법이 궁금합니다.

0

234

0

DCGAN Generator 질문

0

270

0

LSGAN 파트 질문입니다

0

361

0

output with shape [1, 28, 28] doesn't match the broadcast shape [3, 28, 28]

0

680

1

runtime error : Found dtype Long but expected Float

0

389

1

runtime error : Found dtype Long but expected Float

0

1532

3

컴퓨터 사양 문의 드립니다.

0

467

2

runtime_Found 0 files

0

227

1

transforms.Normalize

0

427

2

cpu로 돌릴 경우, 코드 수정

1

304

1

GAN - Audio 관련 연구

0

261

1

강의자료 문의

0

338

2

문의사항

0

251

1

데이터

0

240

1

GAN

0

213

1

GAN 프로젝트

0

273

1

celeba 이미지 불러오기 실패

0

622

2

dcgan, lsgan 질문

0

305

2