Instantiates a Keras function. Arguments: inputs: List of placeholder tensors. outputs: List of output tensors. updates: List of update ops. name: String, name of function. **kwargs: Passed to `tf.Session.run`. Returns: Output values as Numpy arrays. Rais
(inputs, outputs, updates=None, name=None, **kwargs)
| 3647 | |
| 3648 | @keras_export('keras.backend.function') |
| 3649 | def function(inputs, outputs, updates=None, name=None, **kwargs): |
| 3650 | """Instantiates a Keras function. |
| 3651 | |
| 3652 | Arguments: |
| 3653 | inputs: List of placeholder tensors. |
| 3654 | outputs: List of output tensors. |
| 3655 | updates: List of update ops. |
| 3656 | name: String, name of function. |
| 3657 | **kwargs: Passed to `tf.Session.run`. |
| 3658 | |
| 3659 | Returns: |
| 3660 | Output values as Numpy arrays. |
| 3661 | |
| 3662 | Raises: |
| 3663 | ValueError: if invalid kwargs are passed in or if in eager execution. |
| 3664 | """ |
| 3665 | if ops.executing_eagerly_outside_functions(): |
| 3666 | if kwargs: |
| 3667 | raise ValueError('Session keyword arguments are not support during ' |
| 3668 | 'eager execution. You passed: %s' % (kwargs,)) |
| 3669 | return EagerExecutionFunction(inputs, outputs, updates=updates, name=name) |
| 3670 | |
| 3671 | if kwargs: |
| 3672 | for key in kwargs: |
| 3673 | if (key not in tf_inspect.getfullargspec(session_module.Session.run)[0] |
| 3674 | and key not in ['inputs', 'outputs', 'updates', 'name']): |
| 3675 | msg = ('Invalid argument "%s" passed to K.function with TensorFlow ' |
| 3676 | 'backend') % key |
| 3677 | raise ValueError(msg) |
| 3678 | return GraphExecutionFunction(inputs, outputs, updates=updates, **kwargs) |
| 3679 | |
| 3680 | |
| 3681 | @keras_export('keras.backend.gradients') |