* Returns the loss value & metrics values for the model in test mode. * * Loss and metrics are specified during `compile()`, which needs to happen * before calls to `evaluate()`. * * Computation is done in batches. * * ```js * const model = tf.sequential({ * layers: [tf.
(
x: Tensor|Tensor[], y: Tensor|Tensor[],
args: ModelEvaluateArgs = {})
| 838 | * @doc {heading: 'Models', subheading: 'Classes'} |
| 839 | */ |
| 840 | evaluate( |
| 841 | x: Tensor|Tensor[], y: Tensor|Tensor[], |
| 842 | args: ModelEvaluateArgs = {}): Scalar|Scalar[] { |
| 843 | const batchSize = args.batchSize == null ? 32 : args.batchSize; |
| 844 | checkBatchSize(batchSize); |
| 845 | |
| 846 | // TODO(cais): Standardize `config.sampleWeights` as well. |
| 847 | // Validate user data. |
| 848 | const checkBatchAxis = true; |
| 849 | const standardizedOuts = |
| 850 | this.standardizeUserDataXY(x, y, checkBatchAxis, batchSize); |
| 851 | try { |
| 852 | // TODO(cais): If uses `useLearningPhase`, set the corresponding element |
| 853 | // of the input to 0. |
| 854 | const ins = standardizedOuts[0].concat(standardizedOuts[1]); |
| 855 | this.makeTestFunction(); |
| 856 | const f = this.testFunction; |
| 857 | const testOuts = |
| 858 | this.testLoop(f, ins, batchSize, args.verbose, args.steps); |
| 859 | return singletonOrArray(testOuts); |
| 860 | } finally { |
| 861 | disposeNewTensors(standardizedOuts[0], x); |
| 862 | disposeNewTensors(standardizedOuts[1], y); |
| 863 | } |
| 864 | } |
| 865 | |
| 866 | // TODO(cais): Add code snippet below once real dataset objects are |
| 867 | // available. |
no test coverage detected