50 }
else if (angle <= -
PI_R1) {
64 if (angle <= -2 *
PI_R1) {
66 }
else if (angle > 2 *
PI_R1) {
185 [
this](
real1 a) { return applyAlpha(a, alpha); });
189 [
this](
real1 a) { return applyLeakyRelu(a, alpha); });
239 [
this](
real1 a) { return -applyAlpha(a, alpha); });
244 [
this](
real1 a) { return -applyLeakyRelu(a, alpha); });
325 angle += eta *
PI_R1;
334 angle = origAngle - eta *
PI_R1;
341 if ((startProb >= plusProb) && (startProb >= minusProb)) {
348 if (plusProb > minusProb) {
349 angle = origAngle + eta *
PI_R1;
Definition: qneuron.hpp:25
void Learn(real1_f eta, bool expected=true, bool resetInit=true)
Perform one learning iteration, training all parameters.
Definition: qneuron.hpp:275
QNeuronActivationFn GetActivationFn()
Get activation function enum.
Definition: qneuron.hpp:128
bitLenInt GetInputCount()
Definition: qneuron.hpp:136
static real1_f clampAngle(real1_f angle)
Definition: qneuron.hpp:60
static real1_f negApplyGelu(real1_f angle)
Definition: qneuron.hpp:42
real1_f GetAlpha()
Get the "alpha" sharpness parameter of this QNeuron.
Definition: qneuron.hpp:122
QInterfacePtr qReg
Definition: qneuron.hpp:34
static real1_f negApplyRelu(real1_f angle)
Definition: qneuron.hpp:38
bitLenInt outputIndex
Definition: qneuron.hpp:28
bitCapIntOcl inputPower
Definition: qneuron.hpp:27
void GetAngles(real1 *oAngles)
Get the angles of this QNeuron.
Definition: qneuron.hpp:134
QNeuron(const QNeuron &toCopy)
Create a new QNeuron which is an exact duplicate of another, including its learned state.
Definition: qneuron.hpp:98
real1_f Predict(bool expected=true, bool resetInit=true)
Predict a binary classification.
Definition: qneuron.hpp:146
QNeuron & operator=(const QNeuron &toCopy)
Definition: qneuron.hpp:105
real1_f Unpredict(bool expected=true)
"Uncompute" the Predict() method
Definition: qneuron.hpp:205
static real1_f applyAlpha(real1_f angle, real1_f alpha)
Definition: qneuron.hpp:44
void SetAngles(real1 *nAngles)
Set the angles of this QNeuron.
Definition: qneuron.hpp:131
std::vector< bitLenInt > inputIndices
Definition: qneuron.hpp:32
static real1_f applyGelu(real1_f angle)
Definition: qneuron.hpp:40
void SetAlpha(real1_f a)
Set the "alpha" sharpness parameter of this QNeuron.
Definition: qneuron.hpp:119
real1_f LearnCycle(bool expected=true)
Definition: qneuron.hpp:260
static real1_f applyLeakyRelu(real1_f angle, real1_f alpha)
Definition: qneuron.hpp:58
bitCapIntOcl GetInputPower()
Definition: qneuron.hpp:138
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 superposi...
Definition: qneuron.hpp:84
real1_f LearnInternal(bool expected, real1_f eta, bitCapIntOcl permOcl, real1_f startProb)
Definition: qneuron.hpp:319
real1_f tolerance
Definition: qneuron.hpp:31
real1_f alpha
Definition: qneuron.hpp:30
QNeuronActivationFn activationFn
Definition: qneuron.hpp:29
static real1_f applyRelu(real1_f angle)
Definition: qneuron.hpp:36
void SetActivationFn(QNeuronActivationFn f)
Sets activation function enum.
Definition: qneuron.hpp:125
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:300
std::unique_ptr< real1[]> angles
Definition: qneuron.hpp:33
Half-precision floating-point type.
Definition: half.hpp:2222
GLOSSARY: bitLenInt - "bit-length integer" - unsigned integer ID of qubit position in register bitCap...
Definition: complex16x2simd.hpp:25
QRACK_CONST real1 SQRT1_2_R1
Definition: qrack_types.hpp:180
std::shared_ptr< QInterface > QInterfacePtr
Definition: qinterface.hpp:29
void U(quid sid, bitLenInt q, real1_f theta, real1_f phi, real1_f lambda)
(External API) 3-parameter unitary gate
Definition: wasm_api.cpp:1143
QRACK_CONST real1 FP_NORM_EPSILON
Definition: qrack_types.hpp:258
QRACK_CONST real1 ONE_R1
Definition: qrack_types.hpp:185
QRACK_CONST real1 ZERO_R1
Definition: qrack_types.hpp:183
float real1_f
Definition: qrack_types.hpp:95
float real1_s
Definition: qrack_types.hpp:96
std::shared_ptr< QNeuron > QNeuronPtr
Definition: qneuron.hpp:22
QRACK_CONST real1 PI_R1
Definition: qrack_types.hpp:178
QNeuronActivationFn
Enumerated list of activation functions.
Definition: qneuron_activation_function.hpp:19
@ Sigmoid
Default.
Definition: qneuron_activation_function.hpp:21
@ ReLU
Rectified linear.
Definition: qneuron_activation_function.hpp:23
@ Generalized_Logistic
Version of (default) "Sigmoid" with tunable sharpness.
Definition: qneuron_activation_function.hpp:27
@ GeLU
Gaussian linear.
Definition: qneuron_activation_function.hpp:25
@ Leaky_ReLU
Leaky rectified linear.
Definition: qneuron_activation_function.hpp:29
bitCapIntOcl pow2Ocl(const bitLenInt &p)
Definition: qrack_functions.hpp:137
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
#define bitLenInt
Definition: qrack_types.hpp:38
#define ZERO_R1_F
Definition: qrack_types.hpp:160
#define bitCapIntOcl
Definition: qrack_types.hpp:50
#define ONE_R1_F
Definition: qrack_types.hpp:163