Trains a network for a project. Args: config : path to the yaml config file of the project shuffle : index of the shuffle we want to train on trainingsetindex : training set index modelprefix: directory containing the deeplabcut configuration files to use
(
config: str | Path,
shuffle: int = 1,
trainingsetindex: int = 0,
modelprefix: str = "",
device: str | None = None,
snapshot_path: str | Path | None = None,
detector_path: str | Path | None = None,
load_head_weights: bool = True,
batch_size: int | None = None,
epochs: int | None = None,
save_epochs: int | None = None,
detector_batch_size: int | None = None,
detector_epochs: int | None = None,
detector_save_epochs: int | None = None,
display_iters: int | None = None,
max_snapshots_to_keep: int | None = None,
pose_threshold: float | None = 0.1,
pytorch_cfg_updates: dict | None = None,
)
| 198 | |
| 199 | |
| 200 | def train_network( |
| 201 | config: str | Path, |
| 202 | shuffle: int = 1, |
| 203 | trainingsetindex: int = 0, |
| 204 | modelprefix: str = "", |
| 205 | device: str | None = None, |
| 206 | snapshot_path: str | Path | None = None, |
| 207 | detector_path: str | Path | None = None, |
| 208 | load_head_weights: bool = True, |
| 209 | batch_size: int | None = None, |
| 210 | epochs: int | None = None, |
| 211 | save_epochs: int | None = None, |
| 212 | detector_batch_size: int | None = None, |
| 213 | detector_epochs: int | None = None, |
| 214 | detector_save_epochs: int | None = None, |
| 215 | display_iters: int | None = None, |
| 216 | max_snapshots_to_keep: int | None = None, |
| 217 | pose_threshold: float | None = 0.1, |
| 218 | pytorch_cfg_updates: dict | None = None, |
| 219 | ) -> None: |
| 220 | """Trains a network for a project. |
| 221 | |
| 222 | Args: |
| 223 | config : path to the yaml config file of the project |
| 224 | shuffle : index of the shuffle we want to train on |
| 225 | trainingsetindex : training set index |
| 226 | modelprefix: directory containing the deeplabcut configuration files to use |
| 227 | to train the network (and where snapshots will be saved). By default, they |
| 228 | are assumed to exist in the project folder. |
| 229 | device: the torch device to train on (such as "cpu", "cuda", "mps") |
| 230 | snapshot_path: if resuming training, the snapshot from which to resume |
| 231 | detector_path: if resuming training of a top-down model, used to specify the |
| 232 | detector snapshot from which to resume |
| 233 | load_head_weights: if resuming training of a pose estimation model (either |
| 234 | through the `snapshot_path` attribute or the `resume_training_from` key in |
| 235 | the `pytorch_config.yaml` file), setting this to True also loads the weights |
| 236 | for the model head (equivalent to the `keepdeconvweights` for TensorFlow |
| 237 | models). Note that if you change the number of bodyparts, you need to set |
| 238 | this to false for re-training. |
| 239 | batch_size: overrides the batch size to train with |
| 240 | epochs: overrides the maximum number of epochs to train the model for |
| 241 | save_epochs: overrides the number of epochs between each snapshot save |
| 242 | detector_batch_size: Only for top-down models. Overrides the batch size with |
| 243 | which to train the detector. |
| 244 | detector_epochs: Only for top-down models. Overrides the maximum number of |
| 245 | epochs to train the model for. Setting to 0 means the detector will not be |
| 246 | trained. |
| 247 | detector_save_epochs: Only for top-down models. Overrides the number of epochs |
| 248 | between each snapshot of the detector is saved. |
| 249 | display_iters: overrides the number of iterations between each log of the loss |
| 250 | within an epoch |
| 251 | max_snapshots_to_keep: the maximum number of snapshots to save for each model |
| 252 | pose_threshold: Used for memory-replay. Pseudo-predictions with confidence lower |
| 253 | than this threshold are discarded for memory-replay |
| 254 | pytorch_cfg_updates: dict, optional, default = None. |
| 255 | A dictionary of updates to the pytorch config. The keys are the dot-separated |
| 256 | paths to the values to update in the config. |
| 257 | For example, to update the gpus to run the training on, you can use: |
no test coverage detected