Examples of ValuesProvider


Examples of com.github.neuralnetworks.calculation.ValuesProvider

    private ValuesProvider activations;
    private ValuesProvider backpropagation;

    public BackPropagationTrainer() {
  super();
  activations = new ValuesProvider();
  backpropagation = new ValuesProvider();
    }
View Full Code Here

Examples of com.github.neuralnetworks.calculation.ValuesProvider

  backpropagation = new ValuesProvider();
    }

    public BackPropagationTrainer(Properties properties) {
  super(properties);
  activations = new ValuesProvider();
  backpropagation = new ValuesProvider();
    }
View Full Code Here

Examples of com.github.neuralnetworks.calculation.ValuesProvider

  List<Connections> connections = new ArrayList<Connections>();
  connections.add(c);

  Matrix o = new Matrix(1, 2);

  ValuesProvider vp = new ValuesProvider();
  vp.addValues(c.getInputLayer(), i1);
  vp.addValues(c.getOutputLayer(), o);

  AparapiStochasticPooling2D calc = new AparapiStochasticPooling2D();
  calc.calculate(connections, vp, c.getOutputLayer());

  assertEquals(2.08, o.get(0, 0), 0.01);
View Full Code Here

Examples of com.github.neuralnetworks.calculation.ValuesProvider

  List<Connections> connections = new ArrayList<Connections>();
  connections.add(c);

  // max pooling
  ValuesProvider vp = new ValuesProvider();
  vp.addValues(c.getInputLayer(), a1);
  vp.addValues(c.getOutputLayer(), o);

  ConnectionCalculator calc = new AparapiMaxPooling2D();
  calc.calculate(connections, vp, c.getOutputLayer());

  ValuesProvider activations = new ValuesProvider();
  activations.addValues(c.getInputLayer(), a1);

  Matrix bpo = new Matrix(32, 2);

  vp = new ValuesProvider();
  vp.addValues(c.getOutputLayer(), o);
  vp.addValues(c.getInputLayer(), bpo);

  BackpropagationMaxPooling2D bp = new BackpropagationMaxPooling2D();
  bp.setActivations(activations);
View Full Code Here

Examples of com.github.neuralnetworks.calculation.ValuesProvider

  ConnectionCalculator calc = new AparapiAveragePooling2D();

  List<Connections> connections = new ArrayList<Connections>();
  connections.add(c);

  ValuesProvider vp = new ValuesProvider();
  vp.addValues(c.getInputLayer(), a1);
  Matrix o = new Matrix(8, 2);
  vp.addValues(c.getOutputLayer(), o);

  calc.calculate(connections, vp, c.getOutputLayer());

  ValuesProvider activations = new ValuesProvider();
  activations.addValues(c.getInputLayer(), a1);

  BackpropagationAveragePooling2D bp = new BackpropagationAveragePooling2D();
  bp.setActivations(activations);

  vp = new ValuesProvider();
  vp.addValues(c.getOutputLayer(), o);
  Matrix bpo = new Matrix(32, 2);
  vp.addValues(c.getInputLayer(), bpo);

  bp.calculate(connections, vp, c.getInputLayer());
View Full Code Here

Examples of com.github.neuralnetworks.calculation.ValuesProvider

  nn.setLayerCalculator(NNFactory.lcWeightedSum(nn, null));

  Conv2DConnection cc = (Conv2DConnection) nn.getInputLayer().getConnections().get(0);
  Util.fillArray(cc.getWeights(), 1);

  ValuesProvider vp = new ValuesProvider();
  vp.addValues(nn.getInputLayer(), new Matrix(new float[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}, 1));

  Set<Layer> calculatedLayers = new HashSet<>();
  calculatedLayers.add(nn.getInputLayer());
  nn.getLayerCalculator().calculate(nn, nn.getOutputLayer(), calculatedLayers, vp);

  Matrix o = vp.getValues(nn.getOutputLayer());
  assertEquals(16, o.get(0, 0), 0.00001);
  assertEquals(24, o.get(1, 0), 0.00001);
  assertEquals(56, o.get(2, 0), 0.00001);
  assertEquals(64, o.get(3, 0), 0.00001);
    }
View Full Code Here

Examples of com.github.neuralnetworks.calculation.ValuesProvider

  Util.fillArray(secondRBM.getHiddenBiasConnections().getConnectionGraph().getElements(), 0.5f);

  Set<Layer> calculatedLayers = new HashSet<>();
  calculatedLayers.add(dbn.getInputLayer());

  ValuesProvider results = new ValuesProvider();

  results.addValues(dbn.getInputLayer(), new Matrix(new float[] {1, 0, 1}, 1));
  dbn.getLayerCalculator().calculate(dbn, dbn.getOutputLayer(), calculatedLayers, results);

  assertEquals(1.06, results.getValues(dbn.getOutputLayer()).get(0, 0), 0.00001);
  assertEquals(1.06, results.getValues(dbn.getOutputLayer()).get(1, 0), 0.00001);
    }
View Full Code Here

Examples of com.github.neuralnetworks.calculation.ValuesProvider

  Util.fillArray(((GraphConnections) secondAE.getConnection(secondAE.getOutputBiasLayer(), secondAE.getOutputLayer())).getConnectionGraph().getElements(), 0.9f);

  Set<Layer> calculatedLayers = new HashSet<>();
  calculatedLayers.add(sae.getInputLayer());

  ValuesProvider results = new ValuesProvider();
  results.addValues(sae.getInputLayer(), new Matrix(new float[] {1, 0, 1}, 1));
  sae.getLayerCalculator().calculate(sae, sae.getOutputLayer(), calculatedLayers, results);

  assertEquals(1.06, results.getValues(sae.getOutputLayer()).get(0, 0), 0.00001);
  assertEquals(1.06, results.getValues(sae.getOutputLayer()).get(1, 0), 0.00001);
    }
View Full Code Here

Examples of com.github.neuralnetworks.calculation.memory.ValuesProvider

  connections.add(c1);

  NeuralNetworkImpl nn = new NeuralNetworkImpl();
  nn.addConnections(connections.toArray(new Connections[connections.size()]));

  ValuesProvider vp = TensorFactory.tensorProvider(nn, 2, true);

  Matrix i1 = vp.get(nn.getInputLayer());
  i1.set(1, 0, 0);
  i1.set(2, 1, 0);
  i1.set(3, 2, 0);
  i1.set(4, 0, 1);
  i1.set(5, 1, 1);
  i1.set(6, 2, 1);

  ConnectionCalculatorFullyConnected aws = new AparapiWeightedSumConnectionCalculator();
  aws.calculate(connections, vp, ol);

  // most simple case
  Matrix o = vp.get(nn.getOutputLayer());
  assertEquals(14, o.get(0, 0), 0);
  assertEquals(32, o.get(0, 1), 0);
  assertEquals(32, o.get(1, 0), 0);
  assertEquals(77, o.get(1, 1), 0);

  // with bias
  connections = new ArrayList<>();
  connections.add(c1);
  connections.add(bc);

  nn = new NeuralNetworkImpl();
  nn.addConnections(connections.toArray(new Connections[connections.size()]));
  vp = TensorFactory.tensorProvider(nn, 2, true);

  i1 = vp.get(nn.getInputLayer());
  i1.set(1, 0, 0);
  i1.set(2, 1, 0);
  i1.set(3, 2, 0);
  i1.set(4, 0, 1);
  i1.set(5, 1, 1);
  i1.set(6, 2, 1);

  aws = new AparapiWeightedSumConnectionCalculator();
  aws.calculate(connections, vp, ol);

  o = vp.get(nn.getOutputLayer());
  assertEquals(14.1, o.get(0, 0), 0.01);
  assertEquals(32.1, o.get(0, 1), 0.01);
  assertEquals(32.2, o.get(1, 0), 0.01);
  assertEquals(77.2, o.get(1, 1), 0.01);

  // combined layers
  connections = new ArrayList<>();
  connections.add(c1);
  connections.add(c2);
  connections.add(bc);
  nn = new NeuralNetworkImpl();
  nn.addConnections(connections.toArray(new Connections[connections.size()]));
  vp = TensorFactory.tensorProvider(nn, 2, true);

  i1 = vp.get(il1);
  i1.set(1, 0, 0);
  i1.set(2, 1, 0);
  i1.set(3, 2, 0);
  i1.set(4, 0, 1);
  i1.set(5, 1, 1);
  i1.set(6, 2, 1);

  Matrix i2 = vp.get(il2);
  i2.set(1, 0, 0);
  i2.set(2, 1, 0);
  i2.set(3, 2, 0);
  i2.set(4, 0, 1);
  i2.set(5, 1, 1);
  i2.set(6, 2, 1);

  aws = new AparapiWeightedSumConnectionCalculator();
  aws.calculate(connections, vp, ol);

  o = vp.get(nn.getOutputLayer());
  assertEquals(28.1, o.get(0, 0), 0.01);
  assertEquals(64.1, o.get(0, 1), 0.01);
  assertEquals(64.2, o.get(1, 0), 0.01);
  assertEquals(154.2, o.get(1, 1), 0.01);
    }
View Full Code Here

Examples of com.github.neuralnetworks.calculation.memory.ValuesProvider

  List<Connections> connections = new ArrayList<>();
  connections.add(c1);
  NeuralNetworkImpl nn = new NeuralNetworkImpl();
  nn.addConnections(connections.toArray(new Connections[connections.size()]));
  ValuesProvider vp = TensorFactory.tensorProvider(nn, 2, true);

  Matrix i1 = vp.get(il1);
  i1.set(1, 0, 0);
  i1.set(2, 1, 0);
  i1.set(3, 2, 0);
  i1.set(4, 0, 1);
  i1.set(5, 1, 1);
  i1.set(6, 2, 1);

  aws.calculate(connections, vp, ol);

  // most simple case
  Matrix o = vp.get(ol);
  assertEquals(14, o.get(0, 0), 0);
  assertEquals(32, o.get(0, 1), 0);
  assertEquals(32, o.get(1, 0), 0);
  assertEquals(77, o.get(1, 1), 0);

  // with bias
  connections = new ArrayList<>();
  connections.add(c1);
  connections.add(bc);
  nn = new NeuralNetworkImpl();
  nn.addConnections(connections.toArray(new Connections[connections.size()]));
  vp = TensorFactory.tensorProvider(nn, 2, true);
  i1 = vp.get(il1);
  i1.set(1, 0, 0);
  i1.set(2, 1, 0);
  i1.set(3, 2, 0);
  i1.set(4, 0, 1);
  i1.set(5, 1, 1);
  i1.set(6, 2, 1);

  aws = new AparapiWeightedSumConnectionCalculator();
  aws.calculate(connections, vp, ol);

  o = vp.get(ol);
  assertEquals(14.1, o.get(0, 0), 0.01);
  assertEquals(32.1, o.get(0, 1), 0.01);
  assertEquals(32.2, o.get(1, 0), 0.01);
  assertEquals(77.2, o.get(1, 1), 0.01);

  // combined layers
  connections = new ArrayList<>();
  connections.add(c1);
  connections.add(c2);
  connections.add(bc);
  nn = new NeuralNetworkImpl();
  nn.addConnections(connections.toArray(new Connections[connections.size()]));
  vp = TensorFactory.tensorProvider(nn, 2, true);

  i1 = vp.get(il1);
  i1.set(1, 0, 0);
  i1.set(2, 1, 0);
  i1.set(3, 2, 0);
  i1.set(4, 0, 1);
  i1.set(5, 1, 1);
  i1.set(6, 2, 1);

  Matrix i2 = vp.get(il2);
  i2.set(1, 0, 0);
  i2.set(2, 1, 0);
  i2.set(3, 2, 0);
  i2.set(4, 0, 1);
  i2.set(5, 1, 1);
  i2.set(6, 2, 1);

  aws = new AparapiWeightedSumConnectionCalculator();
  aws.calculate(connections, vp, ol);

  o = vp.get(ol);
  assertEquals(28.1, o.get(0, 0), 0.01);
  assertEquals(64.1, o.get(0, 1), 0.01);
  assertEquals(64.2, o.get(1, 0), 0.01);
  assertEquals(154.2, o.get(1, 1), 0.01);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.