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

How to train on datasets containing general integers #367

Open
samwu-learn opened this issue Sep 21, 2023 · 0 comments
Open

How to train on datasets containing general integers #367

samwu-learn opened this issue Sep 21, 2023 · 0 comments
Labels
type/bug 🐛 Something isn't working

Comments

@samwu-learn
Copy link

Describe the bug

Setting

  • OS: <!--- e.g. MacOS, LInux --->
  • Compiler: <!--- if applicable e.g. gcc, clang... with version --->
  • Python version:
  • Ecole version:

To Reproduce

episode_counter, sample_counter = 0, 0
Path("samples/").mkdir(exist_ok=True)

We will solve problems (run episodes) until we have saved enough samples

while sample_counter < DATA_MAX_SAMPLES:
episode_counter += 1

observation, action_set, _, done, _ = env.reset(next(instances))
while not done:
    (scores, scores_are_expert), node_observation = observation
    action = action_set[scores[action_set].argmax()]

    # Only save samples if they are coming from the expert (strong branching)
    if scores_are_expert and (sample_counter < DATA_MAX_SAMPLES):
        sample_counter += 1
        data = [node_observation, action, action_set, scores]
        filename = f"samples/sample_{sample_counter}.pkl"

        with gzip.open(filename, "wb") as f:
            pickle.dump(data, f)

    observation, action_set, _, done, _ = env.step(action)

print(f"Episode {episode_counter}, {sample_counter} samples collected so far")

In the above code(code in ecole
/example.ipynb) , if the input instance contains an integer, the done variable is always true, and a pkl file cannot be generated for this instance,

Expected behavior

Additional context

I would greatly appreciate it with your generous assistance.

@samwu-learn samwu-learn added the type/bug 🐛 Something isn't working label Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant