Assume our model have two outputs :
output 1 'class' for classification
output 2 'location' for regression
Now we have the imbalance dataset(eg. binary classification, class '0': 98 percent, class '1': 2 percent), so we need set the class_weight params in model.fit() function, but for output 2 'location' regression task, we do not need class_weight.
How can we set the class_weight in this situation?
Does "class_weight = {0: ratio 1 , 1: ratio 2} is applied the classification task and ignore the regression task by default?
And a second situation is that:
output 1 'class_1' for classification
output 2 'class_2' for classification
Both outputs do the classification, but we want to give each output different class_weight params.
How can we do this? (I am not sure whether this situation makes sense or not. )
Maybe Like this?:
class_weight = { 'class_1': {0: ratio 1 , 1: ratio 2} , 'class_2': {0: ratio 3 , 1: ratio 4} }
You should pass a dict with string keys corresponding to the names of your
outputs. Like you describe.
On 15 December 2016 at 15:14, Ke Young notifications@github.com wrote:
And a second situation is that:
output 1 'class_1' for classification
output 2 'class_2' for classificationBoth outputs do the classification, but we want to give each output
different class_weight params.
How can we do this? (I am not sure whether this situation makes sense or
not. )
Maybe Like this?:
class_weight = { 'class_1': {0: ratio 1 , 1: ratio 2} , 'class_2': {0:
ratio 3 , 1: ratio 4} }—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/fchollet/keras/issues/4735#issuecomment-267472549,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AArWb6wWFGIUv7e82crHb9ggQ4M2oyAnks5rIcnJgaJpZM4LOrKk
.
Thanks for your quick response.
If we use the one-hot code.
For the two classes classification, should the class_weight like this? :
class_weight = {10: weight 1, 11: weight 2}
10 and 11 repesent the one hot codes of the two classes
No, use integers. 0 and 1.
On 15 December 2016 at 15:31, Ke Young notifications@github.com wrote:
Thanks for your quick response.
If we use the one-hot code.
For the two classes classification, should the class_weight like this? :
class_weight = {10: weight 1, 11: weight 2}
10 and 11 repesent the one hot codes of the two classes—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/fchollet/keras/issues/4735#issuecomment-267475515,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AArWb98elmzifptTjsU3SK1SYX-_wIT3ks5rIc23gaJpZM4LOrKk
.
@fchollet what is the right way to set weights given multi-class, one-hot encoded outputs? e.g. y = [0, 1, 1, 1, 0]
Yup. Same issue
@olix20 did you find a solution ?
For a multi output model how can I change class_weights during training ie after each step according to a batch.
In 2020 / TF 2.3.0 this does not work: class_weights = {'output1': {0: 1, 1: 10}, 'output2': {0: 5, 1: 1, 2: 10}}
Most helpful comment
@fchollet what is the right way to set weights given multi-class, one-hot encoded outputs? e.g. y = [0, 1, 1, 1, 0]