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

Error with code notation. #12

Open
akanimax opened this issue Aug 26, 2018 · 2 comments
Open

Error with code notation. #12

akanimax opened this issue Aug 26, 2018 · 2 comments

Comments

@akanimax
Copy link

Hi @mkocabas,

There is a slight mismatch in the notation used to denote the extracted dimensions from the shape of the input tensor. here

batch_size, _, x_dim, y_dim = input_tensor.size()

You extract x_dim from dimension number 2 and y_dim from dimension number 3. As per the image based 4d tensors of Pytorch, it is the height that comes before width. Please refer to the documentation of Pytorch's Conv2d layer. Notice the input and output tensor shapes.

The code would run fine since the extracted dimensions end up in right place when constructing the output tensor, but for a code reader like me (implementation checking), it seems like a mistake at first glance. Perhaps, the notation can be changed as per Pytorch.
Thanks

Cheers!
@akanimax

@CharlesNord
Copy link

Hi @mkocabas,

There is a slight mismatch in the notation used to denote the extracted dimensions from the shape of the input tensor. here

batch_size, _, x_dim, y_dim = input_tensor.size()

You extract x_dim from dimension number 2 and y_dim from dimension number 3. As per the image based 4d tensors of Pytorch, it is the height that comes before width. Please refer to the documentation of Pytorch's Conv2d layer. Notice the input and output tensor shapes.

The code would run fine since the extracted dimensions end up in right place when constructing the output tensor, but for a code reader like me (implementation checking), it seems like a mistake at first glance. Perhaps, the notation can be changed as per Pytorch.
Thanks

Cheers!
@akanimax

I agree with you , the code works fine is because on line 95 and 96, the author applies .transpose(2, 3) to the xx_channel and yy_channel:

xx_channel = xx_channel.repeat(batch_size, 1, 1, 1).transpose(2, 3)
yy_channel = yy_channel.repeat(batch_size, 1, 1, 1).transpose(2, 3)

@akanimax
Copy link
Author

akanimax commented Mar 8, 2019

@CharlesNord,

Yes the code works fine but I just pointed out that it is slightly confusing to read. Has it been updated yet? Let me know if you need any more help.

Best regards,
@akanimax

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