All Projects → Fangyh09 → Pytorch Receptive Field

Fangyh09 / Pytorch Receptive Field

Compute CNN receptive field size in pytorch in one line

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pytorch Receptive Field

Adnet
Attention-guided CNN for image denoising(Neural Networks,2020)
Stars: ✭ 135 (-15.62%)
Mutual labels:  cnn
Self Driving Car 3d Simulator With Cnn
Implementing a self driving car using a 3D Driving Simulator. CNN will be used for training
Stars: ✭ 143 (-10.62%)
Mutual labels:  cnn
Awesome Speech Recognition Speech Synthesis Papers
Automatic Speech Recognition (ASR), Speaker Verification, Speech Synthesis, Text-to-Speech (TTS), Language Modelling, Singing Voice Synthesis (SVS), Voice Conversion (VC)
Stars: ✭ 2,085 (+1203.13%)
Mutual labels:  cnn
Vpilot
Scripts and tools to easily communicate with DeepGTAV. In the future a self-driving agent will be implemented.
Stars: ✭ 136 (-15%)
Mutual labels:  cnn
Image classifier
CNN image classifier implemented in Keras Notebook 🖼️.
Stars: ✭ 139 (-13.12%)
Mutual labels:  cnn
Visualizing cnns
Using Keras and cats to visualize layers from CNNs
Stars: ✭ 143 (-10.62%)
Mutual labels:  cnn
Webml Polyfill
A polyfill for Web Neural Network (WebNN) API
Stars: ✭ 133 (-16.87%)
Mutual labels:  cnn
Simple cnn
Simple Convolutional Neural Network Library
Stars: ✭ 158 (-1.25%)
Mutual labels:  cnn
Brdnet
Image denoising using deep CNN with batch renormalization(Neural Networks,2020)
Stars: ✭ 141 (-11.87%)
Mutual labels:  cnn
Dcrnn pytorch
Diffusion Convolutional Recurrent Neural Network Implementation in PyTorch
Stars: ✭ 146 (-8.75%)
Mutual labels:  cnn
Flownet2 Docker
Dockerfile and runscripts for FlowNet 2.0 (estimation of optical flow)
Stars: ✭ 137 (-14.37%)
Mutual labels:  cnn
Pytorch Fcn Easiest Demo
PyTorch Implementation of Fully Convolutional Networks (a very simple and easy demo).
Stars: ✭ 138 (-13.75%)
Mutual labels:  cnn
Text Classification Demos
Neural models for Text Classification in Tensorflow, such as cnn, dpcnn, fasttext, bert ...
Stars: ✭ 144 (-10%)
Mutual labels:  cnn
Ncrfpp
NCRF++, a Neural Sequence Labeling Toolkit. Easy use to any sequence labeling tasks (e.g. NER, POS, Segmentation). It includes character LSTM/CNN, word LSTM/CNN and softmax/CRF components.
Stars: ✭ 1,767 (+1004.38%)
Mutual labels:  cnn
Documentclassification
This code implements a simple CNN model for document classification with tensorflow.
Stars: ✭ 151 (-5.62%)
Mutual labels:  cnn
Easyocr
Ready-to-use OCR with 80+ supported languages and all popular writing scripts including Latin, Chinese, Arabic, Devanagari, Cyrillic and etc.
Stars: ✭ 13,379 (+8261.88%)
Mutual labels:  cnn
Livianet
This repository contains the code of LiviaNET, a 3D fully convolutional neural network that was employed in our work: "3D fully convolutional networks for subcortical segmentation in MRI: A large-scale study"
Stars: ✭ 143 (-10.62%)
Mutual labels:  cnn
Dgc Net
A PyTorch implementation of "DGC-Net: Dense Geometric Correspondence Network"
Stars: ✭ 159 (-0.62%)
Mutual labels:  cnn
Tensorflow template application
TensorFlow template application for deep learning
Stars: ✭ 1,851 (+1056.88%)
Mutual labels:  cnn
Tensorflow Class Activation Mapping
Learning Deep Features for Discriminative Localization (2016)
Stars: ✭ 147 (-8.12%)
Mutual labels:  cnn

pytorch-receptive-field

Build Status

Compute CNN receptive field size in pytorch

Usage

git clone https://github.com/Fangyh09/pytorch-receptive-field.git

from torch_receptive_field import receptive_field
receptive_field(model, input_size=(channels, H, W))

Or

from torch_receptive_field import receptive_field
dict = receptive_field(model, input_size=(channels, H, W))
receptive_field_for_unit(receptive_field_dict, "2", (2,2))

Example

import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_receptive_field import receptive_field

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv = nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3, bias=False)
        self.bn = nn.BatchNorm2d(64)
        self.relu = nn.ReLU(inplace=True)
        self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)

    def forward(self, x):
        y = self.conv(x)
        y = self.bn(y)
        y = self.relu(y)
        y = self.maxpool(y)
        return y


device = torch.device("cuda" if torch.cuda.is_available() else "cpu") # PyTorch v0.4.0
model = Net().to(device)

receptive_field_dict = receptive_field(model, (3, 256, 256))
receptive_field_for_unit(receptive_field_dict, "2", (2,2))
------------------------------------------------------------------------------
        Layer (type)    map size      start       jump receptive_field
==============================================================================
        0             [256, 256]        0.5        1.0             1.0
        1             [128, 128]        0.5        2.0             7.0
        2             [128, 128]        0.5        2.0             7.0
        3             [128, 128]        0.5        2.0             7.0
        4               [64, 64]        0.5        4.0            11.0
==============================================================================
Receptive field size for layer 2, unit_position (1, 1),  is
 [(0, 6.0), (0, 6.0)]

More

start is the center of first item in the map grid .

jump is the distance of the adjacent item in the map grid.

receptive_field is the field size of the item in the map grid.

Todo

  • [x] Add Travis CI

Related

Thanks @pytorch-summary

https://medium.com/mlreview/a-guide-to-receptive-field-arithmetic-for-convolutional-neural-networks-e0f514068807

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].