2 # -*- coding: utf-8 -*-
4 from math import tanh, exp
6 def ActivationFunction(sum):
7 return ( 1.0 / ( 1.0 + exp( -1.0 * sum ) ) );
11 ##############################
13 # File used by unit test
14 # PMMLBasicsTest1::testExportNeuralNetworkPython
16 ##############################
25 # --- Preprocessing of the inputs and outputs
26 myTestFunc_minInput = [
27 0.099999, 25048.9, 89334.9, 89.5523, 1050,
28 760.001, 1400.02, 10950,
30 myTestFunc_minOutput = [
33 myTestFunc_maxInput = [
34 0.028899, 14419.8, 15180.8, 15.2866, 34.6793,
35 34.6718, 161.826, 632.913,
37 myTestFunc_maxOutput = [
40 # --- Values of the weights
42 -1.74548, 6.96551, -1.26357, 0.753663, 0.00165366,
43 0.004725, 0.00996979, 0.178798, -0.180981, -0.173569,
50 for i in range(nInput) :
51 myTestFunc_act.append( ( param[i] - myTestFunc_minInput[i] ) / myTestFunc_maxInput[i] ) ;
56 for member in range(nHidden):
57 CrtW = member * ( nInput + 2) + 2;
58 sum = myTestFunc_valW[CrtW];
60 for source in range(nInput) :
61 sum += myTestFunc_act[source] * myTestFunc_valW[CrtW];
64 myTestFunc_act.append( ActivationFunction(sum) ) ;
69 for member in range(nOutput):
70 sum = myTestFunc_valW[0];
71 for source in range(nHidden):
72 CrtW = source * ( nInput + 2) + 1;
73 sum += myTestFunc_act[nInput+source] * myTestFunc_valW[CrtW];
75 myTestFunc_act.append( sum );
77 res.append( myTestFunc_minOutput[member] + myTestFunc_maxOutput[member] * sum );