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

Java example source code file (UpdaterCreator.java)

This example Java source code file (UpdaterCreator.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

adadeltaupdater, adagrad, adagradupdater, adamupdater, custom, multilayernetwork, nesterovs, none, noopupdater, rmspropupdater, sgd, unsupportedoperationexception, updater, updatercreator

The UpdaterCreator.java Java example source code

package org.deeplearning4j.nn.updater;

import org.deeplearning4j.nn.api.Model;
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
import org.deeplearning4j.nn.conf.Updater;
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;

/**
 *
 *
 * @author Adam Gibson
 */
public class UpdaterCreator {

    /**
     * Create an updater based on the configuration
     * @param conf the configuration to get the updater for
     * @return the updater for the configuration
     */
    private static org.deeplearning4j.nn.api.Updater getUpdater(NeuralNetConfiguration conf) {
        Updater updater = conf.getLayer().getUpdater();

        switch(updater) {
            case ADADELTA: return new AdaDeltaUpdater();
            case ADAGRAD: return new AdaGradUpdater();
            case ADAM: return new AdamUpdater();
            case NESTEROVS: return new NesterovsUpdater();
            case RMSPROP: return new RmsPropUpdater();
            case SGD: return new SgdUpdater();
            case NONE: return new NoOpUpdater();
            case CUSTOM: throw new UnsupportedOperationException("Not implemented yet.");
        }

        return null;
    }

    public static org.deeplearning4j.nn.api.Updater getUpdater(Model layer) {
    	if( layer instanceof MultiLayerNetwork ){
    		return new MultiLayerUpdater((MultiLayerNetwork)layer);
    	} else {
    		return getUpdater(layer.conf());
    	}
    }

}

Other Java examples (source code examples)

Here is a short list of links related to this Java UpdaterCreator.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.