Page 149 - 《软件学报》2021年第11期
P. 149
宋冰冰 等:自动化张量分解加速卷积神经网络 3475
④
Parameter ① ②
Acc calculation and Trained model Compressed Group
initialization Tensor model searching
decomposition
Parameter Best model
③ estimation
Fig.7 Auto acceleration CNN based on parameter estimation
图 7 基于参数估计的自动化加速 CNN
算法 1. 基于参数估计的自动化加速 CNN 算法.
Input:原模型卷积层参数 W[i],i 表示第几个卷积核;张量分解加速后模型的容忍精度 Acc.
Output:输出最优秩选择方案 Progm.
1: L=W.lenth,S[i]=sum(W[i].shape),Num_W (i) =multiply(W[i].shape),PER=[1,sum(Num_W)]
2: while (PER[1]−PER[0])/sum(S)>2 do
3: PE=(PER[1]+PER[0])/2
4: Rank[1,…,L] //由公式(26)计算每层秩
5: if model_acc(Rank)>Acc then PER[1]=PE //model_acc 返回分解后模型的准确率
6: else PER[0]=PE
7: end
8: Combn[1,…,L]=0 //秩的组合
9: Group[1]=[1,…,Max_Rank[1]] //Max_Rank 公式(28)
10: Level=1
11: while Level>0 do
12: while Level!=L do
13: if group[level].lenth==Combn[Level] then
14: Level−=1
15: break
16: else
17: Combn[Level]+=1
18: Level+=1
19: Group[Level]=[1,…,Max_Rank[Level]] //Max_Rank 公式(28)
20: if Level!=L then Combn[Level]=0
21: if Level==L then
22: time, Best_rank=top_one(Combn,Group) //查找最优秩以及模型加速时间
23: Combn[Level]=Best_rank
24: Progm.add([time,Combn.copy])
25: end
26: end
27: return Progm.min(key=time)