Example usage for org.deeplearning4j.nn.multilayer MultiLayerNetwork pretrainLayer

List of usage examples for org.deeplearning4j.nn.multilayer MultiLayerNetwork pretrainLayer

Introduction

In this page you can find the example usage for org.deeplearning4j.nn.multilayer MultiLayerNetwork pretrainLayer.

Prototype

public void pretrainLayer(int layerIdx, INDArray features) 

Source Link

Document

Perform layerwise unsupervised training on a single pre-trainable layer in the network (VAEs, Autoencoders, etc)
If the specified layer index (0 to numLayers - 1) is not a pretrainable layer, this is a no-op.

Usage

From source file:org.knime.ext.dl4j.base.nodes.learn.AbstractDLLearnerNodeModel.java

License:Open Source License

/**
 * Performs one epoch of pretraining of the specified {@link MultiLayerNetwork}. Checks {@link LearningMonitor} of
 * this learner if learning should be prematurely stopped.
 *
 * @param mln the network to train//from  w  ww . ja  v  a  2 s  .c  om
 * @param data the data to train on
 * @param exec used to check for cancelled execution and stop learning
 * @throws CanceledExecutionException
 */
protected void pretrainOneEpoch(final MultiLayerNetwork mln, final DataSetIterator data,
        final ExecutionContext exec) throws CanceledExecutionException {
    for (int i = 0; i < mln.getnLayers(); i++) {
        exec.setMessage("Performing Pretraining on Layer: " + (i + 1));
        while (data.hasNext()) {
            exec.checkCanceled();
            if (m_learningMonitor.checkStopLearning()) {
                break;
            }
            mln.pretrainLayer(i, data.next().getFeatureMatrix());
        }
        data.reset();
    }
}