# tfg.geometry.representation.grid.generate

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/graphics/blob/master/tensorflow_graphics/geometry/representation/grid.py#L51-L128) |

Generates a M-D uniform axis-aligned grid.

    tfg.geometry.representation.grid.generate(
        starts, stops, nums, name='grid_generate'
    )

<br />

<br />

<br />

| ## Warning ||
|---|---|
| This op is not differentiable. Indeed, the gradient of tf.linspace and tf.meshgrid are currently not defined. ||

<br />

<br />

<br />

<br />

| ## Note ||
|---|---|
| In the following, `B` is an optional batch dimension. ||

<br />

<br />

<br />

<br />

| ## Args ||
|---|---|
| `starts` | A tensor of shape `[M]` or `[B, M]`, where the last dimension represents a M-D start point. |
| `stops` | A tensor of shape `[M]` or `[B, M]`, where the last dimension represents a M-D end point. |
| `nums` | A tensor of shape `[M]` representing the number of subdivisions for each dimension. |
| `name` | A name for this op. Defaults to "grid_generate". |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A tensor of shape `[nums[0], ..., nums[M-1], M]` containing an M-D uniform grid or a tensor of shape `[B, nums[0], ..., nums[M-1], M]` containing B M-D uniform grids. Please refer to the example below for more details. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If the shape of `starts`, `stops`, or `nums` is not supported. |

<br />

<br />

<br />

<br />

| ## Examples ||
|---|---|
| <br /> print(generate((-1.0, -2.0), (1.0, 2.0), (3, 5))) > > > \[\[\[-1. -2.\] > > > \[-1. -1.\] > > > \[-1. 0.\] > > > \[-1. 1.\] > > > \[-1. 2.\]\] > > > \[\[ 0. -2.\] > > > \[ 0. -1.\] > > > \[ 0. 0.\] > > > \[ 0. 1.\] > > > \[ 0. 2.\]\] > > > \[\[ 1. -2.\] > > > \[ 1. -1.\] > > > \[ 1. 0.\] > > > \[ 1. 1.\] > > > \[ 1. 2.\]\]\] Generates a 3x5 2d grid from -1.0 to 1.0 with 3 subdivisions for the x axis and from -2.0 to 2.0 with 5 subdivisions for the y axis. This lead to a tensor of shape (3, 5, 2). <br /> ||

<br />