Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Related to Fixing errors with _obtain_steps function #27 #28

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
13 changes: 6 additions & 7 deletions scope_rl/dataset/synthetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,10 @@ def _obtain_steps(
actions = np.zeros(n_trajectories * step_per_trajectory, dtype=int)
action_probs = np.zeros(n_trajectories * step_per_trajectory, dtype=int)
else:
actions = np.zeros(n_trajectories * step_per_trajectory, self.action_dim)
action_probs = np.zeros(
actions = np.zeros((n_trajectories * step_per_trajectory, self.action_dim))
action_probs = np.zeros((
n_trajectories * step_per_trajectory, self.action_dim
)
))

rewards = np.zeros(n_trajectories * step_per_trajectory)
dones = np.zeros(n_trajectories * step_per_trajectory)
Expand All @@ -709,7 +709,7 @@ def _obtain_steps(
idx, step = 0, 0
done = False
state, info_ = self.env.reset()

next_state = None
for i in tqdm(
np.arange(n_trajectories),
desc="[obtain_trajectories]",
Expand All @@ -720,7 +720,7 @@ def _obtain_steps(
if not obtain_trajectories_from_single_interaction:
done = True

for rollout_step in rollout_lengths[i]:
for rollout_step in range(rollout_lengths[i]):
if done:
state, info_ = self.env.reset()
step = 0
Expand Down Expand Up @@ -750,7 +750,7 @@ def _obtain_steps(
(
action,
action_prob,
) = self.behavior_policy.sample_action_and_output_pscore_online(state)
) = behavior_policy.sample_action_and_output_pscore_online(state)
next_state, reward, done, truncated, info_ = self.env.step(action)

states[idx] = state
Expand Down Expand Up @@ -1268,7 +1268,6 @@ def obtain_steps(
path=path,
save_relative_path=save_relative_path,
)

for j in tqdm(
np.arange(len(behavior_policies)),
desc="[obtain_datasets: behavior_policy]",
Expand Down