use of org.deeplearning4j.nn.conf.layers.AutoEncoder in project deeplearning4j by deeplearning4j.
the class SeedTest method testAutoEncoderSeed.
@Test
public void testAutoEncoderSeed() {
AutoEncoder layerType = new AutoEncoder.Builder().nIn(4).nOut(3).corruptionLevel(0.0).activation(Activation.SIGMOID).build();
NeuralNetConfiguration conf = new NeuralNetConfiguration.Builder().iterations(1).layer(layerType).seed(123).build();
int numParams = conf.getLayer().initializer().numParams(conf);
INDArray params = Nd4j.create(1, numParams);
Layer layer = conf.getLayer().instantiate(conf, null, 0, params, true);
layer.fit(data.getFeatureMatrix());
layer.computeGradientAndScore();
double score = layer.score();
INDArray parameters = layer.params();
layer.setParams(parameters);
layer.computeGradientAndScore();
double score2 = layer.score();
assertEquals(parameters, layer.params());
assertEquals(score, score2, 1e-4);
}
Aggregations