* Builds a map of internal node keys to node ordering. * Used in serializaion a node orderings may change as unused nodes are * dropped. Porting Note: This helper method was pulled out of getConfig to * improve readability. * @param layers An array of Layers in the model. * @returns
(layers: Layer[])
| 984 | * @returns Map of Node Keys to index order within the layer. |
| 985 | */ |
| 986 | private buildNodeConversionMap(layers: Layer[]): {[nodeKey: string]: number} { |
| 987 | const nodeConversionMap: {[nodeKey: string]: number} = {}; |
| 988 | let keptNodes: number; |
| 989 | for (const layer of this.layers) { |
| 990 | keptNodes = layer instanceof Container ? 1 : 0; |
| 991 | for (let originalNodeIndex = 0; |
| 992 | originalNodeIndex < layer.inboundNodes.length; originalNodeIndex++) { |
| 993 | const nodeKey = Container.nodeKey(layer, originalNodeIndex); |
| 994 | if (this.containerNodes.has(nodeKey)) { |
| 995 | // i.e. we mark it to be saved |
| 996 | nodeConversionMap[nodeKey] = keptNodes; |
| 997 | keptNodes += 1; |
| 998 | } |
| 999 | } |
| 1000 | } |
| 1001 | return nodeConversionMap; |
| 1002 | } |
| 1003 | |
| 1004 | /** |
| 1005 | * Retrieves a layer based on either its name (unique) or index. |
nothing calls this directly
no test coverage detected
searching dependent graphs…