8000 [2023.05.29] commit-2 · DarriusL/DRL-ExampleCode@cbcab7a · GitHub
[go: up one dir, main page]

Skip to content

Commit cbcab7a

Browse files
committed
[2023.05.29] commit-2
`Fixed the problem that each sampling of PER in the system is the first experience.
1 parent c2b7e14 commit cbcab7a

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

agent/algorithm/dqn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ def init_net(self, net_cfg, optim_cfg, lr_schedule_cfg, in_dim, out_dim, max_epo
9292
'''
9393
super().init_net(net_cfg, optim_cfg, lr_schedule_cfg, in_dim, out_dim, max_epoch);
9494
self.q_target_net = get_net(net_cfg, in_dim, out_dim).to(glb_var.get_value('device'));
95-
self.net_updater.set_net(self.q_net, self.q_target_net);
9695
#Initialize q_target_net with q_net
9796
self.net_updater.net_param_copy(self.q_net, self.q_target_net);
97+
self.net_updater.set_net(self.q_net, self.q_target_net);
9898
self.q_eval_net = self.q_target_net;
9999

100100
def update(self):

agent/memory/offpolicy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def get_stock(self):
293293
def sample(self):
294294
'''Sample batch'''
295295
if self.is_training:
296-
if len(self.exps_latest) == 0:
296+
if len(self.exps_latest) != 0:
297297
#Add the experience that has not been added to the tree first.
298298
idxs, priorities = tuple(zip(*self.exps_latest));
299299
self.exps_latest.clear();

config/dqn/doubledqn_cartpole_per.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
"name":"linear",
77
"var_start":5.0,
88
"var_end":0.05,
9-
"star_epoch":1000,
9+
"star_epoch":100,
1010
"end_epoch":10000
1111
},
1212
"gamma": 0.99,
1313
"net_updte_cfg":{
1414
"name":"polyak",
1515
"beta":0.5,
16-
"update_step":10
16+
"update_step":50
1717
}
1818
},
1919
"net_cfg":{
@@ -23,7 +23,7 @@
2323
},
2424
"optimizer_cfg":{
2525
"name":"adam",
26-
"lr":2e-3,
26+
"lr":1e-2,
2727
"weight_decay": 1e-08,
2828
"betas": [
2929
0.9,

0 commit comments

Comments
 (0)
0