Git Product home page Git Product logo

from_fourier_to_koopman's Introduction

From Fourier to Koopman: Spectral methods for Long-term Forecasting

Fourier and Koopman constitute spectral algorithms for learning linear and non-linear oscillators from data respectively. Both algorithms solve a global optimization problem in frequency domain and allow for modeling of systems of any dimensionality. The algorithms are written in numpy and pytorch.

The objective of the algorithms is, respectively:

Koopman and Fourier forecasting objectives

This code accompanies the following paper. A video abstract of the paper can be found here. Results on modeling a number of fluid flows can be found here.

-----------------How to use Fourier -----------------

Fourier fits a linear oscillator to data. The number of frequencies k that the signal is assumed to exhibit and a learning rate needs to be specified. It is recommended to whiten the signal (zero-mean and unit-variance).

To learn the oscillator from data, do:

To perform forecasting, do:

-----------------How to use Koopman -----------------

Because of the many different ways in which the Koopman algorithm can be utilized, running it is more involved and might require writing a custom model_object. Below we provide an example where f is a simple MLP and the squared loss is employed. In general, the class koopman is instantiated with a model object that specifies:

  • the topology of f
  • the loss
  • the number of frequencies num_freqs

To perform forecasting, do:

Examples

In the following, a more involved example is given that uses a 1D tranpose-convolutional Neural Network to learn a traveling wave.

TO DO: ADD EXAMPLE

Koopman and Fourier forecasting objectives

License

Please see the LICENSE file.

from_fourier_to_koopman's People

Contributors

alextmallen avatar helange23 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

from_fourier_to_koopman's Issues

float32 issue in Fourier example

Just opening official issue based on e-mail I sent. I had to manually cast the types of arrays in the fourier method to be torch.float when running the short example (lines 110 and 111 in fourier.py). This fixed the error but I also think just removing the cast to a float32 in the example would fix things (don't have the code easily accessible right now to test that).

pip install fails

pip install -v git+https://github.com/helange23/from_fourier_to_koopman

Created temporary directory: /tmp/pip-ephem-wheel-cache-0diicyt8
Created temporary directory: /tmp/pip-req-tracker-zszz0zyc
Created requirements tracker '/tmp/pip-req-tracker-zszz0zyc'
Created temporary directory: /tmp/pip-install-7ox3m5jn
Collecting git+https://github.com/helange23/from_fourier_to_koopman
  Created temporary directory: /tmp/pip-req-build-6al2kggh
  Cloning https://github.com/helange23/from_fourier_to_koopman to /tmp/pip-req-build-6al2kggh
  Running command git clone -q https://github.com/helange23/from_fourier_to_koopman /tmp/pip-req-build-6al2kggh
  Added git+https://github.com/helange23/from_fourier_to_koopman to build tracker '/tmp/pip-req-tracker-zszz0zyc'
    Running setup.py (path:/tmp/pip-req-build-6al2kggh/setup.py) egg_info for package from git+https://github.com/helange23/from_fourier_to_koopman
    Running command python setup.py egg_info
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.6/tokenize.py", line 452, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-req-build-6al2kggh/setup.py'
Cleaning up...
  Removing source in /tmp/pip-req-build-6al2kggh
Removed git+https://github.com/helange23/from_fourier_to_koopman from build tracker '/tmp/pip-req-tracker-zszz0zyc'
Removed build tracker '/tmp/pip-req-tracker-zszz0zyc'
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Exception information:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 153, in _main
    status = self.run(options, args)
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/install.py", line 382, in run
    resolver.resolve(requirement_set)
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/legacy_resolve.py", line 201, in resolve
    self._resolve_one(requirement_set, req)
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/legacy_resolve.py", line 365, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/legacy_resolve.py", line 313, in _get_abstract_dist_for
    req, self.session, self.finder, self.require_hashes
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/operations/prepare.py", line 224, in prepare_linked_requirement
    req, self.req_tracker, finder, self.build_isolation,
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/operations/prepare.py", line 49, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(finder, build_isolation)
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/distributions/source/legacy.py", line 39, in prepare_distribution_metadata
    self.req.prepare_metadata()
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/req/req_install.py", line 563, in prepare_metadata
    self.metadata_directory = metadata_generator(self)
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/operations/generate_metadata.py", line 124, in _generate_metadata_legacy
    command_desc='python setup.py egg_info',
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/utils/subprocess.py", line 242, in call_subprocess
    raise InstallationError(exc_msg)
pip._internal.exceptions.InstallationError: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

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.