Comments (3)
I think this is a great direction to go in! 💯
Consider compute_for(y)
to indicate that the computation is being applied to a given array and distinguish it from the synonym evaluate()
.
EDIT: After some more thought, I think using any synonym here (such as "compute" is confusing and I would instead vote for something like evaluate_on_prediction(y)
.
from pybop.
Thanks for the comment @NicolaCourtier!
On further thought, I think we can make better use of the __call__
method within the cost class to simplify these methods. Here's what I'm thinking:
- The
__call__
method is updated to implement the currentevaluate
andevaluateS1
functionality, with an optional arg added ascalculate_grad
with default asFalse
. This aligns with PyBaMM's solver interface, which should simplify this change for users. I think this is a nice solution as it remains non-breaking for users, with added functionality for obtaining gradients. This results inevaluate
andevaluateS1
being redundant and removed. For v24.9, these should be deprecated with full removal in 24.12. _evaluate
and_evaluateS1
are refactored intocost.compute
with optional arg for returning gradients. This method computes the cost between two vectors without performing aproblem.evaluate
. The default would be for the ground truth and the user supplied vector, but an optional arg will be added to replace the ground truth in the computation.
To summarise, the API looks like this:
phi = cost([0.5,0.5]) # stays the same
phi, grad = cost([0.5, 0.5], calculate_grad=True) # returns cost and gradient
phi = cost.compute(np.ones(100)*4.0) # compute the cost against the ground truth and the user supplied vector
phi, grad = cost.compute(np.ones(100)*4.0, calculate_grad=True) # compute the cost and gradient against the ground truth and the user supplied vector
This is a large change to the internal cost API, as the S1
methods are removed and replaced with an optional arg in the non-gradient implementation. I think this is worth doing, as the current naming convention isn't clear to users, and would we would end up with less duplicate code. I'm be interested to hear others' thoughts on this!
from pybop.
This sounds good to me- the function names are not direct synonyms and the amount of duplicate code will be reduced!
from pybop.
Related Issues (20)
- [Bug]: Defining a voltage vector is necessary for evaluating impedance while it shouldn't HOT 1
- Design problems should have a default `init_soc`
- Compute initial concentrations from initial OCV HOT 2
- Fitting Problem with experimental data HOT 6
- Clean metadata from notebooks during pre-commit
- [Bug]: Quick Plot not plotting.
- Linting private member access
- Add Thermal Thevenin Example (Remove Params from Others) HOT 2
- Add multi-start functionality to optimisers
- Add a random sample optimiser
- Add an example that uses a pybamm.FunctionalParameter
- [Bug]: nox doesn't run with conda HOT 3
- Refactor BaseModel.rebuild() and BaseModel.build()
- Refactor BaseModel property setters
- [Bug]: multi_model_identification.ipynb shows incorrect results
- [Bug]: spm_electrode_design.ipynb not producing correct results
- Avoid rebuild if OCV unaffected by parameters
- Add an example notebook on the MultiFittingProblem
- [Bug]: Fix failing benchmarks
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pybop.