MCPcopy Create free account
hub / github.com/Modulus-Labs/RockyBot / get_weights

Function get_weights

pytorch-model/datasets.py:11–21  ·  view source on GitHub ↗

Gets reweighting for loss function while training multi-class classifier.

(dataset_y)

Source from the content-addressed store, hash-verified

9
10
11def 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
24class BTC_ETH_Hour_Day_Week_Dataset(Dataset):

Callers 3

get_weightsMethod · 0.85
get_weightsMethod · 0.85
get_weightsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected