MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / evaluate_generator

Method evaluate_generator

tensorflow/python/keras/engine/training.py:1298–1363  ·  view source on GitHub ↗

Evaluates the model on a data generator. The generator should return the same kind of data as accepted by `test_on_batch`. Arguments: generator: Generator yielding tuples (inputs, targets) or (inputs, targets, sample_weights) or an instance of `keras.uti

(self,
                         generator,
                         steps=None,
                         callbacks=None,
                         max_queue_size=10,
                         workers=1,
                         use_multiprocessing=False,
                         verbose=0)

Source from the content-addressed store, hash-verified

1296 steps_name='steps_per_epoch')
1297
1298 def evaluate_generator(self,
1299 generator,
1300 steps=None,
1301 callbacks=None,
1302 max_queue_size=10,
1303 workers=1,
1304 use_multiprocessing=False,
1305 verbose=0):
1306 """Evaluates the model on a data generator.
1307
1308 The generator should return the same kind of data
1309 as accepted by `test_on_batch`.
1310
1311 Arguments:
1312 generator: Generator yielding tuples (inputs, targets)
1313 or (inputs, targets, sample_weights)
1314 or an instance of `keras.utils.Sequence`
1315 object in order to avoid duplicate data
1316 when using multiprocessing.
1317 steps: Total number of steps (batches of samples)
1318 to yield from `generator` before stopping.
1319 Optional for `Sequence`: if unspecified, will use
1320 the `len(generator)` as a number of steps.
1321 callbacks: List of `keras.callbacks.Callback` instances.
1322 List of callbacks to apply during evaluation.
1323 See [callbacks](/api_docs/python/tf/keras/callbacks).
1324 max_queue_size: maximum size for the generator queue
1325 workers: Integer. Maximum number of processes to spin up
1326 when using process-based threading.
1327 If unspecified, `workers` will default to 1. If 0, will
1328 execute the generator on the main thread.
1329 use_multiprocessing: Boolean.
1330 If `True`, use process-based threading.
1331 If unspecified, `use_multiprocessing` will default to `False`.
1332 Note that because this implementation relies on multiprocessing,
1333 you should not pass non-picklable arguments to the generator
1334 as they can't be passed easily to children processes.
1335 verbose: Verbosity mode, 0 or 1.
1336
1337 Returns:
1338 Scalar test loss (if the model has a single output and no metrics)
1339 or list of scalars (if the model has multiple outputs
1340 and/or metrics). The attribute `model.metrics_names` will give you
1341 the display labels for the scalar outputs.
1342
1343 Raises:
1344 ValueError: in case of invalid arguments.
1345
1346 Raises:
1347 ValueError: In case the generator yields data in an invalid format.
1348 """
1349 if self._distribution_strategy:
1350 raise NotImplementedError('`evaluate_generator` is not supported for '
1351 'models compiled with tf.distribute.Strategy.')
1352 _keras_api_gauge.get_cell('evaluate_generator').set(True)
1353 self._check_call_args('evaluate_generator')
1354
1355 return training_generator.evaluate_generator(

Calls 3

_check_call_argsMethod · 0.95
setMethod · 0.45
get_cellMethod · 0.45