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

Improve predictor module #562

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
32 changes: 12 additions & 20 deletions mala/network/predictor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tester class for testing a network."""
"""Predictor class."""

import numpy as np
import torch
Expand Down Expand Up @@ -59,13 +59,6 @@ def predict_from_qeout(self, path_to_file, gather_ldos=False):
predicted_ldos : numpy.array
Precicted LDOS for these atomic positions.
"""
self.data.grid_dimension = self.parameters.inference_data_grid
self.data.grid_size = (
self.data.grid_dimension[0]
* self.data.grid_dimension[1]
* self.data.grid_dimension[2]
)

RandomDefaultUser marked this conversation as resolved.
Show resolved Hide resolved
self.data.target_calculator.read_additional_calculation_data(
path_to_file, "espresso-out"
)
Expand Down Expand Up @@ -230,18 +223,17 @@ def _forward_snap_descriptors(
)

for i in range(0, self.number_of_batches_per_snapshot):
inputs = snap_descriptors[
i
* self.parameters.mini_batch_size : (i + 1)
* self.parameters.mini_batch_size
]
inputs = inputs.to(self.parameters._configuration["device"])
predicted_outputs[
i
* self.parameters.mini_batch_size : (i + 1)
* self.parameters.mini_batch_size
] = self.data.output_data_scaler.inverse_transform(
self.network(inputs).to("cpu"), as_numpy=True
sl = slice(
i * self.parameters.mini_batch_size,
(i + 1) * self.parameters.mini_batch_size,
)
inputs = snap_descriptors[sl].to(
self.parameters._configuration["device"]
)
predicted_outputs[sl] = (
self.data.output_data_scaler.inverse_transform(
self.network(inputs).to("cpu"), as_numpy=True
)
)

# Restricting the actual quantities to physical meaningful values,
Expand Down