CMSIS-NN: Tuned the softmax test criterion based upon analysis done with

scipy.
pull/19/head
Christophe Favergeon 6 years ago
parent 244770716b
commit 780a7ce3d9

@ -5,7 +5,7 @@ import random
import numpy as np import numpy as np
import scipy.special as sp import scipy.special as sp
NBTESTSAMPLES = 1000 NBTESTSAMPLES = 100
def softmax(v): def softmax(v):
m = sp.softmax(v) m = sp.softmax(v)
@ -23,7 +23,7 @@ def writeTest(config,nb,vecDim):
for _ in range(0,NBTESTSAMPLES): for _ in range(0,NBTESTSAMPLES):
va = np.random.randn(vecDim) va = np.abs(np.random.randn(vecDim))
va = va / np.sum(va) va = va / np.sum(va)
r = sp.softmax(va) r = sp.softmax(va)

@ -1,6 +1,6 @@
H H
2 2
// 1000 // 100
0x03E8 0x0064
// 15 // 15
0x000F 0x000F

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -59,9 +59,10 @@ int16_t differences(int16_t *pa,int16_t *pb, int length)
vec_in += this->vecDim; vec_in += this->vecDim;
} }
printf("Nb diffs : %d\n",differences(ref.ptr(),output.ptr(),this->nbSamples)); int diff = differences(ref.ptr(),output.ptr(),this->nbSamples);
// 5% of errors are accepted
ASSERT_EQ(output,ref); ASSERT_TRUE(100.0*diff/this->nbSamples <= 5);
} }
@ -91,6 +92,6 @@ int16_t differences(int16_t *pa,int16_t *pb, int length)
void Softmax::tearDown(Testing::testID_t id,Client::PatternMgr *mgr) void Softmax::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
{ {
//output.dump(mgr); output.dump(mgr);
//temp.dump(mgr); //temp.dump(mgr);
} }

Loading…
Cancel
Save