use of org.gitia.froog.layer.Layer in project froog by mroodschild.
the class LayerTest method testOutput_doubleArr.
/**
* Test of output method, of class Layer.
*/
@Test
public void testOutput_doubleArr() {
SimpleMatrix w1 = new SimpleMatrix(2, 2, true, 0.1, 0.2, 0.3, 0.4);
SimpleMatrix b1 = new SimpleMatrix(2, 1, true, 0.5, 0.1);
double[] a = { 0.2, 0.6 };
Layer instance = new Layer(w1, b1, "tansig");
double[] esperado = { 0.5648995528462, 0.3799489622552 };
assertArrayEquals(esperado, instance.output(a).getMatrix().getData(), 0.0000001);
}
use of org.gitia.froog.layer.Layer in project froog by mroodschild.
the class LayerTest method testOutput_SimpleMatrix.
/**
* Test of output method, of class Layer.
*/
@Test
public void testOutput_SimpleMatrix() {
SimpleMatrix w1 = new SimpleMatrix(2, 2, true, 0.1, 0.2, 0.3, 0.4);
SimpleMatrix b1 = new SimpleMatrix(2, 1, true, 0.5, 0.1);
SimpleMatrix a = new SimpleMatrix(2, 1, true, 0.2, 0.6);
Layer instance = new Layer(w1, b1, "tansig");
double[] esperado = { 0.5648995528462, 0.3799489622552 };
assertArrayEquals(esperado, instance.output(a).getMatrix().getData(), 0.0000001);
}
use of org.gitia.froog.layer.Layer in project froog by mroodschild.
the class LayerTest method testOutput_SimpleMatrix.
/**
* Test of output method, of class Layer.
*/
@Test
public void testOutput_SimpleMatrix() {
System.out.println("output");
SimpleMatrix w = new SimpleMatrix(2, 3, true, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6);
SimpleMatrix b = new SimpleMatrix(2, 1, true, 0.1, 0.2);
SimpleMatrix input = new SimpleMatrix(3, 1, true, 0.2, 0.4, 0.6);
Layer instance = new Layer(w, b, TransferFunction.LOGSIG);
double[] expResult = { 0.5938731029341, 0.6984652160025 };
double[] result = instance.output(input).getMatrix().getData();
instance.output(input).print();
assertArrayEquals(expResult, result, 0.0000000000001);
}
use of org.gitia.froog.layer.Layer in project froog by mroodschild.
the class LayerTest method testOutput_SimpleMatrixAll.
/**
* Test of output method, of class Layer.
*/
@Test
public void testOutput_SimpleMatrixAll() {
System.out.println("output");
SimpleMatrix w = new SimpleMatrix(2, 3, true, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6);
SimpleMatrix b = new SimpleMatrix(2, 1, true, 0.1, 0.2);
SimpleMatrix input = new SimpleMatrix(3, 2, false, 0.2, 0.4, 0.6, 0.2, 0.4, 0.6);
Layer instance = new Layer(w, b, TransferFunction.LOGSIG);
double[] expResult = { 0.5938731029341, 0.5938731029341, 0.6984652160025, 0.6984652160025 };
double[] result = instance.output(input).getMatrix().getData();
assertArrayEquals(expResult, result, 0.0000000000001);
}
use of org.gitia.froog.layer.Layer in project froog by mroodschild.
the class Open method agregarCapas.
private static void agregarCapas() {
try {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
// new File(archivo.getAbsolutePath()));
Document doc = docBuilder.parse(archivo);
doc.getDocumentElement().normalize();
// creamos un listado de nodos Capa
NodeList layers = doc.getElementsByTagName("layer");
// recorremos capa por capa
for (int i = 0; i < layers.getLength(); i++) {
// creamos un Nodo para obtener el primer elemento
Node layerNode = layers.item(i);
if (layerNode.getNodeType() == Node.ELEMENT_NODE) {
Element layerElement = (Element) layerNode;
String function = obtenerNodoValor("transferFunction", layerElement);
String bias = obtenerNodoValor("bias", layerElement);
String weight = obtenerNodoValor("w", layerElement);
double[] b = Arrays.stream(bias.split(",")).mapToDouble(Double::valueOf).toArray();
double[] w = Arrays.stream(weight.split(",")).mapToDouble(Double::valueOf).toArray();
net.addLayer(new Layer(new SimpleMatrix(b.length, w.length / b.length, true, w), new SimpleMatrix(b.length, 1, true, b), function));
}
// fin de creacion de las capas
}
} catch (SAXException | IOException | ParserConfigurationException ex) {
Logger.getLogger(Open.class.getName()).log(Level.SEVERE, null, ex);
}
}
Aggregations