# tfg.geometry.representation.mesh.sampler.weighted_random_sample_triangle_mesh

<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/mesh/sampler.py#L247-L332) |

Performs a face probability weighted random sampling of a tri mesh.

    tfg.geometry.representation.mesh.sampler.weighted_random_sample_triangle_mesh(
        vertex_attributes: type_alias.TensorLike,
        faces: type_alias.TensorLike,
        num_samples: int,
        face_weights: type_alias.TensorLike,
        seed: Optional[type_alias.TensorLike] = None,
        stateless: bool = False,
        name: str = 'weighted_random_sample_triangle_mesh'
    ) -> Tuple[type_alias.TensorLike, type_alias.TensorLike]

<br />

<br />

<br />

| ## Note ||
|---|---|
| In the following, A1 to An are optional batch dimensions. ||

<br />

<br />

<br />

<br />

| ## Args ||
|---|---|
| `vertex_attributes` | A `float` tensor of shape `[A1, ..., An, V, D]`, where V is the number of vertices, and D is dimensionality of each vertex. |
| `faces` | A `int` tensor of shape `[A1, ..., An, F, 3]`, where F is the number of faces. |
| `num_samples` | A `int` 0-D tensor denoting number of samples to be drawn from each mesh. |
| `face_weights` | A `float` tensor of shape \``[A1, ..., An, F]`, denoting unnormalized sampling probability of each face, where F is the number of faces. |
| `seed` | Optional random seed. |
| `stateless` | Optional flag to use stateless random sampler. If stateless=True, then seed must be provided as shape `[2]` int tensor. Stateless random sampling is useful for testing to generate same sequence across calls. |
| `name` | Name for op. Defaults to "weighted_random_sample_triangle_mesh". |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| `sample_points` | A `float` tensor of shape `[A1, ..., An, num_samples, D]`, where D is dimensionality of each sampled point. |
| `sample_face_indices` | A `int` tensor of shape `[A1, ..., An, num_samples]`. |

<br />