GithubHelp home page GithubHelp logo

walsvid / coordconv Goto Github PK

View Code? Open in Web Editor NEW
144.0 3.0 27.0 242 KB

Pytorch implementation of "An intriguing failing of convolutional neural networks and the CoordConv solution" - https://arxiv.org/abs/1807.03247

License: MIT License

Python 27.34% Jupyter Notebook 72.66%
coordconv pytorch computer-vision deep-learning pytorch-implmention pytorch-cnn convolution

coordconv's Introduction

CoordConv

Pytorch implementation of CoordConv for N-D ConvLayers, and the experiments.

Reference from the paper: An intriguing failing of convolutional neural networks and the CoordConv solution

Extends the CoordinateChannel concatenation from 2D to 1D and 3D tensors.

Requirements

  • pytorch 0.4.0
  • torchvision 0.2.1
  • torchsummary 1.3
  • sklearn 0.19.1

Usage

from coordconv import CoordConv1d, CoordConv2d, CoordConv3d

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.coordconv = CoordConv2d(2, 32, 1, with_r=True)
        self.conv1 = nn.Conv2d(32, 64, 1)
        self.conv2 = nn.Conv2d(64, 64, 1)
        self.conv3 = nn.Conv2d(64,  1, 1)
        self.conv4 = nn.Conv2d( 1,  1, 1)

    def forward(self, x):
        x = self.coordconv(x)
        x = F.relu(self.conv1(x))
        x = F.relu(self.conv2(x))
        x = F.relu(self.conv3(x))
        x = self.conv4(x)
        x = x.view(-1, 64*64)
        return x

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
net = Net().to(device)

Experiments

Implement experiments from origin paper.

Coordinate Classification

Use experiments/generate_data.py to generate Uniform and Quadrant datasets for Coordinate Classification task.

Use experiments/train_and_test.py to train and test neural network model.

Uniform Datasets

Train Test Predictions

Quadrant Datasets

Train Test Predictions

coordconv's People

Contributors

walsvid avatar wassname 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

coordconv's Issues

doesnt seem to work on quadrant data

Hi, thanks for sharing the code. The jupyter notebook is very helpful indeed, but it doesn't seem to work on the quadrant data whereas the same code works fine for the uniform data. Anybody else facing this problem?

Question about generate_data.py

Although it does not affect the final results,
please consider this minor change in your code to reflect the original paper contents

It will be helpful for debugging

paper :

## bias is basically neglected in tensorflow
onehots = np.pad(np.eye(3136).reshape((3136, 56, 56, 1)), ((0,0), (4,4), (4,4), (0,0)), "constant");  
images = tf.nn.conv2d(onehots, np.ones((9, 9, 1, 1)), [1]*4, "SAME")

code as is :

conv_layer = nn.Conv2d(in_channels=1, out_channels=1, kernel_size=(9, 9), padding=4, stride=1)

code to be:

conv_layer = nn.Conv2d(in_channels=1, out_channels=1, kernel_size=(9, 9), padding=4, stride=1, bias=False)

Training time increases linearly for each epoch.

Currently, I have been using this implementation for one of my object detection models.
As the model is training, batch processing time increases linearly. I still haven't figured out why.

Does anyone see a similar behavior?

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.