Git Product home page Git Product logo

applications's Introduction

Applications

Applications for Geomstats that illustrate more involved uses of the package.

Brain Connectome Analysis

We consider the fMRI data from the 2014 MLSP Schizophrenia Classification challenge, consisting of the resting-state fMRIs of 86 patients split into two balanced categories: control vs people suffering schizophrenia.

We approach the classification task by using a SVM classifier on pairwise-similarities between brain connectomes, represented as the SPD matrices of their regularized Laplacians. The similarities are computed with the affine-invariant Riemannian distance on the manifold of SPD matrices.

pip3 install geomstats==1.7

# from the root of your unziped directory
cd brain_connectome
pip3 install -r requirements.txt
python3 spd_fmri.py

Robotics Application

We consider a robot arm in this application. In robotics, it is common to control a manipulator in Cartesian space rather than configuration space. We generate a geodesic on SO(3) between the initial orientation of the robot arm and its desired final orientation. We use the generated trajectory as an input to the robot controller.

The robotics application is a little bit more involved. It has its own README.md file and corresponding instructions. You will need a C++ compilation toolchain.

pip3 install geomstats==1.7

# from the root of your unziped directory
cat robotics/README.md

Training MNIST on the Hypersphere

We consider the training of MNIST with weights constrained on the Hypersphere. The optimization step has been modified in keras such that the stochastic gradient descent is done on the manifold through the Exponential Map.

The deep learning application requires a tensorflow patch and installing a modified version of keras.

pip3 install geomstats==1.7

# from the root of your unziped directory
cat deep_learning/README.md

Training a Pose Estimation Network

This example trains a pose estimation network using a SE3 Geodesic Loss function.

pip3 install geomstats==1.7

# from the root of your unziped directory
cat se3_pose_estimation/README.md

Impact of the curvature on the empirical Fréchet mean estimation manifolds

This application illustrates the modulation of the speed of convergence of the empirical Fréchet mean with the curvature in spheres and hyperbolic spaces described in the arXiv paper 1906.07418. The application is actually the source-code to create the figures of this paper.

The variance of the Fréchet mean FM_n of a sample of n IID random variables of variance Var is decreasing more slowly in a sphere than in a Euclidean space, and more quickly in a Hyperbolic space. Two scripts of this application compare the speed of convergence in spheres and hyperbolic spaces to the classical one in Euclidean spaces by computing the modulation factor alpha = Var( FM_n) / ( n * Var) for synthetic IID n-samples drawn from isotropic distributions on hyper-spheres (bubble distributions) of different radii. The last script computes the modulation factor for bootstrap n-samples drawn from a few real-world empirical distributions on the sphere S2 taken from the book of Fisher, Lewis and Embleton 1987.

pip3 install geomstats==1.18

# from the root of your unziped directory
cat modulation_empirical_frechet_mean/README.md

Enjoy :)

applications's People

Contributors

alebrigant avatar donnate avatar johmathe avatar ninamiolane avatar xpennec 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

applications's Issues

deep learning applications readme patch breaks tensorflow>=1.12

Hi,

I'm trying to run geomstats deep learning applications on Ubuntu 18.04 LTS using my RTX 2080 GPU. I systematically encounter an error that suggests the patch on variables.py described in the repo's readme breaks my tensorflow. Hardware and drivers description:

  • Ubuntu LTS 18.04
  • NVIDIA driver version 418.56 (proprietary)
  • CUDA 10.0
  • cuDNN 7.5.0 (installed from .deb files)
  • RTX 2080 GPU
  • Ryzen 2700x CPU

I have one possible explanation, although I find it absurd, but in case it saves us a lot of time: do the deep learning applications only work with tensorflow version 1.8 ? Because the requirements.txt of geomstats says tensorflow>=1.12, whereas the applications repo readme only mentions 1.8.

I tried the following installation steps, with:

  • tensorflow-gpu 1.13.1
  • tf-nightly-gpu 1.14.0.dev2019032201
  • tensorflow 1.13.1 (basic CPU-only version, just in case it was GPU-related in some way)
  1. create a Python 3 (3.6.7) virtual env
  2. install one of the three previously mentioned tensorflow and geomstats (1.15), with pip
  3. run tensorflow toy code to check if unpatched virtual env tensorflow works (it does this far in the steps, for all three versions of tf considered)
  4. patch virtual env tensorflow according to the applications repo's instructions
  5. install patched keras thanks to the previous step instructions, doing so with a modification of the original instructions since the target is the virtual env and not the system, hence use python setup.py install and not the readme sudo version. The shell return allows to check which Keras was installed and updated, and more specifically the exact version and whether this was indeed done in the virtual env
Using /home/mbauw/Documents/virtual_env/geomstats_env_third/lib/python3.6/site-packages
Finished processing dependencies for Keras==2.1.6
  1. try ./run.sh or python <MNIST or CIFAR example>.py and encounter same error (see at the end of this issue for complete error message)
  2. try tensorflow toy code that worked in the virtual env before patching, and encounter same error
  3. conclude that the patch broke tensorflow according to related tf repo issue
    (they advise re-installing tensorflow to solve this error, but this basically means cancelling the patch here...)

One should note that the error specifically mentions the unique file that was modified by the patch virtual_env/geomstats_env_third/lib/python3.6/site-packages/tensorflow/python/ops/variables.py.

In addition, I tried both installing Keras with pip right after tensorflow when launching the venv, and only installing Keras with the provided setup.py script. All ended with the same error.

Complete error message:

geomstats_examples/applications/deep_learning$ python cifar_10_resnet_hypersphere.py 
Using TensorFlow backend.
Traceback (most recent call last):
  File "cifar_10_resnet_hypersphere.py", line 13, in <module>
    import keras
  File "/home/mbauw/Documents/virtual_env/geomstats_env_third/lib/python3.6/site-packages/Keras-2.1.6-py3.6.egg/keras/__init__.py", line 3, in <module>
  File "/home/mbauw/Documents/virtual_env/geomstats_env_third/lib/python3.6/site-packages/Keras-2.1.6-py3.6.egg/keras/utils/__init__.py", line 6, in <module>
  File "/home/mbauw/Documents/virtual_env/geomstats_env_third/lib/python3.6/site-packages/Keras-2.1.6-py3.6.egg/keras/utils/conv_utils.py", line 9, in <module>
  File "/home/mbauw/Documents/virtual_env/geomstats_env_third/lib/python3.6/site-packages/Keras-2.1.6-py3.6.egg/keras/backend/__init__.py", line 84, in <module>
  File "/home/mbauw/Documents/virtual_env/geomstats_env_third/lib/python3.6/site-packages/Keras-2.1.6-py3.6.egg/keras/backend/tensorflow_backend.py", line 5, in <module>
  File "/home/mbauw/Documents/virtual_env/geomstats_env_third/lib/python3.6/site-packages/tensorflow/__init__.py", line 28, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/home/mbauw/Documents/virtual_env/geomstats_env_third/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 63, in <module>
    from tensorflow.python.framework.framework_lib import *  # pylint: disable=redefined-builtin
  File "/home/mbauw/Documents/virtual_env/geomstats_env_third/lib/python3.6/site-packages/tensorflow/python/framework/framework_lib.py", line 52, in <module>
    from tensorflow.python.framework.importer import import_graph_def
  File "/home/mbauw/Documents/virtual_env/geomstats_env_third/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 28, in <module>
    from tensorflow.python.framework import function
  File "/home/mbauw/Documents/virtual_env/geomstats_env_third/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 37, in <module>
    from tensorflow.python.ops import resource_variable_ops
  File "/home/mbauw/Documents/virtual_env/geomstats_env_third/lib/python3.6/site-packages/tensorflow/python/ops/resource_variable_ops.py", line 41, in <module>
    from tensorflow.python.ops import variables
  File "/home/mbauw/Documents/virtual_env/geomstats_env_third/lib/python3.6/site-packages/tensorflow/python/ops/variables.py", line 32, in <module>
    from tensorflow.python.training import checkpointable
  ImportError: cannot import name 'checkpointable'

TypeError: ('Keyword argument not understood:', 'kernel_manifold')

Hi,

I tried to run the deep learning example, but I encountered some issues.

I applied the procedure from examples/nips2018/deep_learning/README.md

I use python 3.6 anaconda environment, and these versions :

  • tensorflow 1.8.0 (patched with the copy of variables
  • geomstats 1.9 (installed from pip install geomstats)
  • keras 2.1.6 (installed from examples/nips2018/deep_learning/keras)

When I try to run with ./run.sh I have this error:

Using TensorFlow backend.
x_train shape: (60000, 28, 28, 1)
60000 train samples
10000 test samples
Traceback (most recent call last):
  File "mnist_hypersphere.py", line 54, in <module>
    kernel_manifold=Hypersphere(hypersphere_dimension)))
  File "build/bdist.linux-x86_64/egg/keras/legacy/interfaces.py", line 91, in wrapper
  File "build/bdist.linux-x86_64/egg/keras/layers/convolutional.py", line 465, in __init__
  File "build/bdist.linux-x86_64/egg/keras/layers/convolutional.py", line 104, in __init__
  File "build/bdist.linux-x86_64/egg/keras/engine/base_layer.py", line 122, in __init__
TypeError: ('Keyword argument not understood:', 'kernel_manifold')

Do you have any idea how to fix it ?

Thanks

Riemannian distance on SPDMatricesSpace is not symmetric in its arguments

Hi,

I am trying to reuse your implementation of Riemannian distance on a manifold of SPD matrices as in the brain_connectome example but I noticed that the distance function is not symmetric in its arguments. For example, I have two SPD matrices M_train and M_test for which the code

SPACE = spd_space.SPDMatricesSpace(n=8)
print(SPACE.belongs(M_test))
print(SPACE.belongs(M_train))

returns True. If I then compute the corresponding square root inverses as in your example

lambda2_test, u_test = np.linalg.eigh(M_test)
inv_test = u_test.dot(np.diag(1.0/np.sqrt(lambda2_test)).dot(u_test.T))
    
lambda2_train, u_train = np.linalg.eigh(M_train)
inv_train = u_train.dot(np.diag(1./np.sqrt(lambda2_train)).dot(u_train.T))

I get the following result when computing the Riemannian distance

riemannian(inv_test, M_train) = 4.67188330737327
riemannian(inv_train, M_test) = 2.223826153286933

which is clearly not symmetric as one would expect by the definition of a metric. Now I am starting to wonder if your implementation of the Riemannian distance

def riemannian(inv_l1, hat_l2):
    log_2 = SPACE.embedding_manifold.group_log(hat_l2).squeeze(0)
    return np.linalg.norm(inv_l1.dot(log_2.dot(inv_l1)), 'fro')

is specific to your example and is relying on some characteristics of regularized Laplacian SPD matrices that I am not aware of, or could it be used in a general case when dealing with SPD matrices? If not, what would be the correct way of computing it in my case?

Best,
Petra

AttributeError: module 'geomstats.spd_matrices_space' has no attribute 'group_log'

Hi,

I tried to run the brain_connectome example but I get the following error

AttributeError: module 'geomstats.spd_matrices_space' has no attribute 'group_log'

that is raised when trying to compute the distances, e.g.,

def frobenius(hat_l1, hat_l2):
    return np.linalg.norm(spd_space.group_log(hat_l1).squeeze(0)
                          - spd_space.group_log(hat_l2).squeeze(0),
                          'fro')

Any idea where to find group_log function?

Thanks,
Petra

Pose network example fails with Tensorflow 2

The SE(3) example fails with the latest version of geomstats, due to the transition to Tensorflow 2.

The making of the dataset files works fine if two small changes are made:

However, the training is based on inception_v1 from tensorflow.contrib.slim.(...), and the whole
contrib module has been deleted in TF 2 (

from tensorflow.contrib.slim.python.slim.nets import inception
).
Maybe another architecture already adapted to TF 2 would be fine for the example ?

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.