-
Notifications
You must be signed in to change notification settings - Fork 211
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
Some comments about code of PartialConv2d #28
Comments
Thanks for your great suggestions. Will update them accordingly after testing. |
Does |
@ivanstepanovftw I don't think it makes a copy. However, since it is only used as an argument for |
Also I think this operation is useless: partialconv/models/partialconv2d.py Line 75 in 610d373
because input will be multiplied by the mask anyway here: partialconv/models/partialconv2d.py Line 70 in 610d373
|
Hi,
I really like your work - thank you for sharing the code.
I have some remarks on the code of PartialConv2d:
1. Using buffers instead of simple "member tensors":
The class attribute
self.weight_maskUpdater
is defined as a "plain" tensor:partialconv/models/partialconv2d.py
Lines 32 to 35 in 610d373
As a result, when the model is transferred to GPU, or data type is changing you need to explicitly check for it and change it:
partialconv/models/partialconv2d.py
Lines 49 to 50 in 610d373
A more elegant way is to use non-persistent buffers:
This way
self.weight_maskUpdater
will be affected by any.to(...)
/.cuda()
/.cpu()
invoked on the model hosting this layer, making the condition on line 49 redundent.2. Use of
torch.ones_like
Instead of
torch.ones(...).to(...)
partialconv/models/partialconv2d.py
Lines 54 to 57 in 610d373
You can use
torch.ones_like
which is simpler and easier to read:3. No need to import
Variable
You import
Variable
, but never use it.partialconv/models/partialconv2d.py
Line 12 in 610d373
BTW All these comments are applicable to the code of
PartialConv3d
.The text was updated successfully, but these errors were encountered: