I am using convolution neural network.
My data is quite imbalanced, I have two classes.
My first class contains: 551,462 image files
My second class contains: 52,377 image files
I want to use weighted_cross_entropy_with_logits
, but I'm not sure I'm calculating pos_weight
variable correctly.
Right now I'm using
classes_weights = tf.constant([0.0949784, 1.0])
cross_entropy = tf.reduce_mean(tf.nn.weighted_cross_entropy_with_logits(logits=logits, targets=y_, pos_weight=classes_weights))
train_step = tf.train.AdamOptimizer(LEARNING_RATE, epsilon=1e-03).minimize(
cross_entropy
, global_step=global_step
)
Or should I use
classes_weights = 10.5287