Git Product home page Git Product logo

kymatio's Introduction

Kymatio: Wavelet scattering in Python

Kymatio is an implementation of the wavelet scattering transform in the Python programming language, suitable for large-scale numerical experiments in signal processing and machine learning. Scattering transforms are translation-invariant signal representations implemented as convolutional networks whose filters are not learned, but fixed (as wavelet filters).

PyPI License Build status Downloads codecov

Use Kymatio if you need a library that:

  • supports 1-D, 2-D, and 3-D wavelets,
  • integrates wavelet scattering in a deep learning architecture, and
  • runs seamlessly on CPU and GPU hardware, with major deep learning APIs, such as PyTorch, TensorFlow, and Jax.

The Kymatio environment

Flexibility

The Kymatio organization associates the developers of several pre-existing packages for wavelet scattering, including ScatNet, scattering.m, PyScatWave, WaveletScattering.jl, and PyScatHarm.

Interfacing Kymatio into deep learning frameworks allows the programmer to backpropagate the gradient of wavelet scattering coefficients, thus integrating them within an end-to-end trainable pipeline, such as a deep neural network.

Portability

Each of these algorithms is written in a high-level imperative paradigm, making it portable to any Python library for array operations as long as it enables complex-valued linear algebra and a fast Fourier transform (FFT).

Each algorithm comes packaged with a frontend and backend. The frontend takes care of interfacing with the user. The backend defines functions necessary for computation of the scattering transform.

Currently, there are eight available frontend–backend pairs, NumPy (CPU), scikit-learn (CPU), pure PyTorch (CPU and GPU), PyTorch>=1.10 (CPU and GPU), PyTorch+scikit-cuda (GPU), PyTorch>=1.10+scikit-cuda (GPU), TensorFlow (CPU and GPU), Keras (CPU and GPU), and Jax (CPU and GPU).

Scalability

Kymatio integrates the construction of wavelet filter banks in 1D, 2D, and 3D, as well as memory-efficient algorithms for extracting wavelet scattering coefficients, under a common application programming interface.

Running Kymatio on a graphics processing unit (GPU) rather than a multi-core conventional central processing unit (CPU) allows for significant speedups in computing the scattering transform. The current speedup with respect to CPU-based MATLAB code is of the order of 10 in 1D and 3D and of the order of 100 in 2D.

We refer to our official benchmarks for further details.

How to cite

If you use this package, please cite our paper Kymatio: Scattering Transforms in Python:

Andreux M., Angles T., Exarchakis G., Leonarduzzi R., Rochette G., Thiry L., Zarka J., Mallat S., Andén J., Belilovsky E., Bruna J., Lostanlen V., Chaudhary M., Hirn M. J., Oyallon E., Zhang S., Cella C., Eickenberg M. (2020). Kymatio: Scattering Transforms in Python. Journal of Machine Learning Research 21(60):1−6, 2020. (paper) (bibtex)

Installation

Dependencies

Kymatio requires:

  • Python (>= 3.7)
  • SciPy (>= 0.13)

Standard installation

We strongly recommend running Kymatio in an Anaconda environment, because this simplifies the installation of other dependencies. You may install the latest version of Kymatio using the package manager pip, which will automatically download Kymatio from the Python Package Index (PyPI):

pip install kymatio

Linux and macOS are the two officially supported operating systems.

Frontends

NumPy

To explicitly call the NumPy frontend, run:

from kymatio.numpy import Scattering2D
scattering = Scattering2D(J=2, shape=(32, 32))

Scikit-learn

You can call also call Scattering2D as a scikit-learn Transformer using:

from kymatio.sklearn import Scattering2D

scattering_transformer = Scattering2D(2, (32, 32))

PyTorch

Using PyTorch, you can instantiate Scattering2D as a torch.nn.Module:

from kymatio.torch import Scattering2D

scattering = Scattering2D(J=2, shape=(32, 32))

TensorFlow and Keras

Similarly, in TensorFlow, you can instantiate Scattering2D as a tf.Module:

from kymatio.tensorflow import Scattering2D

scattering = Scattering2D(J=2, shape=(32, 32))

Alternatively, you can call Scattering2D as a Keras Layer using:

from tensorflow.keras.layers import Input
from kymatio.keras import Scattering2D

inputs = Input(shape=(32, 32))
scattering = Scattering2D(J=2)(inputs)

Jax

Finally, with Jax installed, you can also instantiate a Jax Scattering2D object:

from kymatio.jax import Scattering2D

scattering = Scattering2D(J=2, shape=(32, 32))

Installation from source

Assuming the Kymatio source has been downloaded, you may install it by running

pip install -r requirements.txt
python setup.py install

Developers can also install Kymatio via:

pip install -r requirements.txt
python setup.py develop

GPU acceleration

Certain frontends, numpy and sklearn, only allow processing on the CPU and are therefore slower. The torch, tensorflow, keras, and jax frontends, however, also support GPU processing, which can significantly accelerate computations. Additionally, the torch backend supports an optimized skcuda backend which currently provides the fastest performance in computing scattering transforms.

To use it, you must first install the scikit-cuda and cupy dependencies:

pip install scikit-cuda cupy

Then you may instantiate a scattering object using the backend='torch_skcuda' argument:

from kymatio.torch import Scattering2D

scattering = Scattering2D(J=2, shape=(32, 32), backend='torch_skcuda')

Documentation

The documentation of Kymatio is officially hosted on the kymat.io website.

Online resources

Building the documentation from source

The documentation can also be found in the doc/ subfolder of the GitHub repository. To build the documentation locally, please clone this repository and run

pip install -r requirements_optional.txt
cd doc; make clean; make html

Support

We wish to thank the Scientific Computing Core at the Flatiron Institute for the use of their computing resources for testing.

Flatiron

We would also like to thank École Normale Supérieure for their support.

ENS

Kymatio

Kyma (κύμα) means wave in Greek. By the same token, Kymatio (κυμάτιο) means wavelet.

Note that the organization and the library are capitalized (Kymatio) whereas the corresponding Python module is written in lowercase (import kymatio).

The recommended pronunciation for Kymatio is kim-ah-tio. In other words, it rhymes with patio, not with ratio.

kymatio's People

Contributors

anakin-datawalker avatar andreuxmath avatar changhongw avatar cyrusvahidi avatar danedane-haider avatar dylex avatar edouardoyallon avatar eickenberg avatar epnev avatar eugenium avatar f0k avatar florentinguth avatar gabrielhuang avatar gexarcha avatar grlee77 avatar janden avatar johmathe avatar jonas1312 avatar lostanlen avatar louity avatar lylyhan avatar marcushaggbom avatar muawizchaudhary avatar nshervt avatar overlordgolddragon avatar parthe avatar pawarrick avatar rleonarduzzi avatar szagoruyko avatar tomas-angles 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kymatio's Issues

sphinx requirements

pip install sphinxcontrib-bibtex
Sphinx>=1.4.3

this must be in requirements to compile the doc!

Scattering1D tests require sklearn

Specifically test_filters, test_scattering and test_utils. They only use the check_random_state function. Perhaps there is a way to do this with only scipy/numpy?

[bug] 2d unit test

Code refactoring required for the unit test of 2d, current code doesn't pass them

[TODO] Computation time... and rough speedup

For 1D,2D,3D, this is absolutely necessary.
For 2D, I'll compare with "pyscatwave" to which I'll compare(for which i have a rough idea of th espeedup w.r.t. MATLAB). Hopefully it'll be faster

CPU + GPU time

  • 1D, batches of size 128x1x262144, J=10, Q=8
  • 2D, batches of size 128x3x256x256, L=8, J=3
  • 3D, batches of size 2x128x128x128, L=2, J=2

E

Sphinx build fails

We need some clear instructions on how to build the sphinx, currnetly it failse.

I checked out from master and got several errors that required the following installs:
pip install sphinx pip install sphinxcontrib-bibtex pip install sphinx-gallery

even after that I get the following errors:

eugene@farnsworth:~/tmpscat/scattering_transform/doc$ make html
Running Sphinx v1.7.4
making output directory...
loading pickled environment... not yet created
generating gallery...
WARNING: /home/eugene/tmpscat/scattering_transform/examples/1d/plot_filters.py failed to execute correctly: Traceback (most recent call last):
File "/home/eugene/tmpscat/scattering_transform/examples/1d/plot_filters.py", line 10, in
from scattering.scattering1d.filter_bank import scattering_filter_factory
File "/home/eugene/anaconda3/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/init.py", line 7, in
from .scattering2d.scattering2d import Scattering2D
File "/home/eugene/anaconda3/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering2d/init.py", line 4, in
from .scattering2d import Scattering2D
File "/home/eugene/anaconda3/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering2d/scattering2d.py", line 10, in
from .backend import cdgmm, Modulus, SubsampleFourier, fft, Pad, unpad
File "/home/eugene/anaconda3/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering2d/backend/init.py", line 16, in
import appdirs
ModuleNotFoundError: No module named 'appdirs'

generating gallery for gallery_1d... [100%] classif.py
WARNING: /home/eugene/tmpscat/scattering_transform/examples/2d/plot_filters.py failed to execute correctly: Traceback (most recent call last):
File "/home/eugene/tmpscat/scattering_transform/examples/2d/plot_filters.py", line 9, in
from scattering.scattering2d.filter_bank import filter_bank
File "/home/eugene/anaconda3/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/init.py", line 7, in
from .scattering2d.scattering2d import Scattering2D
File "/home/eugene/anaconda3/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering2d/init.py", line 4, in
from .scattering2d import Scattering2D
File "/home/eugene/anaconda3/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering2d/scattering2d.py", line 10, in
from .backend import cdgmm, Modulus, SubsampleFourier, fft, Pad, unpad
File "/home/eugene/anaconda3/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering2d/backend/init.py", line 16, in
import appdirs
ModuleNotFoundError: No module named 'appdirs'

generating gallery for gallery_2d... [100%] regularized_inverse_scattering_MNIST.py
generating gallery for gallery_3d... [100%] compute_speed.py
computation time summary:
- regularized_inverse_scattering_MNIST.py: 0 sec
- plot_filters.py: 0 sec
- plot_filters.py: 0 sec
- compute_speed.py: 0 sec
- compute_speed.py: 0 sec
- compute_speed.py: 0 sec
- classif.py: 0 sec
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 6 source files that are out of date
updating environment: 16 added, 0 changed, 0 removed
checking for /home/eugene/tmpscat/scattering_transform/doc/source/_static/bibtex.bib in bibtex cache... not found
parsing bibtex file /home/eugene/tmpscat/scattering_transform/doc/source/_static/bibtex.bib... parsed 4 entries

WARNING: autodoc: failed to import module 'scattering'; the following exception was raised:
No module named 'appdirs'
/home/eugene/tmpscat/scattering_transform/doc/source/gallery_2d/compute_speed.rst:104: WARNING: Explicit markup ends without a blank line; unexpected unindent.
/home/eugene/tmpscat/scattering_transform/doc/source/gallery_3d/compute_speed.rst:99: WARNING: Explicit markup ends without a blank line; unexpected unindent.
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] userguide
WARNING: dvipng command 'dvipng' cannot be run (needed for math display), check the imgmath_dvipng setting
generating indices... genindex
writing additional pages... search
copying images... [100%] _static/algorithm.png
copying downloadable files... [100%] gallery_3d/gallery_3d_jupyter.zip
copying static files... done
copying extra files... done
dumping search index in English (code: en) ... done
dumping object inventory... done
build succeeded, 6 warnings.

The HTML pages are in build/html.

Exception occurred:
File "/home/eugene/anaconda3/lib/python3.6/site-packages/sphinx_gallery/gen_gallery.py", line 313, in sumarize_failing_examples
"\n" + "-" * 79)
ValueError: Here is a summary of the problems encountered when running the examples

Unexpected failing examples:
/home/eugene/tmpscat/scattering_transform/examples/2d/plot_filters.py failed leaving traceback:
Traceback (most recent call last):
File "/home/eugene/tmpscat/scattering_transform/examples/2d/plot_filters.py", line 9, in
from scattering.scattering2d.filter_bank import filter_bank
File "/home/eugene/anaconda3/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/init.py", line 7, in
from .scattering2d.scattering2d import Scattering2D
File "/home/eugene/anaconda3/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering2d/init.py", line 4, in
from .scattering2d import Scattering2D
File "/home/eugene/anaconda3/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering2d/scattering2d.py", line 10, in
from .backend import cdgmm, Modulus, SubsampleFourier, fft, Pad, unpad
File "/home/eugene/anaconda3/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering2d/backend/init.py", line 16, in
import appdirs
ModuleNotFoundError: No module named 'appdirs'

/home/eugene/tmpscat/scattering_transform/examples/1d/plot_filters.py failed leaving traceback:
Traceback (most recent call last):
File "/home/eugene/tmpscat/scattering_transform/examples/1d/plot_filters.py", line 10, in
from scattering.scattering1d.filter_bank import scattering_filter_factory
File "/home/eugene/anaconda3/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/init.py", line 7, in
from .scattering2d.scattering2d import Scattering2D
File "/home/eugene/anaconda3/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering2d/init.py", line 4, in
from .scattering2d import Scattering2D
File "/home/eugene/anaconda3/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering2d/scattering2d.py", line 10, in
from .backend import cdgmm, Modulus, SubsampleFourier, fft, Pad, unpad
File "/home/eugene/anaconda3/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering2d/backend/init.py", line 16, in
import appdirs
ModuleNotFoundError: No module named 'appdirs'


The full traceback has been saved in /tmp/sphinx-err-sivo5f77.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at https://github.com/sphinx-doc/sphinx/issues. Thanks!
Makefile:20: recipe for target 'html' failed
make: *** [html] Error 2

1D classif example now fails

Specifically, we get

TEST, average loss = nan, accuracy = 0.100

which is not very impressive. This used to work before (as of 5b41a31), giving

TEST, average loss = 0.092, accuracy = 0.973

but no longer...

3D crashes on CPU

Getting the following error when calling forward:

  File "/home/janden/projects/kymatio/scattering/scattering3d/scattering3d.py", line 326, in forward
    conv_modulus, method, method_args, j_1))
  File "/home/janden/projects/kymatio/scattering/scattering3d/scattering3d.py", line 175, in _compute_scattering_coefs
    return self._compute_standard_scattering_coefs(input_array)
  File "/home/janden/projects/kymatio/scattering/scattering3d/scattering3d.py", line 105, in _compute_standard_scattering_coefs
    convolved_input = self._low_pass_filter(input_array, self.J)
  File "/home/janden/projects/kymatio/scattering/scattering3d/scattering3d.py", line 85, in _low_pass_filter
    cuda = isinstance(input_array, torch.cuda.FloatTensor)
RuntimeError: cuda runtime error (30) : unknown error at /opt/conda/conda-bld/pytorch_1532584813488/work/aten/src/THC/THCGeneral.cpp:74

From what I understand, the code is set up to detect whether the input is GPU and apply the appropriate operators (there's not cuda() or cpu() functions to convert the transformer like in 1D and 2D). Looks like when I run this without CUDA enabled, it crashes when trying to determine the type of the input tensor. It might be my personal config, but I should mention that torch.cuda.is_available() works without crashing.

More bigger picture, do we want to modify this implementation to more closely align with the 1D/2D calling sequence? May make things easier for users (and also prevent the above type of errors).

Bug with backends

Hi,

When doing:

export SCATTERING_BACKEND=torch
cd scattering_transform/scattering/scattering2d/tests
pytest test_scattering.py

I obtain the following error:

===================================================================================== ERRORS =====================================================================================
_______________________________________________________ ERROR collecting scattering/scattering2d/tests/test_scattering.py ________________________________________________________
ImportError while importing test module '/home/eugene/forkedouard/scattering_transform/scattering/scattering2d/tests/test_scattering.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
test_scattering.py:5: in <module>
    from scattering.scattering2d import Scattering2D
/home/eugene/anaconda3/envs/pytorch_scattering_transform/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/__init__.py:10: in <module>
    ???
/home/eugene/anaconda3/envs/pytorch_scattering_transform/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering3d/__init__.py:6: in <module>
    ???
/home/eugene/anaconda3/envs/pytorch_scattering_transform/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering3d/scattering3d.py:8: in <module>
    ???
E   ImportError: cannot import name 'cdgmm3d'

It works like a charm when doing
export SCATTERING_BACKEND=skcuda
or when not assigning SCATTERING_BACKEND

The main reason is that for some reasons, the 3D tries to import its own backend, even when doing 2D test. It's a bit annoying because since this, I do not test the 2d scattering code and it has plenty of bugs that I try to fix in: #57

My attempt to fix this bug is: https://github.com/edouardoyallon/scattering_transform/blob/small_bug/scattering/scattering3d/backend/__init__.py#L65-L67

CPU fallback for skcuda backend

Currently, the skcuda backend errors when you try to give it CPU tensors. While this makes sense, it does make it quite hard for people to structure their code. Things like

scattering = Scattering2D(32, 32, 4);
x = torch.randn(1, 1, 32, 32);
Sx = scattering.forward(x);

will run for SCATTERING_BACKEND_2D="torch" but fail for SCATTERING_BACKEND_2D="skcuda".

To get code that runs for both backends, you must write the code to always run on GPU. If you write code that runs on CPU, your code will crash if the user selects the skcuda backend. The only way to write portable code is to detect both the presence of GPU and identify the backend currently in use, which is quite cumbersome.

I suggest we have the skcuda backend fall back to the torch backend for CPU tensors. This way, using the library only involves the decision of CPU/GPU inside the code, which is more manageable, I think.

Lazy imports for skcuda + other gpu-only modules

Currently the examples cannot run without skcuda installed, which is a problem for computers that don't have an nvidia graphics card.

We'll probably need to lazy-import this package when it is needed.

I am wondering @rleonarduzzi did you run into exactly this problem?

With a little bit of luck this might go away when we fully rely on torch.fft. Let's wait for that merge to see whether something needs to be done

Test coverage

Tests are required for every single function in this codebase.

Rule: If you contributed the code, you are the person being looked to first for the tests. Please make sure your part is covered. Please ask for help.

  • Fixing: #2 (3d MAE)

sphinx-gallery: 1d/compute_speed 2d/compute_speed 3d/compute_speed

Please make sure that on CPU, the running time will not be to slow. Please fix the current warning. Please improve a bit the narrative. Please do a first forward to make sure we do not count also the comptuation time for building the cuda kernels/memory creation

thanks

Please close this issue only when you're happy with the sphinx-gallery.

3d_qm7 example crashes

After running for a while, I get

Traceback (most recent call last):
  File "examples/3d/scattering3d_qm7.py", line 212, in <module>
    np.save(os.path.join(cachedir, 'order_0_' + basename), np_order_0)
NameError: name 'os' is not defined

Not sure why this is crashing for me but not for others. Doesn't os always have to be imported before use?

Problem installing torchnet

When installing from requirements.txt, I get a strange error:

Building wheels for collected packages: torchnet, torchnet
  Running setup.py bdist_wheel for torchnet ... done
  Stored in directory: /tmp/pip-ephem-wheel-cache-qj3s1xz3/wheels/57/85/73/7ab5d819ec37d9553d06ee5c8851a7f9ebaf63588b5981f477
  Running setup.py bdist_wheel for torchnet ... error
  Complete output from command /mnt/home/janden/local/anaconda2/envs/scattering/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-dx69i07c/torchnet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-6uh2xagl --python-tag cp37:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/mnt/home/janden/local/anaconda2/envs/scattering/lib/python3.7/tokenize.py", line 447, in open
      buffer = _builtin_open(filename, 'rb')
  FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-install-dx69i07c/torchnet/setup.py'
  
  ----------------------------------------
  Failed building wheel for torchnet
  Running setup.py clean for torchnet
  Complete output from command /mnt/home/janden/local/anaconda2/envs/scattering/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-dx69i07c/torchnet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" clean --all:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/mnt/home/janden/local/anaconda2/envs/scattering/lib/python3.7/tokenize.py", line 447, in open
      buffer = _builtin_open(filename, 'rb')
  FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-install-dx69i07c/torchnet/setup.py'
  
  ----------------------------------------
  Failed cleaning build dir for torchnet
Successfully built torchnet
Failed to build torchnet

I'm guessing this may have something to do with my local configuration.

What's strange is that when I replace the line git+git://github.com/pytorch/tnt.git#egg=tnt with git+git://github.com/pytorch/tnt.git in requirements.txt, it works fine. Even just plain torchnet works well, which get us version 0.0.4.

Documentation

We need

  • narrative documentation using sphinx-doc
  • an automatic example gallery using sphinx-gallery
  • an updated README and INSTALL instructions

sphinx stuff to be set up by @eickenberg in the next days.
Narrative documentation to be written by everybody.

Clear Instructions for Backend (was: 2d has drastically slowed down on GPU versus pyscatwave)

I've compared to imagenet sizes pyscatwave and kymatio 2d. The results are on 1080 Ti and use the script currently in examples/2d/compute_speed.py with a minor change

pyscatwave:
Elapsed time: 5.118290 [s / 10 evals], avg: 0.51 (s/batch)

kymatio:
avg: 3.06 (s/batch)

@edouardoyallon

To reproduce my results in the current speed example set N,M to 224

To reproduce the result for pyscatwave I attach the following script that is almost identical to the kymatio one and can be placed in the pyscatwave. Test done with pyscatwave master.. https://gist.github.com/eugenium/6e4a50f3d18d0e4b5ea42f25b31dbf67

Missing dependency `appdirs`

Just tried a fresh install and the backends crash when trying to import appdirs. A quick pip install appdirs fixes it. I'm guessing it was a dependency of some of the packages we have now removed, so we should probably put it in requirements.txt.

Comparison to matlab (1D,3D)

Hi,

  • 1D
  • 3D

I saved from the matlab version of Joakim and Laurent some data {x,Sx}, a while ago, here, for the 2D:

https://github.com/edouardoyallon/scattering_transform/blob/master/scattering/scattering2d/tests/test_data.pt

It was my "garde fou": I was making sure that the scattering outputs the same Sx. Would it be possible to collect something similar for 1D and 3D? It's probably one of the most reliable unit test to ensure consistency through the different scattering versions.

Thanks
E

removing warnings from 3d code

hi,

Just getting this kind of warning:
scattering/scattering3d/scattering3d.py:239: DeprecationWarning: invalid escape sequence \s

Easy to fix

[2fix] Annoying warning to invalid escape

/home/eugene/anaconda3/envs/pytorch_scattering_transform/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering3d/scattering3d.py:86: DeprecationWarning: invalid escape sequence \s

/home/eugene/anaconda3/envs/pytorch_scattering_transform/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering3d/scattering3d.py:105: DeprecationWarning: invalid escape sequence \s

/home/eugene/anaconda3/envs/pytorch_scattering_transform/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering3d/scattering3d.py:204: DeprecationWarning: invalid escape sequence \s

/home/eugene/anaconda3/envs/pytorch_scattering_transform/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering3d/scattering3d.py:240: DeprecationWarning: invalid escape sequence \s

/home/eugene/anaconda3/envs/pytorch_scattering_transform/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering3d/scattering3d.py:307: DeprecationWarning: invalid escape sequence \s

/home/eugene/anaconda3/envs/pytorch_scattering_transform/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering3d/scattering3d.py:86: DeprecationWarning: invalid escape sequence \s

/home/eugene/anaconda3/envs/pytorch_scattering_transform/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering3d/scattering3d.py:105: DeprecationWarning: invalid escape sequence \s

/home/eugene/anaconda3/envs/pytorch_scattering_transform/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering3d/scattering3d.py:204: DeprecationWarning: invalid escape sequence \s

/home/eugene/anaconda3/envs/pytorch_scattering_transform/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering3d/scattering3d.py:240: DeprecationWarning: invalid escape sequence \s

/home/eugene/anaconda3/envs/pytorch_scattering_transform/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering3d/scattering3d.py:307: DeprecationWarning: invalid escape sequence \s

/home/eugene/anaconda3/envs/pytorch_scattering_transform/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering3d/utils.py:92: DeprecationWarning: invalid escape sequence \i
/home/eugene/anaconda3/envs/pytorch_scattering_transform/lib/python3.6/site-packages/scattering-0.0.1-py3.6.egg/scattering/scattering3d/utils.py:92: DeprecationWarning: invalid escape sequence \i

/home/eugene/anaconda3/envs/pytorch_scattering_transform/lib/python3.6/site-packages/scipy/fftpack/basic.py:160: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  z[index] = x

-- Docs: https://docs.pytest.org/en/latest/warnings.html

Sphynx gallery

Hi,

Those files :

mnist.py|synthetic.py|real_signal.py|scattering3d_qm7.py

do not pass in sphynx gallery because there is no doc string. I'm willing to removing the warning also

[ENH] differentiable skcuda

Hi,

So Stéphane would be super happy to have a super fast differentiable scattering... who has the time to do this?(not me, I'm sorry about that) A simple unit-test to compare the gradients with torch backend is enough to validate the approach.

Best,
EO

sphinx-gallery: 1d/real_signal or 1d/synthetic

Please remove from line 60 of doc/conf.py the name real signal or synthetix, and work on one of them.

Add a basic narrive, display. If you don't want to add it to the sphinx gallery, please say it here and close this issue with a comment.

Please close this issue only when you're happy with the sphinx-gallery.

sphinx-gallery: mnist.py

Please do a basic narrive, running script, pretty display. Un comment lline 60 of doc/conf.py to build the doc

Please close this issue only when you're happy with the sphinx-gallery.

[improvement] Annoying warning


============================================================================================ warnings summary =============================================================================================
/Users/oyallon/anaconda/envs/pytorch/lib/python3.5/site-packages/scipy/fftpack/basic.py:160: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  z[index] = x

-- Docs: https://docs.pytest.org/en/latest/warnings.html
================================================================================= 26 passed, 1 warnings in 93.01 seconds =================================================================================

It probably comes from:

https://github.com/eickenberg/scattering_transform/blob/master/scattering/scattering2d/filter_bank.py#L10

but numpy fft are slow slow slow annoyingly slow slow and I'm too lazy to switch everything to pytorch. Any ideas?

gcc49 required

Build failed on the standard server of Courant (NYU) (x86_64) due to gcc49. Here is the log:

``[bruna@vine7 scattering_transform]$ pip install -r requirements.txt
Requirement already satisfied: cupy in /home/bruna/anaconda3/lib/python3.6/site-packages (from -r requirements.txt (line 1))
Requirement already satisfied: torch>=0.1.11 in /home/bruna/anaconda3/lib/python3.6/site-packages (from -r requirements.txt (line 2))
Requirement already satisfied: numpy in /home/bruna/anaconda3/lib/python3.6/site-packages (from -r requirements.txt (line 3))
Requirement already satisfied: scikit-cuda in /home/bruna/anaconda3/lib/python3.6/site-packages (from -r requirements.txt (line 4))
Requirement already satisfied: scipy in /home/bruna/anaconda3/lib/python3.6/site-packages (from -r requirements.txt (line 5))
Requirement already satisfied: pynvrtc in /home/bruna/anaconda3/lib/python3.6/site-packages (from -r requirements.txt (line 6))
Collecting tnt from git+git://github.com/pytorch/tnt.git#egg=tnt (from -r requirements.txt (line 7))
Cloning git://github.com/pytorch/tnt.git to /tmp/pip-build-ofmazb86/tnt
Running setup.py (path:/tmp/pip-build-ofmazb86/tnt/setup.py) egg_info for package tnt produced metadata for project name torchnet. Fix your #egg=tnt fragments.
Collecting pyfftw (from -r requirements.txt (line 8))
Downloading https://files.pythonhosted.org/packages/c2/2e/b25edc6960fc837e915eb1b38e5f0e3013e32e90aff14a1d0f4556b3d145/pyFFTW-0.10.4.tar.gz (365kB)
100% |████████████████████████████████| 368kB 1.4MB/s
Requirement already satisfied: scikit-learn in /home/bruna/anaconda3/lib/python3.6/site-packages (from -r requirements.txt (line 9))
Requirement already satisfied: matplotlib in /home/bruna/anaconda3/lib/python3.6/site-packages (from -r requirements.txt (line 10))
Requirement already satisfied: six>=1.9.0 in /home/bruna/anaconda3/lib/python3.6/site-packages (from cupy->-r requirements.txt (line 1))
Requirement already satisfied: nose in /home/bruna/anaconda3/lib/python3.6/site-packages (from cupy->-r requirements.txt (line 1))
Requirement already satisfied: filelock in /home/bruna/anaconda3/lib/python3.6/site-packages (from cupy->-r requirements.txt (line 1))
Requirement already satisfied: pyyaml in /home/bruna/anaconda3/lib/python3.6/site-packages (from torch>=0.1.11->-r requirements.txt (line 2))
Requirement already satisfied: pycuda>=2014.1 in /home/bruna/anaconda3/lib/python3.6/site-packages (from scikit-cuda->-r requirements.txt (line 4))
Requirement already satisfied: mako>=1.0.1 in /home/bruna/anaconda3/lib/python3.6/site-packages (from scikit-cuda->-r requirements.txt (line 4))
Collecting visdom (from torchnet->-r requirements.txt (line 7))
Downloading https://files.pythonhosted.org/packages/c1/48/d90e1519768107811fd6e7760bea46fff9e9c9ffb490441684003ae634a9/visdom-0.1.8.5.tar.gz (248kB)
100% |████████████████████████████████| 256kB 2.2MB/s
Requirement already satisfied: python-dateutil in /home/bruna/anaconda3/lib/python3.6/site-packages (from matplotlib->-r requirements.txt (line 10))
Requirement already satisfied: pytz in /home/bruna/anaconda3/lib/python3.6/site-packages (from matplotlib->-r requirements.txt (line 10))
Requirement already satisfied: cycler>=0.10 in /home/bruna/anaconda3/lib/python3.6/site-packages (from matplotlib->-r requirements.txt (line 10))
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 in /home/bruna/anaconda3/lib/python3.6/site-packages (from matplotlib->-r requirements.txt (line 10))
Requirement already satisfied: pytest>=2 in /home/bruna/anaconda3/lib/python3.6/site-packages (from pycuda>=2014.1->scikit-cuda->-r requirements.txt (line 4))
Requirement already satisfied: appdirs>=1.4.0 in /home/bruna/anaconda3/lib/python3.6/site-packages (from pycuda>=2014.1->scikit-cuda->-r requirements.txt (line 4))
Requirement already satisfied: pytools>=2011.2 in /home/bruna/anaconda3/lib/python3.6/site-packages (from pycuda>=2014.1->scikit-cuda->-r requirements.txt (line 4))
Requirement already satisfied: decorator>=3.2.0 in /home/bruna/anaconda3/lib/python3.6/site-packages (from pycuda>=2014.1->scikit-cuda->-r requirements.txt (line 4))
Requirement already satisfied: MarkupSafe>=0.9.2 in /home/bruna/anaconda3/lib/python3.6/site-packages (from mako>=1.0.1->scikit-cuda->-r requirements.txt (line 4))
Requirement already satisfied: requests in /home/bruna/anaconda3/lib/python3.6/site-packages (from visdom->torchnet->-r requirements.txt (line 7))
Requirement already satisfied: tornado in /home/bruna/anaconda3/lib/python3.6/site-packages (from visdom->torchnet->-r requirements.txt (line 7))
Requirement already satisfied: pyzmq in /home/bruna/anaconda3/lib/python3.6/site-packages (from visdom->torchnet->-r requirements.txt (line 7))
Collecting torchfile (from visdom->torchnet->-r requirements.txt (line 7))
Downloading https://files.pythonhosted.org/packages/91/af/5b305f86f2d218091af657ddb53f984ecbd9518ca9fe8ef4103a007252c9/torchfile-0.1.0.tar.gz
Collecting websocket-client (from visdom->torchnet->-r requirements.txt (line 7))
Downloading https://files.pythonhosted.org/packages/14/d4/6a8cd4e7f67da465108c7cc0a307a1c5da7e2cdf497330b682069b1d4758/websocket_client-0.53.0-py2.py3-none-any.whl (198kB)
100% |████████████████████████████████| 204kB 2.6MB/s
Requirement already satisfied: pillow in /home/bruna/anaconda3/lib/python3.6/site-packages (from visdom->torchnet->-r requirements.txt (line 7))
Requirement already satisfied: py>=1.4.29 in /home/bruna/anaconda3/lib/python3.6/site-packages (from pytest>=2->pycuda>=2014.1->scikit-cuda->-r requirements.txt (line 4))
Collecting olefile (from pillow->visdom->torchnet->-r requirements.txt (line 7))
Downloading https://files.pythonhosted.org/packages/34/81/e1ac43c6b45b4c5f8d9352396a14144bba52c8fec72a80f425f6a4d653ad/olefile-0.46.zip (112kB)
100% |████████████████████████████████| 112kB 3.7MB/s
Building wheels for collected packages: pyfftw, visdom, torchfile, olefile
Running setup.py bdist_wheel for pyfftw ... error
Complete output from command /home/bruna/anaconda3/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-ofmazb86/pyfftw/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d /tmp/tmpjf_88pj9pip-wheel- --python-tag cp36:
Compiling /tmp/pip-build-ofmazb86/pyfftw/pyfftw/pyfftw.pyx because it depends on /home/bruna/anaconda3/lib/python3.6/site-packages/Cython/Includes/numpy/init.pxd.
[1/1] Cythonizing /tmp/pip-build-ofmazb86/pyfftw/pyfftw/pyfftw.pyx
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/pyfftw
copying pyfftw/version.py -> build/lib.linux-x86_64-3.6/pyfftw
copying pyfftw/init.py -> build/lib.linux-x86_64-3.6/pyfftw
creating build/lib.linux-x86_64-3.6/pyfftw/builders
copying pyfftw/builders/_utils.py -> build/lib.linux-x86_64-3.6/pyfftw/builders
copying pyfftw/builders/init.py -> build/lib.linux-x86_64-3.6/pyfftw/builders
copying pyfftw/builders/builders.py -> build/lib.linux-x86_64-3.6/pyfftw/builders
creating build/lib.linux-x86_64-3.6/pyfftw/interfaces
copying pyfftw/interfaces/scipy_fftpack.py -> build/lib.linux-x86_64-3.6/pyfftw/interfaces
copying pyfftw/interfaces/numpy_fft.py -> build/lib.linux-x86_64-3.6/pyfftw/interfaces
copying pyfftw/interfaces/cache.py -> build/lib.linux-x86_64-3.6/pyfftw/interfaces
copying pyfftw/interfaces/_utils.py -> build/lib.linux-x86_64-3.6/pyfftw/interfaces
copying pyfftw/interfaces/init.py -> build/lib.linux-x86_64-3.6/pyfftw/interfaces
running build_ext
building 'pyfftw.pyfftw' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/tmp
creating build/temp.linux-x86_64-3.6/tmp/pip-build-ofmazb86
creating build/temp.linux-x86_64-3.6/tmp/pip-build-ofmazb86/pyfftw
creating build/temp.linux-x86_64-3.6/tmp/pip-build-ofmazb86/pyfftw/pyfftw
gcc49 -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip-build-ofmazb86/pyfftw/include -I/tmp/pip-build-ofmazb86/pyfftw/pyfftw -I/home/bruna/anaconda3/lib/python3.6/site-packages/numpy/core/include -I/home/bruna/anaconda3/include/python3.6m -c /tmp/pip-build-ofmazb86/pyfftw/pyfftw/pyfftw.c -o build/temp.linux-x86_64-3.6/tmp/pip-build-ofmazb86/pyfftw/pyfftw/pyfftw.o
unable to execute 'gcc49': No such file or directory
error: command 'gcc49' failed with exit status 1


Failed building wheel for pyfftw
Running setup.py clean for pyfftw
Running setup.py bdist_wheel for visdom ... done
Stored in directory: /home/bruna/.cache/pip/wheels/fb/ef/d8/ad95fbafb505c507b476c4e907af570d2dd41ae725cdc9b391
Running setup.py bdist_wheel for torchfile ... done
Stored in directory: /home/bruna/.cache/pip/wheels/b1/c3/d6/9a1cc8f3a99a0fc1124cae20153f36af59a6e683daca0a0814
Running setup.py bdist_wheel for olefile ... done
Stored in directory: /home/bruna/.cache/pip/wheels/4b/f4/11/bc4166107c27f07fd7bba707ffcb439619197638a1ac986df3
Successfully built visdom torchfile olefile
Failed to build pyfftw
Installing collected packages: torchfile, websocket-client, visdom, torchnet, pyfftw, olefile
Running setup.py install for torchnet ... done
Running setup.py install for pyfftw ... error
Complete output from command /home/bruna/anaconda3/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-ofmazb86/pyfftw/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-aaoqs0yd-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
running build_ext
building 'pyfftw.pyfftw' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/tmp
creating build/temp.linux-x86_64-3.6/tmp/pip-build-ofmazb86
creating build/temp.linux-x86_64-3.6/tmp/pip-build-ofmazb86/pyfftw
creating build/temp.linux-x86_64-3.6/tmp/pip-build-ofmazb86/pyfftw/pyfftw
gcc49 -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip-build-ofmazb86/pyfftw/include -I/tmp/pip-build-ofmazb86/pyfftw/pyfftw -I/home/bruna/anaconda3/lib/python3.6/site-packages/numpy/core/include -I/home/bruna/anaconda3/include/python3.6m -c /tmp/pip-build-ofmazb86/pyfftw/pyfftw/pyfftw.c -o build/temp.linux-x86_64-3.6/tmp/pip-build-ofmazb86/pyfftw/pyfftw/pyfftw.o
unable to execute 'gcc49': No such file or directory
error: command 'gcc49' failed with exit status 1

----------------------------------------

Command "/home/bruna/anaconda3/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-ofmazb86/pyfftw/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-aaoqs0yd-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-ofmazb86/pyfftw/
You are using pip version 9.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.``

sphinx-gallery: 1d/classif

please fix the narrative and try to do a shot story by splitting the code in few blocks(short sentences)

Please close this issue only when you're happy with the sphinx-gallery.

sphinx-gallery: 1d/plot_filters

Plot first-order (Q = 8) and second-order (Q = 1) wavelets along with their lowpass filters —————————————————————————

This is not long enough and does not display well on sphinx-gallery

Please close this issue only when you're happy with the sphinx-gallery.

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.