Giter Club home page Giter Club logo

octaveconv_pytorch's Introduction

Beyond Convolution

OctaveConv_pytorch

Pytorch implementation of recent operators

This is third parity implementation(un-official) of Following Paper.

  1. Drop an Octave: Reducing Spatial Redundancy in Convolutional Neural Networks with Octave Convolution(ICCV 2019). paper
  2. Adaptively Connected Neural Networks.(CVPR 2019) paper
  3. Res2net:A New Multi-scale Backbone Architecture(PAMI 2019) paper
  4. ScaleNet:Data-Driven Neuron Allocation for Scale Aggregation Networks (CVPR2019) paper
  5. SRM : A Style-based Recalibration Module for Convolutional Neural Networks paper
  6. SEnet: Squeeze-and-Excitation Networks(CVPR 2018) paper
  7. GEnet: Exploiting Feature Context in Convolutional Neural Networks(NIPS 2018) paper
  8. ECA-Net: Efficient Channel Attention for Deep Convolutional Neural Networks paper
  9. SK-Net: Selective Kernel Networks(CVPR 2019) paper
  10. More Net will be added.

Plan

  1. add Res2Net bolock with SE-layer (done)
  2. add Adaptive-Convolution: both pixel-aware and dataset-aware (done)
  3. Train code on Imagenet. (done)
  4. Add SE-like models. (done)
  5. Keep tracking with new proposed operators. (-)

Usage

check model files under the fig/nn floder.

from lib.nn.OCtaveResnet import resnet50
from lib.nn.res2net import se_resnet50
from lib.nn.AdaptiveConvResnet import PixelAwareResnet50, DataSetAwareResnet50

model = resnet50().cuda()
model = se_resnet50().cuda()
model = PixelAwareResnet50().cuda()
model = DataSetAwareResnet50().cuda()

Training

see exp floder for the detailed information

CheckPoint

Reference and Citation:

  1. OctaveConv: MXNet implementation here
  2. AdaptiveCov: Offical tensorflow implementation here
  3. ScaleNet: here
  4. SGENet:here

Please consider cite the author's paper when using the code for your research.

License

MIT License

octaveconv_pytorch's People

Contributors

lxtgh avatar parap1uie-s avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

octaveconv_pytorch's Issues

Strided convolutions handled incorrectly

Edit

Now I am not so sure, since a careful reading of the papers seems to show the authors believe that strided convolutions cause misaligned feature maps, which is an erroneous conclusion. I go into more detail in the linked issue, below.


Original issue text

X_h, X_l = self.h2g_pool(X_h), self.h2g_pool(X_l)

I don't think strided convolutions receive any special treatment in the paper. I think maybe there was some confusion about the discussion of how downsampling is implemented. That refers to the H->L downsampling operation, it does not refer to the way a strided convolution layer is ported to OctConv.

Since the paper is not explicit about strided convolutions, I assume they are ported to OctConv just as any other convolutional layer. So I would just use the given stride argument in each of the convolutions, L->L, L->H, H->L, H-H.

Unless somebody finds information to the contrary, this appears to be the only sensible reading of the paper.

there is a problem in "upsample"

  X_h = X_l2h + X_h2h
RuntimeError: The size of tensor a (6) must match the size of tensor b (7) at non-singleton dimension 3

because X_l comes from X_h throgh AvgPooling , when H×W=7×7, the output is 3×3.Through upsample, the result is 6×6, not 7×7

1d version

Thank you very much. I would welcome if you can share the 1d version of OctConv as well.

Handling different input and output number of channels in AdaptiveConv

In this line shouldn't we pass x to gap, otherwise if our input and output number of channels is different this will throw error, because x1 will have different number of channels than x and fc1 layers maps from number of input channels to number of output channels.

gap = self.gap(x1)

Please let me know if I am missing something.

training is slow

I tried to train oct_res50 on 4 TITAN X (Pascal). It took around 0.9 s/iter, while original res50 took around 0.4~0.5 s/iter. Is it reasonable?

the test speed

the test speed of the oct101 is 17fps is much slower than res101(55fps) ,is that right?

Why bias sharing?

Hi, lxtGH.

Thanks for the implement, however, there is some details that confused me.

As defined under this line

X_h2h = F.conv2d(X_h, self.weights[0:end_h_y, 0:end_h_x, :,:], self.bias[0:end_h_y], 1,
                        self.padding, self.dilation, self.groups)

X_l2l = F.conv2d(X_l, self.weights[end_h_y:, end_h_x:, :,:], self.bias[end_h_y:], 1,
                        self.padding, self.dilation, self.groups)

X_h2l = F.conv2d(X_h2l, self.weights[end_h_y:, 0: end_h_x, :,:], self.bias[end_h_y:], 1,
                        self.padding, self.dilation, self.groups)

X_l2h = F.conv2d(X_l, self.weights[0:end_h_y, end_h_x:, :,:], self.bias[0:end_h_y], 1,
                        self.padding, self.dilation, self.groups)

why the calculation of X_h2h and X_l2h sharing convolution bias? Which same as X_l2l and X_h2l.

I didn't find any details about bias sharing written in the paper, is this sharing reasonable?

Thanks in advance.

训练效果

你好,我实际应用于我的一个算法,替代resnet50,其他保持不变,但是发现训练速度明显变慢了,而且模型收敛反而更不好。不知道是和原因。

Training Strategy

Recently, I am doing experiments on octave convolution. Should I be getting the same performance as vanilla convolution neural network by keeping the learning strategy same while training my model with octave convolution or I might have to change my learning strategy in order to get the same performance as that of vanilla convolution neural network?

softmax in AdaptiveConv class

首先非常感谢您的代码,让人受益匪浅,在这里提一点发现的可能的问题:在文件resnet_adaptiveconv.py的class AdaptiveConv中的代码行“weight = self.softmax(self.w)”,看起来直接对shape为torch.Size([3, 1, 64, 64])的self.w按您代码中如下softmax并没起作用,操作后weight仍然是全1的矩阵

Bug and error in Octave conv

When I used the model in libs/nn/OCtaveResnet.py, I found tow things.

One is the stride of last Bottleneck is 2, which cause bug when using this model, because the input size of last Bottleneck is 1414 and 77, and after conv block of stride=2, there will be two tensor, 66 and 77 which can not be added together, bug comes. Setting the stride of last Bottleneck equals to 1 will solve this bug, with a little change of resnet.

Another one is about stride of Octaveconv2.py. I found that when stride=2, you still used conv layer with stride=1, and implement pooing(stride=2) before ocnv layer instead, which is totally different from conv layer with stride=2. I think the latter one is what author do in original paper.

Still, thanks for sharing your work!

Environment

Hi @lxtGH ,

Thank you for your contribution. It would be nice if you can share the required libraries(i.e. the version of pytorch). Just tiny advice.

some bugs

exp/train_val_step_se_resnet50.sh : tha last parameter name should be --warmup
libs/nn/res2net.py : line 57: missing paranthesis (generates syntax error)

Non-linearity in Res2Net

@lxtGH, thanks for the great repo.

I just have a question regarding your implementation of Res2Net. Your implementation has sub-convolution along with BN & ReLU.

https://github.com/lxtGH/OctaveConv_pytorch/blob/master/libs/nn/res2net.py#L57

However, I couldn't find any mention of non-linearity in the paper so it is bit unclear to me. Have you tested the performance with & without non-linearity? I think adding BN & ReLU to every sub conv might slow down the training process.

tensor dimension mismatching

Dear Sir, when I use nn.OCtaveResnet in image classification--input image size is [224,224,3], batch_size=72-- the shape of X_l2h doesn't match X_h2h (from OCtaveConv2--OCtaveConv).

WeChat597ca554349433817b1cda84c4e65668

it seems that it is something wrong with upsample. I don't know how to fix it

求助环境配置问题

你好,你能方便告知一下你的octconv所运行的环境,即pytorch的版本号,torchvision的版本号,cuda的版本号吗?我一调试就提示找不到transform的模块,希望得到你的帮助

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.