MultitaskReadout#
- class core.nn.MultitaskReadout(dim, readout_specs, task_index)[source]#
Bases:
torch.nn.modules.module.ModuleLinear readout with one head per task, routed by integer index.
- Parameters:
dim (
int) – Dimensionality of the incoming output embeddings.readout_specs (
Mapping[str,ReadoutSpec]) – Task name toibl_bwb_eval.tasks.ReadoutSpec. Keys name the projections and the entries of the returned dicts.task_index (
Mapping[str,int]) – Task name to the integer written intooutput_readout_index. Routing uses these, notReadoutSpec.id, which is a string.
- forward(output_embs, output_readout_index, unpack_output=False)[source]#
Project padded output embeddings through their per-task heads.
- Parameters:
- Return type:
- Returns:
{task_name: (total_queries, n_channels)}, or a list of such dicts with(n_queries, n_channels)entries whenunpack_outputis set.
- forward_varlen(output_embs, output_readout_index, output_batch_index, unpack_output=False)[source]#
Project chained output embeddings through their per-task heads.
As
forward(), but for sequences chained along a single batch dimension rather than padded, which avoids the padding memory.- Parameters:
- Return type:
- Returns:
See
forward().