focal loss、importance sampling、 adaptive batch normlization

本文介绍了深度学习中的三种优化技术:focal loss用于解决类别不平衡问题,特别是对于密集目标检测;重要性采样是一种在复杂分布下进行蒙特卡洛积分的策略;而适应性批量归一化(ABN)则适用于训练和测试样本分布不一致的情况,特别是在模型迁移学习中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

focal loss

Focal Loss for Dense Object Detection,ICCV 2017, RBG和Kaiming大神

  • 作者提出focal loss的出发点是:希望one-stage detector可以达到two-stage detector的准确率,同时不影响原有的速度。
  • one-stage detector的准确率不如two-stage detector的原因,作者认为原因是:样本的类别不均衡导致的
  • 不平衡导致的后果:负样本数量太大,占总的loss的大部分,而且多是容易分类的,因此使得模型的优化方向并不是我们所希望的那样。
  • OHEM(online hard example mining):OHEM算法虽然增加了错分类样本的权重,但是OHEM算法忽略了容易分类的样本。
  • focal loss,在标准交叉熵损失基础上修改得到的:
    a. 这个函数首先通过 α\alphaα 给正负样本加上权重,负样本出现的频次多,那么就降低负样本的权重,正样本数量少,就相对提高正样本的权重。因此可以通过设定a的值来控制正负样本对总的loss的共享权重。
### Importance Sampling in Computer Science and Machine Learning Importance sampling is a variance reduction technique used extensively within Monte Carlo methods, particularly useful when estimating properties of a particular distribution while only having samples generated from another distribution rather than the target one. This method allows for more efficient estimation by focusing on regions where the integrand has higher values. In machine learning, importance sampling can be applied to various scenarios such as evaluating expectations under complex distributions or optimizing models through stochastic gradient descent variants like weighted SGD. By adjusting sample weights according to their likelihood ratio between source and target densities, this approach helps mitigate issues related to rare events simulation and improves convergence rates during optimization processes[^1]. #### Implementation Example Using Python Below demonstrates how one might implement an importance sampler for approximating expectation over some arbitrary function \( f(x) \): ```python import numpy as np def importance_sampling(f, p_target, q_proposal, num_samples=1000): """Estimate E_p[f(X)] via importance sampling.""" # Draw samples from proposal distribution Q xs = q_proposal.rvs(size=num_samples) # Compute unnormalized weight w_i = P(x)/Q(x) ws_unnorm = p_target.pdf(xs) / q_proposal.pdf(xs) # Normalize weights so they sum up to 1 ws_normed = ws_unnorm / np.sum(ws_unnorm) # Estimate expected value using normalized weights estimate = np.dot(ws_normed.T, f(xs)) return estimate # Define your own functions here... from scipy.stats import norm, cauchy p_target = norm(loc=0., scale=1.) # Target N(0,1) q_proposal = cauchy(loc=0., scale=2.) # Proposal Cauchy(0,2) f = lambda x: x ** 2 # Function we want to compute its mean wrt p_target estimate = importance_sampling(f=f, p_target=p_target, q_proposal=q_proposal, num_samples=int(1e6)) print("Estimated Expectation:", estimate) ``` This code snippet illustrates basic usage of importance sampling algorithm implemented directly without relying upon any specialized libraries beyond NumPy/SciPy. It estimates the second moment (\(\mathbb{E}[X^2]\)) of standard normal variable X but uses Cauchy distribution instead as auxiliary density due to heavy tails property making it suitable candidate for demonstrating effectiveness against naive MC estimator.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值