File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -261,7 +261,10 @@ def forward(self, x):
261
261
# Get number of actions from gym action space
262
262
n_actions = env .action_space .n
263
263
# Get the number of state observations
264
- state , _ = env .reset ()
264
+ if gym .__version__ [:4 ] == '0.26' :
265
+ state , _ = env .reset ()
266
+ elif gym .__version__ [:4 ] == '0.25' :
267
+ state , _ = env .reset (return_info = True )
265
268
n_observations = len (state )
266
269
267
270
policy_net = DQN (n_observations , n_actions ).to (device )
@@ -401,7 +404,10 @@ def optimize_model():
401
404
402
405
for i_episode in range (num_episodes ):
403
406
# Initialize the environment and get it's state
404
- state , _ = env .reset ()
407
+ if gym .__version__ [:4 ] == '0.26' :
408
+ state , _ = env .reset ()
409
+ elif gym .__version__ [:4 ] == '0.25' :
410
+ state , _ = env .reset (return_info = True )
405
411
state = torch .tensor (state , dtype = torch .float32 , device = device ).unsqueeze (0 )
406
412
for t in count ():
407
413
action = select_action (state )
You can’t perform that action at this time.
0 commit comments