Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style_gan2_pytorch/simple_upfirdn_2d.pyについて #17

Closed
kazukiyamaji opened this issue Apr 7, 2022 · 1 comment
Closed

style_gan2_pytorch/simple_upfirdn_2d.pyについて #17

kazukiyamaji opened this issue Apr 7, 2022 · 1 comment

Comments

@kazukiyamaji
Copy link

simple_upfirdn_2d.py内のforward関数内の処理で、

# pad_all = batch_in_ch_pad + in_height_pad + in_h_in_w_pad + in_width_pad + in_w_minor_dim_pad + minor_dim_pad
pad_all = pad00 + pad01 + pad02 + pad03 + pad04 + pad05 + pad06
x_ = F.pad(x_, pad_all)

と書いてあるのですが、pytorchのF.pad(x,pad)はxの後ろの次元から、padの先頭から順に決められた数でpadを取るので、正式にはコメントは

#pad_all=minor_dim_pad+in_w_minor_dim_pad +in_width_pad+ in_h_in_w_pad + in_height_pad+batch_in_ch_pad

となるのではないのでしょうか。

また、

in_height_pad = [max(pady0, 0), max(pady1, 0)]
in_width_pad = [max(padx0, 0), max(padx1, 0)]
pad_crop = pad00 + in_height_pad + in_width_pad + pad06
x_ = F.pad(x_, pad_crop)

の処理も同様で、
この処理だと、in_height_padでwidthのpadを作り、in_width_padでheightのpadを作るようになっていると思われます。

間違っていたら申し訳ございません。

@h-s-dev
Copy link
Collaborator

h-s-dev commented Apr 17, 2022

ご指摘ありがとうございます。

# pad_all = batch_in_ch_pad + in_height_pad + in_h_in_w_pad + in_width_pad + in_w_minor_dim_pad + minor_dim_pad
pad_all = pad00 + pad01 + pad02 + pad03 + pad04 + pad05 + pad06

上記についてはコメントが間違っていました

n_height_pad = [max(pady0, 0), max(pady1, 0)]
in_width_pad = [max(padx0, 0), max(padx1, 0)]
pad_crop = pad00 + in_height_pad + in_width_pad + pad06
x_ = F.pad(x_, pad_crop)

上記については

pad_crop = pad00 + in_width_pad + in_height_pad + pad06

が正しい処理となります

@h-s-dev h-s-dev closed this as completed Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants