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

The following examples show how to use org.deeplearning4j.nn.conf.NeuralNetConfiguration#clone() . 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: Bidirectional.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) {
    NeuralNetConfiguration c1 = conf.clone();
    NeuralNetConfiguration c2 = conf.clone();
    c1.setLayer(fwd);
    c2.setLayer(bwd);

    long n = layerParamsView.length() / 2;
    INDArray fp = layerParamsView.get(interval(0,0,true), interval(0, n));
    INDArray bp = layerParamsView.get(interval(0,0,true), interval(n, 2 * n));
    org.deeplearning4j.nn.api.Layer f = fwd.instantiate(c1, trainingListeners, layerIndex, fp, initializeParams, networkDataType);

    org.deeplearning4j.nn.api.Layer b = bwd.instantiate(c2, trainingListeners, layerIndex, bp, initializeParams, networkDataType);

    BidirectionalLayer ret = new BidirectionalLayer(conf, f, b, layerParamsView);
    Map<String, INDArray> paramTable = initializer().init(conf, layerParamsView, initializeParams);
    ret.setParamTable(paramTable);
    ret.setConf(conf);

    return ret;
}
 
Example 2
Source File: TimeDistributed.java    From deeplearning4j with Apache License 2.0 5 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) {
    NeuralNetConfiguration conf2 = conf.clone();
    conf2.setLayer(((TimeDistributed) conf2.getLayer()).getUnderlying());
    return new TimeDistributedLayer(underlying.instantiate(conf2, trainingListeners, layerIndex, layerParamsView,
            initializeParams, networkDataType), rnnDataFormat);
}
 
Example 3
Source File: LastTimeStep.java    From deeplearning4j with Apache License 2.0 5 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) {
    NeuralNetConfiguration conf2 = conf.clone();
    conf2.setLayer(((LastTimeStep) conf2.getLayer()).getUnderlying());
    return new LastTimeStepLayer(underlying.instantiate(conf2, trainingListeners, layerIndex, layerParamsView,
                    initializeParams, networkDataType));
}
 
Example 4
Source File: MaskZeroLayer.java    From deeplearning4j with Apache License 2.0 5 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) {

    NeuralNetConfiguration conf2 = conf.clone();
    conf2.setLayer(((BaseWrapperLayer) conf2.getLayer()).getUnderlying());

    org.deeplearning4j.nn.api.Layer underlyingLayer =
                    underlying.instantiate(conf2, trainingListeners, layerIndex, layerParamsView, initializeParams, networkDataType);
    return new org.deeplearning4j.nn.layers.recurrent.MaskZeroLayer(underlyingLayer, maskingValue);
}
 
Example 5
Source File: FrozenLayerWithBackprop.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
public NeuralNetConfiguration getInnerConf(NeuralNetConfiguration conf) {
    NeuralNetConfiguration nnc = conf.clone();
    nnc.setLayer(underlying);
    return nnc;
}
 
Example 6
Source File: FrozenLayer.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
public NeuralNetConfiguration getInnerConf(NeuralNetConfiguration conf) {
    NeuralNetConfiguration nnc = conf.clone();
    nnc.setLayer(layer);
    return nnc;
}