Search in sources :

Example 11 with FrozenLayer

use of org.deeplearning4j.nn.layers.FrozenLayer in project deeplearning4j by deeplearning4j.

the class MultiLayerNetwork method clone.

@Override
public MultiLayerNetwork clone() {
    MultiLayerConfiguration conf = this.layerWiseConfigurations.clone();
    MultiLayerNetwork ret = new MultiLayerNetwork(conf);
    ret.init(this.params().dup(), false);
    if (solver != null) {
        //If  solver is null: updater hasn't been initialized -> getUpdater call will force initialization, however
        Updater u = this.getUpdater();
        INDArray updaterState = u.getStateViewArray();
        if (updaterState != null) {
            ret.getUpdater().setStateViewArray(ret, updaterState.dup(), false);
        }
    }
    if (hasAFrozenLayer()) {
        //correct layers to frozen layers
        Layer[] clonedLayers = ret.getLayers();
        for (int i = 0; i < layers.length; i++) {
            if (layers[i] instanceof FrozenLayer) {
                clonedLayers[i] = new FrozenLayer<>(ret.getLayer(i));
            }
        }
        ret.setLayers(clonedLayers);
    }
    return ret;
}
Also used : FrozenLayer(org.deeplearning4j.nn.layers.FrozenLayer) MultiLayerConfiguration(org.deeplearning4j.nn.conf.MultiLayerConfiguration) INDArray(org.nd4j.linalg.api.ndarray.INDArray) MultiLayerUpdater(org.deeplearning4j.nn.updater.MultiLayerUpdater) FeedForwardLayer(org.deeplearning4j.nn.conf.layers.FeedForwardLayer) FrozenLayer(org.deeplearning4j.nn.layers.FrozenLayer) IOutputLayer(org.deeplearning4j.nn.api.layers.IOutputLayer) RecurrentLayer(org.deeplearning4j.nn.api.layers.RecurrentLayer)

Aggregations

FrozenLayer (org.deeplearning4j.nn.layers.FrozenLayer)11 INDArray (org.nd4j.linalg.api.ndarray.INDArray)6 IOutputLayer (org.deeplearning4j.nn.api.layers.IOutputLayer)5 RecurrentLayer (org.deeplearning4j.nn.api.layers.RecurrentLayer)4 FeedForwardLayer (org.deeplearning4j.nn.conf.layers.FeedForwardLayer)4 GraphVertex (org.deeplearning4j.nn.graph.vertex.GraphVertex)3 Triple (org.deeplearning4j.berkeley.Triple)2 Layer (org.deeplearning4j.nn.api.Layer)2 ComputationGraphConfiguration (org.deeplearning4j.nn.conf.ComputationGraphConfiguration)2 MultiLayerConfiguration (org.deeplearning4j.nn.conf.MultiLayerConfiguration)2 NeuralNetConfiguration (org.deeplearning4j.nn.conf.NeuralNetConfiguration)2 DenseLayer (org.deeplearning4j.nn.conf.layers.DenseLayer)2 OutputLayer (org.deeplearning4j.nn.conf.layers.OutputLayer)2 DefaultGradient (org.deeplearning4j.nn.gradient.DefaultGradient)2 Gradient (org.deeplearning4j.nn.gradient.Gradient)2 ComputationGraph (org.deeplearning4j.nn.graph.ComputationGraph)2 VertexIndices (org.deeplearning4j.nn.graph.vertex.VertexIndices)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1