use of org.deeplearning4j.nn.layers.BaseOutputLayer in project deeplearning4j by deeplearning4j.
the class MultiLayerTest method testGradientWithAsList.
@Test
public void testGradientWithAsList() {
MultiLayerNetwork net1 = new MultiLayerNetwork(getConf());
MultiLayerNetwork net2 = new MultiLayerNetwork(getConf());
net1.init();
net2.init();
DataSet x1 = new IrisDataSetIterator(1, 150).next();
DataSet all = new IrisDataSetIterator(150, 150).next();
DataSet x2 = all.asList().get(0);
//x1 and x2 contain identical data
assertArrayEquals(asFloat(x1.getFeatureMatrix()), asFloat(x2.getFeatureMatrix()), 0.0f);
assertArrayEquals(asFloat(x1.getLabels()), asFloat(x2.getLabels()), 0.0f);
assertEquals(x1, x2);
//Set inputs/outputs so gradient can be calculated:
net1.feedForward(x1.getFeatureMatrix());
net2.feedForward(x2.getFeatureMatrix());
((BaseOutputLayer) net1.getLayer(1)).setLabels(x1.getLabels());
((BaseOutputLayer) net2.getLayer(1)).setLabels(x2.getLabels());
net1.gradient();
net2.gradient();
}
Aggregations