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

fixed aggregation_mode bug for avg pooling #361

Merged
merged 4 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/schnetpack/atomistic/atomwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ def forward(self, inputs: Dict[str, torch.Tensor]) -> Dict[str, torch.Tensor]:

# aggregate
if self.aggregation_mode is not None:
if self.aggregation_mode == "avg":
y = y / inputs[properties.n_atoms][:, None]

idx_m = inputs[properties.idx_m]
maxm = int(idx_m[-1]) + 1
y = snn.scatter_add(y, idx_m, dim_size=maxm)
y = torch.squeeze(y, -1)

if self.aggregation_mode == "avg":
y = y / inputs[properties.n_atoms]

inputs[self.output_key] = y
return inputs

Expand Down
5 changes: 1 addition & 4 deletions src/schnetpack/interfaces/ase_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ def __init__(
else:
raise AtomsConverterError(f"Unrecognized precision {dtype}")

for t in self.transforms:
t.preprocessor()

def __call__(self, atoms: Atoms):
"""

Expand Down Expand Up @@ -162,7 +159,7 @@ def __init__(
self.property_units = {
self.energy: convert_units(energy_units, "eV"),
self.forces: convert_units(forces_units, "eV/Angstrom"),
self.stress: convert_units(stress_units, "eV/A/A/A"),
self.stress: convert_units(stress_units, "eV/Ang/Ang/Ang"),
}

def calculate(
Expand Down