Closed BowenD-UCB closed 1 month ago
The changes in the codebase involve transitioning certain tensor operations from PyTorch to NumPy within the _AtomRef
class. This update includes returning a NumPy array instead of a PyTorch tensor in the get_feature_matrix
method and utilizing NumPy functions for matrix operations in the fit
method. These modifications aim to enhance compatibility and potentially boost performance.
File Path | Change Summary |
---|---|
.../src/matgl/layers/_atom_ref.py |
- Converted return value of get_feature_matrix method to NumPy array.- Updated fit method to use NumPy for matrix operations. |
I think I also went into this before. This seems to be an issue only when using CPU, while it gives consistent results when using CUDA. Not sure why.
@JiQi535 This may be the reason see the linkhttps://github.com/pytorch/pytorch/issues/71222. I also want to say that I didn't discover the problem when I used GPU. Anyway, I think it is better to have more consistent outputs with CPU and CUDA. Thanks Bowen for finding out the problem!
Summary
Change the fitting method of AtomRef from
torch.linalg.lstsq
tonp.linalg.pinv
mthodIssue with previous implementation
The output for the above block gives:
The fitted parameters have super large deviations from several runs.
np.linalg.pinv
should solve the issue