Preferences¶
- weavenet.preference.batch_sum(matching, mat, batch_size)[source]¶
summate elements of mat filtered by matching for each sample in a batch.
- Shape:
matching: (B, ldots, N, M)
mat: (B, N, M)
output: (B, ldots)
- Parameters
matching (Tensor) – (continuous) matching results
mat (Tensor) – summation targets
batch_size (int) –
- Returns
\(\sum_{ij} (\text{matching}*\text{mat})\) for each sample and channel in a batch
- Return type
Tensor
- weavenet.preference.sat2rank(sat, dim=-1)[source]¶
convert satisfaction to rank
- Shape:
sat: (B, N, M)
output: (B, N, M)
- Parameters
sat (Tensor) – preference lists formatted in satisfaction.
dim – dim of agents’ matching targets.
- Returns
preference lists formatted in rank.
- Return type
Tensor
- weavenet.preference.cost2rank(cost, dim=-1)[source]¶
convert cost to rank
- Shape:
cost: (B, N, M)
output: (B, N, M)
- Parameters
cost (Tensor) – preference lists formatted in cost.
dim (int) – dim of agents’ matching targets.
- Returns
preference lists formatted in rank.
- Return type
Tensor
- weavenet.preference.sat2cost(sat, dim=-1)[source]¶
convert satisfaction to cost
- Shape:
sat: (B, N, M)
output: (B, N, M)
- Parameters
sat (Tensor) – preference lists formatted in satisfaction.
dim (int) – dim of agents’ matching targets.
- Returns
preference lists formatted in cost.
- Return type
Tensor
- weavenet.preference.cost2sat(cost, dim=-1)[source]¶
convert cost to satisfaction
- Shape:
cost: (B, N, M)
output: (B, N, M)
- Parameters
cost (Tensor) – preference lists formatted in cost.
dim (int) – dim of agents’ matching targets.
- Returns
preference lists formatted in satisfaction.
- Return type
Tensor
- weavenet.preference.to_cost(mat, pformat, dim=-1)[source]¶
convert mat to cost, where mat’s format is assumed to be pformat.
- Shape:
mat: (B, N, M)
output: (B, N, M)
- Parameters
mat (Tensor) – preference lists.
pformat (PreferenceFormat) – the format of sat
dim (int) – dim of agents’ matching targets.
- Returns
preference lists formatted in cost.
- Return type
Tensor
- weavenet.preference.to_sat(mat, pformat, dim=-1)[source]¶
convert mat to satisfaction, where mat’s format is assumed to be pformat.
- Shape:
mat: (B, N, M)
output: (B, N, M)
- Parameters
mat (Tensor) – preference lists.
pformat (PreferenceFormat) – the format of sat
dim (int) – dim of agents’ matching targets.
- Returns
preference lists formatted in satisfaction.
- Return type
Tensor
- weavenet.preference.to_rank(mat, pformat, dim=-1)[source]¶
convert mat to rank, where mat’s format is assumed to be pformat.
- Shape:
mat: (B, N, M)
output: (B, N, M)
- Parameters
mat (Tensor) – preference lists.
pformat (PreferenceFormat) – the format of sat
dim (int) – dim of agents’ matching targets.
- Returns
preference lists formatted in rank.
- Return type
Tensor