Package com.github.neuralnetworks.input

Examples of com.github.neuralnetworks.input.SimpleInputProvider


 
  Matrix cgb2 = secondRBM.getHiddenBiasConnections().getWeights();
  cgb2.set(-0.4f, 0, 0);
  cgb2.set(0.2f, 1, 0);

  SimpleInputProvider inputProvider = new SimpleInputProvider(new float[][] { { 1, 0, 1 } }, null);

  AparapiCDTrainer firstTrainer = TrainerFactory.cdSigmoidTrainer(firstRBM, null, null, null, null, 0f, 0f, 0f, 0f, 0, 1, 1, true);

  AparapiCDTrainer secondTrainer = TrainerFactory.cdSigmoidTrainer(secondRBM, null, null, null, null, 1f, 0f, 0f, 0f, 1, 1, 1, true);
View Full Code Here


    }

    @Test
    public void testScaling() {
  float[][] input = new float[][] { { 1, 3 }, { -2, 1.5f } };
  ScalingInputFunction si = new ScalingInputFunction(new SimpleInputProvider(input));
  Matrix m = TensorFactory.matrix(input);
  si.value(m);

  assertEquals(0.5f, m.get(0, 0), 0);
  assertEquals(-1f, m.get(0, 1), 0);
View Full Code Here

  FullyConnected c2 = (FullyConnected) nn.getOutputLayer().getConnections().iterator().next();
  Matrix cg2 = c2.getWeights();
  cg2.set(0.3f, 0, 0);
  cg2.set(0.9f, 0, 1);

  BackPropagationTrainer<?> bpt = TrainerFactory.backPropagation(nn, new SimpleInputProvider(new float[][] { { 0.35f, 0.9f } }, new float[][] { { 0.5f } }), new SimpleInputProvider(new float[][] { { 0.35f, 0.9f } }, new float[][] { { 0.5f } }), null, null, 1f, 0f, 0f, 0f, 0f, 1, 1, 1);
  bpt.train();

  assertEquals(0.09916, cg1.get(0, 0), 0.001);
  assertEquals(0.7978, cg1.get(0, 1), 0.001);
  assertEquals(0.3972, cg1.get(1, 0), 0.01);
View Full Code Here

  }

  Conv2DConnection b = (Conv2DConnection) nn.getOutputLayer().getConnections().get(1);
  b.getWeights().getElements()[b.getWeights().getStartIndex()] = -3f;
 
  SimpleInputProvider ts = new SimpleInputProvider(new float[][] { { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f }, { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f } }, new float[][] { { 1, 1, 1, 1 }, { 1, 1, 1, 1 } });
  BackPropagationTrainer<?> t = TrainerFactory.backPropagation(nn, ts, null, null, null, 0.5f, 0f, 0f, 0f, 0f, 1, 1, 1);
  t.train();

  it = c.getWeights().iterator();
  assertEquals(0.12317, c.getWeights().getElements()[it.next()], 0.00001);
View Full Code Here

  }

  Conv2DConnection b = (Conv2DConnection) nn.getOutputLayer().getConnections().get(1);
  b.getWeights().getElements()[b.getWeights().getStartIndex()] = -3f;

  SimpleInputProvider ts = new SimpleInputProvider(new float[][] { { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f } }, new float[][] { { 1, 1, 1, 1 } });
  BackPropagationTrainer<?> t = TrainerFactory.backPropagation(nn, ts, null, null, null, 0.5f, 0f, 0f, 0f, 0f, 1, 1, 1);
  t.train();

  it = c.getWeights().iterator();
  assertEquals(0.11756, c.getWeights().getElements()[it.next()], 0.00001);
View Full Code Here

  // example 0 0 0 1 0 0 means that he has a flu vaccine. It's possible
  // to have combinations between both - for exmample 0 1 0 1 0 0 means
  // that the patient is vaccinated, but he's also coughing. We will
  // consider a patient to be sick when he has at least two of the first
  // three and healthy if he has two of the second three
  TrainingInputProvider trainInputProvider = new SimpleInputProvider(new float[][] { { 1, 1, 1, 0, 0, 0 }, { 1, 0, 1, 0, 0, 0 }, { 1, 1, 0, 0, 0, 0 }, { 0, 1, 1, 0, 0, 0 }, { 0, 1, 1, 1, 0, 0 }, { 0, 0, 0, 1, 1, 1 }, { 0, 0, 1, 1, 1, 0 }, { 0, 0, 0, 1, 0, 1 }, { 0, 0, 0, 0, 1, 1 }, { 0, 0, 0, 1, 1, 0 } }, null);
  TrainingInputProvider testInputProvider = new SimpleInputProvider(new float[][] { { 1, 1, 1, 0, 0, 0 }, { 1, 0, 1, 0, 0, 0 }, { 1, 1, 0, 0, 0, 0 }, { 0, 1, 1, 0, 0, 0 }, { 0, 1, 1, 1, 0, 0 }, { 0, 0, 0, 1, 1, 1 }, { 0, 0, 1, 1, 1, 0 }, { 0, 0, 0, 1, 0, 1 }, { 0, 0, 0, 0, 1, 1 }, { 0, 0, 0, 1, 1, 0 } }, new float[][] { { 1, 0 }, { 1, 0 }, { 1, 0 }, { 1, 0 }, { 1, 0 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 } });
  MultipleNeuronsOutputError error = new MultipleNeuronsOutputError();

  // Contrastive divergence training
  AparapiCDTrainer t = TrainerFactory.cdSigmoidTrainer(rbm, trainInputProvider, testInputProvider, error, new NNRandomInitializer(new MersenneTwisterRandomInitializer(-0.01f, 0.01f)), 0.02f, 0.5f, 0f, 0f, 1, 1, 100, false);
View Full Code Here

  // example 0 0 0 1 0 0 means that he has a flu vaccine. It's possible
  // to have combinations between both - for exmample 0 1 0 1 0 0 means
  // that the patient is vaccinated, but he's also coughing. We will
  // consider a patient to be sick when he has at least two of the first
  // three and healthy if he has two of the second three
  TrainingInputProvider trainInputProvider = new SimpleInputProvider(new float[][] { { 1, 1, 1, 0, 0, 0 }, { 1, 0, 1, 0, 0, 0 }, { 1, 1, 0, 0, 0, 0 }, { 0, 1, 1, 0, 0, 0 }, { 0, 1, 1, 1, 0, 0 }, { 0, 0, 0, 1, 1, 1 }, { 0, 0, 1, 1, 1, 0 }, { 0, 0, 0, 1, 0, 1 }, { 0, 0, 0, 0, 1, 1 }, { 0, 0, 0, 1, 1, 0 } }, null);
  TrainingInputProvider testInputProvider = new SimpleInputProvider(new float[][] { { 1, 1, 1, 0, 0, 0 }, { 1, 0, 1, 0, 0, 0 }, { 1, 1, 0, 0, 0, 0 }, { 0, 1, 1, 0, 0, 0 }, { 0, 1, 1, 1, 0, 0 }, { 0, 0, 0, 1, 1, 1 }, { 0, 0, 1, 1, 1, 0 }, { 0, 0, 0, 1, 0, 1 }, { 0, 0, 0, 0, 1, 1 }, { 0, 0, 0, 1, 1, 0 } }, new float[][] { { 1, 0 }, { 1, 0 }, { 1, 0 }, { 1, 0 }, { 1, 0 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 } });
  MultipleNeuronsOutputError error = new MultipleNeuronsOutputError();

  // Persistent Contrastive divergence trainer
  AparapiCDTrainer t = TrainerFactory.cdSigmoidTrainer(rbm, trainInputProvider, testInputProvider, error, new NNRandomInitializer(new MersenneTwisterRandomInitializer(-0.01f, 0.01f)), 0.02f, 0.5f, 0f, 0f, 1, 1, 100, true);
View Full Code Here

  Matrix cgb2 = rbm.getHiddenBiasConnections().getWeights();
  cgb2.set(-0.4f, 0, 0);
  cgb2.set(0.2f, 1, 0);

  AparapiCDTrainer t = TrainerFactory.cdSigmoidTrainer(rbm, new SimpleInputProvider(new float[][] { { 1, 0, 1 } }, null), null, null, null, 1f, 0f, 0f, 0f, 1, 1, 1, true);

  t.train();

  assertEquals(0.52276707, cgb1.get(0, 0), 0.00001);
  assertEquals(- 0.54617375, cgb1.get(1, 0), 0.00001);
View Full Code Here

  Matrix cgb2 = rbm.getHiddenBiasConnections().getWeights();
  cgb2.set(-0.4f, 0, 0);
  cgb2.set(0.2f, 1, 0);

  AparapiCDTrainer t = TrainerFactory.cdSigmoidTrainer(rbm, new SimpleInputProvider(new float[][] { { 1, 0, 1 }, { 1, 1, 0 } }, null), null, null, null, 1f, 0f, 0f, 0f, 1, 1, 1, false);

  t.train();

  assertEquals(0.86090606, cgb1.get(0, 0), 0.00001);
  assertEquals(0.089616358, cgb1.get(1, 0), 0.00001);
View Full Code Here

TOP

Related Classes of com.github.neuralnetworks.input.SimpleInputProvider

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.