本文整理汇总了Java中org.deeplearning4j.nn.conf.MultiLayerConfiguration.getConfs方法的典型用法代码示例。如果您正苦于以下问题:Java MultiLayerConfiguration.getConfs方法的具体用法?Java MultiLayerConfiguration.getConfs怎么用?Java MultiLayerConfiguration.getConfs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.deeplearning4j.nn.conf.MultiLayerConfiguration
的用法示例。
在下文中一共展示了MultiLayerConfiguration.getConfs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mlpToCG
import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入方法依赖的package包/类
/**
* Convert a MultiLayerConfiguration into a Computation graph
*
* @param mlc Layer-wise configuration
* @param shape Inputshape
* @return ComputationGraph based on the configuration in the MLC
*/
default ComputationGraph mlpToCG(MultiLayerConfiguration mlc, int[][] shape) {
ComputationGraphConfiguration.GraphBuilder builder =
new NeuralNetConfiguration.Builder()
.trainingWorkspaceMode(WorkspaceMode.SEPARATE)
.inferenceWorkspaceMode(WorkspaceMode.SEPARATE)
.graphBuilder();
List<NeuralNetConfiguration> confs = mlc.getConfs();
// Start with input
String currentInput = "input";
builder.addInputs(currentInput);
// Iterate MLN configurations layer-wise
for (NeuralNetConfiguration conf : confs) {
Layer l = conf.getLayer();
String lName = l.getLayerName();
// Connect current layer with last layer
builder.addLayer(lName, l, currentInput);
currentInput = lName;
}
builder.setOutputs(currentInput);
// Configure inputs
builder.setInputTypes(InputType.convolutional(shape[0][1], shape[0][2], shape[0][0]));
// Build
ComputationGraphConfiguration cgc = builder.build();
return new ComputationGraph(cgc);
}
示例2: buildGraphInfo
import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入方法依赖的package包/类
public static GraphInfo buildGraphInfo(MultiLayerConfiguration config) {
List<String> vertexNames = new ArrayList<>();
List<String> originalVertexName = new ArrayList<>();
List<String> layerTypes = new ArrayList<>();
List<List<Integer>> layerInputs = new ArrayList<>();
List<Map<String, String>> layerInfo = new ArrayList<>();
vertexNames.add("Input");
originalVertexName.add(null);
layerTypes.add("Input");
layerInputs.add(Collections.emptyList());
layerInfo.add(Collections.emptyMap());
List<NeuralNetConfiguration> list = config.getConfs();
int layerIdx = 1;
for (NeuralNetConfiguration c : list) {
Layer layer = c.getLayer();
String layerName = layer.getLayerName();
if (layerName == null)
layerName = "layer" + layerIdx;
vertexNames.add(layerName);
originalVertexName.add(String.valueOf(layerIdx - 1));
String layerType = c.getLayer().getClass().getSimpleName().replaceAll("Layer$", "");
layerTypes.add(layerType);
layerInputs.add(Collections.singletonList(layerIdx - 1));
layerIdx++;
//Extract layer info
Map<String, String> map = getLayerInfo(c, layer);
layerInfo.add(map);
}
return new GraphInfo(vertexNames, layerTypes, layerInputs, layerInfo, originalVertexName);
}
示例3: toComputationGraph
import org.deeplearning4j.nn.conf.MultiLayerConfiguration; //导入方法依赖的package包/类
/**
* Convert a MultiLayerNetwork to a ComputationGraph
*
* @return ComputationGraph equivalent to this network (including parameters and updater state)
*/
public static ComputationGraph toComputationGraph(MultiLayerNetwork net) {
//We rely heavily here on the fact that the topological sort order - and hence the layout of parameters - is
// by definition the identical for a MLN and "single stack" computation graph. This also has to hold
// for the updater state...
ComputationGraphConfiguration.GraphBuilder b = new NeuralNetConfiguration.Builder()
.graphBuilder();
MultiLayerConfiguration origConf = net.getLayerWiseConfigurations().clone();
int layerIdx = 0;
String lastLayer = "in";
b.addInputs("in");
for (NeuralNetConfiguration c : origConf.getConfs()) {
String currLayer = String.valueOf(layerIdx);
InputPreProcessor preproc = origConf.getInputPreProcess(layerIdx);
b.addLayer(currLayer, c.getLayer(), preproc, lastLayer);
lastLayer = currLayer;
layerIdx++;
}
b.setOutputs(lastLayer);
ComputationGraphConfiguration conf = b.build();
ComputationGraph cg = new ComputationGraph(conf);
cg.init();
cg.setParams(net.params());
//Also copy across updater state:
INDArray updaterState = net.getUpdater().getStateViewArray();
if (updaterState != null) {
cg.getUpdater().getUpdaterStateViewArray()
.assign(updaterState);
}
return cg;
}