Skip to content

Commit cd5b69b

Browse files
authored
Update actor_critic_cartpole.py
1 parent 1d548e4 commit cd5b69b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

examples/rl/actor_critic_cartpole.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
import os
4646

4747
os.environ["KERAS_BACKEND"] = "tensorflow"
48-
import gym
48+
import gymnasium as gym
4949
import numpy as np
5050
import keras
5151
from keras import ops
@@ -98,13 +98,13 @@
9898
episode_count = 0
9999

100100
while True: # Run until solved
101-
state = env.reset()[0]
101+
obs, _ = env.reset()
102102
episode_reward = 0
103103
with tf.GradientTape() as tape:
104104
for timestep in range(1, max_steps_per_episode):
105105

106-
state = ops.convert_to_tensor(state)
107-
state = ops.expand_dims(state, 0)
106+
state = tf.convert_to_tensor(state)
107+
state = tf.expand_dims(state, 0)
108108

109109
# Predict action probabilities and estimated future rewards
110110
# from environment state

0 commit comments

Comments
 (0)