* 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 = {})
| 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. |
nothing calls this directly
no test coverage detected