Skip to content

MicKam/keras-non-local-nets

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Keras Non-Local Neural Networks

Keras implementation of Non-local blocks from the paper "Non-local Neural Networks"

  • Support for "Gaussian", "Embedded Gaussian" and "Dot" instantiations of the Non-Local block.
  • Support for variable shielded computation mode (reduces computation by N**2 x, where N is default to 2)
  • Support for "Concatenation" instantiation will be supported when authors release their code.

Usage

The script non_local.py contains a single function : non_local_block which takes in an input tensor and wraps a non-local block around it.

from non_local import non_local_block

ip = Input(shape=(##)) # this can be a rank 3, 4 or 5 tensor shape
x = ConvND(...)  # as againm can be Conv1D, Conv2D or Conv3D
x = non_local_block(x, computation_compression=2, mode='embedded')
...

Basic block

From the paper, a basic Non-Local block looks like below (with the Embedded Gaussian instantiation)

About

Keras implementation of Non-local Neural Networks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%