Dar*_*tis 2 python artificial-intelligence machine-learning convolution tensorflow
我正在使用卷积神经网络。
我的数据很不平衡,我有两个班级。
我的第一堂课包含:551,462 个图像文件
我的第二堂课包含:52,377 个图像文件
我想使用weighted_cross_entropy_with_logits,但我不确定我pos_weight是否正确计算了变量。
现在我正在使用
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
)
Run Code Online (Sandbox Code Playgroud)
或者我应该使用
classes_weights = 10.5287
从文档:
pos_weight:用于正例的系数。
和
参数 pos_weight 用作正目标的乘数:
所以如果你的第一堂课是积极的,那么pos_weights = 52,377 / 551,462,否则551,462 / 52,377