Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tf2rl/algos/ddpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def get_action(self, state, test=False, tensor=False):
state = np.expand_dims(state, axis=0).astype(
np.float32) if is_single_state else state
action = self._get_action_body(
tf.constant(state), self.sigma * (1. - test),
tf.constant(state),
tf.constant(self.sigma * (1. - test), dtype=tf.float32),
tf.constant(self.actor.max_action, dtype=tf.float32))
if tensor:
return action
Expand Down
3 changes: 2 additions & 1 deletion tf2rl/algos/dqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ def train(self, states, actions, next_states, rewards, done, weights=None):
if weights is None:
weights = np.ones_like(rewards)
td_errors, q_func_loss = self._train_body(
states, actions, next_states, rewards, done, weights)
tf.constant(states), tf.constant(actions), tf.constant(next_states),
tf.constant(rewards), tf.constant(done), tf.constant(weights))

tf.summary.scalar(name=self.policy_name +
"/q_func_Loss", data=q_func_loss)
Expand Down
2 changes: 1 addition & 1 deletion tf2rl/algos/sac.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def get_action(self, state, test=False):

state = np.expand_dims(state, axis=0).astype(
np.float32) if is_single_state else state
action = self._get_action_body(tf.constant(state), test)
action = self._get_action_body(tf.constant(state), tf.constant(test))

return action.numpy()[0] if is_single_state else action

Expand Down
3 changes: 2 additions & 1 deletion tf2rl/algos/vpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def get_action(self, state, test=False):
is_single_input = state.ndim == self._state_ndim
if is_single_input:
state = np.expand_dims(state, axis=0).astype(np.float32)
action, logp, _ = self._get_action_body(state, test)
action, logp, _ = self._get_action_body(tf.constant(state, dtype=tf.float32),
tf.constant(test))

if is_single_input:
return action.numpy()[0], logp.numpy()
Expand Down