On 13.04.2017 12:31,
jie....@gmail.com wrote:
> We know that we can pass a class weights dictionary in the fit method
> for imbalanced data in binary classification model. My question is that,
> when using only 1 node in the output layer with sigmoid activation, can
> we still apply the class weights during the training?
Sure, it will work just fine.
The type of output of the network does not actually matter when
specifying weights, because weights are applied to the all output
gradients, not just to a specific output—which, I suspect, is a
misconception you might have.
Besides, if you follow the call stack of the `train` method, you will
see that it invokes an internal `_standardize_user_data` method [1],
which translates class weights into sample weights. In fact, class
weights in Keras is just a convenience API, so that you don't have to
generate sample weights on your own.
[1]
https://github.com/fchollet/keras/blob/2.0.3/keras/engine/training.py#L1277
--
Tomasz Melcer