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

fix np.random.choice issue when subselecting from pre-trained configs for multihead fine tune #448

Merged
Merged
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
14 changes: 8 additions & 6 deletions mace/cli/fine_tuning_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,19 @@ def select_samples(
]
if len(atoms_list_pt_filtered) <= args.num_samples:
logging.info(
"Number of configurations after filtering is less than the number of samples, "
"selecting random configurations, for the rest."
f"Number of configurations after filtering {len(atoms_list_pt_filtered} "
f"is less than the number of samples {args.num_samples}, "
"selecting random configurations for the rest."
)
atoms_list_pt_minus_filtered = [
x for x in atoms_list_pt if x not in atoms_list_pt_filtered
]
atoms_list_pt_random = np.random.choice(
atoms_list_pt_minus_filtered,
atoms_list_pt_random_inds = np.random.choice(
list(range(len(atoms_list_pt_minus_filtered))),
args.num_samples - len(atoms_list_pt_filtered),
).tolist()
atoms_list_pt = atoms_list_pt_filtered + atoms_list_pt_random
replace=False
)
atoms_list_pt = atoms_list_pt_filtered + [atoms_list_pt_minus_filtered[ind] for ind in atoms_list_pt_random_inds]
else:
atoms_list_pt = atoms_list_pt_filtered

Expand Down