Skip to content
Implementation of Non-local Block.
Branch: master
Clone or download
Latest commit 0b122c1 Jul 26, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
Non-Local_pytorch_0.3.1 package code of pytorch_0.3.1 Nov 28, 2018
lib code supporting pytorch 0.4.1 Nov 28, 2018
LICENSE Create LICENSE Apr 18, 2019



  • You can find different kinds of non-local block in lib/.
  • The code is tested on MNIST dataset. You can select the type of non-local block in lib/
  • If there is something wrong in my code, please contact me, thanks!


  • python 3.6 or python 3.7.3
  • pytorch 0.4.1 or pytorch 1.1.0

Update Records

  1. Figure out how to implement the concatenation type, and add the code to lib/.
  2. Fix the bug in lib/ (old version) when using multi-gpu. Someone shares the reason with me, and you can find it in here.
  3. Fix the error of 3D pooling in lib/ (old version). Appreciate protein27 for pointing it out.
  4. For convenience, I split the lib/ into four python files, and move the old versions (lib/ and lib/ into lib/backup/.
  5. Modify the code to support pytorch 0.4.1, and move the code supporting pytorch 0.3.1
    to Non-Local_pytorch_0.3.1/.
  6. Test the code with pytorch 1.1.0 and it works.

Running Steps

  1. Select the type of non-local block in lib/
    from lib.non_local_concatenation import NONLocalBlock2D
    from lib.non_local_gaussian import NONLocalBlock2D
    from lib.non_local_embedded_gaussian import NONLocalBlock2D
    from lib.non_local_dot_product import NONLocalBlock2D
  2. Run with one GPU or multi GPU.


  • Experiments on Charades dataset.
  • Experiments on COCO dataset.

Related Repositories

  1. Non-local ResNet-50 TSM (Paper) on Kinetics dataset. They report that their model achieves a good performance of 75.6% on Kinetics, which is even higher than Non-local ResNet-50 I3D (Here).
You can’t perform that action at this time.