OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Developer Tools & SDKs

Pytorch Receptive Field

Pytorch Receptive Field is a Python library for calculating receptive-field sizes in PyTorch 2D and 3D convolutional neural networks, with a function for visualizing 2D receptive fields.

Independent OpenViST project profile, based on linked sources.

Pytorch Receptive Field — Focused receptive-field analysis of PyTorch CNNs
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use it when inspecting how a PyTorch CNN’s layers and units relate to input regions, including in workflows that need receptive-field measurements for either 2D or 3D models.

Who it is for

  • PyTorch developers analyzing CNN architecture and feature-map behavior.
  • Teams adding receptive-field calculations or 2D visualizations to model-inspection workflows.

Documented uses

  • Calculate receptive-field measurements across CNN layers.
  • Query the receptive field for a particular layer and unit position.
  • Create a 2D GIF visualization using model results and an image.
Before you choose

Requirements & limits

The source repository is public and specifies the Apache-2.0 license. The README documents installation from Git using pip.

  • The library supports calculations for both 2D and 3D CNNs, while the documented visualization function is 2D.
  • The calculation takes a model and input dimensions; querying an individual unit uses the returned result data.
  • The README’s worked example refers to PyTorch v0.4.0 and does not provide a broader compatibility statement.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Calculate receptive fields for a PyTorch CNN

Install the library and request receptive-field results for a 2D model.

Before you start

  • A PyTorch model
  • An input size expressed as channels, height and width
  • Python with pip

Steps

  1. Install from the Git repository with the command below.

    Documented command
    pip install git+https://github.com/Fangyh09/pytorch-receptive-field.git
  2. Import receptive_field from torch_receptive_field.

  3. Call receptive_field(model, input_size=(channels, H, W)) with the model and its input dimensions.

  4. Use the returned data with receptive_field_for_unit to query a layer and unit position.

Expected outcome

A dictionary of receptive-field results that can be queried for a specified layer and unit.

Guide limitations

  • The documented input-size form is for 2D models; the README gives a separate 3D example using channels, depth, height and width.
  • The README's example mentions PyTorch v0.4.0; it does not establish compatibility with other versions.
Source-based practical guide

Create a 2D receptive-field visualization GIF

Generate the documented 2D visualization using model results and an input image.

Before you start

  • A PyTorch model and its 2D input dimensions
  • A receptive-field result dictionary
  • An image file path
  • The installed torch_receptive_field library

Steps

  1. Install the library from the Git repository with pip.

  2. Import receptive_field and receptive_field_visualization_2d from torch_receptive_field.

  3. Calculate the model results with receptive_field(model, (channels, H, W)).

  4. Call receptive_field_visualization_2d with the result dictionary, image path and output path without an extension.

Expected outcome

A 2D receptive-field visualization GIF at the specified output path.

Guide limitations

  • The documented visualization function is for 2D models.
  • The README demonstrates a GIF but does not specify further output-format options.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
16 November 2026
Original website title
Fangyh09/pytorch-receptive-field · Official homepage title · retained in its source language