Generates output predictions for the input samples. Computation is done in batches. Arguments: x: Input samples. It could be: - A Numpy array (or array-like), or a list of arrays (in case the model has multiple inputs). - A TensorFlow tensor, or a li
(self,
x,
batch_size=None,
verbose=0,
steps=None,
callbacks=None,
max_queue_size=10,
workers=1,
use_multiprocessing=False)
| 832 | use_multiprocessing=use_multiprocessing) |
| 833 | |
| 834 | def predict(self, |
| 835 | x, |
| 836 | batch_size=None, |
| 837 | verbose=0, |
| 838 | steps=None, |
| 839 | callbacks=None, |
| 840 | max_queue_size=10, |
| 841 | workers=1, |
| 842 | use_multiprocessing=False): |
| 843 | """Generates output predictions for the input samples. |
| 844 | |
| 845 | Computation is done in batches. |
| 846 | |
| 847 | Arguments: |
| 848 | x: Input samples. It could be: |
| 849 | - A Numpy array (or array-like), or a list of arrays |
| 850 | (in case the model has multiple inputs). |
| 851 | - A TensorFlow tensor, or a list of tensors |
| 852 | (in case the model has multiple inputs). |
| 853 | - A `tf.data` dataset. |
| 854 | - A generator or `keras.utils.Sequence` instance. |
| 855 | batch_size: Integer or `None`. |
| 856 | Number of samples per gradient update. |
| 857 | If unspecified, `batch_size` will default to 32. |
| 858 | Do not specify the `batch_size` is your data is in the |
| 859 | form of symbolic tensors, dataset, |
| 860 | generators, or `keras.utils.Sequence` instances (since they generate |
| 861 | batches). |
| 862 | verbose: Verbosity mode, 0 or 1. |
| 863 | steps: Total number of steps (batches of samples) |
| 864 | before declaring the prediction round finished. |
| 865 | Ignored with the default value of `None`. If x is a `tf.data` |
| 866 | dataset and `steps` is None, `predict` will |
| 867 | run until the input dataset is exhausted. |
| 868 | callbacks: List of `keras.callbacks.Callback` instances. |
| 869 | List of callbacks to apply during prediction. |
| 870 | See [callbacks](/api_docs/python/tf/keras/callbacks). |
| 871 | max_queue_size: Integer. Used for generator or `keras.utils.Sequence` |
| 872 | input only. Maximum size for the generator queue. |
| 873 | If unspecified, `max_queue_size` will default to 10. |
| 874 | workers: Integer. Used for generator or `keras.utils.Sequence` input |
| 875 | only. Maximum number of processes to spin up when using |
| 876 | process-based threading. If unspecified, `workers` will default |
| 877 | to 1. If 0, will execute the generator on the main thread. |
| 878 | use_multiprocessing: Boolean. Used for generator or |
| 879 | `keras.utils.Sequence` input only. If `True`, use process-based |
| 880 | threading. If unspecified, `use_multiprocessing` will default to |
| 881 | `False`. Note that because this implementation relies on |
| 882 | multiprocessing, you should not pass non-picklable arguments to |
| 883 | the generator as they can't be passed easily to children processes. |
| 884 | |
| 885 | |
| 886 | Returns: |
| 887 | Numpy array(s) of predictions. |
| 888 | |
| 889 | Raises: |
| 890 | ValueError: In case of mismatch between the provided |
| 891 | input data and the model's expectations, |