Giter Club home page Giter Club logo

nonlocalandsenet's Introduction

nonlocalandsenet's People

Contributors

willsuen avatar

Stargazers

atongmu_524 avatar htYan avatar justiceli avatar Aruen24 avatar  avatar  avatar lawy623 avatar 何飞 avatar Abraham Montoya avatar Mos Ming avatar  avatar Sun Qi avatar jiaxin avatar  avatar Liang Depeng avatar Hung Le avatar Meet Shah  avatar Lawrence avatar  avatar  avatar Yu Zheng avatar Aleksey Ushakov avatar ScutterKey avatar  avatar

Watchers

James Cloos avatar justiceli avatar  avatar  avatar paper2code - bot avatar

Forkers

keyky victorkkkk

nonlocalandsenet's Issues

Which one is better?

Senet and NL network. Which one is better in term of accuracy on imagenet and cifar dataset? Thanks

SE , SGE

作者你好,我想改动一个新的结构,是在SE的地方改动的,有点困惑,mxnet 的symbol,不能直接得到bchw的值,
pytorch 的SGE,一个实现架构语句, 对应你提供的模型SE代码位置修改的话,symbol每一层bn3 后边的bchw,我直接得不到,我要mxnet,实现这句话,b, c, h, w = x.size(), x = x.reshape(b * self.groups, -1, h, w) 我对mxnet 不是那么熟悉,不知道作者你有没有好的方式实现这句reshape
我在修改的地方
bn3 = mx.sym.BatchNorm(data=conv2, fix_gamma=False, eps=2e-5, momentum=bn_mom, name=name + '_bn3')
#if use_se:
if usr_sge:
得到 bn3的 bchw
然后reshape

下面是对应pytorch 实现

class SpatialGroupEnhance(nn.Module): # 3 2 1 hw is half, 311 is same size
def init(self, groups = 64):
super(SpatialGroupEnhance, self).init()
self.groups = groups
self.avg_pool = nn.AdaptiveAvgPool2d(1)
self.weight = Parameter(torch.zeros(1, groups, 1, 1))
self.bias = Parameter(torch.ones(1, groups, 1, 1))
self.sig = nn.Sigmoid()

def forward(self, x): # (b, c, h, w)
b, c, h, w = x.size()
x = x.view(b * self.groups, -1, h, w) ##reshape
xn = x * self.avg_pool(x) # x * global pooling(h,w change 1)
xn = xn.sum(dim=1, keepdim=True) #(b,1,h,w)
t = xn.view(b * self.groups, -1)
t = t - t.mean(dim=1, keepdim=True)
std = t.std(dim=1, keepdim=True) + 1e-5
t = t / std # normalize -mean/std
t = t.view(b, self.groups, h, w)
t = t * self.weight + self.bias
t = t.view(b * self.groups, 1, h, w)
x = x * self.sig(t) #in order to sigmod facter,this is group factor (0-1)
x = x.view(b, c, h, w) #get to varying degrees of importance,Restoration dimension
return x

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.