Skip to main content

An easy-to-use api for the closed-form continuous models in tensorflow

Project description

PyPI 📦   PyTests Downloads

Closed-form Continuous-time Models

Closed-form Continuous-time Neural Networks (CfCs) are powerful sequential neural information processing units.

Paper Open Access: https://www.nature.com/articles/s42256-022-00556-7

Arxiv: https://arxiv.org/abs/2106.13898

Installation

pip install cfc-model

Requirements

  • Python 3.7 or newer
  • Tensorflow 2.4 or newer
  • Pandas
  • Numpy

For a fresh anaconda environment with the required dependencies:

conda env create --file environment.yml
conda activate cfc

Usage

Example

from cfc_model.dense_models import SequentialModel
X = np.array([[1, 1, 1, 0], [1, 1, 0, 1], [1, 0, 0, 1], [1, 1, 0, 0],
              [1, 0, 1, 0], [1, 1, 0, 1], [1, 0, 0, 1], [1, 0, 1, 0]])
y = np.array([0, 0, 1, 1, 1, 0, 1, 1])
model = SequentialModel()
model.fit(X, y)
y_pred = model.predict([1, 1, 0, 1]) # y_pred equals 0

Configuration

The following configuration states can be used

  • no_gate Runs the CfC without the (1-sigmoid) part
  • minimal Runs the CfC direct solution
  • use_ltc Runs an LTC with a semi-implicit ODE solver instead of a CfC
  • use_mixed Mixes the CfC's RNN-state with a LSTM to avoid vanishing gradients

If none of these flags are provided, the full CfC model is used

Example

from cfc_model.dense_models import SequentialModel
X = np.array([[1, 1, 1, 0], [1, 1, 0, 1], [1, 0, 0, 1], [1, 1, 0, 0],
              [1, 0, 1, 0], [1, 1, 0, 1], [1, 0, 0, 1], [1, 0, 1, 0]])
y = np.array([0, 0, 1, 1, 1, 0, 1, 1])
model = SequentialModel()

# Runs an LTC with a semi-implicit ODE solver instead of a CfC
config = {"use_ltc": True}
model.fit(X, y, config=config)
y_pred = model.predict([1, 1, 0, 1]) # y_pred equals 0

Cite

@article{hasani_closed-form_2022,
	title = {Closed-form continuous-time neural networks},
	journal = {Nature Machine Intelligence},
	author = {Hasani, Ramin and Lechner, Mathias and Amini, Alexander and Liebenwein, Lucas and Ray, Aaron and Tschaikowski, Max and Teschl, Gerald and 	    Rus, Daniela},
	issn = {2522-5839},
	month = nov,
	year = {2022}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cfc_model-1.1.0.tar.gz (23.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cfc_model-1.1.0-py3-none-any.whl (23.0 MB view details)

Uploaded Python 3

File details

Details for the file cfc_model-1.1.0.tar.gz.

File metadata

  • Download URL: cfc_model-1.1.0.tar.gz
  • Upload date:
  • Size: 23.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for cfc_model-1.1.0.tar.gz
Algorithm Hash digest
SHA256 066e22982ff02118e5c000daa42e9e40e303e7716eff99005e3ffaeb36b6a01d
MD5 4ed3c5061f02f927eabf6e3662963a33
BLAKE2b-256 8e20c2a6f27eb7d1d84a1fc7b9fc243ed3e8762e9f535a4f368d576a0c9f1f7f

See more details on using hashes here.

File details

Details for the file cfc_model-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: cfc_model-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for cfc_model-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 958c1180f1861972f3a2f11aabc8f8ff000a5a3d4035d32f1d03081669644f1f
MD5 e6a069b5a6fd3b755fc2c3a83579e51d
BLAKE2b-256 98f51f627b67ea0b99d438fb16f6219caeee5ef0bccb0118e535359f3ab3e379

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page