Package com.github.neuralnetworks.architecture

Examples of com.github.neuralnetworks.architecture.GraphConnections


  NNRandomInitializer rand = new NNRandomInitializer(new MersenneTwisterRandomInitializer(-0.1f, 0.1f), 0.5f);
  rand.initialize(nn);

  for (Layer l : nn.getLayers()) {
      if (Util.isBias(l)) {
    GraphConnections gc = (GraphConnections) l.getConnections().get(0);
    for (float v : gc.getConnectionGraph().getElements()) {
        assertEquals(0.5, v, 0f);
    }
      } else {
    GraphConnections gc = (GraphConnections) l.getConnections().get(0);
    for (float v : gc.getConnectionGraph().getElements()) {
        assertTrue(v >= -0.1f && v <= 0.1f && v != 0);
    }
      }
  }

  rand = new NNRandomInitializer(new MersenneTwisterRandomInitializer(2f, 3f), new MersenneTwisterRandomInitializer(-2f, -1f));
  rand.initialize(nn);

  for (Layer l : nn.getLayers()) {
      if (Util.isBias(l)) {
    GraphConnections gc = (GraphConnections) l.getConnections().get(0);
    for (float v : gc.getConnectionGraph().getElements()) {
        assertTrue(v >= -2f && v <= -1f);
    }
      } else {
    GraphConnections gc = (GraphConnections) l.getConnections().get(0);
    for (float v : gc.getConnectionGraph().getElements()) {
        assertTrue(v >= 2f && v <= 3f);
    }
      }
  }
    }
View Full Code Here


    Util.fillArray(biasValue, 1);
      }

      float[] out = valuesProvider.getValues(bias.getOutputLayer(), bias).getElements();
      for (int i = 0; i < out.length; i++) {
    GraphConnections gc = (GraphConnections) bias;
    out[i] += gc.getConnectionGraph().getElements()[i / valuesProvider.getColumns()];
      }
  }
    }
View Full Code Here

      if (c.getInputLayer() == layer) {
    if (c instanceof Conv2DConnection) {
        Conv2DConnection cc = (Conv2DConnection) c;
        return cc.getInputFilters() == 1 && cc.getInputFeatureMapRows() == cc.getOutputFeatureMapRows() && cc.getInputFeatureMapColumns() == cc.getOutputFeatureMapColumns();
    } else if (c instanceof GraphConnections) {
        GraphConnections cg = (GraphConnections) c;
        return cg.getConnectionGraph().getColumns() == 1;
    }
      }
  }

  return false;
View Full Code Here

    public void initialize(NeuralNetwork nn) {
  List<ConnectionCandidate> ccs = new BreadthFirstOrderStrategy(nn, nn.getInputLayer()).order();
  for (ConnectionCandidate cc : ccs) {
      if (cc.connection instanceof GraphConnections) {
    GraphConnections fc = (GraphConnections) cc.connection;
    if (Util.isBias(fc.getInputLayer())) {
        if (biasDefaultValue != null) {
      Util.fillArray(fc.getConnectionGraph().getElements(), biasDefaultValue);
        } else if (biasRandomInitializer != null) {
      biasRandomInitializer.initialize(fc.getConnectionGraph().getElements());
        } else {
      randomInitializer.initialize(fc.getConnectionGraph().getElements());
        }
    } else {
        randomInitializer.initialize(fc.getConnectionGraph().getElements());
    }
      } else if (cc.connection instanceof Conv2DConnection) {
    Conv2DConnection c = (Conv2DConnection) cc.connection;
    if (Util.isBias(c.getInputLayer())) {
        if (biasDefaultValue != null) {
View Full Code Here

  l = l.getConnections().get(1).getOutputLayer();
  assertEquals(1, cc.getOutputFeatureMapRows(), 0);
  assertEquals(1, cc.getOutputFeatureMapColumns(), 0);
  assertEquals(120, cc.getOutputFilters(), 0);

  GraphConnections cg = (GraphConnections) l.getConnections().get(2);
  assertEquals(84, cg.getConnectionGraph().getRows(), 0);

  GraphConnections cg2 = (GraphConnections) cg.getOutputLayer().getConnections().get(2);
  assertEquals(10, cg2.getConnectionGraph().getRows(), 0);
    }
View Full Code Here

TOP

Related Classes of com.github.neuralnetworks.architecture.GraphConnections

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.