Giter Site home page Giter Site logo

reservoir_nn's Introduction

reservoir_nn

This package enables the use of reservoir computing architectures in Keras.

It enables the flexible creation of reservoir layers that can be used just like any other type of Keras layer.

What principally distinguishes reservoir layers from other layer types is that they have fixed weights. In practice, effective reservoir layers are often also very (>99%) sparse, although this is not a requirement.

N.B: Reservoir systems can overfit VERY fast, so training of models with these layers may need to be adjusted in order to prevent overfitting.

This package enables:

--creation of reservoir layers of a specified size and sparsity and drawn from any arbitrary distribution.

--insertion of reservoir layers into conventional architectures (e.g., Unets, LSTMs, etc).

--creation of "trainable" reservoirs that fix only the zero weights of the layer, but not the non-zero weights.

--local learning (e.g., contrastive Hebbian learning) within the reservoir layers.

--recurrence within reservoir layers.

--"next generation" reservoir computing wherein raw inputs are replaced with concatenated sequences of non-linear transforms of the input. We refer to this as "sideways time".

For more details on the package components and their usage, see the docstrings for the individual functions.

Examples

Here we build a simple input -> reservoir -> output model.

input_shape = (32,32)
reservoir_size = (1024, 1024)
reservoir_weight = np.random.uniform(low=0.0, high=1.0, size=reservoir_size)

model = reservoir_nn.models.segmentation_models.minimal_reservoir_model(
  input_shape = input_shape,
  reservoir_weight = reservoir_weight
  )

This will build a model that has a trainable input layer, a fixed reservoir with random uniform weights of size (1024, 1024), and a trainable output layer.

The output of the model is the same size as the input, which is appropriate in, for example, image segmentation problems.

Instead of using a random matrix, it is usually advantageous to use a sparse random matrix. This is done like so:

input_shape = (32,32)
reservoir_size = (1024, 1024)
reservoir_weight = np.random.uniform(low=0.0, high=1.0, size=reservoir_size)
sparse_weights = reservoir_nn.utils.weight_transforms.make_sparse(
  reservoir_weight,
  zero_weight_proportion = .95)

model = models.segmentation_models.minimal_reservoir_model(
  input_shape = input_shape,
  reservoir_weight = sparse_weights
  )

It can also be effective to fix only the zero valued weights of the sparse reservoir, and allow the non-zeroed weights to train (i.e., fix the topology of the reservoir but not the magnitude of the non-zero weights). This can be accomplished like so:

input_shape = (32,32)
reservoir_size = (1024, 1024)
reservoir_weight = np.random.uniform(low=0.0, high=1.0, size=reservoir_size)
sparse_weights = reservoir_nn.utils.weight_transforms.make_sparse(
  reservoir_weight,
  zero_weight_proportion = .95)

model = models.segmentation_models.minimal_reservoir_model(
  input_shape = input_shape,
  reservoir_weight = sparse_weights,
  trainable_reservoir = True
  )

There are a lot of options of other tweaks that can be made to even the base reservoir model (e.g., recurrence within the reservoir, batchnorm, dropout, etc). To see the full list of these, examine the docstring in reservoir_nn.models.segmentation_models.minimal_reservior_model().

Support

You can ask questions and join the development discussion:

[In the TensorFlow forum.] (https://discuss.tensorflow.org/)\ [On the Keras Google group.] (https://groups.google.com/g/keras-users)\ [On the Keras Slack channel.] (https://kerasteam.slack.com/)

Use [this link] (https://keras-slack-autojoin.herokuapp.com/) to request an invitation to the channel.

Opening an issue

You can also post bug reports and feature requests (only) in GitHub issues.

Opening a PR

We welcome contributions! Before opening a PR, please read our contributor guide, and the API design guideline.

reservoir_nn's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.