MCPcopy
hub / github.com/tensorflow/tfjs / constructor

Function constructor

tfjs-layers/src/engine/container.ts:93–483  ·  view source on GitHub ↗
(args: ContainerArgs)

Source from the content-addressed store, hash-verified

91 protected feedOutputNames: string[];
92
93 constructor(args: ContainerArgs) {
94 // No args passed to super's constructor.
95 super({});
96 this.name = args.name;
97 if (this.name == null) {
98 const prefix = this.getClassName().toLowerCase();
99 this.name = getUid(prefix);
100 }
101
102 this.supportsMasking = false;
103 this.trainable_ = true;
104
105 // TODO(michaelterry): Initialize perInputLosses/Updates here.
106
107 // Container-specific properties.
108 if (Array.isArray(args.inputs)) {
109 this.inputs = args.inputs.slice();
110 } else {
111 this.inputs = [args.inputs];
112 }
113 if (Array.isArray(args.outputs)) {
114 this.outputs = args.outputs.slice();
115 } else {
116 this.outputs = [args.outputs];
117 }
118
119 // Check for redundancy in inputs.
120 if (generic_utils.unique(this.inputs).length !== this.inputs.length) {
121 throw new ValueError(
122 'The list of inputs passed to the model is ' +
123 'redundant. All inputs should only appear once. Found: ' +
124 `${this.inputs.map(x => x.name)}`);
125 }
126
127 // Check for redundancy in outputs.
128 if (generic_utils.unique(this.outputs).length !== this.outputs.length) {
129 console.warn(
130 'The list of outputs passed to the model is redundant. ' +
131 'All outputs should only appear once. Found: ' +
132 `${this.outputs.map(x => x.name)}`);
133 }
134
135 /*
136 List of initial layers (1 to 1 mapping with this.inputs, hence the same
137 layer might appear twice)
138 */
139 this.inputLayers = [];
140 this.inputLayersNodeIndices = [];
141 this.inputLayersTensorIndices = [];
142 /*
143 List of layers (1 to 1 mapping with this.outputs, hence the same layer
144 might appear twice)
145 */
146 this.outputLayers = [];
147 this.outputLayersNodeIndices = [];
148 this.outputLayersTensorIndices = [];
149 /*
150 All layers in order of horizontal graph traversal. Entries are unique.

Callers

nothing calls this directly

Calls 8

getUidFunction · 0.90
buildMapOfGraphFunction · 0.85
uniqueMethod · 0.80
reverseMethod · 0.80
maxMethod · 0.80
getClassNameMethod · 0.65
sliceMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…