Deep learning 如何计算例外论文中的可分离卷积?
我读了这篇论文(甚至有一个描述NN的例子),它谈到了可分离卷积。 我试图理解它们是如何精确计算的。我没有把它留给不精确的词,而是在下面包含了一段伪代码,它总结了我的理解。代码从18x18x728要素图映射到18x18x1024要素图:Deep learning 如何计算例外论文中的可分离卷积?,deep-learning,conv-neural-network,Deep Learning,Conv Neural Network,我读了这篇论文(甚至有一个描述NN的例子),它谈到了可分离卷积。 我试图理解它们是如何精确计算的。我没有把它留给不精确的词,而是在下面包含了一段伪代码,它总结了我的理解。代码从18x18x728要素图映射到18x18x1024要素图: XSIZE = 18; YSIZE = 18; ZSIZE = 728; ZSIXE2 = 1024; float mapin[XSIZE][YSIZE][ZSIZE]; // Input map float imap[XSIZE][YSIZE][ZSIZE2
XSIZE = 18;
YSIZE = 18;
ZSIZE = 728;
ZSIXE2 = 1024;
float mapin[XSIZE][YSIZE][ZSIZE]; // Input map
float imap[XSIZE][YSIZE][ZSIZE2]; // Intermediate map
float mapout[XSIZE][YSIZE][ZSIZE2]; // Output map
float wz[ZSIZE][ZSIZE2]; // Weights for 1x1 convs
float wxy[3][3][ZSIZE2]; // Weights for 3x3 convs
// Apply 1x1 convs
for(y=0;y<YSIZE;y++)
for(x=0;x<XSIZE;x++)
for(o=0;o<ZSIZE2;o++){
s=0.0;
for(z=0;z<ZSIZE;z++)
s+=mapin[x][y][z]*wz[z][o];
imap[x][y][o]=s;
}
// Apply 2D 3x3 convs
for(o=0;o<ZSIZE2;o++)
for(y=0y<YSIZE;y++)
for(x=0;x<XSIZE;x++){
s=0.0;
for(i=-1;i<2;i++)
for(j=-1;j<2;j++)
s+=imap[x+j][y+i][o]*wxy[j+1][i+1][o]; // This value is 0 if falls off the edge
mapout[x][y][o]=s;
}
XSIZE=18;
YSIZE=18;
ZSIZE=728;
ZSIXE2=1024;
float-mapin[XSIZE][YSIZE][ZSIZE];//输入映射
浮点imap[XSIZE][YSIZE][ZSIZE2];//中间图
浮点映射输出[XSIZE][YSIZE][ZSIZE2];//输出映射
浮动wz[ZSIZE][ZSIZE2];//1x1转换的权重
浮点数wxy[3][3][ZSIZE2];//3x3转换的重量
//应用1x1转换
对于(y=0;y,我在Tensorflow中找到了tf.nn.separable_conv2d,正好做到了这一点。因此,我构建了一个非常简单的图,并借助随机数,尝试获得上面的代码以匹配结果。正确的代码是:
XSIZE = 18;
YSIZE = 18;
ZSIZE = 728;
ZSIXE2 = 1024;
float mapin[XSIZE][YSIZE][ZSIZE]; // Input map
float imap[XSIZE][YSIZE][ZSIZE]; // Intermediate map
float mapout[XSIZE][YSIZE][ZSIZE2]; // Output map
float wxy[3][3][ZSIZE]; // Weights for 3x3 convs
float wz[ZSIZE][ZSIZE2]; // Weights for 1x1 convs
// Apply 2D 3x3 convs
for(o=0;o<ZSIZE;o++)
for(y=0y<YSIZE;y++)
for(x=0;x<XSIZE;x++){
s=0.0;
for(i=-1;i<2;i++)
for(j=-1;j<2;j++)
s+=mapin[x+j][y+i][o]*wxy[j+1][i+1][o]; // This value is 0 if falls off the edge
imap[x][y][o]=s;
}
// Apply 1x1 convs
for(y=0;y<YSIZE;y++)
for(x=0;x<XSIZE;x++)
for(o=0;o<ZSIZE2;o++){
s=0.0;
for(z=0;z<ZSIZE;z++)
s+=imap[x][y][z]*wz[z][o];
mapout[x][y][o]=s;
}
XSIZE=18;
YSIZE=18;
ZSIZE=728;
ZSIXE2=1024;
浮点映射[XSIZE][YSIZE][ZSIZE];//输入映射
浮点imap[XSIZE][YSIZE][ZSIZE];//中间映射
浮点映射输出[XSIZE][YSIZE][ZSIZE2];//输出映射
浮点wxy[3][3][ZSIZE];//3x3转换的权重
浮点wz[ZSIZE][ZSIZE2];//1x1转换的权重
//应用2D 3x3转换
对于(o=0;o