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

Method predict

tfjs-layers/src/engine/training.ts:1105–1120  ·  view source on GitHub ↗

* Generates output predictions for the input samples. * * Computation is done in batches. * * Note: the "step" mode of predict() is currently not supported. * This is because the TensorFlow.js core backend is imperative only. * * ```js * const model = tf.sequential({ *

(x: Tensor|Tensor[], args: ModelPredictArgs = {})

Source from the content-addressed store, hash-verified

1103 * @doc {heading: 'Models', subheading: 'Classes'}
1104 */
1105 predict(x: Tensor|Tensor[], args: ModelPredictArgs = {}): Tensor|Tensor[] {
1106 const xsRank2OrHigher = ensureTensorsRank2OrHigher(x);
1107 checkInputData(
1108 xsRank2OrHigher, this.inputNames, this.feedInputShapes, false);
1109 try {
1110 // TODO(cais): Take care of stateful models.
1111 // if (this.stateful) ...
1112 // TODO(cais): Take care of the learning_phase boolean flag.
1113 // if (this.useLearningPhase) ...
1114 const batchSize = args.batchSize == null ? 32 : args.batchSize;
1115 checkBatchSize(batchSize);
1116 return this.predictLoop(xsRank2OrHigher, batchSize);
1117 } finally {
1118 disposeNewTensors(xsRank2OrHigher, x);
1119 }
1120 }
1121
1122 /**
1123 * Returns predictions for a single batch of samples.

Callers

nothing calls this directly

Calls 5

predictLoopMethod · 0.95
checkBatchSizeFunction · 0.90
disposeNewTensorsFunction · 0.90
checkInputDataFunction · 0.85

Tested by

no test coverage detected