前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >神经网络架构搜索——可微分搜索(SGAS)​

神经网络架构搜索——可微分搜索(SGAS)​

作者头像
AI异构
发布2020-07-29 15:18:08
9530
发布2020-07-29 15:18:08
举报
文章被收录于专栏:AI异构AI异构

神经网络架构搜索——可微分搜索(SGAS)

KAUST&Intel发表在CVPR 2020上的NAS工作,针对现有DARTS框架在搜索阶段具有高验证集准确率的架构可能在评估阶段表现不好的问题,提出了分解神经网络架构搜索过程为一系列子问题,SGAS使用贪婪策略选择并剪枝候选操作的技术,在搜索CNN和GCN网络架构均达到了SOTA。

  • Paper: SGAS: Sequential Greedy Architecture Search
  • Code: https://github.com/lightaime/sgas

动机

NAS技术都有一个通病:在搜索过程中验证精度较高,但是在实际测试精度却没有那么高。传统的基于梯度搜索的DARTS技术,是根据block构建更大的超网,由于搜索的过程中验证不充分,最终eval和test精度会出现鸿沟。从下图的Kendall系数来看,DARTS搜出的网络精度排名和实际训练完成的精度排名偏差还是比较大。

"Accuracy GAP"

方法

整体思路

本文使用与DARTS相同的搜索空间,SGAS搜索过程简单易懂,如下图所示。类似DARTS搜索过程为每条边指定参数α,超网训练时通过文中判定规则逐渐确定每条边的具体操作,搜索结束后即可得到最终模型。

SGAS架构示意图

算法伪代码

为了保证在贪心搜索的过程中能尽量保证搜索的全局最优性,进而引入了三个指标两个评估准则

三个指标
边的重要性

非零操作参数对应的softmax值求和,作为边的重要性衡量指标。

S_{E I}^{(i, j)}=\sum_{o \in \mathcal{O}, o \neq z e r o} \frac{\exp \left(\alpha_{o}^{(i, j)}\right)}{\sum_{o^{\prime} \in \mathcal{O}} \exp \left(\alpha_{o^{\prime}}^{(i, j)}\right)}
代码语言:javascript
复制
alphas = []
for i in range(4):
    for n in range(2 + i):
        alphas.append(Variable(1e-3 * torch.randn(8)))
# alphas经过训练后
mat = F.softmax(torch.stack(alphas, dim=0), dim=-1).detach() # mat为14*8维度的二维列表,softmax归一化。 
EI = torch.sum(mat[:, 1:], dim=-1) # EI为14个数的一维列表,去掉none后的7个ops对应alpha值相加
选择的准确性

计算操作分布的标准化熵,熵越小确定性越高;熵越高确定性越小。

\begin{array}{c} p_{o}^{(i, j)}=\frac{\exp \left(\alpha_{o}^{(i, j)}\right)}{S_{E I}^{(i, j)} \sum_{o^{\prime} \in \mathcal{O}} \exp \left(\alpha_{o^{\prime}}^{(i, j)}\right)}, o \in \mathcal{O}, o \neq z e r o \\ S_{S C}^{(i, j)}=1-\frac{-\sum_{o \in \mathcal{O}, o \neq z e r o} p_{o}^{(i, j)} \log \left(p_{o}^{(i, j)}\right)}{\log (|\mathcal{O}|-1)} \end{array}
代码语言:javascript
复制
import torch.distributions.categorical as cate
probs = mat[:, 1:] / EI[:, None]
entropy = cate.Categorical(probs=probs).entropy() / math.log(probs.size()[1])
SC = 1-entropy
选择的稳定性

将历史信息纳入操作分布评估,使用直方图交叉核计算平均选择稳定性。直方图交叉核的原理详见(https://blog.csdn.net/hong__fang/article/details/50550656)。

S_{S S}^{(i, j)}=\frac{1}{K} \sum_{t=T-K}^{T-1} \sum_{o_{t} \in \mathcal{O}, o_{t} \neq z e r o} \min \left(p_{o_{t}}^{(i, j)}, p_{o_{T}}^{(i, j)}\right)
代码语言:javascript
复制
def histogram_intersection(a, b):
  c = np.minimum(a.cpu().numpy(),b.cpu().numpy())
  c = torch.from_numpy(c).cuda()
  sums = c.sum(dim=1)
  return sums

def histogram_average(history, probs):
  histogram_inter = torch.zeros(probs.shape[0], dtype=torch.float).cuda()
  if not history:
    return histogram_inter
  for hist in history:
    histogram_inter += utils.histogram_intersection(hist, probs)
  histogram_inter /= len(history)
  return histogram_inter

probs_history = []

probs_history.append(probs)
if (len(probs_history) > args.history_size):
  probs_history.pop(0)
  
histogram_inter = histogram_average(probs_history, probs)

SS = histogram_inter
两种评估准则
评估准则1:

选择具有高边缘重要性和高选择确定性的操作

S_{1}^{(i, j)}=\text { normalize }\left(S_{E I}^{(i, j)}\right) * \text { normalize }\left(S_{S C}^{(i, j)}\right)
代码语言:javascript
复制
def normalize(v):
  min_v = torch.min(v)
  range_v = torch.max(v) - min_v
  if range_v > 0:
    normalized_v = (v - min_v) / range_v
  else:
    normalized_v = torch.zeros(v.size()).cuda()

  return normalized_v

score = utils.normalize(EI) * utils.normalize(SC)
评估准则2:

在评估准则1的基础上,加入考虑选择稳定性

S_{2}^{(i, j)}=S_{1}^{(i, j)} * \text { normalize }\left(S_{S S}^{(i, j)}\right)
代码语言:javascript
复制
score = utils.normalize(EI) * utils.normalize(SC) * utils.normalize(SS)

实验结果

CIFAR-10(CNN)

CIFAR-10(CNN)

ImageNet(CNN)

ImageNet(CNN)

ModelNet40(GCN)

ModelNet40(GCN)

PPI(GCN)

PPI(GCN)

参考

[1] Li, Guohao et al. ,SGAS: Sequential Greedy Architecture Search

[2] https://zhuanlan.zhihu.com/p/134294068

[3] 直方图交叉核 https://blog.csdn.net/hong__fang/article/details/50550656

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-05-27,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 AI异构 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 神经网络架构搜索——可微分搜索(SGAS)
    • 动机
      • 方法
        • 整体思路
        • 三个指标
        • 两种评估准则
      • 实验结果
        • CIFAR-10(CNN)
        • ImageNet(CNN)
        • ModelNet40(GCN)
        • PPI(GCN)
      • 参考
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档