MCPcopy Create free account
hub / github.com/tensorflow/tfjs / buildNodeConversionMap

Function buildNodeConversionMap

tfjs-layers/src/engine/container.ts:986–1002  ·  view source on GitHub ↗

* 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[])

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 1

hasMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…