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

Method evaluate

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

* 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 = {})

Source from the content-addressed store, hash-verified

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.

Callers 3

training_test.tsFile · 0.45
container_test.tsFile · 0.45
fitDatasetFunction · 0.45

Calls 7

standardizeUserDataXYMethod · 0.95
makeTestFunctionMethod · 0.95
testLoopMethod · 0.95
checkBatchSizeFunction · 0.90
singletonOrArrayFunction · 0.90
disposeNewTensorsFunction · 0.90
concatMethod · 0.65

Tested by

no test coverage detected