rslearn.models.breakpoint_scan¶
breakpoint_scan ¶
Learned changepoint scan over the token (time) dimension of a TokenFeatureMaps.
BreakpointOutput ¶
Bases: StrEnum
Which feature of the changepoint scan a BreakpointScan returns.
Source code in rslearn/models/breakpoint_scan.py
BreakpointScan ¶
Bases: IntermediateComponent
Changepoint scan over the T chronological tokens at each spatial location.
The input is a BCHWT token feature map (one token per timestep). For every candidate split t in [0, T-2], the mean of the tokens up to and including t (the "before" aggregate A_t) and the mean of the tokens after t (the "after" aggregate B_t) are compared via |B_t - A_t| by a shared 1x1 conv scorer. Depending on the configured output, the component returns one of:
- EVIDENCE: the per-split hidden scorer features max-pooled over the splits (B x hidden x H x W). A decoder on this feature can only express "change" as a before-vs-after dissimilarity at some breakpoint.
- BEFORE / AFTER: the before and after aggregates weighted by a softmax over a scalar per-split score (B x C x H x W). These represent the state before and after the most likely breakpoint and are suitable for decoding the source and destination classes of a transition.
- BEFORE_AFTER: the channel concatenation of before and after (B x 2C x H x W).
We suggest using EVIDENCE if predicting whether a change occurred, BEFORE_AFTER if predicting a category of change, and BEFORE or AFTER individually if predicting a pre and post category about the conditions before and after the change.
If the input TokenFeatureMaps has masks, invalid tokens are excluded from the before/after means, and splits with no valid token on one side are excluded from the evidence max-pooling and the split-attention softmax.
Source code in rslearn/models/breakpoint_scan.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
forward ¶
forward(intermediates: Any, context: ModelContext) -> FeatureMaps
Apply the changepoint scan.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intermediates
|
Any
|
the output from the previous component, which must be a TokenFeatureMaps with a single BCHWT feature map. |
required |
context
|
ModelContext
|
the model context. |
required |
Returns:
| Type | Description |
|---|---|
FeatureMaps
|
a FeatureMaps with one BCHW map, the configured output of the scan. |