neuron_kd_switch3.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <errno.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <memory.h>
  7. #include "neuron_switch3.h"
  8. #include "iop_Rrs_neuron.h"
  9. /* -------------------------------------------------------------------------------
  10. Lecture des differrentes Look Up Tables
  11. ------------------------------------------------------------------------------- */
  12. void neuron_lect_LUTswitch(int idSensor, char *lutpath)
  13. {
  14. FILE *fic;
  15. int i,j,poub;
  16. char *ligne=malloc(sizeof(char)*150), nomfic[1000];
  17. float fpoub;
  18. if( (poub = strcmp(lutpath, "None")) == 0){
  19. if( (lutpath = getenv("IOP_LUTS_PATH")) == NULL) {perror("IOP_LUTS_PATH"); exit(-1);}
  20. }
  21. /* ===================================== SeaWiFS ===================================== */
  22. if( idSensor == idSEAWIFS || idSensor == idMERIS){
  23. /* ----- LUTs for Rrs490/Rrs555 >= .85 ------ */
  24. sprintf(nomfic,"%s/%s", lutpath, rsupSW_LUT_POIDS);
  25. if( (fic=fopen(nomfic,"r")) == NULL) {perror(nomfic); exit(-1);}
  26. fgets(ligne,150,fic);
  27. for(i=0; i<rsupSW_NC1; i++)
  28. fscanf(fic,"%d %d %f",&poub,&poub,&rsupSW_b1[i]);
  29. for(i=0; i<rsupSW_NC2; i++)
  30. fscanf(fic,"%d %d %f",&poub,&poub,&rsupSW_b2[i]);
  31. fscanf(fic,"%d %d %f",&poub,&poub,&rsupSW_b3);
  32. for(j=0; j<rsupSW_NE; j++){
  33. for(i=0; i<rsupSW_NC1; i++)
  34. fscanf(fic,"%d %d %f",&poub,&poub,&rsupSW_w1[j][i]);
  35. }
  36. for(j=0; j<rsupSW_NC1; j++){
  37. for(i=0; i<rsupSW_NC2; i++)
  38. fscanf(fic,"%d %d %f",&poub,&poub,&rsupSW_w2[j][i]);
  39. }
  40. for(i=0; i<rsupSW_NC2; i++)
  41. fscanf(fic,"%d %d %f",&poub,&poub,&rsupSW_w3[i]);
  42. fclose(fic);
  43. sprintf(nomfic,"%s/%s", lutpath, rsupSW_LUT_MOY);
  44. if( (fic=fopen(nomfic,"r")) == NULL) {perror(nomfic); exit(-1);}
  45. fscanf(fic,"%f",&fpoub);
  46. for(i=0; i<rsupSW_NE-1; i++)
  47. fscanf(fic,"%f",&rsupSW_moy[i]);
  48. fscanf(fic,"%f",&fpoub);
  49. fscanf(fic,"%f",&rsupSW_moy[rsupSW_NE-1]);
  50. fscanf(fic,"%f",&fpoub);
  51. fscanf(fic,"%f",&rsupSW_moy[rsupSW_NES-1]);
  52. fclose(fic);
  53. sprintf(nomfic,"%s/%s", lutpath, rsupSW_LUT_ECART);
  54. if( (fic=fopen(nomfic,"r")) == NULL) {perror(nomfic); exit(-1);}
  55. fscanf(fic,"%f",&fpoub);
  56. for(i=0; i<rsupSW_NE-1; i++)
  57. fscanf(fic,"%f",&rsupSW_ecart[i]);
  58. fscanf(fic,"%f",&fpoub);
  59. fscanf(fic,"%f",&rsupSW_ecart[rsupSW_NE-1]);
  60. fscanf(fic,"%f",&fpoub);
  61. fscanf(fic,"%f",&rsupSW_ecart[rsupSW_NES-1]);
  62. fclose(fic);
  63. /* ----- LUTs for Rrs490/Rrs555 < .85 ------ */
  64. sprintf(nomfic,"%s/%s", lutpath, rinfSW_LUT_POIDS);
  65. if( (fic=fopen(nomfic,"r")) == NULL) {perror(nomfic); exit(-1);}
  66. fgets(ligne,150,fic);
  67. for(i=0; i<rinfSW_NC1; i++)
  68. fscanf(fic,"%d %d %f",&poub,&poub,&rinfSW_b1[i]);
  69. for(i=0; i<rinfSW_NC2; i++)
  70. fscanf(fic,"%d %d %f",&poub,&poub,&rinfSW_b2[i]);
  71. fscanf(fic,"%d %d %f",&poub,&poub,&rinfSW_b3);
  72. for(j=0; j<rinfSW_NE; j++){
  73. for(i=0; i<rinfSW_NC1; i++)
  74. fscanf(fic,"%d %d %f",&poub,&poub,&rinfSW_w1[j][i]);
  75. }
  76. for(j=0; j<rinfSW_NC1; j++){
  77. for(i=0; i<rinfSW_NC2; i++)
  78. fscanf(fic,"%d %d %f",&poub,&poub,&rinfSW_w2[j][i]);
  79. }
  80. for(i=0; i<rinfSW_NC2; i++)
  81. fscanf(fic,"%d %d %f",&poub,&poub,&rinfSW_w3[i]);
  82. fclose(fic);
  83. sprintf(nomfic,"%s/%s", lutpath, rinfSW_LUT_MOY);
  84. if( (fic=fopen(nomfic,"r")) == NULL) {perror(nomfic); exit(-1);}
  85. fscanf(fic,"%f",&fpoub);
  86. for(i=0; i<rinfSW_NE; i++)
  87. fscanf(fic,"%f",&rinfSW_moy[i]);
  88. fscanf(fic,"%f",&fpoub);
  89. fscanf(fic,"%f",&rinfSW_moy[rinfSW_NES-1]);
  90. fclose(fic);
  91. sprintf(nomfic,"%s/%s", lutpath, rinfSW_LUT_ECART);
  92. if( (fic=fopen(nomfic,"r")) == NULL) {perror(nomfic); exit(-1);}
  93. fscanf(fic,"%f",&fpoub);
  94. for(i=0; i<rinfSW_NE; i++)
  95. fscanf(fic,"%f",&rinfSW_ecart[i]);
  96. fscanf(fic,"%f",&fpoub);
  97. fscanf(fic,"%f",&rinfSW_ecart[rinfSW_NES-1]);
  98. fclose(fic);
  99. }
  100. /* ===================================== MODIS ===================================== */
  101. if( idSensor == idMODIS){
  102. /* ----- LUTs for Rrs490/Rrs555 >= .85 ------ */
  103. sprintf(nomfic,"%s/%s", lutpath, rsupMO_LUT_POIDS);
  104. if( (fic=fopen(nomfic,"r")) == NULL) {perror(nomfic); exit(-1);}
  105. fgets(ligne,150,fic);
  106. for(i=0; i<rsupMO_NC1; i++)
  107. fscanf(fic,"%d %d %f",&poub,&poub,&rsupMO_b1[i]);
  108. for(i=0; i<rsupMO_NC2; i++)
  109. fscanf(fic,"%d %d %f",&poub,&poub,&rsupMO_b2[i]);
  110. fscanf(fic,"%d %d %f",&poub,&poub,&rsupMO_b3);
  111. for(j=0; j<rsupMO_NE; j++){
  112. for(i=0; i<rsupMO_NC1; i++)
  113. fscanf(fic,"%d %d %f",&poub,&poub,&rsupMO_w1[j][i]);
  114. }
  115. for(j=0; j<rsupMO_NC1; j++){
  116. for(i=0; i<rsupMO_NC2; i++)
  117. fscanf(fic,"%d %d %f",&poub,&poub,&rsupMO_w2[j][i]);
  118. }
  119. for(i=0; i<rsupMO_NC2; i++)
  120. fscanf(fic,"%d %d %f",&poub,&poub,&rsupMO_w3[i]);
  121. fclose(fic);
  122. sprintf(nomfic,"%s/%s", lutpath, rsupMO_LUT_MOY);
  123. if( (fic=fopen(nomfic,"r")) == NULL) {perror(nomfic); exit(-1);}
  124. fscanf(fic,"%f",&fpoub);/*412*/
  125. fscanf(fic,"%f",&rsupMO_moy[0]); /*443*/
  126. fscanf(fic,"%f",&rsupMO_moy[1]); /*488*/
  127. fscanf(fic,"%f",&rsupMO_moy[2]); /*531*/
  128. fscanf(fic,"%f",&rsupMO_moy[3]); /*547*/
  129. fscanf(fic,"%f",&fpoub); /*620*/
  130. fscanf(fic,"%f",&fpoub); /*667*/
  131. fscanf(fic,"%f",&rsupMO_moy[rsupMO_NE-1]);
  132. fscanf(fic,"%f",&fpoub);
  133. fscanf(fic,"%f",&rsupMO_moy[rsupMO_NES-1]);
  134. fclose(fic);
  135. sprintf(nomfic,"%s/%s", lutpath, rsupMO_LUT_ECART);
  136. if( (fic=fopen(nomfic,"r")) == NULL) {perror(nomfic); exit(-1);}
  137. fscanf(fic,"%f",&fpoub);
  138. fscanf(fic,"%f",&rsupMO_ecart[0]); /*443*/
  139. fscanf(fic,"%f",&rsupMO_ecart[1]); /*488*/
  140. fscanf(fic,"%f",&rsupMO_ecart[2]); /*531*/
  141. fscanf(fic,"%f",&rsupMO_ecart[3]); /*547*/
  142. fscanf(fic,"%f",&fpoub); /*620*/
  143. fscanf(fic,"%f",&fpoub); /*667*/
  144. fscanf(fic,"%f",&rsupMO_ecart[rsupMO_NE-1]);
  145. fscanf(fic,"%f",&fpoub);
  146. fscanf(fic,"%f",&rsupMO_ecart[rsupMO_NES-1]);
  147. fclose(fic);
  148. /* ----- LUTs for Rrs490/Rrs555 < .85 ------ */
  149. sprintf(nomfic,"%s/%s", lutpath, rinfMO_LUT_POIDS);
  150. if( (fic=fopen(nomfic,"r")) == NULL) {perror(nomfic); exit(-1);}
  151. fgets(ligne,150,fic);
  152. for(i=0; i<rinfMO_NC1; i++)
  153. fscanf(fic,"%d %d %f",&poub,&poub,&rinfMO_b1[i]);
  154. for(i=0; i<rinfMO_NC2; i++)
  155. fscanf(fic,"%d %d %f",&poub,&poub,&rinfMO_b2[i]);
  156. fscanf(fic,"%d %d %f",&poub,&poub,&rinfMO_b3);
  157. for(j=0; j<rinfMO_NE; j++){
  158. for(i=0; i<rinfMO_NC1; i++)
  159. fscanf(fic,"%d %d %f",&poub,&poub,&rinfMO_w1[j][i]);
  160. }
  161. for(j=0; j<rinfMO_NC1; j++){
  162. for(i=0; i<rinfMO_NC2; i++)
  163. fscanf(fic,"%d %d %f",&poub,&poub,&rinfMO_w2[j][i]);
  164. }
  165. for(i=0; i<rinfMO_NC2; i++)
  166. fscanf(fic,"%d %d %f",&poub,&poub,&rinfMO_w3[i]);
  167. fclose(fic);
  168. sprintf(nomfic,"%s/%s", lutpath, rinfMO_LUT_MOY);
  169. if( (fic=fopen(nomfic,"r")) == NULL) {perror(nomfic); exit(-1);}
  170. fscanf(fic,"%f",&fpoub);/*412*/
  171. fscanf(fic,"%f",&rinfMO_moy[0]); /*443*/
  172. fscanf(fic,"%f",&rinfMO_moy[1]); /*488*/
  173. fscanf(fic,"%f",&rinfMO_moy[2]); /*531*/
  174. fscanf(fic,"%f",&rinfMO_moy[3]); /*547*/
  175. fscanf(fic,"%f",&fpoub); /*620*/
  176. fscanf(fic,"%f",&rinfMO_moy[4]); /*667*/
  177. fscanf(fic,"%f",&rinfMO_moy[rinfMO_NE-1]);
  178. fscanf(fic,"%f",&fpoub);
  179. fscanf(fic,"%f",&rinfMO_moy[rinfMO_NES-1]);
  180. fclose(fic);
  181. sprintf(nomfic,"%s/%s", lutpath, rinfMO_LUT_ECART);
  182. if( (fic=fopen(nomfic,"r")) == NULL) {perror(nomfic); exit(-1);}
  183. fscanf(fic,"%f",&fpoub);
  184. fscanf(fic,"%f",&rinfMO_ecart[0]); /*443*/
  185. fscanf(fic,"%f",&rinfMO_ecart[1]); /*488*/
  186. fscanf(fic,"%f",&rinfMO_ecart[2]); /*531*/
  187. fscanf(fic,"%f",&rinfMO_ecart[3]); /*547*/
  188. fscanf(fic,"%f",&fpoub); /*620*/
  189. fscanf(fic,"%f",&rinfMO_ecart[4]); /*667*/
  190. fscanf(fic,"%f",&rinfMO_ecart[rinfMO_NE-1]);
  191. fscanf(fic,"%f",&fpoub);
  192. fscanf(fic,"%f",&rinfMO_ecart[rinfMO_NES-1]);
  193. fclose(fic);
  194. }
  195. }
  196. /* =============================================== SEAWIFS =============================================== */
  197. /* -------------------------------------------------------------------------------
  198. Calcul du Kd a partir des poids
  199. - Input:
  200. input[NE] = Rrs 443 490 510 555 Lambda
  201. ------------------------------------------------------------------------------- */
  202. float rsupSW_neuron_passe_avant(float input[rsupSW_NE+1])
  203. {
  204. float a[rsupSW_NC1], b[rsupSW_NC2], y=0.0, x[rsupSW_NE];
  205. int i,j;
  206. /* Normalisation */
  207. for(i=0; i<rsupSW_NE; i++){
  208. x[i] = ((2./3.)*(input[i]-rsupSW_moy[i]))/rsupSW_ecart[i];
  209. }
  210. for(i=0;i<rsupSW_NC1;i++){
  211. a[i] = 0.0;
  212. for(j=0;j<rsupSW_NE;j++){
  213. a[i] += (x[j]*rsupSW_w1[j][i]);
  214. }
  215. a[i] = 1.715905*(float)tanh((2./3.)*(double)(a[i] + rsupSW_b1[i]));
  216. }
  217. for(i=0;i<rsupSW_NC2;i++){
  218. b[i] = 0.0;
  219. for(j=0;j<rsupSW_NC1;j++){
  220. b[i] += (a[j]*rsupSW_w2[j][i]);
  221. }
  222. b[i] = 1.715905*(float)tanh((2./3.)*(double)(b[i] + rsupSW_b2[i]));
  223. }
  224. for(j=0;j<rsupSW_NC2;j++){
  225. y += (b[j]*rsupSW_w3[j]);
  226. }
  227. /* Denormalisation */
  228. y = 1.5*(y + rsupSW_b3)*rsupSW_ecart[rsupSW_NES-1] + rsupSW_moy[rsupSW_NES-1];
  229. y = (float)pow(10.,y);
  230. return(y);
  231. }
  232. /* -------------------------------------------------------------------------------
  233. Calcul du Kd a partir des poids
  234. - Input:
  235. input[NE] = Rrs 443 490 510 555 670 Lambda
  236. ------------------------------------------------------------------------------- */
  237. float rinfSW_neuron_passe_avant(float input[rinfSW_NE])
  238. {
  239. float a[rinfSW_NC1], b[rinfSW_NC2], y=0.0, x[rinfSW_NE];
  240. int i,j;
  241. /* Normalisation */
  242. for(i=0; i<rinfSW_NE; i++){
  243. x[i] = ((2./3.)*(input[i]-rinfSW_moy[i]))/rinfSW_ecart[i];
  244. }
  245. for(i=0;i<rinfSW_NC1;i++){
  246. a[i] = 0.0;
  247. for(j=0;j<rinfSW_NE;j++){
  248. a[i] += (x[j]*rinfSW_w1[j][i]);
  249. }
  250. a[i] = 1.715905*(float)tanh((2./3.)*(double)(a[i] + rinfSW_b1[i]));
  251. }
  252. for(i=0;i<rinfSW_NC2;i++){
  253. b[i] = 0.0;
  254. for(j=0;j<rinfSW_NC1;j++){
  255. b[i] += (a[j]*rinfSW_w2[j][i]);
  256. }
  257. b[i] = 1.715905*(float)tanh((2./3.)*(double)(b[i] + rinfSW_b2[i]));
  258. }
  259. for(j=0;j<rinfSW_NC2;j++){
  260. y += (b[j]*rinfSW_w3[j]);
  261. }
  262. /* Denormalisation */
  263. y = 1.5*(y + rinfSW_b3)*rinfSW_ecart[rinfSW_NES-1] + rinfSW_moy[rinfSW_NES-1];
  264. y = (float)pow(10.,y);
  265. return(y);
  266. }
  267. /* =============================================== MODIS ================================================ */
  268. /* -------------------------------------------------------------------------------
  269. Calcul du Kd a partir des poids
  270. - Input:
  271. input[NE] = Rrs 443 490 510 555 Lambda
  272. ------------------------------------------------------------------------------- */
  273. float rsupMO_neuron_passe_avant(float input[rsupMO_NE+1])
  274. {
  275. float a[rsupMO_NC1], b[rsupMO_NC2], y=0.0, x[rsupMO_NE];
  276. int i,j;
  277. /* Normalisation */
  278. for(i=0; i<rsupMO_NE; i++){
  279. x[i] = ((2./3.)*(input[i]-rsupMO_moy[i]))/rsupMO_ecart[i];
  280. }
  281. for(i=0;i<rsupMO_NC1;i++){
  282. a[i] = 0.0;
  283. for(j=0;j<rsupMO_NE;j++){
  284. a[i] += (x[j]*rsupMO_w1[j][i]);
  285. }
  286. a[i] = 1.715905*(float)tanh((2./3.)*(double)(a[i] + rsupMO_b1[i]));
  287. }
  288. for(i=0;i<rsupMO_NC2;i++){
  289. b[i] = 0.0;
  290. for(j=0;j<rsupMO_NC1;j++){
  291. b[i] += (a[j]*rsupMO_w2[j][i]);
  292. }
  293. b[i] = 1.715905*(float)tanh((2./3.)*(double)(b[i] + rsupMO_b2[i]));
  294. }
  295. for(j=0;j<rsupMO_NC2;j++){
  296. y += (b[j]*rsupMO_w3[j]);
  297. }
  298. /* Denormalisation */
  299. y = 1.5*(y + rsupMO_b3)*rsupMO_ecart[rsupMO_NES-1] + rsupMO_moy[rsupMO_NES-1];
  300. y = (float)pow(10.,y);
  301. return(y);
  302. }
  303. /* -------------------------------------------------------------------------------
  304. Calcul du Kd a partir des poids
  305. - Input:
  306. input[NE] = Rrs 443 490 510 555 670 Lambda
  307. ------------------------------------------------------------------------------- */
  308. float rinfMO_neuron_passe_avant(float input[rinfMO_NE])
  309. {
  310. float a[rinfMO_NC1], b[rinfMO_NC2], y=0.0, x[rinfMO_NE];
  311. int i,j;
  312. /* Normalisation */
  313. for(i=0; i<rinfMO_NE; i++){
  314. x[i] = ((2./3.)*(input[i]-rinfMO_moy[i]))/rinfMO_ecart[i];
  315. }
  316. for(i=0;i<rinfMO_NC1;i++){
  317. a[i] = 0.0;
  318. for(j=0;j<rinfMO_NE;j++){
  319. a[i] += (x[j]*rinfMO_w1[j][i]);
  320. }
  321. a[i] = 1.715905*(float)tanh((2./3.)*(double)(a[i] + rinfMO_b1[i]));
  322. }
  323. for(i=0;i<rinfMO_NC2;i++){
  324. b[i] = 0.0;
  325. for(j=0;j<rinfMO_NC1;j++){
  326. b[i] += (a[j]*rinfMO_w2[j][i]);
  327. }
  328. b[i] = 1.715905*(float)tanh((2./3.)*(double)(b[i] + rinfMO_b2[i]));
  329. }
  330. for(j=0;j<rinfMO_NC2;j++){
  331. y += (b[j]*rinfMO_w3[j]);
  332. }
  333. /* Denormalisation */
  334. y = 1.5*(y + rinfMO_b3)*rinfMO_ecart[rinfMO_NES-1] + rinfMO_moy[rinfMO_NES-1];
  335. y = (float)pow(10.,y);
  336. return(y);
  337. }
  338. /*int main (int argc, char *argv[])
  339. {
  340. FILE *fic;
  341. float data_in[rinfSW_NE],result_in,result_out,res_norm, sumInf_rms=0., sumInf_rel=0., sumSup_rms=0., sumSup_rel=0.;
  342. int i,nb,lu;
  343. if( (fic=fopen("../LUTS/base_KdSeaWiFS_IOCCG_NOMAD_BOUM_ss_12_COASTCOLOUR_412_to_670_log_Kd_lambda_merge_seuil_15_publi_091213_test.dat","r")) == NULL) {perror("input"); exit(-1);}
  344. neuron_lect_LUTs();
  345. nb = 0;
  346. while((lu=fscanf(fic,"%f",&data_in[0])) == 1){
  347. for(i=1; i<rinfSW_NE; i++)
  348. fscanf(fic,"%f",&data_in[i]);
  349. fscanf(fic,"%f",&result_in);
  350. result_out = rinfSW_neuron_passe_avant(data_in);
  351. result_in = (float)pow(10.,result_in);
  352. sumInf_rms += (float)pow((double)(result_in-result_out),2.);
  353. sumInf_rel += (float)sqrt((double)(((result_in-result_out)/result_in) * ((result_in-result_out)/result_in)));
  354. printf("%f %f",result_in,result_out);
  355. data_in[5] = data_in[6];
  356. result_out = rsupSW_neuron_passe_avant(data_in);
  357. sumSup_rms += (float)pow((double)(result_in-result_out),2.);
  358. sumSup_rel += (float)sqrt((double)(((result_in-result_out)/result_in) * ((result_in-result_out)/result_in)));
  359. printf(" %f\n",result_out);
  360. nb++;
  361. }
  362. printf("rmseInf = %f, rel errInf= %f, rmseSup = %f, rel errSup= %f nb = %d\n",(float)sqrt((double)sumInf_rms/nb),sumInf_rel/nb, (float)sqrt((double)sumSup_rms/nb),sumSup_rel/nb, nb);
  363. fclose(fic);
  364. exit(1);
  365. }*/
  366. /*int main (int argc, char *argv[])
  367. {
  368. FILE *fic;
  369. float fpoub, data_in[rinfSW_NE],result_in,result_out,res_norm, sumInf_rms=0., sumInf_rel=0., sumSup_rms=0., sumSup_rel=0.;
  370. int i,nb,lu;
  371. printf(" -- SUP --\n");
  372. if( (fic=fopen("../LUTS/base_KdMODIS_IOCCG_NOMAD_BOUM_ss_12_COASTCOLOUR_412_to_555_log_Kd_lambda_merge_seuil_15_ss_645_publi_test_sup_CSIRO.dat","r")) == NULL) {perror("input"); exit(-1);}
  373. neuron_lect_LUTswitch(idMODIS);
  374. nb = 0;
  375. while((lu=fscanf(fic,"%f",&fpoub)) == 1){
  376. for(i=0; i<4; i++)
  377. fscanf(fic,"%f",&data_in[i]);
  378. fscanf(fic,"%f",&fpoub);
  379. fscanf(fic,"%f",&fpoub);
  380. fscanf(fic,"%f",&data_in[4]);
  381. fscanf(fic,"%f",&fpoub);
  382. fscanf(fic,"%f",&result_in);
  383. result_out = rsupMO_neuron_passe_avant(data_in);
  384. result_in = (float)pow(10.,result_in);
  385. if (data_in[4] == 488 ){
  386. sumSup_rms += (float)pow((double)(result_in-result_out),2.);
  387. sumSup_rel += (float)sqrt((double)(((result_in-result_out)/result_in) * ((result_in-result_out)/result_in)));
  388. nb++;
  389. }
  390. }
  391. printf("rmseSup = %f, rel errSup= %f nb = %d\n",(float)sqrt((double)sumSup_rms/nb),sumSup_rel/nb, nb);
  392. fclose(fic);
  393. printf(" -- INF --\n");
  394. if( (fic=fopen("../LUTS/base_KdMODIS_IOCCG_NOMAD_BOUM_ss_12_COASTCOLOUR_412_to_670_log_Kd_lambda_merge_seuil_15_ss_645_publi_test_inf_CSIRO.dat","r")) == NULL) {perror("input"); exit(-1);}
  395. nb = 0;
  396. while((lu=fscanf(fic,"%f",&fpoub)) == 1){
  397. for(i=0; i<4; i++)
  398. fscanf(fic,"%f",&data_in[i]);
  399. fscanf(fic,"%f",&fpoub);
  400. fscanf(fic,"%f",&data_in[4]);
  401. fscanf(fic,"%f",&data_in[5]);
  402. fscanf(fic,"%f",&fpoub);
  403. fscanf(fic,"%f",&result_in);
  404. result_out = rinfMO_neuron_passe_avant(data_in);
  405. result_in = (float)pow(10.,result_in);
  406. if (data_in[5] == 488 ){
  407. sumInf_rms += (float)pow((double)(result_in-result_out),2.);
  408. sumInf_rel += (float)sqrt((double)(((result_in-result_out)/result_in) * ((result_in-result_out)/result_in)));
  409. nb++;
  410. }
  411. }
  412. printf("rmseInf = %f, rel errInf= %f nb = %d\n",(float)sqrt((double)sumInf_rms/nb),sumInf_rel/nb, nb);
  413. exit(1);
  414. }*/