Package for classification

Hey @nvitucci,

Thanks for providing these details, it’s great that you’re interested in lowering the barrier for hybrid ML in PennyLane!

We think that the best way to proceed is to start working on a small initial feature and keep iterating as we go. In particular, it would be interesting for users to have access to commonly-used cost functions in ML. For example, perhaps we could add an MSECost class similar to the current VQECost that allows users to combine an ansatz circuit with some target observables and then derive a cost function from their expectation values. An example flow would look like:

def ansatz(weights, x=None, **kwargs):
    qml.AngleEmbedding(x, wires=[1, 2, 3])
    qml.templates.StronglyEntanglingLayers(weights, wires=[1, 2, 3])

observables = [qml.PauliZ(0), qml.PauliX(0), qml.PauliZ(1) @ qml.PauliZ(2)]
>>> cost = qml.qnn.MSECost(ansatz, observables, device)
>>> cost(weights, x=x, y=y)
0.54657

This feature would mainly involve wrapping around the existing map() function but would be a useful addition for regression/classification.

However, we’re also interested if you have any ideas along these lines? Our preference is to start out focusing on core, flexible features such as the one above and it would be great to interface with QNodeCollections to give some flexibility on the chosen observables.

I also wanted to point out that there is a qnn module in the latest version of PennyLane (https://pennylane.readthedocs.io/en/latest/code/qml_qnn.html). This module is currently targeted at converting PennyLane QNodes to Keras and PyTorch layers, but something like MSECost could also go there as well.

We can of course discuss more here, but the next step to get started is to make a PR on our PennyLane GitHub repo as outlined here.

Thanks and don’t hesitate to ask any questions!
Tom