torchrelay.itertools
Same as the itertools python package, but in pytorch.
Overview
|
Cartesian product of a set. |
|
|
All possible r-length permutations of a set. |
|
|
Return the inverse of a permutation. |
product
Cartesian product of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs |
iterable of tensor_like
|
Input sets (tensors are flattened is not vectors)
with |
()
|
r |
int
|
Repeats. keyword argument only |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
output |
(prod(n)**r, r) tensor
|
Cartesian product |
permutations
All possible r-length permutations of a set.
Note
This function loops over the number of input elements, It can therefore be slow if this number is large.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input |
tensor_like
|
Input vector (tensor is flattened is not a vector)
with |
required |
r |
int
|
Length of the permutation vectors |
n
|
Returns:
| Name | Type | Description |
|---|---|---|
output |
(k, r) tensor
|
All possible |
invert_permutation
Return the inverse of a permutation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
perm |
(..., N) tensor_like
|
Permutations. A permutation is a shuffled set of indices. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
iperm |
(..., N) tensor
|
Inverse permutation. |
Examples: