65 }
else if (angle <= -
PI_R1) {
79 if (angle <= -2 *
PI_R1) {
81 }
else if (angle > 2 *
PI_R1) {
200 [
this](
real1 a) { return applyAlpha(a, alpha); });
204 [
this](
real1 a) { return applyLeakyRelu(a, alpha); });
254 [
this](
real1 a) { return -applyAlpha(a, alpha); });
259 [
this](
real1 a) { return -applyLeakyRelu(a, alpha); });
339 angle += eta *
PI_R1;
348 angle = origAngle - eta *
PI_R1;
355 if ((startProb >= plusProb) && (startProb >= minusProb)) {
362 if (plusProb > minusProb) {
363 angle = origAngle + eta *
PI_R1;
Definition: qneuron.hpp:40
real1_f LearnInternal(bool expected, real1_f eta, bitCapInt perm, real1_f startProb)
Definition: qneuron.hpp:332
void Learn(real1_f eta, bool expected=true, bool resetInit=true)
Perform one learning iteration, training all parameters.
Definition: qneuron.hpp:290
QNeuronActivationFn GetActivationFn()
Get activation function enum.
Definition: qneuron.hpp:143
bitLenInt GetInputCount()
Definition: qneuron.hpp:151
static real1_f clampAngle(real1_f angle)
Definition: qneuron.hpp:75
static real1_f negApplyGelu(real1_f angle)
Definition: qneuron.hpp:57
real1_f GetAlpha()
Get the "alpha" sharpness parameter of this QNeuron.
Definition: qneuron.hpp:137
QInterfacePtr qReg
Definition: qneuron.hpp:49
static real1_f negApplyRelu(real1_f angle)
Definition: qneuron.hpp:53
bitLenInt outputIndex
Definition: qneuron.hpp:43
bitCapIntOcl inputPower
Definition: qneuron.hpp:42
void GetAngles(real1 *oAngles)
Get the angles of this QNeuron.
Definition: qneuron.hpp:149
QNeuron(const QNeuron &toCopy)
Create a new QNeuron which is an exact duplicate of another, including its learned state.
Definition: qneuron.hpp:113
real1_f Predict(bool expected=true, bool resetInit=true)
Predict a binary classification.
Definition: qneuron.hpp:161
QNeuron & operator=(const QNeuron &toCopy)
Definition: qneuron.hpp:120
real1_f Unpredict(bool expected=true)
"Uncompute" the Predict() method
Definition: qneuron.hpp:220
static real1_f applyAlpha(real1_f angle, real1_f alpha)
Definition: qneuron.hpp:59
bitCapInt GetInputPower()
Definition: qneuron.hpp:153
void SetAngles(real1 *nAngles)
Set the angles of this QNeuron.
Definition: qneuron.hpp:146
std::vector< bitLenInt > inputIndices
Definition: qneuron.hpp:47
static real1_f applyGelu(real1_f angle)
Definition: qneuron.hpp:55
void SetAlpha(real1_f a)
Set the "alpha" sharpness parameter of this QNeuron.
Definition: qneuron.hpp:134
real1_f LearnCycle(bool expected=true)
Definition: qneuron.hpp:275
static real1_f applyLeakyRelu(real1_f angle, real1_f alpha)
Definition: qneuron.hpp:73
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)
"QNeuron" is a "Quantum neuron" or "quantum perceptron" class that can learn and predict in superposi...
Definition: qneuron.hpp:99
real1_f tolerance
Definition: qneuron.hpp:46
real1_f alpha
Definition: qneuron.hpp:45
QNeuronActivationFn activationFn
Definition: qneuron.hpp:44
static real1_f applyRelu(real1_f angle)
Definition: qneuron.hpp:51
void SetActivationFn(QNeuronActivationFn f)
Sets activation function enum.
Definition: qneuron.hpp:140
void LearnPermutation(real1_f eta, bool expected=true, bool resetInit=true)
Perform one learning iteration, measuring the entire QInterface and training the resulting permutatio...
Definition: qneuron.hpp:315
std::unique_ptr< real1[]> angles
Definition: qneuron.hpp:48
Half-precision floating-point type.
Definition: half.hpp:2222
Definition: complex16x2simd.hpp:25
std::shared_ptr< QInterface > QInterfacePtr
Definition: qinterface.hpp:28
constexpr real1_f ZERO_R1_F
Definition: qrack_types.hpp:152
const real1 ONE_R1
Definition: qrack_types.hpp:153
constexpr real1_f ONE_R1_F
Definition: qrack_types.hpp:154
QRACK_CONST real1 FP_NORM_EPSILON
Definition: qrack_types.hpp:243
bitCapInt pow2(const bitLenInt &p)
Definition: qrack_functions.hpp:22
const real1 PI_R1
Definition: qrack_types.hpp:158
const real1 ZERO_R1
Definition: qrack_types.hpp:151
float real1_f
Definition: qrack_types.hpp:64
float real1_s
Definition: qrack_types.hpp:65
std::shared_ptr< QNeuron > QNeuronPtr
Definition: qneuron.hpp:37
QNeuronActivationFn
Enumerated list of activation functions.
Definition: qneuron.hpp:24
@ Sigmoid
Default.
Definition: qneuron.hpp:26
@ ReLU
Rectified linear.
Definition: qneuron.hpp:28
@ Generalized_Logistic
Version of (default) "Sigmoid" with tunable sharpness.
Definition: qneuron.hpp:32
@ GeLU
Gaussian linear.
Definition: qneuron.hpp:30
@ Leaky_ReLU
Leaky rectified linear.
Definition: qneuron.hpp:34
bitCapIntOcl pow2Ocl(const bitLenInt &p)
Definition: qrack_functions.hpp:23
const real1 SQRT1_2_R1
Definition: qrack_types.hpp:160
unsigned int erf(unsigned int arg)
Error function and postprocessing.
Definition: half.hpp:2092
HALF_CONSTEXPR half abs(half arg)
Absolute value.
Definition: half.hpp:2975
half fmod(half x, half y)
Remainder of division.
Definition: half.hpp:2983
half pow(half x, half y)
Power function.
Definition: half.hpp:3738
MICROSOFT_QUANTUM_DECL void U(_In_ uintq sid, _In_ uintq q, _In_ double theta, _In_ double phi, _In_ double lambda)
(External API) 3-parameter unitary gate
Definition: pinvoke_api.cpp:1362
#define bitLenInt
Definition: qrack_types.hpp:44
#define bitCapInt
Definition: qrack_types.hpp:105
#define bitCapIntOcl
Definition: qrack_types.hpp:91