execute(inputs, outputs) {
          inputs = this.mapInputs(inputs);
          const names = Object.keys(inputs).sort();
          this.checkInputs(inputs);
          this.checkInputShapeAndType(inputs);
          outputs = this.mapOutputs(outputs);
          this.checkOutputs(outputs);
          const inputNodes = names.map(name => this.graph.nodes[parseNodeName(name)[0]]);
          const outputNodeNames = outputs.map(name => parseNodeName(name)[0]);
          let outputNodes = outputNodeNames.map(name => this.graph.nodes[name]);
          // If no outputs are specified, then use the default outputs of the model.
          if (outputNodes.length === 0) {
              outputNodes = this._outputs;
          }
          const compilationKey = this.getCompilationKey(inputNodes, outputNodes);
          // Do nothing if the compiled graph cache contains the input.
          let orderedNodes = this.compiledMap.get(compilationKey);
          if (orderedNodes == null) {
              orderedNodes = this.compile(inputs, outputNodes);
              this.compiledMap.set(compilationKey, orderedNodes);
          }
          const tensorArrayMap = {};
          const tensorListMap = {};
          return tfc.tidy(() => {
              const context = new ExecutionContext(this.weightMap, tensorArrayMap, tensorListMap, this.functionExecutorMap);
              const tensorsMap = Object.assign({}, this.weightMap);
              Object.keys(inputs).forEach(name => {
                  const [nodeName, index] = parseNodeName(name);
                  const tensors = [];
                  tensors[index] = inputs[name];
                  tensorsMap[nodeName] = tensors;
              });
              const tensorsToKeep = this.getFrozenTensorIds(tensorsMap);
              const intermediateTensorConsumerCount = {};
              for (let i = 0; i < orderedNodes.length; i++) {
                  const node = orderedNodes[i];
                  if (!tensorsMap[node.name]) {
                      const tensors = executeOp$h(node, tensorsMap, context, this._resourceManager);
                      if (tfc.util.isPromise(tensors)) {
                          throw new Error(`The execution of the op '${node.op}' returned a promise. ` +
                              `Please use model.executeAsync() instead.`);
                      }
                      tensorsMap[node.name] = tensors;
                      this.checkTensorForDisposal(node.name, node, tensorsMap, context, tensorsToKeep, outputNodeNames, intermediateTensorConsumerCount);
                  }
              }
              // dispose the context for the root executor
              if (this.parent == null) {
                  context.dispose(tensorsToKeep);
              }
              return outputs.map(name => getTensor(name, tensorsMap, context));
          });
      }
/**
       * Executes the inference for given input tensors.
       * @param inputs Tensor map for the model inputs, keyed by the input node
       * names.
       * @param outputs Optional. output node name from the Tensorflow model, if
       * no outputs are specified, the default outputs of the model would be used.
       * You can inspect intermediate nodes of the model by adding them to the
       * outputs array.
       */
Executes the inference for given input tensors.
@param inputs Tensor map for the model inputs, keyed by the input node
names.
@param outputs Optional. output node name from the Tensorflow model, if
no outputs are specified, the default outputs of the model would be used.
You can inspect intermediate nodes of the model by adding them to the
outputs array.
Executes the inference for given input tensors . @param inputs Tensor map for the model inputs keyed by the input node names . @param outputs Optional . output node name from the Tensorflow model if no outputs are specified the default outputs of the model would be used . You can inspect intermediate nodes of the model by adding them to the outputs array .
execute(inputs, outputs) {
          inputs = this.mapInputs(inputs);
          const names = Object.keys(inputs).sort();
          this.checkInputs(inputs);
          this.checkInputShapeAndType(inputs);
          outputs = this.mapOutputs(outputs);
          this.checkOutputs(outputs);
          const inputNodes = names.map(name => this.graph.nodes[parseNodeName(name)[0]]);
          const outputNodeNames = outputs.map(name => parseNodeName(name)[0]);
          let outputNodes = outputNodeNames.map(name => this.graph.nodes[name]);
          if (outputNodes.length === 0) {
              outputNodes = this._outputs;
          }
          const compilationKey = this.getCompilationKey(inputNodes, outputNodes);
          let orderedNodes = this.compiledMap.get(compilationKey);
          if (orderedNodes == null) {
              orderedNodes = this.compile(inputs, outputNodes);
              this.compiledMap.set(compilationKey, orderedNodes);
          }
          const tensorArrayMap = {};
          const tensorListMap = {};
          return tfc.tidy(() => {
              const context = new ExecutionContext(this.weightMap, tensorArrayMap, tensorListMap, this.functionExecutorMap);
              const tensorsMap = Object.assign({}, this.weightMap);
              Object.keys(inputs).forEach(name => {
                  const [nodeName, index] = parseNodeName(name);
                  const tensors = [];
                  tensors[index] = inputs[name];
                  tensorsMap[nodeName] = tensors;
              });
              const tensorsToKeep = this.getFrozenTensorIds(tensorsMap);
              const intermediateTensorConsumerCount = {};
              for (let i = 0; i < orderedNodes.length; i++) {
                  const node = orderedNodes[i];
                  if (!tensorsMap[node.name]) {
                      const tensors = executeOp$h(node, tensorsMap, context, this._resourceManager);
                      if (tfc.util.isPromise(tensors)) {
                          throw new Error(`The execution of the op '${node.op}' returned a promise. ` +
                              `Please use model.executeAsync() instead.`);
                      }
                      tensorsMap[node.name] = tensors;
                      this.checkTensorForDisposal(node.name, node, tensorsMap, context, tensorsToKeep, outputNodeNames, intermediateTensorConsumerCount);
                  }
              }
              if (this.parent == null) {
                  context.dispose(tensorsToKeep);
              }
              return outputs.map(name => getTensor(name, tensorsMap, context));
          });
      }
execute ( inputs , outputs ) { inputs = this . mapInputs ( inputs ) ; const names = Object . keys ( inputs ) . sort ( ) ; this . checkInputs ( inputs ) ; this . checkInputShapeAndType ( inputs ) ; outputs = this . mapOutputs ( outputs ) ; this . checkOutputs ( outputs ) ; const inputNodes = names . map ( name => this . graph . nodes [ parseNodeName ( name ) [ 0 ] ] ) ; const outputNodeNames = outputs . map ( name => parseNodeName ( name ) [ 0 ] ) ; let outputNodes = outputNodeNames . map ( name => this . graph . nodes [ name ] ) ; if ( outputNodes . length === 0 ) { outputNodes = this . _outputs ; } const compilationKey = this . getCompilationKey ( inputNodes , outputNodes ) ; let orderedNodes = this . compiledMap . get ( compilationKey ) ; if ( orderedNodes == null ) { orderedNodes = this . compile ( inputs , outputNodes ) ; this . compiledMap . set ( compilationKey , orderedNodes ) ; } const tensorArrayMap = { } ; const tensorListMap = { } ; return tfc . tidy ( ( ) => { const context = new ExecutionContext ( this . weightMap , tensorArrayMap , tensorListMap , this . functionExecutorMap ) ; const tensorsMap = Object . assign ( { } , this . weightMap ) ; Object . keys ( inputs ) . forEach ( name => { const [ nodeName , index ] = parseNodeName ( name ) ; const tensors = [ ] ; tensors [ index ] = inputs [ name ] ; tensorsMap [ nodeName ] = tensors ; } ) ; const tensorsToKeep = this . getFrozenTensorIds ( tensorsMap ) ; const intermediateTensorConsumerCount = { } ; for ( let i = 0 ; i < orderedNodes . length ; i ++ ) { const node = orderedNodes [ i ] ; if ( ! tensorsMap [ node . name ] ) { const tensors = executeOp$h ( node , tensorsMap , context , this . _resourceManager ) ; if ( tfc . util . isPromise ( tensors ) ) { throw new Error ( ` ${ node . op } ` + ` ` ) ; } tensorsMap [ node . name ] = tensors ; this . checkTensorForDisposal ( node . name , node , tensorsMap , context , tensorsToKeep , outputNodeNames , intermediateTensorConsumerCount ) ; } } if ( this . parent == null ) { context . dispose ( tensorsToKeep ) ; } return outputs . map ( name => getTensor ( name , tensorsMap , context ) ) ; } ) ; }
Executes the inference for given input tensors.
Executes the inference for given input tensors .
// If no outputs are specified, then use the default outputs of the model. // Do nothing if the compiled graph cache contains the input. // dispose the context for the root executor