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

Initialize Concat network automatically #77

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Adjust for passing input_size.
kaminow committed Sep 18, 2024
commit 7f8b34222c7278f6f809ce28f5ec76f7783b8856
15 changes: 8 additions & 7 deletions mtenn/conversion_utils/e3nn.py
Original file line number Diff line number Diff line change
@@ -108,6 +108,7 @@ def _get_representation(self, reduce_output=False):
# Remove last layer
model_copy.layers = model_copy.layers[:-1]
model_copy.reduce_output = reduce_output
model_copy.irreps_out = model_copy.layers[-1].irreps_out

return model_copy

@@ -169,7 +170,10 @@ def _get_concat_strategy(self):
``ConcatStrategy`` for the model
"""

return ConcatStrategy(extract_key="x")
# Calculate input size as 3 * dimensionality of output of Representation
# (last layer in Representation is 2nd to last in original model)
input_size = 3 * self.layers[-2].irreps_out.dim
return ConcatStrategy(input_size=input_size, extract_key="x")

@staticmethod
def get_model(
@@ -227,24 +231,21 @@ def get_model(
if model is None:
model = E3NN(model_kwargs)

# Get representation module
representation = model._get_representation(reduce_output=strategy == "concat")

# Construct strategy module based on model and
# representation (if necessary)
strategy = strategy.lower()
if strategy == "delta":
strategy = model._get_delta_strategy()
reduce_output = False
elif strategy == "concat":
strategy = model._get_concat_strategy()
reduce_output = True
elif strategy == "complex":
strategy = model._get_complex_only_strategy()
reduce_output = False
else:
raise ValueError(f"Unknown strategy: {strategy}")

# Get representation module
representation = model._get_representation(reduce_output=reduce_output)

# Check on `combination`
if grouped and (combination is None):
raise ValueError(