Closed ACE07-Sev closed 2 years ago
Hi,
the QuantumTrainer
provides a high level abstraction of a standard machine learning training routine. It stores the training statistics and takes a model as input. During the training, it saves the state of the model in checkpoint files, that can be used to instantiate a new model for inference through:
model = TketModel.from_checkpoint('path/to/checkpoint')
The output of your model depends on your circuit/diagrams. If you have one open (qubit) wire, the output will be a 2-d array, if you have two output wires, the output will be a 4-d array, and so on. Currently, only the PytorchModel
supports additional layers, however, we'll add Pennylane and tensorflow-quantum support soon.
So imagining I have a dataset of 1 feature, and one label, if I feed the dataset to the quantum_trainer.ipynb version, can I extract predictions for binary classification?
Is the quantum_trainer.ipynb basically creating and training the model on the dataset? If so, how can I extract predictions on new samples?
The trainer only wraps the training routine of the model
. You define an instance of the model
first, pass it to the trainer
and after training, you can predict the outcome of a new diagram through:
score = model(new_samples_diagrams)
Understood, so to call the model on new instances I have to first pass them through the parser to be reformed as diagrams as well correct?
That is correct. But bear in mind that you have to take care of word tokens that are unknown to the model. If you pass a diagram to the model that contains a word that wasn't part of the training process, it'll fail to calculate the output.
In classical NLP, one would for example deal with that by introducing an <unk>
token, that replaces all rare words in your corpus.
The original question has been answered, so this issue will be closed.
Hi, I wish to use the Quantum_trainer to do a Depression Detection using a chatbot (the sentences would be the input for the QNLP module), and wish to then classify as whether the person has depression or not.
May I ask what is the input and what is the output in the sample trainer for the quantum module? Does it do binary classification or is it something I need to add as an additional layer?