Changeset 40376
- Timestamp:
- Mar 26, 2018, 12:54:01 PM (8 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 1 added
- 6 edited
-
cmd.astro/Makefile (modified) (1 diff)
-
cmd.astro/init.c (modified) (2 diffs)
-
cmd.astro/jdtolst.c (added)
-
cmd.data/nnet.c (modified) (2 diffs)
-
cmd.data/nnet_commands.c (modified) (1 diff)
-
cmd.data/test/nnet.sh (modified) (1 diff)
-
include/data.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.astro/Makefile
r39591 r40376 82 82 $(SRC)/wcs.$(ARCH).o \ 83 83 $(SRC)/imsub.$(ARCH).o \ 84 $(SRC)/jdtolst.$(ARCH).o \ 84 85 $(SRC)/imfit.$(ARCH).o \ 85 86 $(SRC)/imfit-fgauss.$(ARCH).o \ -
trunk/Ohana/src/opihi/cmd.astro/init.c
r39591 r40376 33 33 int imfit PROTO((int, char **)); 34 34 int imsub PROTO((int, char **)); 35 int jdtolst PROTO((int, char **)); 35 36 int medianmap PROTO((int, char **)); 36 37 int galsectors PROTO((int, char **)); … … 103 104 {1, "imfit", imfit, "fit function"}, 104 105 {1, "imsub", imsub, "subtract function"}, 106 {1, "jdtolst", jdtolst, "JD to LST conversion"}, 105 107 {1, "medianmap", medianmap, "small median image"}, 106 108 {1, "mkgauss", mkgauss, "generate a 2-D gaussian centered in image"}, -
trunk/Ohana/src/opihi/cmd.data/nnet.c
r40371 r40376 9 9 {1, "get", nnet_get, "get nnet node values"}, 10 10 {1, "read", nnet_read, "read nnet values from a file"}, 11 //{1, "write", nnet_write, "write nnet values to a file"},11 {1, "write", nnet_write, "write nnet values to a file"}, 12 12 {1, "train", nnet_train, "train nnet on a set of data"}, 13 13 {1, "apply", nnet_apply, "apply nnet to a set of data"}, … … 27 27 gprint (GP_ERR, " nnet get (nnet) [weights] [biases] ... [weights] [biases] : get nnet weights (images) and biases (vectors)\n"); 28 28 gprint (GP_ERR, " nnet read (nnet) (filename) : set nnet weights and biases using a data file\n"); 29 gprint (GP_ERR, " nnet write (nnet) (filename) : save nnet weights and biases to a data file\n"); 29 30 gprint (GP_ERR, " nnet train (nnet) [input] [input] ... [output] [output] ... : train nnet on data from a set of vectors\n"); 30 31 gprint (GP_ERR, " nnet apply (nnet) [input] [input] ... [output] [output] ... : apply nnet to input data and generate output\n"); -
trunk/Ohana/src/opihi/cmd.data/nnet_commands.c
r40371 r40376 258 258 } 259 259 260 int nnet_write (int argc, char **argv) { 261 262 if (argc < 3) { 263 gprint (GP_ERR, "USAGE: nnet write (nnet) (filename) : save nnet weights and biases to a file\n"); 264 return FALSE; 265 } 266 267 Nnet *nnet = FindNnet (argv[1]); 268 if (nnet == NULL) { 269 gprint (GP_ERR, "nnet %s not found, create it first\n", argv[1]); 270 return FALSE; 271 } 272 273 // open the file and read the number of layers 274 FILE *f = fopen (argv[2], "w"); 275 if (f == NULL) { 276 gprint (GP_ERR, "USAGE: nnet write (nnet) (filename) : save nnet weights and biases to a file\n"); 277 gprint (GP_ERR, "file %s could not be opened\n", argv[2]); 278 return FALSE; 279 } 280 281 // write the number of layers 282 // NLAYER 3 283 fprintf (f, "NLAYER %d\n", nnet->Nlayer); 284 285 // write the number of nodes for each layer 286 // LAYERS 2 4 2 287 fprintf (f, "LAYERS"); 288 for (int i = 0; i < nnet->Nlayer; i++) { 289 fprintf (f, " %d", nnet->Nnodes[i]); 290 } 291 fprintf (f, "\n"); 292 293 // read the weights and biases from the data file 294 for (int L = 1; L < nnet[0].Nlayer; L++) { 295 296 fprintf (f, "LAYER %d NX %d NY %d\n", L - 1, nnet->Nnodes[L-1], nnet->Nnodes[L]); 297 298 for (int j = 0; j < nnet->Nnodes[L]; j++) { 299 for (int i = 0; i < nnet->Nnodes[L-1]; i++) { 300 int k = i + j*nnet[0].Nnodes[L-1]; 301 fprintf (f, "%f ", nnet[0].weight[L][k]); 302 } 303 fprintf (f, "%f\n", nnet[0].biases[L][j]); 304 } 305 } 306 fclose (f); 307 308 return TRUE; 309 } 310 260 311 int nnet_get (int argc, char **argv) { 261 312 -
trunk/Ohana/src/opihi/cmd.data/test/nnet.sh
r40371 r40376 1 2 macro test.io 3 4 nnet create t1 2 3 2 5 6 # biases: 7 vlist v1 -0.2 0.0 0.2 8 vlist v2 -0.3 0.3 9 10 # weights 11 mcreate m1 2 3 12 m1[0][0] = 0.2 13 m1[1][0] = -0.2 14 m1[0][1] = -0.6 15 m1[1][1] = 0.5 16 m1[0][2] = -0.2 17 m1[1][2] = 0.2 18 19 mcreate m2 3 2 20 m2[0][0] = -0.6 21 m2[1][0] = -0.4 22 m2[2][0] = -0.5 23 24 m2[0][1] = -0.2 25 m2[1][1] = -0.5 26 m2[2][1] = 0.1 27 28 # set weights and biases 29 nnet set t1 m1 v1 m2 v2 30 31 nnet write t1 test.nnet.dat 32 nnet read t2 test.nnet.dat 33 34 nnet get t2 M1 V1 M2 V2 35 36 set dM1 = M1 - m1 37 set dM2 = M2 - m2 38 set dV1 = V1 - v1 39 set dV2 = V2 - v2 40 41 stat dM1 42 stat dM2 43 44 vstat dV1 45 vstat dV2 46 end 1 47 2 48 macro test.python -
trunk/Ohana/src/opihi/include/data.h
r40371 r40376 278 278 int nnet_get (int argc, char **argv); 279 279 int nnet_read (int argc, char **argv); 280 int nnet_write (int argc, char **argv); 280 281 int nnet_print (int argc, char **argv); 281 282
Note:
See TracChangeset
for help on using the changeset viewer.
