achgls / music-genre-classification

Music genre classification project as part of the Numerical Analysis for Machine Learning course at Politecnico di Milano, A.Y 2022-2023.
2 stars 1 forks source link

Not accounting for potentially smaller final batch at gradient computation in training loop #3

Open achgls opened 1 week ago

achgls commented 1 week ago

File: train.py Function: train_one_epoch(...)

Description:

Assuming reduction method set to 'mean'(default) for loss function and drop_last set to False(default) for DataLoader, calling loss.backward() without accounting for potentially smaller size of the final batch could yield disproportionate effects on parameter update (and more generally, the optimizer behaviour).

Proposed solutions:

achgls commented 1 week ago

Issue discovered on commit 84bbff10e1d619f29c1f590457ab3635a77503da