Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
lli
YM-Seminar
Commits
3e7338b7
Commit
3e7338b7
authored
Apr 29, 2021
by
lli
Browse files
update
parent
25c32d11
Changes
2
Hide whitespace changes
Inline
Side-by-side
train_dqn.py
View file @
3e7338b7
...
...
@@ -139,7 +139,7 @@ for episode in range(n_episode):
f
'num_no_capacity:
{
num_no_capacity
[
episode
]
}
, accepted orders:
{
accepted_orders
[
episode
]
}
'
)
print
(
f
"Training time for
{
n_episode
}
episodes:
{
timer
()
-
start_time
}
"
)
print
(
f
"Training time for
{
args
.
n_episode
}
episodes:
{
timer
()
-
start_time
}
"
)
# save the model parameters
torch
.
save
(
dqn
.
state_dict
(),
os
.
path
.
join
(
OUT_PATH
,
'dqn_{}.pk1'
.
format
(
n_episode
)))
...
...
@@ -186,7 +186,7 @@ plt.savefig(os.path.join(OUT_PATH, 'penalties.png'), dpi=1200, transparent=True,
plt
.
close
()
# Plot loss
loss
=
plt
.
plot
(
losses
,
label
=
'Loss'
)
loss
=
plt
.
plot
(
sliding_window
(
losses
,
len
(
losses
))
,
label
=
'Loss'
)
plt
.
title
(
'Loss'
)
plt
.
xlabel
(
'Steps'
)
plt
.
ylabel
(
'Loss'
)
...
...
train_reinforce.py
View file @
3e7338b7
...
...
@@ -178,6 +178,8 @@ for episode in range(n_episode):
#writer.close()
print
(
f
"Training time for
{
args
.
n_episode
}
episodes:
{
timer
()
-
start_time
}
"
)
# save the model parameters
torch
.
save
(
policy_net
.
state_dict
(),
os
.
path
.
join
(
OUT_PATH
,
'policy_{}.pk1'
.
format
(
n_episode
)))
torch
.
save
(
value_net
.
state_dict
(),
os
.
path
.
join
(
OUT_PATH
,
'value_{}.pk1'
.
format
(
n_episode
)))
...
...
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