Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
210130121
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2021
210130121
Commits
a94748f1
Unverified
Commit
a94748f1
authored
3 years ago
by
Xiaoyu Xu
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
rm nn.Graph.train (#5424)
* rm nn.Graph.train * Update graph.py GraphCofig default predict * Update test_graph.py
parent
9356c9d7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
oneflow/python/nn/graph.py
+1
-7
1 addition, 7 deletions
oneflow/python/nn/graph.py
oneflow/python/test/graph/test_graph.py
+2
-14
2 additions, 14 deletions
oneflow/python/test/graph/test_graph.py
with
3 additions
and
21 deletions
oneflow/python/nn/graph.py
+
1
−
7
View file @
a94748f1
...
...
@@ -39,7 +39,6 @@ class Graph(object):
self
.
_optimizers
=
OrderedDict
()
self
.
_is_compiled
=
False
self
.
_state_tensortuple
=
None
self
.
train
(
True
)
@property
def
name
(
self
):
...
...
@@ -64,12 +63,6 @@ class Graph(object):
optimizer
,
lr_scheduler
,
grad_clipping_conf
,
weight_decay_conf
)
def
train
(
self
,
mode
:
bool
=
True
):
self
.
config
.
_train
(
mode
)
for
name
,
block
in
self
.
_blocks
.
items
():
assert
block
.
type
==
BlockType
.
MODULE
block
.
origin
.
train
(
mode
)
def
_named_state
(
self
):
for
_
,
b
in
self
.
_blocks
.
items
():
prefix
=
b
.
name
+
"
.
"
...
...
@@ -329,6 +322,7 @@ class Block(object):
class
GraphConfig
(
FunctionConfig
):
def
__init__
(
self
):
super
().
__init__
()
self
.
_train
(
False
)
@property
def
proto
(
self
):
...
...
This diff is collapsed.
Click to expand it.
oneflow/python/test/graph/test_graph.py
+
2
−
14
View file @
a94748f1
...
...
@@ -114,23 +114,11 @@ class TestGraph(flow.unittest.TestCase):
g
=
CustomGraph
()
# check set train to True
g
.
train
(
True
)
test_case
.
assertEqual
(
g
.
training
,
True
)
test_case
.
assertEqual
(
g
.
m
.
training
,
True
)
test_case
.
assertEqual
(
g
.
m
.
layer
.
conv1
.
training
,
True
)
# check default training is True
test_case
.
assertEqual
(
g
.
config
.
training
,
False
)
# set graph config
g
.
config
.
enable_fuse_add_to_output
(
True
)
# check set train to False
g
.
train
(
False
)
test_case
.
assertEqual
(
g
.
training
,
False
)
test_case
.
assertEqual
(
g
.
training
,
False
)
test_case
.
assertEqual
(
g
.
m
.
training
,
False
)
test_case
.
assertEqual
(
g
.
m
.
layer
.
conv1
.
training
,
False
)
# set graph config
g
.
config
.
enable_fuse_add_to_output
(
False
)
# check _named_state get the right tensor
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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