Integration » Histórico » Versión 1
Federico Vera, 2018-06-10 00:38
1 | 1 | Federico Vera | # Integration |
---|---|---|---|
2 | |||
3 | # What to do with the Data |
||
4 | Now that you have successfully trained your `MLP` you might want to integrate it with other things, or whatever. |
||
5 | ## Evaluating from Java |
||
6 | First of all you'll need to grab a copy of [`libai`](https://github.com/kronenthaler/libai) and add it to your classpath. |
||
7 | |||
8 | Then here's a sample code that can be used as a guide: |
||
9 | ~~~Java |
||
10 | import libai.nn.supervised.MLP; |
||
11 | import libai.common.Matrix; |
||
12 | |||
13 | ... |
||
14 | //The rest of your code |
||
15 | ... |
||
16 | |||
17 | public double f(double x) { |
||
18 | MLP mlp = MLP.open("weights.dat"); //<- the weights you want to use |
||
19 | Matrix m = new Matrix(1, 1); //<- we only use single neuron inputs |
||
20 | m.position(0, 0, x); //<- set the value in the matrix |
||
21 | return mlp.simulate(m).position(0, 0); //<- we only use single neuron output |
||
22 | } |
||
23 | ~~~ |
||
24 | |||
25 | ## Evaluating from CLI |
||
26 | ``` |
||
27 | $ java -jar mrft-VERSION.jar FILENAME VALUES |
||
28 | ``` |
||
29 | So for instance if you train the MLP with `cos(x)`, it should output: |
||
30 | ``` |
||
31 | $ java -jar mrft-VERSION.jar weights.dat 0 |
||
32 | 1.0 |
||
33 | ``` |
||
34 | You can also use the `-csv` or `-tsv` flags, so the output will be: |
||
35 | ``` |
||
36 | $ java -jar mrft-VERSION.jar weights.dat -csv 0 |
||
37 | 0.0, 1.0 |
||
38 | ``` |
||
39 | The output will always be via `sdt::out` so you can use something like `tee` to create a file |
||
40 | ``` |
||
41 | $ java -jar mrft-VERSION.jar -csv FILENAME VALUES | tee OUT.csv |
||
42 | ``` |
||
43 | |||
44 | ## GNU Octave |
||
45 | The current version of `libai` supports exporting matrices as `Octave-Level-1` binary matrices, but it still doesn't do that for `MLP`, so if someone actually want's to collaborate with some code, or wait a bit till I have some spare time. |