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

Loss function clarity #28

Merged
merged 29 commits into from Feb 7, 2022
Merged

Loss function clarity #28

merged 29 commits into from Feb 7, 2022

Conversation

MSRudolph
Copy link
Contributor

Goals of this draft PR:

  • Allow parameters to be any np.ndarray rather than strictly a 1D np.ndarray
  • Improve docstrings for what we define as a loss function
  • Improve README to specify what we define as a loss function, and how to wrap their loss function with functools.partial
  • Alternatively, allow loss_function_kwargs in the scanning functions that we pass to the loss_function with more than one argument.

@MSRudolph MSRudolph changed the base branch from main to dev December 6, 2021 14:23
@codecov
Copy link

codecov bot commented Dec 6, 2021

Codecov Report

Merging #28 (3778fe0) into dev (2b24039) will increase coverage by 0.62%.
The diff coverage is 98.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev      #28      +/-   ##
==========================================
+ Coverage   83.52%   84.15%   +0.62%     
==========================================
  Files          28       28              
  Lines         680      713      +33     
  Branches       71       71              
==========================================
+ Hits          568      600      +32     
- Misses         92       93       +1     
  Partials       20       20              
Impacted Files Coverage Δ
src/orqviz/pca/plots.py 100.00% <ø> (ø)
src/orqviz/elastic_band/data_structures.py 82.35% <90.00%> (-0.26%) ⬇️
src/orqviz/aliases.py 100.00% <100.00%> (ø)
src/orqviz/elastic_band/auto_neb.py 85.71% <100.00%> (ø)
src/orqviz/elastic_band/neb.py 82.92% <100.00%> (+0.42%) ⬆️
src/orqviz/elastic_band/plots.py 100.00% <100.00%> (ø)
src/orqviz/geometric.py 100.00% <100.00%> (ø)
src/orqviz/gradients.py 89.65% <100.00%> (+0.76%) ⬆️
src/orqviz/hessians/data_structures.py 100.00% <100.00%> (ø)
src/orqviz/hessians/hessians.py 96.49% <100.00%> (+0.26%) ⬆️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b24039...3778fe0. Read the comment docs.

src/orqviz/geometric.py Outdated Show resolved Hide resolved
src/orqviz/hessians/hessians.py Outdated Show resolved Hide resolved
src/orqviz/pca/data_structures.py Outdated Show resolved Hide resolved
tests/orqviz/scans/scans_test.py Show resolved Hide resolved
@MSRudolph MSRudolph marked this pull request as ready for review January 21, 2022 10:38
Copy link
Contributor

@mstechly mstechly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of minor requests, overall looks good!

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved

import numpy as np
from scipy.interpolate import interp1d

from ..aliases import ArrayOfParameterVectors, Weights
from ..aliases import ArrayOfParameterVectors, LossFunction, ParameterVector, Weights
from ..geometric import _norm_of_arrayofparametervectors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are using _norm_of_arrayofparametervectors in a different module than it comes from (i.e. in elastic_band and not in geometric, I think it makes more sense to not make it private?
Not 100% sure though, thoughts @alexjuda?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. It is only a helper function for us though. I doubt that anyone would need that apart from us.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can recommend a 3-fold distinction for project symbols – public/internal/fileprivate based on a convention with leading underscores in the module and symbol names;

  • public: module, function
  • internal: _module, function
  • fileprivate: w/e, _function
    The above use case looks like an "internal" one :). Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexjuda In our case the content of geometric packages should be public, so not really ;)
@MSRudolph fine 🤷‍♂️

@@ -148,3 +155,11 @@ def uniformly_distribute_trajectory(
)
eval_points = np.linspace(0, 1, num=n_points)
return weight_interpolator(eval_points)


def _norm_of_arrayofparametervectors(param_array: ArrayOfParameterVectors):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the name of the function...
Thoughts, @alexjuda ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just def _norm(param_array: ArrayOfParameterVectors):?

src/orqviz/hessians/hessians.py Outdated Show resolved Hide resolved
src/orqviz/scans/scans_1D.py Outdated Show resolved Hide resolved
src/orqviz/scans/scans_1D.py Outdated Show resolved Hide resolved
src/orqviz/scans/scans_2D.py Outdated Show resolved Hide resolved
tests/orqviz/scans/scans_test.py Show resolved Hide resolved
@MSRudolph MSRudolph merged commit ad0481e into dev Feb 7, 2022
mstechly added a commit that referenced this pull request Sep 8, 2022
5bfa0bc ci: Windows Support (#30)
f19a9ee Show offline code coverage report in 'TestCoverage' workflow (#28)

git-subtree-dir: subtrees/z_quantum_actions
git-subtree-split: 5bfa0bc5df261a2702c998342349618804028e65
mstechly added a commit that referenced this pull request Sep 8, 2022
77ce94e Removed code associated with codecov.
5bfa0bc ci: Windows Support (#30)
f19a9ee Show offline code coverage report in 'TestCoverage' workflow (#28)

git-subtree-dir: subtrees/z_quantum_actions
git-subtree-split: 77ce94ec4bfba81627c85ad3a77aa8964bd653a0
mstechly added a commit that referenced this pull request Sep 8, 2022
5b664df Removed code associated with codecov.
5bfa0bc ci: Windows Support (#30)
f19a9ee Show offline code coverage report in 'TestCoverage' workflow (#28)

git-subtree-dir: subtrees/z_quantum_actions
git-subtree-split: 5b664dfaa021497c8745b92cb7a42f21e81f2575
@mstechly mstechly deleted the loss-function-clarity branch October 29, 2022 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants