Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
OvoTools
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林帅浩
OvoTools
Commits
1237f3d8
Commit
1237f3d8
authored
Apr 05, 2019
by
IlyaOvodov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
To new ignite with my update
parent
0b5d797d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
13 deletions
+4
-13
ignite_tools.py
ovotools/ignite_tools.py
+4
-13
No files found.
ovotools/ignite_tools.py
View file @
1237f3d8
...
@@ -271,21 +271,12 @@ def create_supervised_trainer(model, optimizer, loss_fn, metrics={},
...
@@ -271,21 +271,12 @@ def create_supervised_trainer(model, optimizer, loss_fn, metrics={},
Returns:
Returns:
Engine: a trainer engine with supervised update function.
Engine: a trainer engine with supervised update function.
"""
"""
if
device
:
engine
=
ignite
.
engine
.
create_supervised_trainer
(
model
,
optimizer
,
loss_fn
,
device
,
non_blocking
,
prepare_batch
,
model
.
to
(
device
)
output_transform
=
lambda
x
,
y
,
y_pred
,
loss
:
(
y_pred
,
y
,)
)
def
_update
(
engine
,
batch
):
@engine.on
(
Events
.
ITERATION_STARTED
)
def
reset_output
(
engine
):
engine
.
state
.
output
=
None
engine
.
state
.
output
=
None
model
.
train
()
optimizer
.
zero_grad
()
x
,
y
=
prepare_batch
(
batch
,
device
=
device
,
non_blocking
=
non_blocking
)
y_pred
=
model
(
x
)
loss
=
loss_fn
(
y_pred
,
y
)
loss
.
backward
()
optimizer
.
step
()
return
y_pred
,
y
engine
=
ignite
.
engine
.
Engine
(
_update
)
for
name
,
metric
in
metrics
.
items
():
for
name
,
metric
in
metrics
.
items
():
metric
.
attach
(
engine
,
'train:'
+
name
)
metric
.
attach
(
engine
,
'train:'
+
name
)
...
...
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