tfp.math.soft_sorting_matrix
Stay organized with collections
Save and categorize content based on your preferences.
Computes a matrix representing a continuous relaxation of sorting.
tfp.math.soft_sorting_matrix(
x, temperature, name=None
)
Given a vector x
, there exists a permutation matrix P_x
, when applied to
x
gives x
sorted in decreasing order. Here, we compute a continuous
relaxation of P_x
, parameterized by temperature
. This continuous
relaxation satisfies the property that it is a unimodal row-stochastic matrix,
meaning that all entries are non-negative, all rows sum to 1., and there is a
unique maximum entry in each column. The unique maximum entry will correspond
to the location of a 1
in the exact sorting permutation.
Complexity: Given a vector x
of size N
, this operation will take O(N**2)
time.
This is also known as a Neural sort in [1].
Args |
x
|
float Tensor . Argument to compute the relaxed sorting matrix with
respect to. The relaxed permutation is computed with respect to the last
axis.
|
temperature
|
Positive float Tensor. When temperatureapproaches zero,
this will retrieve the exact permutation matrix corresponding to sorting
from largest to smallest.
</td>
</tr><tr>
<td> name<a id="name"></a>
</td>
<td>
Python strname prefixed to Ops created by this function.
Default value: None(i.e., 'soft_sorting_matrix'`).
|
Returns |
soft_sort
|
A unimodal row-stochastic matrix. Applying this matrix on x
will in the limit of low temperature, sort it.
|
References
[1]: Aditya Grover, Eric Wang, Aaron Zweig, Stefano Ermon.
Stochastic Optimization of Sorting Networks via Continuous Relaxations.
https://arxiv.org/abs/1903.08850
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-11-21 UTC.
[null,null,["Last updated 2023-11-21 UTC."],[],[],null,["# tfp.math.soft_sorting_matrix\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/math/generic.py#L795-L844) |\n\nComputes a matrix representing a continuous relaxation of sorting. \n\n tfp.math.soft_sorting_matrix(\n x, temperature, name=None\n )\n\nGiven a vector `x`, there exists a permutation matrix `P_x`, when applied to\n`x` gives `x` sorted in decreasing order. Here, we compute a continuous\nrelaxation of `P_x`, parameterized by `temperature`. This continuous\nrelaxation satisfies the property that it is a unimodal row-stochastic matrix,\nmeaning that all entries are non-negative, all rows sum to 1., and there is a\nunique maximum entry in each column. The unique maximum entry will correspond\nto the location of a `1` in the exact sorting permutation.\n\nComplexity: Given a vector `x` of size `N`, this operation will take `O(N**2)`\ntime.\n\nThis is also known as a Neural sort in \\[1\\].\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `x` | `float` `Tensor`. Argument to compute the relaxed sorting matrix with respect to. The relaxed permutation is computed with respect to the last axis. |\n| `temperature` | Positive `float` Tensor`. When`temperature`approaches zero, this will retrieve the exact permutation matrix corresponding to sorting from largest to smallest. \u003c/td\u003e \u003c/tr\u003e\u003ctr\u003e \u003ctd\u003e`name`\u003ca id=\"name\"\u003e\u003c/a\u003e \u003c/td\u003e \u003ctd\u003e Python`str`name prefixed to Ops created by this function. Default value:`None`(i.e.,`'soft_sorting_matrix'\\`). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|-------------|------------------------------------------------------------------------------------------------------------|\n| `soft_sort` | A unimodal row-stochastic matrix. Applying this matrix on x will in the limit of low temperature, sort it. |\n\n\u003cbr /\u003e\n\n#### References\n\n\\[1\\]: Aditya Grover, Eric Wang, Aaron Zweig, Stefano Ermon.\nStochastic Optimization of Sorting Networks via Continuous Relaxations.\n\u003chttps://arxiv.org/abs/1903.08850\u003e"]]