rslearn.models.trunk¶
trunk ¶
Trunk module for decoder.
DecoderTrunkLayer ¶
Bases: Module, ABC
Trunk layer for decoder.
Source code in rslearn/models/trunk.py
forward
abstractmethod
¶
Forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
input tensor of shape (batch_size, seq_len, dim) |
required |
task_embedding
|
Tensor | None
|
task embedding tensor of shape (batch_size, dim), or None |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Tensor]
|
dict with key "outputs" (output tensor of shape (batch_size, seq_len, dim)) |
dict[str, Tensor]
|
and optionally other keys. |
Source code in rslearn/models/trunk.py
apply_auxiliary_losses
abstractmethod
¶
apply_auxiliary_losses(trunk_out: dict[str, Any], outs: ModelOutput) -> None
Apply auxiliary losses in-place.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trunk_out
|
dict[str, Any]
|
The output of the trunk. |
required |
outs
|
ModelOutput
|
The output of the decoders, with key "loss_dict" containing the losses. |
required |
Source code in rslearn/models/trunk.py
DecoderTrunk ¶
Bases: Module
Trunk module for decoder, including arbitrary layers plus an optional task embedding.
Source code in rslearn/models/trunk.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
register_tasks ¶
Register tasks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_names
|
list[str]
|
list of task names |
required |
forward ¶
Forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
list[tensor]
|
The encoder features, a 1-list of B x C x H x W features. |
required |
inputs
|
list[dict[str, Any]]
|
The original inputs to the encoder. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict with key "outputs" (output tensor of shape (batch_size, seq_len, dim)) |
dict[str, Any]
|
and optionally other keys from the other layers. |
Source code in rslearn/models/trunk.py
apply_auxiliary_losses ¶
apply_auxiliary_losses(trunk_out: dict[str, Any], outs: ModelOutput) -> None
Apply auxiliary losses in-place.
Each layer handles its own auxiliary losses, assuming the loss key is loss_dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trunk_out
|
dict[str, Any]
|
The output of the trunk. |
required |
outs
|
ModelOutput
|
The output of the decoders. |
required |