Task
flyvision.task.tasks ¶
Task ¶
Defines a task for a multi-task dataset from configurations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset |
Namespace
|
Configuration for the dataset. |
required |
decoder |
Namespace
|
Configuration for the decoder. |
required |
loss |
Namespace
|
Configuration for the loss functions. |
required |
batch_size |
int
|
Size of each batch. Defaults to 4. |
4
|
n_iters |
int
|
Number of iterations. Defaults to 250,000. |
250000
|
n_folds |
int
|
Number of folds for cross-validation. Defaults to 4. |
4
|
fold |
int
|
Current fold number. Defaults to 1. |
1
|
seed |
int
|
Random seed for reproducibility. Defaults to 0. |
0
|
original_split |
bool
|
Whether to use the original data split. Defaults to False. |
False
|
Attributes:
Name | Type | Description |
---|---|---|
batch_size |
Size of each batch. |
|
n_iters |
Number of iterations. |
|
n_folds |
Number of folds for cross-validation. |
|
fold |
Current fold number. |
|
seed |
Random seed for reproducibility. |
|
decoder |
Configuration for the decoder. |
|
dataset |
MultiTaskDataset
|
The initialized multi-task dataset. |
losses |
Namespace
|
Loss functions for each task. |
train_seq_index |
List[int]
|
Indices of training sequences. |
val_seq_index |
List[int]
|
Indices of validation sequences. |
train_data |
DataLoader
|
DataLoader for training data. |
train_batch |
DataLoader
|
DataLoader for a single training batch. |
val_data |
DataLoader
|
DataLoader for validation data. |
val_batch |
DataLoader
|
DataLoader for a single validation batch. |
overfit_data |
DataLoader
|
DataLoader for overfitting on a single sample. |
Source code in flyvision/task/tasks.py
18 19 20 21 22 23 24 25 26 27 28 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 161 162 163 164 165 166 167 168 |
|
init_decoder ¶
init_decoder(connectome)
Initialize the decoder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
connectome |
ConnectomeFromAvgFilters
|
The connectome directory. |
required |
Returns:
Type | Description |
---|---|
Dict[str, ActivityDecoder]
|
A dictionary of initialized decoders. |
Source code in flyvision/task/tasks.py
123 124 125 126 127 128 129 130 131 132 133 134 |
|
loss ¶
loss(input, target, task, **kwargs)
Returns the task loss multiplied with the task weight.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input |
Tensor
|
Input tensor. |
required |
target |
Tensor
|
Target tensor. |
required |
task |
str
|
Task name. |
required |
**kwargs |
Additional keyword arguments for the loss function. |
{}
|
Returns:
Type | Description |
---|---|
Tensor
|
Weighted task loss. |
Source code in flyvision/task/tasks.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
init_task_weights ¶
init_task_weights(task_weights)
Returns the task weights.
Returns:
Type | Description |
---|---|
Dict[str, float]
|
A dictionary of task weights. |
Source code in flyvision/task/tasks.py
156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
init_decoder ¶
init_decoder(config, connectome)
Initialize decoders.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
Dict
|
Configuration for the decoders. |
required |
connectome |
ConnectomeFromAvgFilters
|
The connectome directory. |
required |
Returns:
Type | Description |
---|---|
Dict[str, ActivityDecoder]
|
A dictionary of decoders. |
Example
decoder = Namespace(
flow=Namespace(
type="DecoderGAVP",
shape=[8, 2],
kernel_size=5,
const_weight=0.001,
p_dropout=0.5,
),
depth=Namespace(
type="DecoderGAVP",
shape=[8, 1],
kernel_size=5,
const_weight=0.001,
p_dropout=0.5,
),
lum=Namespace(
type="DecoderGAVP",
shape=[8, 3],
n_out_features=2,
kernel_size=5,
const_weight=0.001,
p_dropout=0.5,
),
shared=False,
)
Source code in flyvision/task/tasks.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|
flyvision.task.objectives ¶
Loss functions compatible with torch loss function API.
l2norm ¶
l2norm(y_est, y_gt, **kwargs)
Calculate the mean root cumulative squared error across the last three dimensions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_est |
Tensor
|
The estimated tensor. |
required |
y_gt |
Tensor
|
The ground truth tensor. |
required |
**kwargs |
Any
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Tensor
|
The mean root cumulative squared error. |
Source code in flyvision/task/objectives.py
10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
epe ¶
epe(y_est, y_gt, **kwargs)
Calculate the average endpoint error, conventionally reported in optic flow tasks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y_est |
Tensor
|
The estimated tensor with shape (samples, frames, ndim, hexals_or_features). |
required |
y_gt |
Tensor
|
The ground truth tensor with the same shape as y_est. |
required |
**kwargs |
Any
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Tensor
|
The average endpoint error. |
Source code in flyvision/task/objectives.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|