Gets reweighting for loss function while training multi-class classifier.
(dataset_y)
| 9 | |
| 10 | |
| 11 | def get_weights(dataset_y): |
| 12 | """ |
| 13 | Gets reweighting for loss function while training multi-class classifier. |
| 14 | """ |
| 15 | counts = torch.zeros(dataset_y.max() + 1) |
| 16 | for y in dataset_y: |
| 17 | counts[y] += 1 |
| 18 | # --- Weight is "count of everything else / count" --- |
| 19 | weights = (torch.sum(counts) - counts) / counts |
| 20 | print(weights) |
| 21 | return weights |
| 22 | |
| 23 | |
| 24 | class BTC_ETH_Hour_Day_Week_Dataset(Dataset): |
no outgoing calls
no test coverage detected