machine learning - Torch7 using weights with unbalanced training sets -


i using crossentropycriterion convnet. have 150 classes , number of training files per class very unbalanced (5 2000 files). according documentation, can compensate using weights:

criterion = nn.crossentropycriterion([weights]) 

"if provided, optional argument weights should 1d tensor assigning weight each of classes. particularly useful when have unbalanced training set."

what format should weights in? eg: number training files in class n / total number of training files.

i assume want balance training in meaning, small class becomes more important. in general there infinitely many possible weightings leading various results. 1 of simpliest ones, assumes each class should equally important (thus efficiently drop empirical prior) put weight proportional to

1 / # samples_in_class 

for example

weight_of_class_y = # all_samples / # samples_in_y 

this way if have 5:2000 dissproportion, smaller class becomes 400 times more important model.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -