Skip to content

Commit

Permalink
fix squeeze update to work with scalar action
Browse files Browse the repository at this point in the history
use float32
  • Loading branch information
pat-coady committed Aug 4, 2017
1 parent 2bb8af5 commit 4a2f6e5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ def run_episode(env, policy, scaler, animate=False):
while not done:
if animate:
env.render()
obs = obs.astype(np.float64).reshape((1, -1))
obs = obs.astype(np.float32).reshape((1, -1))
obs = np.append(obs, [[step]], axis=1) # add time step feature
unscaled_obs.append(obs)
obs = (obs - offset) * scale # center and scale observations
observes.append(obs)
action = policy.sample(obs).reshape((1, -1)).astype(np.float64)
action = policy.sample(obs).reshape((1, -1)).astype(np.float32)
actions.append(action)
obs, reward, done, _ = env.step(np.squeeze(action))
obs, reward, done, _ = env.step(np.squeeze(action, axis=0))
if not isinstance(reward, float):
reward = np.asscalar(reward)
rewards.append(reward)
Expand Down

0 comments on commit 4a2f6e5

Please sign in to comment.