Skip to content

Commit

Permalink
fix head selection
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyes319 committed Aug 27, 2024
1 parent b0bbd5b commit 529b261
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mace/calculators/lammps_mace.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, model, **kwargs):
torch.tensor(
self.model.heads.index(kwargs.get("head", self.model.heads[-1])),
dtype=torch.long,
),
).unsqueeze(0),
)

for param in self.model.parameters():
Expand Down
6 changes: 4 additions & 2 deletions mace/cli/create_lammps_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def parse_args():
type=str,
nargs="?",
help="Head of the model to be converted to LAMMPS",
default="default",
default=None,
)
return parser.parse_args()

Expand All @@ -30,7 +30,9 @@ def main():
head = args.head
model = torch.load(model_path)
model = model.double().to("cpu")
lammps_model = LAMMPS_MACE(model, head=head)
lammps_model = (
LAMMPS_MACE(model, head=head) if head is not None else LAMMPS_MACE(model)
)
lammps_model_compiled = jit.compile(lammps_model)
lammps_model_compiled.save(model_path + "-lammps.pt")

Expand Down

0 comments on commit 529b261

Please sign in to comment.