Comments (9)
I agree in general, but we have other loss functions coded as lower case strings: cross_entropy
, cross_entropy_sigmoid
, so I think we need a consistent solution. I suggest replace l1
with absolute_error
and l2
with squared_error
.
@beichensinn what do you think?
from qiskit-machine-learning.
The strings across the API are case insensitive as it does a lower() on what is passed in to compare against constants in the code in lowercase. If upper() was done instead it would just mean the constants all became upper internally and maybe we'd show them that way in the docstring too. It would not change the API in this case; but changing to different strings means deprecating the l1 and l2 so they'd have to stay in the code for a while. Of course doing this upper() instead, and having it as 'L1' internally and in the docs, the API, would not prevent users from using the 'l1' etc in lowercase in their code and thus have the potential readability problem there still, that different strings would prevent.
from qiskit-machine-learning.
@woodsp-ibm @adekusar-drl I am new to qiskit contributions but I am interested in picking up this issue. Would that be ok?
I think using upper()
and comparing to 'L1'
internally is a good idea since it would make the code more readible and the docstrings more clear. I think it could also be beneficial to add support for 'absolute_error'
and 'squared_error'
in addition to 'L1'
and 'L2'
respectively.
I also saw a comment in #92 suggesting that we should extract the if...else
block to a seperate class and I could see that being in the scope of this PR. Do you agree? If so, could you provide some more information on that (e.g. what class should I look at)?
Thanks!
from qiskit-machine-learning.
@mattwright99 Surely, you can work on this issue!
I'd prefer to keep string constants in lower case just to keep them more readable in the documentation. I suggest to gracefully deprecate l1
and l2
in favor of 'absolute_error' and 'squared_error' cause this would solve the issue completely.
The if
block you mentioned, is it the if
block where we instantiate a loss object out of a string value? If so, then I happy to discuss your suggestion here, but please don't code it upfront.
from qiskit-machine-learning.
@adekusar-drl Alright thanks, i am excited to start contributing! I will let you know if I have any questions!
from qiskit-machine-learning.
@manoelmarques we want to deprecate certain values passed to the TrainableModel
constructor, e.g. instead of loss="l2"
we'd like to have loss="squared_error"
and deprecate l2
. I know you've added a few functions for handling deprecations, but I'm not sure how they can be applied to argument values. Is there an example of such deprecation somewhere?
from qiskit-machine-learning.
@adekusar-drl I added all the possible ways you can use deprecations in the test_deprecation.py. However All methods/decorators expect you to deprecate a class, method, argument. property or function. Nothing for default values. The message being created automatically doesn't support it. Would it be possible for you to add a warnings.warn method in your PR for that situation and I will then create some method to support it and use it in place, either in the same PR or another ?
from qiskit-machine-learning.
@manoelmarques Yes, we can generate manual warnings.
@mattwright99 Please add lines like these:
warnings.warn(
"The 'l2' value is deprecated as of 0.2.0 "
"and will be removed no sooner than 3 months after the release. "
"You should use the 'squared_error' value instead.",
DeprecationWarning,
)
The version number in the text depends on the date when you'll be able to finish the PR. We can edit it later on.
from qiskit-machine-learning.
@adekusar-drl sounds good, I am just about to publish a PR
from qiskit-machine-learning.
Related Issues (20)
- Enhancement of PyTorch connector HOT 2
- Extend unit test coverage with `Hypothesis` in numerical tests
- Add `jit` compilation to the Torch connector with `thunder`
- Revamp `README.md` with structured information HOT 4
- Set up a security policy (@maintainers)
- Multi-class Classification Problem Using QSVC HOT 3
- Error when testing samples with labels other than {0, 1} in the MNIST dataset. HOT 6
- Revert CI environment to latest PyTorch once UTF bug is fixed
- Binary classification problem using NeuralNetworkClassifier and cross entropy loss HOT 1
- MacOS in CI - macos-latest is now ARM HOT 2
- Link Qiskit 1.0 migration instructions in Readme
- Add support for EstimatorV2 from ibm-qiskit-runtime to run circuits over hardware HOT 1
- Migrate `qiskit_algorithms` following end-of-support HOT 2
- Pinned `torch==2.2.2` breaks CI due to `numpy>=2.0`
- NeuralNetworkClassifier Accuracy Updates HOT 2
- Revert Numpy to the latest version in CI environment once UTF bug in PyTorch is fixed
- Restore mypy checks on Windows and lowest Numpy version
- The return values from SamplerQNN are in the wrong shape.
- Separate parameters for the trainable part and the encoding part in EstimatorQNN
- Mismatching between loss function code and documentation formula
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 qiskit-machine-learning.