#include <qneuron.hpp>
|
| QNeuron (QInterfacePtr reg, const std::vector< bitLenInt > &inputIndcs, bitLenInt outputIndx, QNeuronActivationFn activationFn=Sigmoid, real1_f alpha=ONE_R1_F, real1_f tol=FP_NORM_EPSILON/2) |
| "QNeuron" is a "Quantum neuron" or "quantum perceptron" class that can learn and predict in superposition. More...
|
|
| QNeuron (const QNeuron &toCopy) |
| Create a new QNeuron which is an exact duplicate of another, including its learned state. More...
|
|
QNeuron & | operator= (const QNeuron &toCopy) |
|
void | SetAlpha (real1_f a) |
| Set the "alpha" sharpness parameter of this QNeuron. More...
|
|
real1_f | GetAlpha () |
| Get the "alpha" sharpness parameter of this QNeuron. More...
|
|
void | SetActivationFn (QNeuronActivationFn f) |
| Sets activation function enum. More...
|
|
QNeuronActivationFn | GetActivationFn () |
| Get activation function enum. More...
|
|
void | SetAngles (real1 *nAngles) |
| Set the angles of this QNeuron. More...
|
|
void | GetAngles (real1 *oAngles) |
| Get the angles of this QNeuron. More...
|
|
bitLenInt | GetInputCount () |
|
bitCapIntOcl | GetInputPower () |
|
real1_f | Predict (bool expected=true, bool resetInit=true) |
| Predict a binary classification. More...
|
|
real1_f | Unpredict (bool expected=true) |
| "Uncompute" the Predict() method More...
|
|
real1_f | LearnCycle (bool expected=true) |
|
void | Learn (real1_f eta, bool expected=true, bool resetInit=true) |
| Perform one learning iteration, training all parameters. More...
|
|
void | LearnPermutation (real1_f eta, bool expected=true, bool resetInit=true) |
| Perform one learning iteration, measuring the entire QInterface and training the resulting permutation. More...
|
|
◆ QNeuron() [1/2]
"QNeuron" is a "Quantum neuron" or "quantum perceptron" class that can learn and predict in superposition.
This is a simple "quantum neuron" or "quantum perceptron" class, for use of the Qrack library for machine learning. See https://arxiv.org/abs/quant-ph/0410066 (and https://arxiv.org/abs/1711.11240) for the basis of this class' theoretical concept.
An untrained QNeuron (with all 0 variational parameters) will forward all inputs to 1/sqrt(2) * (|0> + |1>). The variational parameters are Pauli Y-axis rotation angles divided by 2 * Pi (such that a learning parameter of 0.5 will train from a default output of 0.5/0.5 probability to either 1.0 or 0.0 on one training input).
◆ QNeuron() [2/2]
Qrack::QNeuron::QNeuron |
( |
const QNeuron & |
toCopy | ) |
|
|
inline |
Create a new QNeuron which is an exact duplicate of another, including its learned state.
◆ applyAlpha()
◆ applyGelu()
◆ applyLeakyRelu()
◆ applyRelu()
◆ clampAngle()
◆ GetActivationFn()
Get activation function enum.
◆ GetAlpha()
real1_f Qrack::QNeuron::GetAlpha |
( |
| ) |
|
|
inline |
Get the "alpha" sharpness parameter of this QNeuron.
◆ GetAngles()
void Qrack::QNeuron::GetAngles |
( |
real1 * |
oAngles | ) |
|
|
inline |
◆ GetInputCount()
◆ GetInputPower()
◆ Learn()
void Qrack::QNeuron::Learn |
( |
real1_f |
eta, |
|
|
bool |
expected = true , |
|
|
bool |
resetInit = true |
|
) |
| |
|
inline |
Perform one learning iteration, training all parameters.
Inputs must be already loaded into "qReg" before calling this method. "expected" is the true binary output category, for training. "eta" is a volatility or "learning rate" parameter with a maximum value of 1.
In the feedback process of learning, default initial conditions forward untrained predictions to 1/sqrt(2) * (|0>
- |1>) for the output bit. If you want to initialize other conditions before "Learn()," set "resetInit" to false.
◆ LearnCycle()
real1_f Qrack::QNeuron::LearnCycle |
( |
bool |
expected = true | ) |
|
|
inline |
◆ LearnInternal()
◆ LearnPermutation()
void Qrack::QNeuron::LearnPermutation |
( |
real1_f |
eta, |
|
|
bool |
expected = true , |
|
|
bool |
resetInit = true |
|
) |
| |
|
inline |
Perform one learning iteration, measuring the entire QInterface and training the resulting permutation.
Inputs must be already loaded into "qReg" before calling this method. "expected" is the true binary output category, for training. "eta" is a volatility or "learning rate" parameter with a maximum value of 1.
In the feedback process of learning, default initial conditions forward untrained predictions to 1/sqrt(2) * (|0>
- |1>) for the output bit. If you want to initialize other conditions before "LearnPermutation()," set "resetInit" to false.
◆ negApplyGelu()
◆ negApplyRelu()
◆ operator=()
◆ Predict()
real1_f Qrack::QNeuron::Predict |
( |
bool |
expected = true , |
|
|
bool |
resetInit = true |
|
) |
| |
|
inline |
Predict a binary classification.
Feed-forward from the inputs, loaded in "qReg", to a binary categorical classification. "expected" flips the binary categories, if false. "resetInit," if true, resets the result qubit to 0.5/0.5 |0>/|1> superposition before proceeding to predict.
◆ SetActivationFn()
Sets activation function enum.
◆ SetAlpha()
void Qrack::QNeuron::SetAlpha |
( |
real1_f |
a | ) |
|
|
inline |
Set the "alpha" sharpness parameter of this QNeuron.
◆ SetAngles()
void Qrack::QNeuron::SetAngles |
( |
real1 * |
nAngles | ) |
|
|
inline |
◆ Unpredict()
real1_f Qrack::QNeuron::Unpredict |
( |
bool |
expected = true | ) |
|
|
inline |
◆ activationFn
◆ alpha
◆ angles
std::unique_ptr<real1[]> Qrack::QNeuron::angles |
|
protected |
◆ inputIndices
std::vector<bitLenInt> Qrack::QNeuron::inputIndices |
|
protected |
◆ inputPower
◆ outputIndex
◆ qReg
◆ tolerance
The documentation for this class was generated from the following file: