Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modularity计算出来为负值是什么原因? #1

Closed
Z-Yh-June opened this issue Jun 18, 2022 · 3 comments
Closed

modularity计算出来为负值是什么原因? #1

Z-Yh-June opened this issue Jun 18, 2022 · 3 comments

Comments

@Z-Yh-June
Copy link

Z-Yh-June commented Jun 18, 2022

您好!我用的自己的数据集在resnet18上用了您的方法做了模块化程度的计算,提取的是relu层之后的特征,发现计算每层modularity会出现负值,这是什么原因呢?之后又尝试提取bn层后的特征还是有大量的负值存在,请问这是正常现象么?

一下是几次计算的结果,len( modularity )=17层
modularity: [-0.019196462265709934, -0.02271897533277316, -0.023171874127450653, -0.022470118258014187, -0.01645792102456704, -0.018011648884517804, -0.010016131091073174, -0.02012415433281817, -0.00993257811055065, -0.008657139629071227, -0.010918394908571914, -0.009388655522269241, -0.002584169673622568, -0.0005555165491241826, -0.012236681334620234, -0.013657490194399866, -0.001615048060680923]

modularity: [-0.009842042437187018, -0.009372720350310716, -0.012085664778406252, 0.005141147857948121, 0.010048463577370794, 0.00018423969515977273, -0.0030635190699569922, -0.00026638565957969734, -0.010287994904722021, -0.012399507863719801, -0.008366178789636743, -0.0032961831139690576, -0.006384714434207794, 0.0067996706828107704, -0.005832453918450487, 0.009217809629457067, -0.006108037287940963]

[-0.008759199831022697, -0.036767948297815836, -0.029265369915441954, -0.025968150236407347, -0.025383781534253247, -0.019468812859621223, -0.012428653247791372, -0.0227319975256084, -0.028128953521547748, -0.02349360946111945, -0.024317913360711686, -0.02071382370153553, -0.02179457870885567, -0.015504702593439782, -0.0127327671915606, -0.005047404214200173, -0.01602515198867172]

@yaolu-zjut
Copy link
Owner

您好,这是正常现象,模块度的值是为负说明类内的连接不如类间连接紧密,此外本文是直接用卷积层之后的特征计算模块度的,你可以再尝试一下。

@Z-Yh-June
Copy link
Author

感谢您的回复!根据您的建议我按卷积层之后的特征计算模块度,但还是与之前无差。请问您的实验中有出现为负数的情况么?还是说对计算出的模块度进行了归一化处理。还有就是,每次bachsize个样本输入到网络后计算的模块度都不一样,并且还差的挺多的,请问您是对每次的数据各层的模块度进行了相加求均值的处理么?

@yaolu-zjut
Copy link
Owner

您好,我的实验中计算结果在前几层是会存在负数的情况,对于特征,我是直接使用卷积层后面的特征reshape成一维进行实验的,至于batchsize,我一般取500(确保您batchsize>topk*类别数),然后进行多次实验取平均。对于您的这种情况,我猜测可能是您数据集的相似性过高?使得他计算相似性矩阵的时候挑不出正确的类。另我们在实验中是把整个resnet的block当作一个layer,因此resnet18只有9层。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants