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

Do you have the evaluation code? #7

Open
XUHAN314 opened this issue Oct 2, 2022 · 7 comments
Open

Do you have the evaluation code? #7

XUHAN314 opened this issue Oct 2, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@XUHAN314
Copy link

XUHAN314 commented Oct 2, 2022

I didn't find the evaluation or test code in the repo. How do you test the generative model?

@bengioe bengioe added the enhancement New feature or request label Oct 3, 2022
@bengioe
Copy link
Collaborator

bengioe commented Oct 3, 2022

Hi, experiments typically produce a file called sampled_mols.pkl.gz:

gflownet/mols/gflownet.py

Lines 384 to 400 in 831a698

def save_stuff():
pickle.dump([i.data.cpu().numpy() for i in model.parameters()],
gzip.open(f'{exp_dir}/params.pkl.gz', 'wb'))
pickle.dump(dataset.sampled_mols,
gzip.open(f'{exp_dir}/sampled_mols.pkl.gz', 'wb'))
pickle.dump({'train_losses': train_losses,
'test_losses': test_losses,
'test_infos': test_infos,
'time_start': time_start,
'time_now': time.time(),
'args': args,},
gzip.open(f'{exp_dir}/info.pkl.gz', 'wb'))
pickle.dump(train_infos,
gzip.open(f'{exp_dir}/train_info.pkl.gz', 'wb'))

What's reported in the paper is the rolling top-k, which we compute after the fact by loading the molecules and computing the top-k-so-far during learning.

The results are stored as a list of 4-tuples:

self.sampled_mols.append((r, m, trajectory_stats, inflow))

So to get the ground reward you can take the r value and inverse-exponentiate it back to the reward prediction of the proxy r ** (1 / args.reward_exp).

It would be nice to add a notebook with that kind of code. It shouldn't be too hard for me to take existing notebooks and clean them up, but I don't have time right now. I'll mark this issue as enhancement.

@XUHAN314
Copy link
Author

XUHAN314 commented Nov 9, 2022

Thanks for your reply. There are some plots in the paper, I am wondering how do you make them. It would be nice if you could create a notebook to show that. Thanks! This is a great work!

@XUHAN314
Copy link
Author

XUHAN314 commented Nov 9, 2022

Does Top K mean you selected K mols with the highest rewards? How do you select K?

@bengioe
Copy link
Collaborator

bengioe commented Nov 9, 2022

By Top K we mean something like topk = lambda x, k: x[np.argsort(x)[-k:]]. In the paper we report for k 10, 100, and 1000, where x is the set of rewards sampled so far.

@XUHAN314
Copy link
Author

Thanks! It helps a lot.

@58191554
Copy link

58191554 commented Dec 8, 2022

which file should I run first, in other words, where is the beginning?

@bengioe
Copy link
Collaborator

bengioe commented Dec 8, 2022

Simply running python gflownet.py in the mols directory should train a model with the default hyperparameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants