Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
2074fd50
Commit
2074fd50
authored
Aug 15, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
linear interpolate schedule
parent
cee79998
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
5 deletions
+23
-5
tensorpack/callbacks/param.py
tensorpack/callbacks/param.py
+23
-5
No files found.
tensorpack/callbacks/param.py
View file @
2074fd50
...
@@ -161,20 +161,38 @@ class ScheduledHyperParamSetter(HyperParamSetter):
...
@@ -161,20 +161,38 @@ class ScheduledHyperParamSetter(HyperParamSetter):
"""
"""
Set hyperparameters by a predefined schedule.
Set hyperparameters by a predefined schedule.
"""
"""
def
__init__
(
self
,
param
,
schedule
):
def
__init__
(
self
,
param
,
schedule
,
interp
=
None
):
"""
"""
:param schedule: [(epoch1, val1), (epoch2, val2), (epoch3, val3), ...]
:param schedule: [(epoch1, val1), (epoch2, val2), (epoch3, val3), ...]
The value is fixed to val1 in epoch [epoch1, epoch2), and so on.
The value is fixed to val1 in epoch [epoch1, epoch2), and so on.
:param interp: None: no interpolation. 'linear': linear interpolation
"""
"""
schedule
=
[(
int
(
a
),
float
(
b
))
for
a
,
b
in
schedule
]
schedule
=
[(
int
(
a
),
float
(
b
))
for
a
,
b
in
schedule
]
self
.
schedule
=
sorted
(
schedule
,
key
=
operator
.
itemgetter
(
0
))
self
.
schedule
=
sorted
(
schedule
,
key
=
operator
.
itemgetter
(
0
))
if
interp
is
not
None
:
assert
interp
==
'linear'
self
.
interp
=
interp
super
(
ScheduledHyperParamSetter
,
self
)
.
__init__
(
param
)
super
(
ScheduledHyperParamSetter
,
self
)
.
__init__
(
param
)
def
_get_value_to_set
(
self
):
def
_get_value_to_set
(
self
):
for
e
,
v
in
self
.
schedule
:
if
self
.
interp
is
None
:
if
e
==
self
.
epoch_num
:
for
e
,
v
in
self
.
schedule
:
return
v
if
e
==
self
.
epoch_num
:
return
None
return
v
return
None
else
:
laste
,
lastv
=
None
,
None
for
e
,
v
in
self
.
schedule
:
if
e
==
self
.
epoch_num
:
return
v
if
e
>
self
.
epoch_num
:
break
laste
,
lastv
=
e
,
v
if
laste
is
None
or
laste
==
e
:
# hasn't reached the first scheduled point, or reached the end of all scheduled points
return
None
v
=
(
self
.
epoch_num
-
laste
)
*
1.
/
(
e
-
laste
)
*
(
v
-
lastv
)
+
lastv
return
v
class
StatMonitorParamSetter
(
HyperParamSetter
):
class
StatMonitorParamSetter
(
HyperParamSetter
):
"""
"""
...
...
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