Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

[Develop] Hot-fix drop_last to cls task #79

Merged
merged 1 commit into from
Nov 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions mpa/cls/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,12 @@ def train_worker(gpu, dataset, cfg, distributed, validate, timestamp, meta):
# prepare data loaders
dataset = dataset if isinstance(dataset, (list, tuple)) else [dataset]
train_data_cfg = Stage.get_data_cfg(cfg, "train")
drop_last = train_data_cfg.drop_last if train_data_cfg.get('drop_last', False) else False

ote_dataset = train_data_cfg.get('ote_dataset', None)
drop_last = False
dataset_len = len(ote_dataset) if ote_dataset else 0
# if task == h-label & dataset size is bigger than batch size
if train_data_cfg.get('hierarchical_info', None) and dataset_len > cfg.data.get('samples_per_gpu', 2):
drop_last = True
# updated to adapt list of dataset for the 'train'
data_loaders = []
sub_loaders = []
Expand Down