private MultiLayerConfiguration constructConf() { //use the editedConfs list to make a new config List<NeuralNetConfiguration> allConfs = new ArrayList<>(); allConfs.addAll(editedConfs); allConfs.addAll(appendConfs); //Set default layer names, if not set - as per NeuralNetConfiguration.ListBuilder.build() for (int i = 0; i < allConfs.size(); i++) { if (allConfs.get(i).getLayer().getLayerName() == null) { allConfs.get(i).getLayer().setLayerName("layer" + i); } } MultiLayerConfiguration conf = new MultiLayerConfiguration.Builder().inputPreProcessors(inputPreProcessors) .setInputType(this.inputType).confs(allConfs).build(); if (finetuneConfiguration != null) { finetuneConfiguration.applyToMultiLayerConfiguration(conf); } return conf; } }
.tBPTTBackwardLength(tbpttBackLength).setInputType(this.inputType) .trainingWorkspaceMode(globalConfig.trainingWorkspaceMode).cacheMode(globalConfig.cacheMode) .inferenceWorkspaceMode(globalConfig.inferenceWorkspaceMode).confs(list).build();
private void initHelperMLN() { if (applyFrozen) { org.deeplearning4j.nn.api.Layer[] layers = origMLN.getLayers(); for (int i = frozenTill; i >= 0; i--) { //unchecked? layers[i] = new FrozenLayer(layers[i]); } origMLN.setLayers(layers); } for (int i = 0; i < origMLN.getnLayers(); i++) { if (origMLN.getLayer(i) instanceof FrozenLayer) { frozenInputLayer = i; } } List<NeuralNetConfiguration> allConfs = new ArrayList<>(); for (int i = frozenInputLayer + 1; i < origMLN.getnLayers(); i++) { allConfs.add(origMLN.getLayer(i).conf()); } MultiLayerConfiguration c = origMLN.getLayerWiseConfigurations(); unFrozenSubsetMLN = new MultiLayerNetwork(new MultiLayerConfiguration.Builder().backprop(c.isBackprop()) .inputPreProcessors(c.getInputPreProcessors()).pretrain(c.isPretrain()) .backpropType(c.getBackpropType()).tBPTTForwardLength(c.getTbpttFwdLength()) .tBPTTBackwardLength(c.getTbpttBackLength()).confs(allConfs).build()); unFrozenSubsetMLN.init(); //copy over params for (int i = frozenInputLayer + 1; i < origMLN.getnLayers(); i++) { unFrozenSubsetMLN.getLayer(i - frozenInputLayer - 1).setParams(origMLN.getLayer(i).params()); } //unFrozenSubsetMLN.setListeners(origMLN.getListeners()); }