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

Type check lint fixes #599

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions opacus/grad_sample/conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ def compute_conv_grad_sample(
return ret

# get activations and backprops in shape depending on the Conv layer
if type(layer) == nn.Conv2d:
if type(layer) is nn.Conv2d:
activations = unfold2d(
activations,
kernel_size=layer.kernel_size,
padding=layer.padding,
stride=layer.stride,
dilation=layer.dilation,
)
elif type(layer) == nn.Conv1d:
elif type(layer) is nn.Conv1d:
activations = activations.unsqueeze(-2) # add the H dimension
# set arguments to tuples with appropriate second element
if layer.padding == "same":
Expand All @@ -77,7 +77,7 @@ def compute_conv_grad_sample(
stride=(1, layer.stride[0]),
dilation=(1, layer.dilation[0]),
)
elif type(layer) == nn.Conv3d:
elif type(layer) is nn.Conv3d:
activations = unfold3d(
activations,
kernel_size=layer.kernel_size,
Expand Down
2 changes: 1 addition & 1 deletion opacus/privacy_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _prepare_model(
if (
module.batch_first != batch_first
or module.loss_reduction != loss_reduction
or type(module) != get_gsm_class(grad_sample_mode)
or type(module) is not get_gsm_class(grad_sample_mode)
):
raise ValueError(
f"Pre-existing GradSampleModule doesn't match new arguments."
Expand Down
Loading