Category Archives: PyTorch
Micro and Macro Averages for imbalance multiclass classification
A macro-average will compute the metric independently for each class and then take the average hence treating all classes equally, whereas a micro-average will aggregate the contributions of all classes to compute the average metric.
How to change the learning rate in the PyTorch using Learning Rate Scheduler?
The optimal learning rate will be dependent on both your model architecture and your dataset. While using a default learning rate may provide decent results, you can often improve the performance or speed up training by searching for an optimal learning rate.
How to deal with an imbalanced dataset using WeightedRandomSampler in PyTorch.
We use something called samplers for OverSampling. Though we did not use samplers exclusively, PyTorch used it for us internally. When we say shuffle=False, PyTorch ended up using SequentialSampler it gives an index from zero to the length of the dataset. When shuffle=True it ends up using a RandomSampler.
How to modify pre-train PyTorch model for Finetuning and Feature Extraction?
classification layer of the pre-trained model is specific to the original classification task, and subsequently specific to the set of classes on which the model was trained. You simply add a new classifier layer, which will be trained from scratch.
How to use class weight in CrossEntropyLoss for an imbalanced dataset?
how to create a loss function for an imbalanced dataset in which minority class proportionally to its underrepresentation. You will use PyTorch to define the loss function and class weights to help the model learn from the imbalanced data.