use of org.deeplearning4j.datasets.fetchers.MnistDataFetcher in project deeplearning4j by deeplearning4j.
the class AutoEncoderTest method testAutoEncoder.
@Test
public void testAutoEncoder() throws Exception {
MnistDataFetcher fetcher = new MnistDataFetcher(true);
NeuralNetConfiguration conf = new NeuralNetConfiguration.Builder().momentum(0.9f).optimizationAlgo(OptimizationAlgorithm.LINE_GRADIENT_DESCENT).iterations(1).learningRate(1e-1f).layer(new org.deeplearning4j.nn.conf.layers.AutoEncoder.Builder().nIn(784).nOut(600).corruptionLevel(0.6).lossFunction(LossFunctions.LossFunction.RECONSTRUCTION_CROSSENTROPY).build()).build();
fetcher.fetch(100);
DataSet d2 = fetcher.next();
INDArray input = d2.getFeatureMatrix();
int numParams = conf.getLayer().initializer().numParams(conf);
INDArray params = Nd4j.create(1, numParams);
AutoEncoder da = (AutoEncoder) conf.getLayer().instantiate(conf, Arrays.<IterationListener>asList(new ScoreIterationListener(1)), 0, params, true);
assertEquals(da.params(), da.params());
assertEquals(471784, da.params().length());
da.setParams(da.params());
da.fit(input);
}
Aggregations