cfzd / FcaNet

FcaNet: Frequency Channel Attention Networks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

关于math.sqrt(POS)

Asthestarsfalll opened this issue · comments

您好,感谢您的代码。
请问这里的除以根号和乘以根号是起到类似求平均的作用吗?
image
为什么不直接在空间维度求和时直接进行.mean()呢

commented

@Asthestarsfalll
这个其实是DCT基函数的定义,在文章中我们为了简化起见去掉了这些缩放因子。可能直接去掉或者求mean也可以,我们这个地方保持了和一般的DCT一样的运算。

@cfzd
好的,感谢您的回答。
另外请问是否能分享论文中进行单个频率分量实验时的预训练模型和代码,我对此有些思考,想进行下对比实验。
再次感谢您。

commented

@Asthestarsfalll
如果想进行单个频率分量实验的话,可以简单的override以下这个函数:

FcaNet/model/layer.py

Lines 5 to 27 in aa5fb63

def get_freq_indices(method):
assert method in ['top1','top2','top4','top8','top16','top32',
'bot1','bot2','bot4','bot8','bot16','bot32',
'low1','low2','low4','low8','low16','low32']
num_freq = int(method[3:])
if 'top' in method:
all_top_indices_x = [0,0,6,0,0,1,1,4,5,1,3,0,0,0,3,2,4,6,3,5,5,2,6,5,5,3,3,4,2,2,6,1]
all_top_indices_y = [0,1,0,5,2,0,2,0,0,6,0,4,6,3,5,2,6,3,3,3,5,1,1,2,4,2,1,1,3,0,5,3]
mapper_x = all_top_indices_x[:num_freq]
mapper_y = all_top_indices_y[:num_freq]
elif 'low' in method:
all_low_indices_x = [0,0,1,1,0,2,2,1,2,0,3,4,0,1,3,0,1,2,3,4,5,0,1,2,3,4,5,6,1,2,3,4]
all_low_indices_y = [0,1,0,1,2,0,1,2,2,3,0,0,4,3,1,5,4,3,2,1,0,6,5,4,3,2,1,0,6,5,4,3]
mapper_x = all_low_indices_x[:num_freq]
mapper_y = all_low_indices_y[:num_freq]
elif 'bot' in method:
all_bot_indices_x = [6,1,3,3,2,4,1,2,4,4,5,1,4,6,2,5,6,1,6,2,2,4,3,3,5,5,6,2,5,5,3,6]
all_bot_indices_y = [6,4,4,6,6,3,1,4,4,5,6,5,2,2,5,1,4,3,5,0,3,1,1,2,4,2,1,1,5,3,3,3]
mapper_x = all_bot_indices_x[:num_freq]
mapper_y = all_bot_indices_y[:num_freq]
else:
raise NotImplementedError
return mapper_x, mapper_y

例如我只想以第0个或第9个频率做实验,那么我只需修改上述函数为:

return [0], [0] # for 0th freq
return [1], [2] # for 9th freq

关于模型的问题,因为总共有49个模型,不是特别容易分享,我可能需要打包上传到Google drive再分享给你。

PS 我们最近也遇到一个新的问题,就是现在论文中单个频率的实验可能会涉及到验证集的问题,我们已经重新跑了这个实验了(重新划分了train和val,并且不涉及原来imagenet的验证集),而且论文也会一并修改掉,我后续上传模型的也应该是这个setting下的。

@cfzd
感谢,49个模型上传过于麻烦,可以只分享文中提到的100个epoch的base model吗?
祝你们实验顺利!

@Asthestarsfalll

您好,我们的base model直接使用的是pytorch官方提供的预训练模型,在单个频域分量上训练时使用0.02的学习率,对整个模型finetune20个epoch。

@peterzpy 好的,非常感谢!