Java Code Examples for org.deeplearning4j.nn.conf.NeuralNetConfiguration#clearVariables()

The following examples show how to use org.deeplearning4j.nn.conf.NeuralNetConfiguration#clearVariables() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FrozenLayerWithBackprop.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
@Override
public org.deeplearning4j.nn.api.Layer instantiate(NeuralNetConfiguration conf,
                                                   Collection<TrainingListener> trainingListeners, int layerIndex, INDArray layerParamsView,
                                                   boolean initializeParams, DataType networkDataType) {

    //Need to be able to instantiate a layer, from a config - for JSON -> net type situations
    org.deeplearning4j.nn.api.Layer underlying = getUnderlying().instantiate(getInnerConf(conf), trainingListeners,
                    layerIndex, layerParamsView, initializeParams, networkDataType);

    NeuralNetConfiguration nncUnderlying = underlying.conf();

    if (nncUnderlying.variables() != null) {
        List<String> vars = nncUnderlying.variables(true);
        nncUnderlying.clearVariables();
        conf.clearVariables();
        for (String s : vars) {
            conf.variables(false).add(s);
            nncUnderlying.variables(false).add(s);
        }
    }

    return new org.deeplearning4j.nn.layers.FrozenLayerWithBackprop(underlying);
}
 
Example 2
Source File: FrozenLayer.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
@Override
public org.deeplearning4j.nn.api.Layer instantiate(NeuralNetConfiguration conf,
                                                   Collection<TrainingListener> trainingListeners, int layerIndex, INDArray layerParamsView,
                                                   boolean initializeParams, DataType networkDataType) {

    //Need to be able to instantiate a layer, from a config - for JSON -> net type situations
    org.deeplearning4j.nn.api.Layer underlying = layer.instantiate(getInnerConf(conf), trainingListeners,
                    layerIndex, layerParamsView, initializeParams, networkDataType);

    NeuralNetConfiguration nncUnderlying = underlying.conf();
    if (nncUnderlying.variables() != null) {
        List<String> vars = nncUnderlying.variables(true);
        nncUnderlying.clearVariables();
        conf.clearVariables();
        for (String s : vars) {
            conf.variables(false).add(s);
            nncUnderlying.variables(false).add(s);
        }
    }

    return new org.deeplearning4j.nn.layers.FrozenLayer(underlying);
}