home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (SeedTest.java)

This example Java source code file (SeedTest.java) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

autoencoder, datasetiterator, indarray, irisdatasetiterator, layer, neuralnetconfiguration, seedtest, test

The SeedTest.java Java example source code

package org.deeplearning4j.nn.layers;

import org.nd4j.linalg.dataset.api.iterator.DataSetIterator;
import org.deeplearning4j.datasets.iterator.impl.IrisDataSetIterator;
import org.deeplearning4j.nn.api.*;
import org.deeplearning4j.nn.api.Layer;
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
import org.deeplearning4j.nn.conf.layers.*;
import org.deeplearning4j.nn.layers.factory.LayerFactories;
import org.junit.Test;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.dataset.DataSet;
import org.nd4j.linalg.factory.Nd4j;

import static org.junit.Assert.assertEquals;


public class SeedTest {

    private DataSetIterator irisIter = new IrisDataSetIterator(50,50);
    private DataSet data = irisIter.next();

    public void testAutoEncoderSeed() {
        AutoEncoder layerType = new AutoEncoder.Builder()

        NeuralNetConfiguration conf = new NeuralNetConfiguration.Builder()

        int numParams = LayerFactories.getFactory(conf).initializer().numParams(conf,true);
        INDArray params = Nd4j.create(1, numParams);
        Layer layer =  LayerFactories.getFactory(conf).create(conf, null, 0, params, true);

        double score = layer.score();
        INDArray parameters = layer.params();

        double score2 = layer.score();
        assertEquals(parameters, layer.params());
        assertEquals(score, score2, 1e-4);

Other Java examples (source code examples)

Here is a short list of links related to this Java SeedTest.java source code file:

my book on functional programming


new blog posts


Copyright 1998-2019 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.