Proyecto

General

Perfil

Integration » Histórico » Versión 2

Federico Vera, 2018-06-10 00:39

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 2 Federico Vera
$ java -jar mrft-VERSION.jar weights.dat 0 1.0
32 1 Federico Vera
```
33
You can also use the `-csv` or `-tsv` flags, so the output will be:
34
```
35 2 Federico Vera
$ java -jar mrft-VERSION.jar weights.dat -csv 0 0.0, 1.0
36 1 Federico Vera
```
37
The output will always be via `sdt::out` so you can use something like `tee` to create a file
38
```
39
$ java -jar mrft-VERSION.jar -csv FILENAME VALUES | tee OUT.csv
40
```
41
42
## GNU Octave
43
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.
Volver al inicio