diff --git a/tf2rl/algos/ddpg.py b/tf2rl/algos/ddpg.py index d3772d0..d48499b 100755 --- a/tf2rl/algos/ddpg.py +++ b/tf2rl/algos/ddpg.py @@ -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 diff --git a/tf2rl/algos/dqn.py b/tf2rl/algos/dqn.py index 6bdae9c..038169e 100644 --- a/tf2rl/algos/dqn.py +++ b/tf2rl/algos/dqn.py @@ -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) diff --git a/tf2rl/algos/sac.py b/tf2rl/algos/sac.py index f1ace1a..985c559 100644 --- a/tf2rl/algos/sac.py +++ b/tf2rl/algos/sac.py @@ -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 diff --git a/tf2rl/algos/vpg.py b/tf2rl/algos/vpg.py index bb3224d..4c31bc4 100644 --- a/tf2rl/algos/vpg.py +++ b/tf2rl/algos/vpg.py @@ -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()