Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ICV-mmengine_basecode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Schiffel
ICV-mmengine_basecode
Commits
f3189918
Unverified
Commit
f3189918
authored
2 years ago
by
RangiLyu
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[Fix] Fix logged and current weight not on the same device. (#382)
parent
16ef54c4
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
mmengine/model/base_module.py
+1
-1
1 addition, 1 deletion
mmengine/model/base_module.py
mmengine/model/utils.py
+1
-1
1 addition, 1 deletion
mmengine/model/utils.py
mmengine/runner/runner.py
+1
-3
1 addition, 3 deletions
mmengine/runner/runner.py
with
3 additions
and
5 deletions
mmengine/model/base_module.py
+
1
−
1
View file @
f3189918
...
...
@@ -80,7 +80,7 @@ class BaseModule(nn.Module, metaclass=ABCMeta):
f
'
after calling `init_weights`
'
\
f
'
of
{
self
.
__class__
.
__name__
}
'
self
.
_params_init_info
[
param
][
'
tmp_mean_value
'
]
=
param
.
data
.
mean
()
'
tmp_mean_value
'
]
=
param
.
data
.
mean
()
.
cpu
()
# pass `params_init_info` to all submodules
# All submodules share the same `params_init_info`,
...
...
This diff is collapsed.
Click to expand it.
mmengine/model/utils.py
+
1
−
1
View file @
f3189918
...
...
@@ -41,7 +41,7 @@ def update_init_info(module, init_info):
# The parameter has been changed during executing the
# `init_weights` of module
mean_value
=
param
.
data
.
mean
()
mean_value
=
param
.
data
.
mean
()
.
cpu
()
if
module
.
_params_init_info
[
param
][
'
tmp_mean_value
'
]
!=
mean_value
:
module
.
_params_init_info
[
param
][
'
init_info
'
]
=
init_info
module
.
_params_init_info
[
param
][
'
tmp_mean_value
'
]
=
mean_value
...
...
This diff is collapsed.
Click to expand it.
mmengine/runner/runner.py
+
1
−
3
View file @
f3189918
...
...
@@ -776,8 +776,7 @@ class Runner:
def
build_model
(
self
,
model
:
Union
[
BaseModel
,
Dict
])
->
BaseModel
:
"""
Build model.
If ``model`` is a dict, it will be used to build a nn.Module object
and initialize the weights if it has ``init_weights`` method.
If ``model`` is a dict, it will be used to build a nn.Module object.
Else, if ``model`` is a nn.Module object it will be returned directly.
An example of ``model``::
...
...
@@ -796,7 +795,6 @@ class Runner:
return
model
elif
isinstance
(
model
,
dict
):
model
=
MODELS
.
build
(
model
)
# init weights
return
model
# type: ignore
else
:
raise
TypeError
(
'
model should be a nn.Module object or dict,
'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment