2#include "ae2f/errGlob.h"
3#include <ae2f/Ann/Slp.h>
11 r[0] = 1.0 / (1.0 + exp(-x));
17 r[0] = output * (1.0 - output);
28 o_i = o_i < epsilon ? epsilon : (o_i > 1.0 - epsilon ? 1.0 - epsilon : o_i);
29 r[0] = (o_i - target[i]) / (c * o_i * (1.0 - o_i));
49#define DIFF_GOOD(a, b) (((a) - (b)) * ((a) - (b))) < THRESHOLD
52 puts(
"Trial: tryand");
61 , Act
, ActDeriv
, LossDeriv
66 printf(
"Learningrate dump: %f, %f\n",
slp->m_learningrate,
slp->m_learningrate_bias);
67 printf(
"function points: %p %p %p\n",
slp->m_act,
slp->m_actderiv,
slp->m_lossderiv);
71 for(
i = 0 ;
i < 2 * 1 + 1; ++
i) {
72 slp->m_weight[
i << 1] = 0.2;
73 slp->m_weight[(
i << 1) + 1] = 0.2;
76 for(
i = 0;
i < 3000; ++
i) {
77 for(
j = 0;
j <
sizeof(
inp) /
sizeof(
inp[0]); ++
j) {
83 for(
j = 0;
j <
sizeof(
inp) /
sizeof(
inp[0]); ++
j) {
91 printf(
"Expected %f. Unexpected.\n",
goal_andor[
j][0]);
102 printf(
"Code from tryand: %d\n",
err);
void ae2f_AnnAct_t(ae2f_float_t *ret, ae2f_float_t x)
Customisable activasion function type.
void ae2f_AnnLoss_t(ae2f_float_t *ret, const ae2f_float_t *out, const ae2f_float_t *goal, size_t index, size_t count)
Specify the way of calculating loss.
const ae2f_float_t inp[4][2]
const ae2f_float_t goal_andor[4][2]
ae2f_SHAREDEXPORT void ae2f_AnnSlpTrain(ae2f_err_t *restrict const err, ae2f_AnnSlp *restrict slp, ae2f_LP(slp::inc) const ae2f_float_t *restrict inp, ae2f_LP(slp::outc) const ae2f_float_t *restrict out_desired) noexcept
ae2f_SHAREDEXPORT void ae2f_AnnSlpPredict(ae2f_err_t *restrict const err_opt, const ae2f_AnnSlp *restrict const _this, const ae2f_float_t *restrict const prm_in, ae2f_float_t *restrict const out) noexcept
ae2f_SHAREDEXPORT void ae2f_AnnSlpDel(ae2f_AnnSlp *restrict const slp) noexcept
ae2f_SHAREDEXPORT void ae2f_AnnSlpMk(ae2f_LP(inc *outc) ae2f_float_t *restrict const weight_opt, ae2f_LP(outc) ae2f_float_t *restrict const bias_opt, ae2f_LP(outc) ae2f_float_t *restrict const cache_opt, const size_t inc, const size_t outc, const size_t offset_opt, const size_t extra_opt, ae2f_FREE(ae2f_AnnSlpDel, __ae2f_AnnSlpDel) ae2f_AnnSlp *restrict *restrict const slp, ae2f_opt ae2f_AnnAct_t *const act, ae2f_opt ae2f_AnnAct_t *const actderiv, ae2f_AnnLoss_t *const lossderiv, ae2f_float_t learningrate, ae2f_float_t learningrate_bias, ae2f_opt ae2f_err_t *restrict const err_opt) noexcept
#define ae2f_errGlob_NFOUND
Found some errors, but not by parameters. The operation has failed.
uint8_t ae2f_err_t
Informs that this number represents the error.