Java Code Examples for org.deeplearning4j.arbiter.optimize.api.ParameterSpace#getNestedSpaces()
The following examples show how to use
org.deeplearning4j.arbiter.optimize.api.ParameterSpace#getNestedSpaces() .
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: LayerSpace.java From deeplearning4j with Apache License 2.0 | 6 votes |
@Override public List<ParameterSpace> collectLeaves() { //To avoid manually coding EVERY parameter, in every layer: // Do a depth-first search of nested spaces LinkedList<ParameterSpace> stack = new LinkedList<>(); stack.add(this); List<ParameterSpace> out = new ArrayList<>(); while (!stack.isEmpty()) { ParameterSpace next = stack.removeLast(); if (next.isLeaf()) { out.add(next); } else { Map<String, ParameterSpace> m = next.getNestedSpaces(); ParameterSpace[] arr = m.values().toArray(new ParameterSpace[m.size()]); for (int i = arr.length - 1; i >= 0; i--) { stack.add(arr[i]); } } } return out; }
Example 2
Source File: BaseNetworkSpace.java From deeplearning4j with Apache License 2.0 | 5 votes |
@Override public List<ParameterSpace> collectLeaves() { Map<String, ParameterSpace> global = getNestedSpaces(); //Note: Results on previous line does NOT include the LayerSpaces, therefore we need to add these manually... //This is because the type is a list, not a ParameterSpace LinkedList<ParameterSpace> stack = new LinkedList<>(); stack.add(this); for (LayerConf layerConf : layerSpaces) { LayerSpace ls = layerConf.getLayerSpace(); stack.addAll(ls.collectLeaves()); } List<ParameterSpace> out = new ArrayList<>(); while (!stack.isEmpty()) { ParameterSpace next = stack.removeLast(); if (next.isLeaf()) { out.add(next); } else { Map<String, ParameterSpace> m = next.getNestedSpaces(); ParameterSpace[] arr = m.values().toArray(new ParameterSpace[m.size()]); for (int i = arr.length - 1; i >= 0; i--) { stack.add(arr[i]); } } } return out; }