Skip to main content

Neural Fields – Old Idea, New Glory

license docs docs pre-commit bandit isort black ci tests coverage

About

In 1977, Shun-ichi Amari introduced neural fields, a class of potential-based recurrent neural networks [1]. This architecture was developed as a simplistic model of the activity of neurons in a (human) brain. It's main characteristic is the lateral in-/exhibition of neurons though their accumulated potential. Due to its simplicity and expressiveness, Amari’s work was highly influential and led to several follow-up papers such as [2-6] to only name a few.

Support

If you use code or ideas from this repository for your projects or research, please cite it.

@misc{Muratore_neuralfields,
  author = {Fabio Muratore},
  title = {neuralfields - A type of potential-based recurrent neural networks implemented with PyTorch},
  year = {2023},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/famura/neuralfields}}
}

Features

  • There are two variants of the neural fields implemented in this repository: one called NeuralField that matches the model of Amari closely using 1D convolutions, as well as another one called SimpleNeuralField that replaces the convolutions and introduces custom potential dynamics function.
  • Both implementations have by modern standards very few, i.e., typically less than 1000, parameters. I suggest that you start with the NeuralField class since it is more expressive. However, the SimpleNeuralField has the benefit of operating with typically less than 20 parameters, which allows you to use optimizers that otherwise might not scale.
  • Both, NeuralField and SimpleNeuralField, model classes are subclasses of torch.nn.Module, hence able to process batched data and run on GPUs.
  • The examples contain a script for time series learning. However, it is also possible to use neural fields as generative models.
  • This repository is a spin-off from SimuRLacra where the neural fields have been used as the backbone for control policies. In SimuRLacra, the focus is on reinforcement learning for sim-to-real transfer. However, the goal of this repository is to make the implementation as general as possible, such that it could for example be used as generative model.

Implementation

Both model variants intentionally detach the incoming hidden state at each step. Parameters receive gradients from the current step's computation, but gradients do not propagate through the recurrent state across time.

Time series learning example

The learning script predicts the next observation from a rolling window of past observations. Normalization is fitted on the training half only, and evaluation uses the same window construction as training. Test inputs include earlier observed test values: this is one-step-ahead forecasting, not an autonomous rollout.

Time series generation example

By default, the generation script drives the trained model with noisy test inputs. It does not feed predictions back as inputs. Run the learning script first.

Getting Started

To install this package, simply run

pip install neuralfields

For further information, please have a look at the getting started guide. In the documentation, you can also find the complete reference of the source code.


References

[1] S-I. Amari. Dynamics of pattern formation in lateral-inhibition type neural fields. Biological Cybernetics. 1977.
[2] K. Kishimoto and S-I. Amari. Existence and stability of local excitations in homogeneous neural fields. Journal of Mathematical Biology, 1979.
[3] W. Erlhagen and G. Schöner. Dynamic field theory of movement preparation. Psychological Review, 2002.
[4] S-I. Amari, H. Park, and T. Ozeki. Singularities affect dynamics of learning in neuromanifolds. Neural Computation, 2006.
[5] T. Luksch, M. Gineger, M. Mühlig, T. Yoshiike, Adaptive Movement Sequences and Predictive Decisions based on Hierarchical Dynamical Systems. International Conference on Intelligent Robots and Systems, 2012.
[6] C. Kuehn and J. M. Tölle. A gradient flow formulation for the stochastic Amari neural field model. Journal of Mathematical Biology, 2019.

Metadata

Release files for neuralfields 0.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for neuralfields 0.5.2
File Size Uploaded
neuralfields-0.5.2.tar.gz 715.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for neuralfields 0.5.2
File Interpreter ABI Platform
neuralfields-0.5.2-py3-none-any.whl Python 3 none any Details

Total release size: 735.7 kB

Release files / neuralfields-0.5.2.tar.gz

Download URL neuralfields-0.5.2.tar.gz
Size 715.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c708e0118e6f2931a7ed8fca39a37d02c0ff2e92a6f26e338e04c0849d4168da
BLAKE2b-256 checksum
How to use checksums
6af4cde3e63274b4e9a660a01dd932886a4f81515079a40444d7cb74693d1c30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / neuralfields-0.5.2-py3-none-any.whl

Download URL neuralfields-0.5.2-py3-none-any.whl
Size 19.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2bb1999fe49a107bb0ae96dae27394b2168af91e15fb1ac835e8e27a2e810fa
BLAKE2b-256 checksum
How to use checksums
23c01980fc439ac6bcb2f80b6b246cf30fe6c01d6ca5883d2dabecaf636acf56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.5.2 This release

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page