English
Languages
English
Bengali
French
Hindi
Italian
Japanese
Korean
Malayalam
Russian
Spanish
Tamil
Turkish
Vietnamese
Shortcuts



Release Notes

0.2.1

New Features

  • The class TrainableModel, and its sub-classes NeuralNetworkClassifier, NeuralNetworkRegressor, VQR, VQC, have a new optional argument callback. User can optionally provide a callback function that can access the intermediate training data to track the optimization process, else it defaults to None. The callback function takes in two parameters: the weights for the objective function and the computed objective value. For each iteration an optimizer invokes the callback and passes current weights and computed value of the objective function.

  • Classification models (i.e. models that extend the NeuralNetworkClassifier class like VQC) can now handle categorical target data in methods like fit() and score(). Categorical data is inferred from the presence of string type data and is automatically encoded using either one-hot or integer encodings. Encoder type is determined by the one_hot argument supplied when instantiating the model.

Bug Fixes

  • Fix a bug, where qiskit_machine_learning.circuit.library.RawFeatureVector.copy() didn’t copy all internal settings which could lead to issues with the copied circuit. As a consequence qiskit_machine_learning.circuit.library.RawFeatureVector.bind_parameters() is also fixed.

  • The QNN weight parameter in TorchConnector is now registered in the torch DAG as weight, instead of _weights. This is consistent with the PyTorch naming convention and the weight property used to get access to the computed weights.

0.2.0

New Features

  • A base class TrainableModel is introduced for machine learning models. This class follows Scikit-Learn principles and makes the quantum machine learning compatible with classical models. Both NeuralNetworkClassifier and NeuralNetworkRegressor extend this class. A base class ObjectiveFunction is introduced for objective functions optimized by machine learning models. There are three objective functions introduced that are used by ML models: BinaryObjectiveFunction, MultiClassObjectiveFunction, and OneHotObjectiveFunction. These functions are used internally by the models.

  • The optimizer argument for the classes NeuralNetworkClassifier and NeuralNetworkRegressor, both of which extends the TrainableModel class, is made optional with the default value being SLSQP(). The same is true for the classes VQC and VQR as they inherit from NeuralNetworkClassifier and NeuralNetworkRegressor respectively.

  • The constructor of NeuralNetwork, and all classes that inherit from it, has a new parameter input_gradients which defaults to False. Previously this parameter could only be set using the setter method. Note that TorchConnector previously set input_gradients of the NeuralNetwork it was instantiated with to True. This is not longer the case. So if you use TorchConnector and want to compute the gradients w.r.t. the input, make sure you set input_gradients=True on the NeuralNetwork before passing it to TorchConnector.

  • Added a parameter initial_point to the neural network classifiers and regressors. This an array that is passed to an optimizer as an initial point to start from.

  • Computation of gradients with respect to input data in the backward method of NeuralNetwork is now optional. By default gradients are not computed. They may inspected and turned on, if required, by getting or setting a new property input_gradients in the NeuralNetwork class.

  • Now NeuralNetworkClassifier extends ClassifierMixin and NeuralNetworkRegressor extends RegressorMixin from Scikit-Learn and rely on their methods for score calculation. This also adds an ability to pass sample weights as an optional parameter to the score methods.

Deprecation Notes

  • The valid values passed to the loss argument of the TrainableModel constructor were partially deprecated (i.e. loss='l1' is replaced with loss='absolute_error' and loss='l2' is replaced with loss='squared_error'). This affects instantiation of classes like the NeuralNetworkClassifier. This change was made to reduce confusion that stems from using lowercase ‘l’ character which can be mistaken for a numeric ‘1’ or capital ‘I’. You should update your model instantiations by replacing ‘l1’ with ‘absolute_error’ and ‘l2’ with ‘squared_error’.

  • The weights property in TorchConnector is deprecated in favor of the weight property which is PyTorch compatible. By default, PyTorch layers expose weight properties to get access to the computed weights.

Bug Fixes

  • This fixes the exception that occurs when no optimizer argument is passed to NeuralNetworkClassifier and NeuralNetworkRegressor.

  • Fixes the computation of gradients in TorchConnector when a batch of input samples is provided.

  • TorchConnector now returns the correct input gradient dimensions during the backward pass in hybrid nn training.

  • Added a dedicated handling of ComposedOp as a operator in OpflowQNN. In this case output shape is determined from the first operator in the ComposedOp instance.

  • Fix the dimensions of the gradient in the quantum generator for the qGAN training.