ComputationGraphConfiguration.GraphBuilder assemble(int numInputs, int numHiddenNodes, int numLayers, String baseLayer, int startingIndex) {
assert numHiddenNodes > 0 : "model capacity is too small. At least some hidden nodes must be created.";
WeightInit WEIGHT_INIT = WeightInit.XAVIER;
float reduction = 1f;
int minimum = (int) (numHiddenNodes * Math.pow(reduction, numLayers));
assert minimum > 2 : "Too much reduction, not enough outputs: ";
int numIn = numInputs;
int numOut = (int) (numHiddenNodes * modelCapacity);
String previousLayerName;
String lastDenseLayerName = "no layers";
for (int i = startingIndex; i < startingIndex + numLayers; i++) {
lastDenseLayerName = "dense" + i;
previousLayerName = i == startingIndex ? baseLayer : "dense" + (i - 1);
numOut = (int) (numHiddenNodes * Math.pow(reductionRate, i) * modelCapacity);
build.addLayer(lastDenseLayerName, new DenseLayer.Builder().nIn(numIn).nOut(numOut)
.weightInit(WEIGHT_INIT)
.activation("relu").learningRateDecayPolicy(learningRatePolicy).epsilon(LAYER_EPSILON)
.build(), previousLayerName);
numIn = numOut;
}
this.numOutputs = numOut;
this.lastLayerName = lastDenseLayerName;
return build;
}