rslearn.train.tasks.embedding¶
embedding ¶
Embedding task.
EmbeddingTask ¶
Bases: Task
A dummy task for computing embeddings.
This task does not compute any targets or loss. Instead, it is just set up for inference, to save embeddings from the configured model.
Source code in rslearn/train/tasks/embedding.py
process_inputs ¶
process_inputs(raw_inputs: dict[str, Tensor], metadata: SampleMetadata, load_targets: bool = True) -> tuple[dict[str, Any], dict[str, Any]]
Processes the data into targets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_inputs
|
dict[str, Tensor]
|
raster or vector data to process |
required |
metadata
|
SampleMetadata
|
metadata about the patch being read |
required |
load_targets
|
bool
|
whether to load the targets or only inputs |
True
|
Returns:
| Type | Description |
|---|---|
tuple[dict[str, Any], dict[str, Any]]
|
tuple (input_dict, target_dict) containing the processed inputs and targets that are compatible with both metrics and loss functions |
Source code in rslearn/train/tasks/embedding.py
process_output ¶
process_output(raw_output: Any, metadata: SampleMetadata) -> NDArray[Any] | list[Feature]
Processes an output into raster or vector data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_output
|
Any
|
the output from prediction head, which must be a CxHxW tensor. |
required |
metadata
|
SampleMetadata
|
metadata about the patch being read |
required |
Returns:
| Type | Description |
|---|---|
NDArray[Any] | list[Feature]
|
either raster or vector data. |
Source code in rslearn/train/tasks/embedding.py
visualize ¶
visualize(input_dict: dict[str, Any], target_dict: dict[str, Any] | None, output: Any) -> dict[str, NDArray[Any]]
Visualize the outputs and targets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_dict
|
dict[str, Any]
|
the input dict from process_inputs |
required |
target_dict
|
dict[str, Any] | None
|
the target dict from process_inputs |
required |
output
|
Any
|
the prediction |
required |
Returns:
| Type | Description |
|---|---|
dict[str, NDArray[Any]]
|
a dictionary mapping image name to visualization image |
Source code in rslearn/train/tasks/embedding.py
EmbeddingHead ¶
Bases: Predictor
Head for embedding task.
It just adds a dummy loss to act as a Predictor.
Source code in rslearn/train/tasks/embedding.py
forward ¶
forward(intermediates: Any, context: ModelContext, targets: list[dict[str, Any]] | None = None) -> ModelOutput
Return the feature map along with a dummy loss.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intermediates
|
Any
|
output from the previous model component, which must be a FeatureMaps consisting of a single feature map. |
required |
context
|
ModelContext
|
the model context. |
required |
targets
|
list[dict[str, Any]] | None
|
the targets (ignored). |
None
|
Returns:
| Type | Description |
|---|---|
ModelOutput
|
model output with the feature map that was input to this component along with a dummy loss. |