<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/ops/numpy.py#L8421-L8460) |

Turn a function into a vectorized function.

#### View aliases


**Main aliases**

[`tf.keras.ops.numpy.vectorize`](https://www.tensorflow.org/api_docs/python/tf/keras/ops/vectorize)

<br />

    tf.keras.ops.vectorize(
        pyfunc, *, excluded=None, signature=None
    )

#### Example:

    def myfunc(a, b):
        return a + b

    vfunc = keras.ops.vectorize(myfunc)
    y = vfunc([1, 2, 3, 4], 2)  # Returns Tensor([3, 4, 5, 6])

<br />

<br />

<br />

| ## Args ||
|---|---|
| `pyfunc` | Callable of a single tensor argument. |
| `excluded` | Optional set of integers representing positional arguments for which the function will not be vectorized. These will be passed directly to `pyfunc` unmodified. |
| `signature` | Optional generalized universal function signature, e.g., `"(m,n),(n)->(m)"` for vectorized matrix-vector multiplication. If provided, `pyfunc` will be called with (and expected to return) arrays with shapes given by the size of corresponding core dimensions. By default, `pyfunc` is assumed to take scalars tensors as input and output. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A new function that applies `pyfunc` to every element of its input along axis 0 (the batch axis). ||

<br />