diff --git a/brutex-extended-tests/src/test/java/net/brutex/gan/App.java b/brutex-extended-tests/src/test/java/net/brutex/gan/App.java
index 532613651..18a0fc50d 100644
--- a/brutex-extended-tests/src/test/java/net/brutex/gan/App.java
+++ b/brutex-extended-tests/src/test/java/net/brutex/gan/App.java
@@ -171,7 +171,7 @@ public class App {
LayerConfiguration[] disLayers = Arrays.stream(disLayers())
.map((layer) -> {
if (layer instanceof DenseLayer || layer instanceof OutputLayer) {
- return new FrozenLayerWithBackprop(layer);
+ return FrozenLayerWithBackprop.builder(layer);
} else {
return layer;
}
diff --git a/cavis-dnn/cavis-dnn-core/src/test/java/org/deeplearning4j/gradientcheck/UtilLayerGradientChecks.java b/cavis-dnn/cavis-dnn-core/src/test/java/org/deeplearning4j/gradientcheck/UtilLayerGradientChecks.java
index 1f5dc6465..7b883e689 100644
--- a/cavis-dnn/cavis-dnn-core/src/test/java/org/deeplearning4j/gradientcheck/UtilLayerGradientChecks.java
+++ b/cavis-dnn/cavis-dnn-core/src/test/java/org/deeplearning4j/gradientcheck/UtilLayerGradientChecks.java
@@ -162,19 +162,19 @@ public class UtilLayerGradientChecks extends BaseDL4JTest {
}
- NeuralNetConfiguration conf = NeuralNetConfiguration.builder()
- .updater(new NoOp())
- .activation(Activation.TANH)
- .dataType(DataType.DOUBLE)
- .dist(new NormalDistribution(0,2))
- .list()
- .layer(l1)
- .layer(new MaskLayer())
- .layer(l2)
- .layer(l3)
- .inputType(it)
- .build();
-
+ NeuralNetConfiguration conf =
+ NeuralNetConfiguration.builder()
+ .updater(new NoOp())
+ .activation(Activation.TANH)
+ .dataType(DataType.DOUBLE)
+ .dist(new NormalDistribution(0, 2))
+ .list()
+ .layer(l1)
+ .layer(MaskLayer.builder().build())
+ .layer(l2)
+ .layer(l3)
+ .inputType(it)
+ .build();
MultiLayerNetwork net = new MultiLayerNetwork(conf);
net.init();
@@ -203,11 +203,11 @@ public class UtilLayerGradientChecks extends BaseDL4JTest {
.list()
.layer(DenseLayer.builder().nIn(10).nOut(10)
.activation(Activation.TANH).weightInit(WeightInit.XAVIER).build())
- .layer(new FrozenLayerWithBackprop(DenseLayer.builder().nIn(10).nOut(10)
- .activation(Activation.TANH).weightInit(WeightInit.XAVIER).build()))
- .layer(new FrozenLayerWithBackprop(
+ .layer(FrozenLayerWithBackprop.builder().underlying(DenseLayer.builder().nIn(10).nOut(10)
+ .activation(Activation.TANH).weightInit(WeightInit.XAVIER).build()).build())
+ .layer(FrozenLayerWithBackprop.builder().underlying(
DenseLayer.builder().nIn(10).nOut(10).activation(Activation.TANH)
- .weightInit(WeightInit.XAVIER).build()))
+ .weightInit(WeightInit.XAVIER).build()).build())
.layer(OutputLayer.builder().lossFunction(LossFunctions.LossFunction.MCXENT)
.activation(Activation.SOFTMAX).nIn(10).nOut(10).build())
.build();
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/ActivationLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/ActivationLayer.java
index 7d67983b4..541ea4e14 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/ActivationLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/ActivationLayer.java
@@ -40,15 +40,12 @@ import org.nd4j.linalg.api.buffer.DataType;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.learning.config.IUpdater;
-@NoArgsConstructor
+
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder(buildMethodName = "initBuild", builderMethodName = "innerBuilder")
public class ActivationLayer extends NoParamLayer {
- {
- setType(LayerType.ACT);
- }
public static ActivationLayerBuilder, ?> builder(Activation activation) {
return innerBuilder().activation(activation);
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/BaseLayerConfiguration.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/BaseLayerConfiguration.java
index c288c8b88..30292b90a 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/BaseLayerConfiguration.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/BaseLayerConfiguration.java
@@ -49,6 +49,8 @@ import org.nd4j.linalg.learning.regularization.WeightDecay;
@SuperBuilder
public abstract class BaseLayerConfiguration extends LayerConfiguration
implements ITraininableLayerConfiguration, Serializable, Cloneable {
+
+
/**
* Set constraints to be applied to all layers. Default: no constraints.
* Constraints can be used to enforce certain conditions (non-negativity of parameters, max-norm
@@ -84,9 +86,9 @@ public abstract class BaseLayerConfiguration extends LayerConfiguration
@Getter @Setter @Builder.Default
protected double gainInit = 0.0;
/** Regularization for the parameters (excluding biases). */
- @Builder.Default @Getter protected List regularization = new ArrayList<>();
+ @Builder.Default @Getter @Setter protected List regularization = new ArrayList<>();
/** Regularization for the bias parameters only */
- @Builder.Default @Getter
+ @Builder.Default @Getter @Setter
protected List regularizationBias = new ArrayList<>();
/**
* Gradient updater. For example, {@link org.nd4j.linalg.learning.config.Adam} or {@link
@@ -210,6 +212,7 @@ public abstract class BaseLayerConfiguration extends LayerConfiguration
C extends BaseLayerConfiguration, B extends BaseLayerConfigurationBuilder>
extends LayerConfigurationBuilder {
+
/**
* Set weight initialization scheme to random sampling via the specified distribution.
* Equivalent to: {@code .weightInit(new WeightInitDistribution(distribution))}
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/BaseOutputLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/BaseOutputLayer.java
index 2f77495ee..3b07c3094 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/BaseOutputLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/BaseOutputLayer.java
@@ -29,8 +29,7 @@ import org.nd4j.linalg.lossfunctions.ILossFunction;
import org.nd4j.linalg.lossfunctions.LossFunctions;
import org.nd4j.linalg.lossfunctions.impl.LossMCXENT;
-@Data
-@NoArgsConstructor
+
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder(builderMethodName = "innerBuilder")
@@ -39,19 +38,16 @@ public abstract class BaseOutputLayer extends FeedForwardLayer {
/**
* Loss function for the output layer
*/
- @lombok.Builder.Default
+ @lombok.Builder.Default @Getter @Setter
protected ILossFunction lossFunction = new LossMCXENT();
/**
* If true (default): include bias parameters in the model. False: no bias.
*
*/
- @lombok.Builder.Default
+ @lombok.Builder.Default @Getter @Setter
protected boolean hasBias = true;
- public boolean hasBias() {
- return hasBias;
- }
@Override
public LayerMemoryReport getMemoryReport(InputType inputType) {
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/BasePretrainNetwork.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/BasePretrainNetwork.java
index 1a580c595..0ea89b064 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/BasePretrainNetwork.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/BasePretrainNetwork.java
@@ -31,11 +31,11 @@ import org.nd4j.linalg.lossfunctions.LossFunctions;
@JsonIgnoreProperties("pretrain")
@SuperBuilder
public abstract class BasePretrainNetwork extends FeedForwardLayer {
- @Builder.Default
+ @Builder.Default @Getter
protected LossFunctions.LossFunction lossFunction =
LossFunctions.LossFunction.RECONSTRUCTION_CROSSENTROPY;
- @Builder.Default protected double visibleBiasInit = 0.0;
+ @Builder.Default @Getter protected double visibleBiasInit = 0.0;
@Override
public boolean isPretrainParam(String paramName) {
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/BaseUpsamplingLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/BaseUpsamplingLayer.java
index 30b8e77bf..d40ac019c 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/BaseUpsamplingLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/BaseUpsamplingLayer.java
@@ -31,8 +31,6 @@ import org.deeplearning4j.nn.conf.inputs.InputType;
* @author Max Pumperla
*/
-@Data
-@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder()
@@ -43,7 +41,7 @@ public abstract class BaseUpsamplingLayer extends NoParamLayer {
* dimensions (e.g. 2 for Upsampling2D etc.)
*
*/
- @Builder.Default
+ @Builder.Default @Getter
protected int[] size = new int[] {1};
@Override
@@ -60,8 +58,4 @@ public abstract class BaseUpsamplingLayer extends NoParamLayer {
}
return InputTypeUtil.getPreProcessorForInputTypeCnnLayers(inputType, getName());
}
-
-
-
-
}
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/CenterLossOutputLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/CenterLossOutputLayer.java
index 5aba016e8..ec95558cf 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/CenterLossOutputLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/CenterLossOutputLayer.java
@@ -42,7 +42,6 @@ import java.util.Collection;
import java.util.Map;
@Data
-@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder(buildMethodName = "initBuild")
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Cnn3DLossLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Cnn3DLossLayer.java
index bba4396a6..15c31aaf2 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Cnn3DLossLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Cnn3DLossLayer.java
@@ -37,15 +37,15 @@ import org.nd4j.linalg.api.buffer.DataType;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.lossfunctions.ILossFunction;
-@Data
-@NoArgsConstructor
+
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
public class Cnn3DLossLayer extends FeedForwardLayer {
-
+@Getter @Setter
protected ILossFunction lossFunction;
/** Format of the input/output data. See {@link Convolution3D.DataFormat} for details */
+ @Getter @Setter
protected Convolution3D.DataFormat dataFormat;
@Override
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Convolution1D.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Convolution1D.java
index e4ab7f9ef..1074b3092 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Convolution1D.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Convolution1D.java
@@ -24,10 +24,11 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
+import lombok.experimental.SuperBuilder;
@Data
-@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
+@SuperBuilder
public class Convolution1D extends Convolution1DLayer {
}
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Convolution1DLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Convolution1DLayer.java
index a0c2ad6e5..a82f6c7c5 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Convolution1DLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Convolution1DLayer.java
@@ -45,7 +45,6 @@ import org.nd4j.linalg.api.ndarray.INDArray;
* wide.
*/
@Data
-@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder(buildMethodName = "initBuild", builderMethodName = "innerBuilder")
@@ -142,7 +141,7 @@ public class Convolution1DLayer extends ConvolutionLayer {
} else {
outLength =
Convolution1DUtils.getOutputSize(
- inputTsLength, kernelSize[0], stride[0], padding[0], convolutionMode, dilation[0]);
+ inputTsLength, kernelSize[0], stride[0], padding[0], getConvolutionMode(), dilation[0]);
}
return InputType.recurrent(nOut, outLength, rnnDataFormat);
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Convolution2D.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Convolution2D.java
index 865c6b9ed..dfe5f5c83 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Convolution2D.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Convolution2D.java
@@ -24,10 +24,12 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
+import lombok.experimental.SuperBuilder;
@Data
-@NoArgsConstructor
+
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
+@SuperBuilder
public class Convolution2D extends ConvolutionLayer {
}
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Convolution3D.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Convolution3D.java
index 49362063a..7f02d91f1 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Convolution3D.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Convolution3D.java
@@ -38,7 +38,6 @@ import org.nd4j.linalg.api.buffer.DataType;
import org.nd4j.linalg.api.ndarray.INDArray;
@Data
-@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder(builderMethodName = "innerBuilder", buildMethodName = "initBuild")
@@ -118,7 +117,7 @@ public class Convolution3D extends ConvolutionLayer {
* kernel size
*/
public boolean hasBias() {
- return hasBias;
+ return isHasBias();
}
@Override
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/ConvolutionLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/ConvolutionLayer.java
index 38dcc7309..619dd6194 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/ConvolutionLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/ConvolutionLayer.java
@@ -46,6 +46,7 @@ import org.nd4j.linalg.api.ndarray.INDArray;
* to be used in the net or in other words the channels The builder specifies the filter/kernel
* size, the stride and padding The pooling layer takes the kernel size
*/
+@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder(buildMethodName = "initBuild", builderMethodName = "innerBuilder")
@@ -55,14 +56,14 @@ public class ConvolutionLayer extends FeedForwardLayer {
*
* @param kernelSize the height and width of the kernel
*/
- public @Builder.Default int[] kernelSize = new int[] {5, 5}; // Square filter
+ private @Builder.Default @Getter @Setter int[] kernelSize = new int[] {5, 5}; // Square filter
/** If true (default): include bias parameters in the model. False: no bias. */
- @Builder.Default protected boolean hasBias = true;
+ @Builder.Default @Getter @Setter private boolean hasBias = true;
/**
* Set the convolution mode for the Convolution layer. See {@link ConvolutionMode} for more
* details Default is {@link ConvolutionMode}.Truncate.
*/
- @Builder.Default protected ConvolutionMode convolutionMode = ConvolutionMode.Truncate;
+ @Builder.Default @Getter @Setter private ConvolutionMode convolutionMode = ConvolutionMode.Truncate;
/**
* Set the data format for the CNN activations - NCHW (channels first) or NHWC (channels last).
@@ -72,7 +73,7 @@ public class ConvolutionLayer extends FeedForwardLayer {
* @param format Format for activations (in and out)
*/
@Builder.Default
- protected CNN2DFormat convFormat =
+ private CNN2DFormat convFormat =
CNN2DFormat.NCHW; // default value for legacy serialization reasons
/**
@@ -85,25 +86,25 @@ public class ConvolutionLayer extends FeedForwardLayer {
* http://deeplearning.net/software/theano/tutorial/conv_arithmetic.html#dilated-convolutions
*
*/
- protected @Builder.Default int[] dilation = new int[] {1, 1};
+ private @Builder.Default int[] dilation = new int[] {1, 1};
/** Default is 2. Down-sample by a factor of 2 */
- protected @Builder.Default int[] stride = new int[] {1, 1};
+ private @Builder.Default int[] stride = new int[] {1, 1};
- protected @Builder.Default int[] padding = new int[] {0, 0};
+ private @Builder.Default int[] padding = new int[] {0, 0};
/**
* When using CuDNN and an error is encountered, should fallback to the non-CuDNN implementatation
* be allowed? If set to false, an exception in CuDNN will be propagated back to the user. If
* false, the built-in (non-CuDNN) implementation for ConvolutionLayer will be used
*/
- @Builder.Default protected boolean cudnnAllowFallback = true;
+ @Builder.Default private boolean cudnnAllowFallback = true;
/** Defaults to "PREFER_FASTEST", but "NO_WORKSPACE" uses less memory. */
- @Builder.Default protected AlgoMode cudnnAlgoMode = AlgoMode.PREFER_FASTEST;
+ @Builder.Default private AlgoMode cudnnAlgoMode = AlgoMode.PREFER_FASTEST;
- protected FwdAlgo cudnnFwdAlgo;
- protected BwdFilterAlgo cudnnBwdFilterAlgo;
- protected BwdDataAlgo cudnnBwdDataAlgo;
- @Builder.Default protected int convolutionDim = 2; // 2D convolution by default
+ private FwdAlgo cudnnFwdAlgo;
+ private BwdFilterAlgo cudnnBwdFilterAlgo;
+ private BwdDataAlgo cudnnBwdDataAlgo;
+ @Builder.Default private int convolutionDim = 2; // 2D convolution by default
/** Causal convolution - allowed for 1D only */
@Builder.Default private boolean allowCausal = false;
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Deconvolution2D.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Deconvolution2D.java
index 6d479808f..cd9990875 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Deconvolution2D.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Deconvolution2D.java
@@ -44,7 +44,6 @@ import java.util.Map;
* The pooling layer takes the kernel size
*/
@Data
-@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder(buildMethodName = "initBuild", builderMethodName = "innerBuild")
@@ -88,20 +87,20 @@ private CNN2DFormat format = CNN2DFormat.NCHW;
}
}
public boolean hasBias() {
- return hasBias;
+ return isHasBias();
}
@Override
public Deconvolution2D clone() {
Deconvolution2D clone = (Deconvolution2D) super.clone();
- if (clone.kernelSize != null) {
- clone.kernelSize = clone.kernelSize.clone();
+ if (clone.getKernelSize() != null) {
+ clone.setKernelSize( clone.getKernelSize().clone());
}
- if (clone.stride != null) {
- clone.stride = clone.stride.clone();
+ if (clone.getStride() != null) {
+ clone.setStride( clone.getStride().clone());
}
- if (clone.padding != null) {
- clone.padding = clone.padding.clone();
+ if (clone.getPadding() != null) {
+ clone.setPadding( clone.getPadding().clone());
}
return clone;
}
@@ -138,7 +137,7 @@ private CNN2DFormat format = CNN2DFormat.NCHW;
+ "\"): Expected CNN input, got " + inputType);
}
- return InputTypeUtil.getOutputTypeDeconvLayer(inputType, kernelSize, stride, padding, dilation, convolutionMode,
+ return InputTypeUtil.getOutputTypeDeconvLayer(inputType, getKernelSize(), getStride(), getPadding(), getDilation(), getConvolutionMode(),
nOut, layerIndex, getName(), Deconvolution2DLayer.class);
}
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Deconvolution3D.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Deconvolution3D.java
index 5ea7d4465..e99ef284d 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Deconvolution3D.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/Deconvolution3D.java
@@ -42,7 +42,6 @@ import org.nd4j.linalg.api.ndarray.INDArray;
* filter/kernel size, the stride and padding The pooling layer takes the kernel size
*/
@Data
-@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder(buildMethodName = "initBuild", builderMethodName = "innerBuilder")
@@ -63,20 +62,20 @@ public class Deconvolution3D extends ConvolutionLayer {
}
public boolean hasBias() {
- return hasBias;
+ return isHasBias();
}
@Override
public Deconvolution3D clone() {
Deconvolution3D clone = (Deconvolution3D) super.clone();
- if (clone.kernelSize != null) {
- clone.kernelSize = clone.kernelSize.clone();
+ if (clone.getKernelSize() != null) {
+ clone.setKernelSize( clone.getKernelSize().clone());
}
- if (clone.stride != null) {
- clone.stride = clone.stride.clone();
+ if (clone.getStride() != null) {
+ clone.setStride( clone.getStride().clone());
}
- if (clone.padding != null) {
- clone.padding = clone.padding.clone();
+ if (clone.getPadding() != null) {
+ clone.setPadding( clone.getPadding().clone());
}
return clone;
}
@@ -147,11 +146,11 @@ public class Deconvolution3D extends ConvolutionLayer {
return InputTypeUtil.getOutputTypeDeconv3dLayer(
inputType,
- kernelSize,
- stride,
- padding,
- dilation,
- convolutionMode,
+ getKernelSize(),
+ getStride(),
+ getPadding(),
+ getDilation(),
+ getConvolutionMode(),
dataFormat,
nOut,
layerIndex,
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/DenseLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/DenseLayer.java
index cbdc89e27..a8fbeb74e 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/DenseLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/DenseLayer.java
@@ -38,7 +38,7 @@ import org.nd4j.linalg.api.buffer.DataType;
import org.nd4j.linalg.api.ndarray.INDArray;
/** Dense Layer Uses WeightInitXavier as default */
-
+@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder(
@@ -47,9 +47,9 @@ import org.nd4j.linalg.api.ndarray.INDArray;
public class DenseLayer extends FeedForwardLayer {
/** If true (default = false): enable layer normalization on this layer */
- @lombok.Builder.Default @Accessors private boolean hasLayerNorm = false;
+ @lombok.Builder.Default private boolean hasLayerNorm = false;
- @lombok.Builder.Default @Accessors private boolean hasBias = true;
+ @lombok.Builder.Default private boolean hasBias = true;
@Override
public Layer instantiate(
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/DepthwiseConvolution2D.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/DepthwiseConvolution2D.java
index 06980d565..394beeb73 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/DepthwiseConvolution2D.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/DepthwiseConvolution2D.java
@@ -20,6 +20,7 @@
package org.deeplearning4j.nn.conf.layers;
+import java.util.*;
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.deeplearning4j.nn.api.Layer;
@@ -36,134 +37,152 @@ import org.nd4j.common.base.Preconditions;
import org.nd4j.linalg.api.buffer.DataType;
import org.nd4j.linalg.api.ndarray.INDArray;
-import java.util.*;
-
@Data
-@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder(buildMethodName = "initBuild")
public class DepthwiseConvolution2D extends ConvolutionLayer {
- /**
- * Set channels multiplier for depth-wise convolution
- *
- * @param depthMultiplier integer value, for each input map we get depthMultiplier outputs in channels-wise
- * step.
- * @return Builder
- */
- @Builder.Default
- protected int depthMultiplier = 1;
- /**
- * Set the data format for the CNN activations - NCHW (channels first) or NHWC (channels last).
- * See {@link CNN2DFormat} for more details.
- * Default: NCHW
- *
- * @param format Format for activations (in and out)
- */
- @Builder.Default
- protected CNN2DFormat dataFormat =
- CNN2DFormat.NCHW; // default value for legacy serialization reasons
- /**
- * Set the data format for the CNN activations - NCHW (channels first) or NHWC (channels last).
- * See {@link CNN2DFormat} for more details.
- * Default: NCHW
- * @param format Format for activations (in and out)
- */
- @Builder.Default
- protected CNN2DFormat cnn2DFormat = CNN2DFormat.NCHW;
+ /**
+ * Set channels multiplier for depth-wise convolution
+ *
+ * @param depthMultiplier integer value, for each input map we get depthMultiplier outputs in
+ * channels-wise step.
+ * @return Builder
+ */
+ @Builder.Default protected int depthMultiplier = 1;
+ /**
+ * Set the data format for the CNN activations - NCHW (channels first) or NHWC (channels last).
+ * See {@link CNN2DFormat} for more details.
+ * Default: NCHW
+ *
+ * @param format Format for activations (in and out)
+ */
+ @Builder.Default
+ protected CNN2DFormat dataFormat =
+ CNN2DFormat.NCHW; // default value for legacy serialization reasons
+ /**
+ * Set the data format for the CNN activations - NCHW (channels first) or NHWC (channels last).
+ * See {@link CNN2DFormat} for more details.
+ * Default: NCHW
+ *
+ * @param format Format for activations (in and out)
+ */
+ @Builder.Default protected CNN2DFormat cnn2DFormat = CNN2DFormat.NCHW;
- public static abstract class DepthwiseConvolution2DBuilder>
- extends ConvolutionLayerBuilder {
- public C build() {
- Preconditions.checkState(depthMultiplier$value > 0, "Depth multiplier must be > 0, got %s", depthMultiplier$value);
- C l = this.initBuild();
- ConvolutionUtils.validateConvolutionModePadding(l.getConvolutionMode(), l.getPadding());
- ConvolutionUtils.validateCnnKernelStridePadding(l.getKernelSize(), l.getStride(), l.getPadding());
- l.initializeConstraints();
- return l;
- }
+ protected boolean allowCausal() {
+ // Causal convolution - allowed for 1D only
+ return false;
+ }
- @Override
- public B kernelSize(int... kernelSize) {
- super.kernelSize(ValidationUtils.validate2NonNegative(kernelSize, false, "kernelSize"));
- return self();
- }
- @Override
- public B stride(int... stride) {
- super.stride(ValidationUtils.validate2NonNegative(stride, false, "stride"));
- return self();
- }
- @Override
- public B padding(int... padding) {
- super.padding(ValidationUtils.validate2NonNegative(padding, false, "padding"));
- return self();
- }
- @Override
- public B dilation(int... dilation) {
- super.dilation(ValidationUtils.validate2NonNegative(dilation, false, "dilation"));
- return self();
- }
+ @Override
+ public DepthwiseConvolution2D clone() {
+ DepthwiseConvolution2D clone = (DepthwiseConvolution2D) super.clone();
+ clone.depthMultiplier = depthMultiplier;
+ return clone;
+ }
+
+ @Override
+ public Layer instantiate(
+ NeuralNetConfiguration conf,
+ Collection trainingListeners,
+ int layerIndex,
+ INDArray layerParamsView,
+ boolean initializeParams,
+ DataType networkDataType) {
+ LayerValidation.assertNInNOutSet(
+ "DepthwiseConvolution2D", getName(), layerIndex, getNIn(), getNOut());
+
+ LayerConfiguration lconf = conf.getFlattenedLayerConfigurations().get(layerIndex);
+ runInheritance();
+ DepthwiseConvolution2DLayer ret = new DepthwiseConvolution2DLayer(lconf, networkDataType);
+
+ ret.addTrainingListeners(trainingListeners);
+ ret.setIndex(layerIndex);
+ ret.setParamsViewArray(layerParamsView);
+ Map paramTable = initializer().init(this, layerParamsView, initializeParams);
+ ret.setParamTable(paramTable);
+ ret.setLayerConfiguration(lconf);
+
+ return ret;
+ }
+
+ @Override
+ public ParamInitializer initializer() {
+ return DepthwiseConvolutionParamInitializer.getInstance();
+ }
+
+ @Override
+ public InputType getOutputType(int layerIndex, InputType inputType) {
+ if (inputType == null || inputType.getType() != InputType.Type.CNN) {
+ throw new IllegalStateException(
+ "Invalid input for depth-wise convolution layer (layer name=\""
+ + getName()
+ + "\"): Expected CNN input, got "
+ + inputType);
}
+ return InputTypeUtil.getOutputTypeCnnLayers(
+ inputType,
+ getKernelSize(),
+ getStride(),
+ getPadding(),
+ getDilation(),
+ getConvolutionMode(),
+ nOut,
+ layerIndex,
+ getName(),
+ dataFormat,
+ DepthwiseConvolution2DLayer.class);
+ }
+ @Override
+ public void setNIn(InputType inputType, boolean override) {
+ super.setNIn(inputType, override);
- protected boolean allowCausal() {
- //Causal convolution - allowed for 1D only
- return false;
- }
- @Override
- public DepthwiseConvolution2D clone() {
- DepthwiseConvolution2D clone = (DepthwiseConvolution2D) super.clone();
- clone.depthMultiplier = depthMultiplier;
- return clone;
+ if (nOut == 0 || override) {
+ nOut = this.nIn * this.depthMultiplier;
}
+ this.dataFormat = ((InputType.InputTypeConvolutional) inputType).getFormat();
+ }
-
- @Override
- public Layer instantiate(NeuralNetConfiguration conf, Collection trainingListeners,
- int layerIndex, INDArray layerParamsView, boolean initializeParams, DataType networkDataType) {
- LayerValidation.assertNInNOutSet("DepthwiseConvolution2D", getName(), layerIndex, getNIn(), getNOut());
-
- LayerConfiguration lconf = conf.getFlattenedLayerConfigurations().get(layerIndex);
- runInheritance();
- DepthwiseConvolution2DLayer ret = new DepthwiseConvolution2DLayer(lconf, networkDataType);
-
- ret.addTrainingListeners(trainingListeners);
- ret.setIndex(layerIndex);
- ret.setParamsViewArray(layerParamsView);
- Map paramTable = initializer().init(this, layerParamsView, initializeParams);
- ret.setParamTable(paramTable);
- ret.setLayerConfiguration(lconf);
-
- return ret;
+ public abstract static class DepthwiseConvolution2DBuilder<
+ C extends DepthwiseConvolution2D, B extends DepthwiseConvolution2DBuilder>
+ extends ConvolutionLayerBuilder {
+ public C build() {
+ Preconditions.checkState(
+ depthMultiplier$value > 0,
+ "Depth multiplier must be > 0, got %s",
+ depthMultiplier$value);
+ C l = this.initBuild();
+ ConvolutionUtils.validateConvolutionModePadding(l.getConvolutionMode(), l.getPadding());
+ ConvolutionUtils.validateCnnKernelStridePadding(
+ l.getKernelSize(), l.getStride(), l.getPadding());
+ l.initializeConstraints();
+ return l;
}
@Override
- public ParamInitializer initializer() {
- return DepthwiseConvolutionParamInitializer.getInstance();
+ public B kernelSize(int... kernelSize) {
+ super.kernelSize(ValidationUtils.validate2NonNegative(kernelSize, false, "kernelSize"));
+ return self();
}
@Override
- public InputType getOutputType(int layerIndex, InputType inputType) {
- if (inputType == null || inputType.getType() != InputType.Type.CNN) {
- throw new IllegalStateException("Invalid input for depth-wise convolution layer (layer name=\""
- + getName() + "\"): Expected CNN input, got " + inputType);
- }
-
- return InputTypeUtil.getOutputTypeCnnLayers(inputType, kernelSize, stride, padding, dilation, convolutionMode,
- nOut, layerIndex, getName(), dataFormat, DepthwiseConvolution2DLayer.class);
+ public B stride(int... stride) {
+ super.stride(ValidationUtils.validate2NonNegative(stride, false, "stride"));
+ return self();
}
@Override
- public void setNIn(InputType inputType, boolean override) {
- super.setNIn(inputType, override);
-
- if(nOut == 0 || override){
- nOut = this.nIn * this.depthMultiplier;
- }
- this.dataFormat = ((InputType.InputTypeConvolutional)inputType).getFormat();
+ public B padding(int... padding) {
+ super.padding(ValidationUtils.validate2NonNegative(padding, false, "padding"));
+ return self();
}
-
-
+ @Override
+ public B dilation(int... dilation) {
+ super.dilation(ValidationUtils.validate2NonNegative(dilation, false, "dilation"));
+ return self();
+ }
+ }
}
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/DropoutLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/DropoutLayer.java
index 18cb5e23c..8c8e5d63d 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/DropoutLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/DropoutLayer.java
@@ -45,15 +45,12 @@ import org.nd4j.linalg.learning.regularization.Regularization;
* the input activation. See {@link Dropout} for the full details
*/
@Data
-@NoArgsConstructor
+
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder(builderMethodName = "innerBuilder")
public class DropoutLayer extends FeedForwardLayer {
- {
- setType(LayerType.DO);
- }
public static DropoutLayerBuilder,?> builder() {
return innerBuilder();
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/FeedForwardLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/FeedForwardLayer.java
index e017fc1e9..44b5f608f 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/FeedForwardLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/FeedForwardLayer.java
@@ -36,6 +36,10 @@ import org.deeplearning4j.nn.conf.preprocessor.RnnToFeedForwardPreProcessor;
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
public abstract class FeedForwardLayer extends BaseLayerConfiguration {
+ public static abstract class FeedForwardLayerBuilder>
+ extends BaseLayerConfigurationBuilder {
+
+ }
/**
* Number of inputs for the layer (usually the size of the last layer).
Note that for Convolutional layers,
* this is the input channels, otherwise is the previous layer size.
@@ -55,7 +59,7 @@ public abstract class FeedForwardLayer extends BaseLayerConfiguration {
* this is the input channels, otherwise is the previous layer size.
*
*/
- @Getter
+ @Getter @Setter
protected long nOut;
protected DataFormat timeDistributedFormat;
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/LayerConfiguration.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/LayerConfiguration.java
index 8abd09a0d..d37d08be0 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/LayerConfiguration.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/LayerConfiguration.java
@@ -57,10 +57,10 @@ public abstract class LayerConfiguration
implements ILayerConfiguration, Serializable, Cloneable { // ITrainableLayerConfiguration
@Getter @Setter protected String name;
- @Getter protected List allParamConstraints;
- @Getter protected List weightConstraints;
- @Getter protected List biasConstraints;
- @Getter protected List constraints;
+ @Getter @Setter protected List allParamConstraints;
+ @Getter @Setter protected List weightConstraints;
+ @Getter @Setter protected List biasConstraints;
+ @Getter @Setter protected List constraints;
@Getter @Setter protected IWeightNoise weightNoise;
@Builder.Default private @Getter @Setter LinkedHashSet variables = new LinkedHashSet<>();
@Getter @Setter private IDropout dropOut;
@@ -325,4 +325,15 @@ public abstract class LayerConfiguration
runInheritance(getNetConfiguration());
}
+ public abstract static class LayerConfigurationBuilder<
+ C extends LayerConfiguration, B extends LayerConfigurationBuilder> {
+ public B dropOut(double d) {
+ this.dropOut(new Dropout(d));
+ return self();
+ }
+ public B dropOut(IDropout d) {
+ this.dropOut = d;
+ return self();
+ }
+ }
}
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/LearnedSelfAttentionLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/LearnedSelfAttentionLayer.java
index d7fa4ea3a..a68ae9872 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/LearnedSelfAttentionLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/LearnedSelfAttentionLayer.java
@@ -61,9 +61,6 @@ public class LearnedSelfAttentionLayer extends SameDiffLayer {
/** Number of queries to learn */
private int nQueries;
- private LearnedSelfAttentionLayer() {
- /*No arg constructor for serialization*/
- }
@Override
public InputPreProcessor getPreProcessorForInputType(InputType inputType) {
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/NoParamLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/NoParamLayer.java
index add785a2f..78ae44d93 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/NoParamLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/NoParamLayer.java
@@ -32,9 +32,6 @@ import org.nd4j.linalg.learning.regularization.Regularization;
@SuperBuilder
public abstract class NoParamLayer extends LayerConfiguration {
- {
- setType(LayerType.POOL);
- }
@Override
public ParamInitializer initializer() {
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/SeparableConvolution2D.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/SeparableConvolution2D.java
index d06a090b5..5d7d25066 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/SeparableConvolution2D.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/SeparableConvolution2D.java
@@ -42,7 +42,6 @@ import org.nd4j.linalg.api.ndarray.INDArray;
* filter/kernel size, the stride and padding The pooling layer takes the kernel size
*/
@Data
-@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder(buildMethodName = "initBuild", builderMethodName = "innerBuilder")
@@ -103,20 +102,20 @@ public class SeparableConvolution2D extends ConvolutionLayer {
}
public boolean hasBias() {
- return hasBias;
+ return isHasBias();
}
@Override
public SeparableConvolution2D clone() {
SeparableConvolution2D clone = (SeparableConvolution2D) super.clone();
- if (clone.kernelSize != null) {
- clone.kernelSize = clone.kernelSize.clone();
+ if (clone.getKernelSize() != null) {
+ clone.setKernelSize( clone.getKernelSize().clone());
}
- if (clone.stride != null) {
- clone.stride = clone.stride.clone();
+ if (clone.getStride() != null) {
+ clone.setStride( clone.getStride().clone());
}
- if (clone.padding != null) {
- clone.padding = clone.padding.clone();
+ if (clone.getPadding() != null) {
+ clone.setPadding( clone.getPadding().clone());
}
return clone;
}
@@ -165,11 +164,11 @@ public class SeparableConvolution2D extends ConvolutionLayer {
return InputTypeUtil.getOutputTypeCnnLayers(
inputType,
- kernelSize,
- stride,
- padding,
- dilation,
- convolutionMode,
+ getKernelSize(),
+ getStride(),
+ getPadding(),
+ getDilation(),
+ getConvolutionMode(),
nOut,
layerIndex,
getName(),
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/misc/FrozenLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/misc/FrozenLayer.java
index bec8eba5a..83f66b966 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/misc/FrozenLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/misc/FrozenLayer.java
@@ -20,6 +20,9 @@
package org.deeplearning4j.nn.conf.layers.misc;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@@ -37,108 +40,111 @@ import org.nd4j.linalg.api.buffer.DataType;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.learning.config.IUpdater;
import org.nd4j.linalg.learning.regularization.Regularization;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
@EqualsAndHashCode(callSuper = false)
-@SuperBuilder
+@SuperBuilder(builderMethodName = "innerBuilder")
public class FrozenLayer extends LayerConfiguration {
- /**
- * A layer configuration, only if this layer config has been created from another one
- */
- @Getter @Setter
- private LayerConfiguration innerConfiguration;
+ /** A layer configuration, only if this layer config has been created from another one */
+ @Getter @Setter private LayerConfiguration innerConfiguration;
+ public static FrozenLayerBuilder, ?> builder() {
+ return innerBuilder();
+ }
- public FrozenLayer(@JsonProperty("layer") LayerConfiguration layer) {
- this.innerConfiguration = layer;
+ public static FrozenLayerBuilder, ?> builder(LayerConfiguration innerConfiguration) {
+ return innerBuilder().innerConfiguration(innerConfiguration);
+ }
+
+ @Override
+ public LayerConfiguration clone() {
+ FrozenLayer l = (FrozenLayer) super.clone();
+ l.innerConfiguration = innerConfiguration.clone();
+ return l;
+ }
+
+ @Override
+ public org.deeplearning4j.nn.api.Layer instantiate(
+ NeuralNetConfiguration conf,
+ Collection 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 =
+ innerConfiguration.instantiate(
+ getNetConfiguration(),
+ trainingListeners,
+ layerIndex,
+ layerParamsView,
+ initializeParams,
+ networkDataType);
+
+ NeuralNetConfiguration nncUnderlying = underlying.getNetConfiguration();
+ if (nncUnderlying.getNetWideVariables() != null) {
+ Set vars = nncUnderlying.getNetWideVariables(true);
+ nncUnderlying.clearNetWideVariable();
+ conf.clearNetWideVariable();
+ for (String s : vars) {
+ conf.getNetWideVariables(false).add(s);
+ nncUnderlying.getNetWideVariables(false).add(s);
+ }
}
- @Override
- public LayerConfiguration clone() {
- FrozenLayer l = (FrozenLayer) super.clone();
- l.innerConfiguration = innerConfiguration.clone();
- return l;
- }
+ return new org.deeplearning4j.nn.layers.FrozenLayer(underlying);
+ }
- @Override
- public org.deeplearning4j.nn.api.Layer instantiate(NeuralNetConfiguration conf,
- Collection trainingListeners, int layerIndex, INDArray layerParamsView,
- boolean initializeParams, DataType networkDataType) {
+ @Override
+ public ParamInitializer initializer() {
+ return FrozenLayerParamInitializer.getInstance();
+ }
- //Need to be able to instantiate a layer, from a config - for JSON -> net type situations
- org.deeplearning4j.nn.api.Layer underlying = innerConfiguration.instantiate(getNetConfiguration(), trainingListeners,
- layerIndex, layerParamsView, initializeParams, networkDataType);
+ @Override
+ public InputType getOutputType(int layerIndex, InputType inputType) {
+ return innerConfiguration.getOutputType(layerIndex, inputType);
+ }
- NeuralNetConfiguration nncUnderlying = underlying.getNetConfiguration();
- if (nncUnderlying.getNetWideVariables() != null) {
- Set vars = nncUnderlying.getNetWideVariables(true);
- nncUnderlying.clearNetWideVariable();
- conf.clearNetWideVariable();
- for (String s : vars) {
- conf.getNetWideVariables(false).add(s);
- nncUnderlying.getNetWideVariables(false).add(s);
- }
- }
+ @Override
+ public void setNIn(InputType inputType, boolean override) {
+ innerConfiguration.setNIn(inputType, override);
+ }
- return new org.deeplearning4j.nn.layers.FrozenLayer(underlying);
- }
+ @Override
+ public InputPreProcessor getPreProcessorForInputType(InputType inputType) {
+ return innerConfiguration.getPreProcessorForInputType(inputType);
+ }
- @Override
- public ParamInitializer initializer() {
- return FrozenLayerParamInitializer.getInstance();
- }
+ @Override
+ public List getRegularizationByParam(String param) {
+ return null;
+ }
- @Override
- public InputType getOutputType(int layerIndex, InputType inputType) {
- return innerConfiguration.getOutputType(layerIndex, inputType);
- }
+ @Override
+ public boolean isPretrainParam(String paramName) {
+ return false;
+ }
- @Override
- public void setNIn(InputType inputType, boolean override) {
- innerConfiguration.setNIn(inputType, override);
- }
+ @Override
+ public IUpdater getUpdaterByParam(String paramName) {
+ return null;
+ }
- @Override
- public InputPreProcessor getPreProcessorForInputType(InputType inputType) {
- return innerConfiguration.getPreProcessorForInputType(inputType);
- }
-
- @Override
- public List getRegularizationByParam(String param){
- return null;
- }
-
- @Override
- public boolean isPretrainParam(String paramName) {
- return false;
- }
-
- @Override
- public IUpdater getUpdaterByParam(String paramName) {
- return null;
- }
-
- @Override
- public LayerMemoryReport getMemoryReport(InputType inputType) {
- return innerConfiguration.getMemoryReport(inputType);
- }
-
- @Override
- public void setName(String layerName) {
- super.setName(layerName);
- innerConfiguration.setName(layerName);
- }
-
- @Override
- public void setConstraints(List constraints) {
- this.constraints = constraints;
- this.innerConfiguration.setConstraints(constraints);
- }
+ @Override
+ public LayerMemoryReport getMemoryReport(InputType inputType) {
+ return innerConfiguration.getMemoryReport(inputType);
+ }
+ @Override
+ public void setName(String layerName) {
+ super.setName(layerName);
+ innerConfiguration.setName(layerName);
+ }
+ @Override
+ public void setConstraints(List constraints) {
+ this.constraints = constraints;
+ this.innerConfiguration.setConstraints(constraints);
+ }
}
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/misc/FrozenLayerWithBackprop.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/misc/FrozenLayerWithBackprop.java
index a7a5b98f1..1e1e7504a 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/misc/FrozenLayerWithBackprop.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/misc/FrozenLayerWithBackprop.java
@@ -22,6 +22,7 @@ package org.deeplearning4j.nn.conf.layers.misc;
import lombok.Data;
import lombok.EqualsAndHashCode;
+import lombok.experimental.SuperBuilder;
import org.deeplearning4j.nn.api.ParamInitializer;
import org.deeplearning4j.nn.api.layers.LayerConstraint;
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
@@ -39,19 +40,23 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
-@Data
+
@EqualsAndHashCode(callSuper = false)
+@SuperBuilder(builderMethodName = "innerBuilder")
public class FrozenLayerWithBackprop extends BaseWrapperLayerConfiguration {
+
+ public static FrozenLayerWithBackpropBuilder, ?> builder() {
+ return innerBuilder();
+ }
/**
* Create a new Frozen Layer, that wraps another layer with backpropagation enabled.
*
- * @param layer configuration of the layer to wrap
+ * @param innerConfiguration configuration of the layer to wrap
*/
- public FrozenLayerWithBackprop(@JsonProperty("layer") LayerConfiguration layer) {
- super(layer);
+ public static FrozenLayerWithBackpropBuilder, ?> builder(LayerConfiguration innerConfiguration) {
+ return innerBuilder().underlying(innerConfiguration);
}
-
public NeuralNetConfiguration getInnerConf(NeuralNetConfiguration conf) {
NeuralNetConfiguration nnc = conf.clone();
nnc.getLayerConfigurations().add(0, underlying);
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/objdetect/Yolo2OutputLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/objdetect/Yolo2OutputLayer.java
index b67ac6a8b..afc42ff1b 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/objdetect/Yolo2OutputLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/objdetect/Yolo2OutputLayer.java
@@ -46,7 +46,7 @@ import org.nd4j.linalg.lossfunctions.ILossFunction;
import org.nd4j.linalg.lossfunctions.impl.LossL2;
import org.nd4j.serde.jackson.shaded.NDArrayTextSerializer;
-@Data
+
@EqualsAndHashCode(callSuper = false)
@SuperBuilder(buildMethodName = "initBuild")
public class Yolo2OutputLayer extends LayerConfiguration {
@@ -55,20 +55,20 @@ public class Yolo2OutputLayer extends LayerConfiguration {
* Loss function coefficient for position and size/scale components of the loss function. Default
* (as per paper): 5
*/
- @Builder.Default private double lambdaCoord = 5;
+ @Builder.Default @Getter private double lambdaCoord = 5;
/**
* Loss function coefficient for the "no object confidence" components of the loss function.
* Default (as per paper): 0.5
*/
- @Builder.Default private double lambdaNoObj = 0.5;
+ @Builder.Default @Getter private double lambdaNoObj = 0.5;
/** Loss function for position/scale component of the loss function */
- @Builder.Default private ILossFunction lossPositionScale = new LossL2();
+ @Builder.Default @Getter private ILossFunction lossPositionScale = new LossL2();
/**
* Loss function for the class predictions - defaults to L2 loss (i.e., sum of squared errors, as
* per the paper), however Loss MCXENT could also be used (which is more common for
* classification).
*/
- @Builder.Default private ILossFunction lossClassPredictions = new LossL2();
+ @Builder.Default @Getter private ILossFunction lossClassPredictions = new LossL2();
;
/**
* Bounding box priors dimensions [width, height]. For N bounding boxes, input has shape [rows,
@@ -78,15 +78,12 @@ public class Yolo2OutputLayer extends LayerConfiguration {
*/
@JsonSerialize(using = NDArrayTextSerializer.class)
@JsonDeserialize(using = BoundingBoxesDeserializer.class)
- @Builder.Default
+ @Builder.Default @Getter
private INDArray boundingBoxes;
- @Builder.Default
+ @Builder.Default @Getter
private CNN2DFormat format = CNN2DFormat.NCHW; // Default for serialization of old formats
- private Yolo2OutputLayer() {
- // No-arg constructor for Jackson JSON
- }
@Override
public Layer instantiate(
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/recurrent/LastTimeStep.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/recurrent/LastTimeStep.java
index da834fa61..3ca38afa7 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/recurrent/LastTimeStep.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/recurrent/LastTimeStep.java
@@ -20,6 +20,7 @@
package org.deeplearning4j.nn.conf.layers.recurrent;
+import lombok.experimental.SuperBuilder;
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
import org.deeplearning4j.nn.conf.inputs.InputType;
import org.deeplearning4j.nn.conf.layers.LayerConfiguration;
@@ -30,14 +31,18 @@ import org.nd4j.linalg.api.buffer.DataType;
import org.nd4j.linalg.api.ndarray.INDArray;
import java.util.Collection;
-
+@SuperBuilder(builderMethodName = "innerBuilder")
public class LastTimeStep extends BaseWrapperLayerConfiguration {
- private LastTimeStep() {}
+ public static LastTimeStepBuilder,?> builder() {
+ return innerBuilder();
+ }
- public LastTimeStep(LayerConfiguration underlying) {
- super(underlying);
- this.name = underlying.getName(); // needed for keras import to match names
+
+ public static LastTimeStepBuilder,?> builder(LayerConfiguration underlying) {
+ return innerBuilder()
+ .underlying(underlying)
+ .name(underlying.getName());
}
public LayerConfiguration getUnderlying() {
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/recurrent/SimpleRnn.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/recurrent/SimpleRnn.java
index 65866d427..832d48034 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/recurrent/SimpleRnn.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/recurrent/SimpleRnn.java
@@ -41,7 +41,6 @@ import java.util.Map;
@EqualsAndHashCode(callSuper = false)
-@NoArgsConstructor
@SuperBuilder
public class SimpleRnn extends BaseRecurrentLayer {
/**
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/recurrent/TimeDistributed.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/recurrent/TimeDistributed.java
index 73cddbf14..d78b4acf3 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/recurrent/TimeDistributed.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/recurrent/TimeDistributed.java
@@ -20,9 +20,9 @@
package org.deeplearning4j.nn.conf.layers.recurrent;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.NonNull;
+import java.util.Collection;
+import lombok.*;
+import lombok.experimental.SuperBuilder;
import org.deeplearning4j.nn.conf.InputPreProcessor;
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
import org.deeplearning4j.nn.conf.RNNFormat;
@@ -33,66 +33,67 @@ import org.deeplearning4j.nn.layers.recurrent.TimeDistributedLayer;
import org.deeplearning4j.optimize.api.TrainingListener;
import org.nd4j.linalg.api.buffer.DataType;
import org.nd4j.linalg.api.ndarray.INDArray;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.Collection;
-
-@Data
@EqualsAndHashCode(callSuper = true)
+@SuperBuilder
public class TimeDistributed extends BaseWrapperLayerConfiguration {
+ @Getter @Setter private RNNFormat rnnDataFormat = RNNFormat.NCW;
- private RNNFormat rnnDataFormat = RNNFormat.NCW;
+ @Override
+ public org.deeplearning4j.nn.api.Layer instantiate(
+ NeuralNetConfiguration conf,
+ Collection trainingListeners,
+ int layerIndex,
+ INDArray layerParamsView,
+ boolean initializeParams,
+ DataType networkDataType) {
+ LayerConfiguration lconf = conf.getFlattenedLayerConfigurations().get(layerIndex);
- /**
- * @param underlying Underlying (internal) layer - should be a feed forward type such as DenseLayerConfiguration
- */
- public TimeDistributed(@JsonProperty("underlying") @NonNull LayerConfiguration underlying, @JsonProperty("rnnDataFormat") RNNFormat rnnDataFormat) {
- super(underlying);
- this.rnnDataFormat = rnnDataFormat;
+ NeuralNetConfiguration conf2 = conf.clone();
+ conf2.setLayer(((TimeDistributed) lconf).getUnderlying());
+ return new TimeDistributedLayer(
+ underlying.instantiate(
+ conf2,
+ trainingListeners,
+ layerIndex,
+ layerParamsView,
+ initializeParams,
+ networkDataType),
+ rnnDataFormat);
+ }
+
+ @Override
+ public InputType getOutputType(int layerIndex, InputType inputType) {
+ if (inputType.getType() != InputType.Type.RNN) {
+ throw new IllegalStateException(
+ "Only RNN input type is supported as input to TimeDistributed layer (layer #"
+ + layerIndex
+ + ")");
}
- public TimeDistributed(LayerConfiguration underlying){
- super(underlying);
+ InputType.InputTypeRecurrent rnn = (InputType.InputTypeRecurrent) inputType;
+ InputType ff = InputType.feedForward(rnn.getSize());
+ InputType ffOut = underlying.getOutputType(layerIndex, ff);
+ return InputType.recurrent(
+ ffOut.arrayElementsPerExample(), rnn.getTimeSeriesLength(), rnnDataFormat);
+ }
+
+ @Override
+ public void setNIn(InputType inputType, boolean override) {
+ if (inputType.getType() != InputType.Type.RNN) {
+ throw new IllegalStateException(
+ "Only RNN input type is supported as input to TimeDistributed layer");
}
- @Override
- public org.deeplearning4j.nn.api.Layer instantiate(NeuralNetConfiguration conf, Collection trainingListeners,
- int layerIndex, INDArray layerParamsView, boolean initializeParams, DataType networkDataType) {
- LayerConfiguration lconf = conf.getFlattenedLayerConfigurations().get(layerIndex);
+ InputType.InputTypeRecurrent rnn = (InputType.InputTypeRecurrent) inputType;
+ InputType ff = InputType.feedForward(rnn.getSize());
+ this.rnnDataFormat = rnn.getFormat();
+ underlying.setNIn(ff, override);
+ }
- NeuralNetConfiguration conf2 = conf.clone();
- conf2.setLayer(((TimeDistributed) lconf).getUnderlying());
- return new TimeDistributedLayer(underlying.instantiate(conf2, trainingListeners, layerIndex, layerParamsView,
- initializeParams, networkDataType), rnnDataFormat);
- }
-
- @Override
- public InputType getOutputType(int layerIndex, InputType inputType) {
- if (inputType.getType() != InputType.Type.RNN) {
- throw new IllegalStateException("Only RNN input type is supported as input to TimeDistributed layer (layer #" + layerIndex + ")");
- }
-
- InputType.InputTypeRecurrent rnn = (InputType.InputTypeRecurrent) inputType;
- InputType ff = InputType.feedForward(rnn.getSize());
- InputType ffOut = underlying.getOutputType(layerIndex, ff);
- return InputType.recurrent(ffOut.arrayElementsPerExample(), rnn.getTimeSeriesLength(), rnnDataFormat);
- }
-
- @Override
- public void setNIn(InputType inputType, boolean override) {
- if (inputType.getType() != InputType.Type.RNN) {
- throw new IllegalStateException("Only RNN input type is supported as input to TimeDistributed layer");
- }
-
- InputType.InputTypeRecurrent rnn = (InputType.InputTypeRecurrent) inputType;
- InputType ff = InputType.feedForward(rnn.getSize());
- this.rnnDataFormat = rnn.getFormat();
- underlying.setNIn(ff, override);
- }
-
- @Override
- public InputPreProcessor getPreProcessorForInputType(InputType inputType) {
- //No preprocessor - the wrapper layer operates as the preprocessor
- return null;
- }
+ @Override
+ public InputPreProcessor getPreProcessorForInputType(InputType inputType) {
+ // No preprocessor - the wrapper layer operates as the preprocessor
+ return null;
+ }
}
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/samediff/SameDiffLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/samediff/SameDiffLayer.java
index 2d05307a9..9bf3e4f6c 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/samediff/SameDiffLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/samediff/SameDiffLayer.java
@@ -20,6 +20,7 @@
package org.deeplearning4j.nn.conf.layers.samediff;
+import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;
import org.deeplearning4j.nn.api.Layer;
@@ -47,7 +48,9 @@ public abstract class SameDiffLayer extends AbstractSameDiffLayer {
/**
* WeightInit, default is XAVIER.
*/
+ @Builder.Default
protected WeightInit weightInit = WeightInit.XAVIER;
+ @Builder.Default
protected Map paramWeightInit = new HashMap<>();
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/samediff/SameDiffOutputLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/samediff/SameDiffOutputLayer.java
index 8fa7fd4d0..d49176fe3 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/samediff/SameDiffOutputLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/samediff/SameDiffOutputLayer.java
@@ -20,6 +20,7 @@
package org.deeplearning4j.nn.conf.layers.samediff;
+import lombok.experimental.SuperBuilder;
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
import org.deeplearning4j.nn.conf.layers.LayerConfiguration;
import org.deeplearning4j.optimize.api.TrainingListener;
@@ -30,13 +31,10 @@ import org.nd4j.linalg.api.ndarray.INDArray;
import java.util.Collection;
import java.util.Map;
-
+@SuperBuilder
public abstract class SameDiffOutputLayer extends AbstractSameDiffLayer {
- protected SameDiffOutputLayer() {
- //No op constructor for Jackson
- }
/**
* Define the output layer
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/util/MaskLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/util/MaskLayer.java
index bd39eb828..50b71e837 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/util/MaskLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/util/MaskLayer.java
@@ -21,6 +21,7 @@
package org.deeplearning4j.nn.conf.layers.util;
import lombok.NoArgsConstructor;
+import lombok.experimental.SuperBuilder;
import org.deeplearning4j.nn.api.ParamInitializer;
import org.deeplearning4j.nn.conf.InputPreProcessor;
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
@@ -38,7 +39,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
-@NoArgsConstructor
+@SuperBuilder
public class MaskLayer extends NoParamLayer {
@Override
public org.deeplearning4j.nn.api.Layer instantiate(NeuralNetConfiguration conf,
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/util/MaskZeroLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/util/MaskZeroLayer.java
index 5215bad77..3161bfb02 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/util/MaskZeroLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/util/MaskZeroLayer.java
@@ -35,22 +35,17 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collection;
-@Data
+
@EqualsAndHashCode(callSuper = false)
@SuperBuilder
public class MaskZeroLayer extends BaseWrapperLayerConfiguration {
-@Builder.Default
+@Builder.Default @Getter @Setter
private double maskingValue = 0.0;
private static final long serialVersionUID = 9074525846200921839L;
- public MaskZeroLayer(@JsonProperty("underlying") LayerConfiguration underlying, @JsonProperty("maskingValue") double maskingValue) {
- this.underlying = underlying;
- this.maskingValue = maskingValue;
- }
-
@Override
public org.deeplearning4j.nn.api.Layer instantiate(NeuralNetConfiguration conf,
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/wrapper/BaseWrapperLayerConfiguration.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/wrapper/BaseWrapperLayerConfiguration.java
index 6c1e2d274..bfa864c29 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/wrapper/BaseWrapperLayerConfiguration.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/layers/wrapper/BaseWrapperLayerConfiguration.java
@@ -23,6 +23,7 @@ package org.deeplearning4j.nn.conf.layers.wrapper;
import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
+import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.deeplearning4j.nn.api.ParamInitializer;
import org.deeplearning4j.nn.conf.InputPreProcessor;
@@ -42,7 +43,8 @@ import org.nd4j.linalg.learning.regularization.Regularization;
public abstract class BaseWrapperLayerConfiguration extends LayerConfiguration {
/** The configuration to of another layer to wrap */
- @Getter protected LayerConfiguration underlying;
+ @Getter @Setter
+ protected LayerConfiguration underlying;
/**
* Set the net configuration for this configuration as well as for the underlying layer (if not
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/ocnn/OCNNOutputLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/ocnn/OCNNOutputLayer.java
index 023668c19..746d25aae 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/ocnn/OCNNOutputLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/conf/ocnn/OCNNOutputLayer.java
@@ -38,8 +38,6 @@ import org.nd4j.linalg.api.buffer.DataType;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.learning.regularization.Regularization;
-@Data
-@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@JsonIgnoreProperties("lossFn")
diff --git a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/layers/BaseOutputLayer.java b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/layers/BaseOutputLayer.java
index 83ce95961..5fc9bfde7 100644
--- a/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/layers/BaseOutputLayer.java
+++ b/cavis-dnn/cavis-dnn-nn/src/main/java/org/deeplearning4j/nn/layers/BaseOutputLayer.java
@@ -349,6 +349,6 @@ public abstract class BaseOutputLayer