Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
61763fa9
Commit
61763fa9
authored
Jan 10, 2020
by
Sergey Zagoruyko
Committed by
Francisco Massa
Jan 10, 2020
Browse files
fix for loading models with num_batches_tracked in frozen bn (#1728)
parent
be6dd472
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
torchvision/ops/misc.py
torchvision/ops/misc.py
+10
-0
No files found.
torchvision/ops/misc.py
View file @
61763fa9
...
...
@@ -130,6 +130,16 @@ class FrozenBatchNorm2d(torch.nn.Module):
self
.
register_buffer
(
"running_mean"
,
torch
.
zeros
(
n
))
self
.
register_buffer
(
"running_var"
,
torch
.
ones
(
n
))
def
_load_from_state_dict
(
self
,
state_dict
,
prefix
,
local_metadata
,
strict
,
missing_keys
,
unexpected_keys
,
error_msgs
):
num_batches_tracked_key
=
prefix
+
'num_batches_tracked'
if
num_batches_tracked_key
in
state_dict
:
del
state_dict
[
num_batches_tracked_key
]
super
(
FrozenBatchNorm2d
,
self
).
_load_from_state_dict
(
state_dict
,
prefix
,
local_metadata
,
strict
,
missing_keys
,
unexpected_keys
,
error_msgs
)
def
forward
(
self
,
x
):
# move reshapes to the beginning
# to make it fuser-friendly
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment