Skip to content

Commit cacd470

Browse files
committed
Test trial
Changes to be committed: modified: test/ann/SlpTrainAND.c modified: test/ann/SlpTrainAND.cc
1 parent d27d654 commit cacd470

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

test/ann/SlpTrainAND.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ ActDeriv(ae2f_float_t output) {
1717
/** Cross entrophy */
1818
static ae2f_float_t
1919
LossDeriv(const ae2f_float_t* output, const ae2f_float_t* target, size_t i, size_t c) {
20-
constexpr ae2f_float_t epsilon = 1e-7; // Small value to prevent division by zero
21-
ae2f_float_t o_i = output[i];
22-
// Clip output to avoid log(0) or division by zero
23-
o_i = o_i < epsilon ? epsilon : (o_i > 1.0 - epsilon ? 1.0 - epsilon : o_i);
24-
return (o_i - target[i]) / (c * o_i * (1.0 - o_i));
20+
ae2f_float_t epsilon = 1e-7; // Small value to prevent division by zero
21+
ae2f_float_t o_i = output[i];
22+
// Clip output to avoid log(0) or division by zero
23+
o_i = o_i < epsilon ? epsilon : (o_i > 1.0 - epsilon ? 1.0 - epsilon : o_i);
24+
return (o_i - target[i]) / (c * o_i * (1.0 - o_i));
2525
}
2626

2727
const ae2f_float_t inp[4][2] = { 1, 1, 0, 0, 0, 1, 1, 0 };

test/ann/SlpTrainAND.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ActDeriv(ae2f_float_t output) {
1717
/** Cross entrophy */
1818
static ae2f_float_t
1919
LossDeriv(const ae2f_float_t* output, const ae2f_float_t* target, size_t i, size_t c) {
20-
constexpr ae2f_float_t epsilon = 1e-7; // Small value to prevent division by zero
20+
ae2f_float_t epsilon = 1e-7; // Small value to prevent division by zero
2121
ae2f_float_t o_i = output[i];
2222
// Clip output to avoid log(0) or division by zero
2323
o_i = o_i < epsilon ? epsilon : (o_i > 1.0 - epsilon ? 1.0 - epsilon : o_i);
@@ -52,7 +52,7 @@ int tryand() {
5252
, Act, ActDeriv, LossDeriv
5353
, 0.1, 0.1
5454
, &err
55-
) ae2f_AnnSlp;
55+
) ae2f_AnnSlp;
5656

5757
printf("Learningrate dump: %f, %f\n", slp->m_learningrate, slp->m_learningrate_bias);
5858
printf("function points: %p %p %p\n", slp->m_act, slp->m_actderiv, slp->m_lossderiv);

0 commit comments

Comments
 (0)