embedding#

ivy.embedding(weights, indices, /, *, max_norm=None, out=None)[source]#

Embeds a given tensor of indices using a given tensor of weights.

Parameters:
  • weights (Union[Array, NativeArray]) – The weights tensor.

  • indices (Union[Array, NativeArray]) – The indices tensor.

  • max_norm (Optional[int], default: None) – The maximum norm of the embeddings.

  • out (Optional[Array], default: None) – Optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Array

Returns:

ret – The result of the embedding operation.

Examples

>>> weights = ivy.array([[1., 2., 3.], [4., 5., 6.], [7., 8., 9.]])
>>> indices = ivy.array([0, 2])
>>> print(ivy.embedding(weights, indices, max_norm=5))
ivy.array([[1.        , 2.        , 3.        ],
       [2.51285338, 2.87183261, 3.2308116 ]])
Array.embedding(self, indices, /, *, max_norm=None, out=None)[source]#
Return type:

Array

Container.embedding(self, indices, /, *, max_norm=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container