Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PD gradient #411

Merged
merged 102 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
11aebf8
added code, doc and test
MathieuCarriere Nov 1, 2020
22202ff
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Nov 13, 2020
3c39821
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Nov 26, 2020
4a14762
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Dec 1, 2020
e1cb636
added doc
MathieuCarriere Dec 7, 2020
0c477ba
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Dec 14, 2020
75721d6
small change of model name + doc
MathieuCarriere Dec 15, 2020
de68241
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Dec 15, 2020
2bdbfd1
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Dec 22, 2020
95e1c4c
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Jan 4, 2021
794aaaf
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Jan 6, 2021
071d5ab
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Jan 20, 2021
a6fba0a
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Jan 22, 2021
44e6bc9
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Jan 23, 2021
6a062a4
small fix on Cubical
MathieuCarriere Feb 2, 2021
ec0f360
error fix
MathieuCarriere Feb 3, 2021
c080d71
avoid tensorflow addons dependency
MathieuCarriere Feb 4, 2021
f926b2c
new try to fix errors
Feb 13, 2021
be01452
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Mar 10, 2021
377d36d
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Mar 22, 2021
6515c60
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Apr 16, 2021
0cf63fe
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Apr 23, 2021
90cc642
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Apr 25, 2021
151192a
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Apr 26, 2021
aa15ae9
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere May 4, 2021
c0ad04d
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere May 4, 2021
8f6a9ba
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere May 5, 2021
5698174
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere May 28, 2021
dc78f94
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Jul 5, 2021
6e2b5ca
removed padding
MathieuCarriere Jul 5, 2021
a384882
small fix
MathieuCarriere Jul 7, 2021
15db370
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Aug 6, 2021
270bdf8
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Aug 14, 2021
5d98260
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Sep 8, 2021
160c0a9
changed name differentiation ---> tensorflow and separated functions …
MathieuCarriere Oct 18, 2021
fc1c33d
update on python documentation
MathieuCarriere Oct 19, 2021
423c4be
fix python documentation
MathieuCarriere Oct 19, 2021
10be828
cleanup
MathieuCarriere Oct 19, 2021
c4269ee
fix doc
MathieuCarriere Nov 1, 2021
6b16678
fix installation doc
MathieuCarriere Nov 1, 2021
1597a5b
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Nov 3, 2021
734622d
update doc and pieces of code
MathieuCarriere Nov 4, 2021
bd7134d
modified API for multiple dimensions and finite + essential
MathieuCarriere Nov 5, 2021
dacc47d
fix cubical code
MathieuCarriere Nov 7, 2021
3f1a6e6
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Nov 7, 2021
6ae793a
removed unraveling in cubical
MathieuCarriere Nov 12, 2021
74dfd10
fix non-default vs default
MathieuCarriere Nov 12, 2021
1fd37bf
avoid transpose
MathieuCarriere Nov 12, 2021
f09d7da
update doc
MathieuCarriere Nov 15, 2021
7e71aff
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Nov 15, 2021
7b83812
fix doc
MathieuCarriere Nov 16, 2021
00ac6d1
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Nov 19, 2021
b966a15
small change on doc
MathieuCarriere Nov 22, 2021
e9b297e
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Dec 3, 2021
979d12e
added min persistence
MathieuCarriere Dec 4, 2021
96c7e5c
update code and doc
MathieuCarriere Dec 4, 2021
2c3710f
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Dec 7, 2021
4d93c78
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Dec 16, 2021
f58cba6
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Dec 17, 2021
c1c837a
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Dec 19, 2021
e646ae2
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Dec 21, 2021
495a912
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Jan 4, 2022
da65cf5
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Jan 5, 2022
5c9715c
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Jan 13, 2022
070e08a
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Jan 13, 2022
c977764
fix error
MathieuCarriere Jan 24, 2022
c07e645
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Feb 1, 2022
5c00d2d
fixed bugs from the new API
MathieuCarriere Feb 2, 2022
7ec5d7c
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Feb 10, 2022
041dfcf
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Feb 14, 2022
fe3fb13
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Feb 14, 2022
3d78c67
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Feb 16, 2022
cbba4bf
changed doc + added tensorflow indexing
MathieuCarriere Feb 28, 2022
2eabdd9
fix rips test code
MathieuCarriere Feb 28, 2022
783945b
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Mar 1, 2022
af1bdca
fix sphinx test for rips
MathieuCarriere Mar 2, 2022
159f869
Missing empty lines in sphinx doc
mglisse Mar 2, 2022
4afd99a
Restore submodule
mglisse Mar 2, 2022
b9e10ca
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Mar 7, 2022
6f4cc44
Merge branch 'diff' of https://github.com/MathieuCarriere/gudhi into …
MathieuCarriere Mar 7, 2022
6d9e3d3
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Apr 3, 2022
92517a8
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Apr 12, 2022
27f8df3
fix doc + reshape in cubical
MathieuCarriere Apr 12, 2022
cc723a7
fix test
MathieuCarriere Apr 16, 2022
b9119a9
update doc + remove numpy/tensorflow mixup
MathieuCarriere Apr 27, 2022
3ef78d7
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Apr 27, 2022
9422b2b
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere May 12, 2022
4dd9bc6
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere May 18, 2022
bff442d
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere May 20, 2022
6e5b348
updated output for cubical complexes
MathieuCarriere May 23, 2022
5216033
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere May 23, 2022
5b4d492
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere May 24, 2022
6da9c23
fix doc
MathieuCarriere Jun 1, 2022
49a3d91
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Jun 4, 2022
c319927
fix doc + added homology field coeff
MathieuCarriere Jun 7, 2022
c0f6767
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Jun 7, 2022
1d51876
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Jun 9, 2022
45d8f7c
removed default field coefficient
MathieuCarriere Jun 9, 2022
2ddce16
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Jun 17, 2022
e0f359c
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Jun 20, 2022
b93fbe5
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
MathieuCarriere Jun 24, 2022
370c091
changed dimensions into homology_dimensions
MathieuCarriere Jun 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ if(PYTHONINTERP_FOUND)
set(GUDHI_PYTHON_MODULES "${GUDHI_PYTHON_MODULES}'euclidean_strong_witness_complex', ")
# Modules that should not be auto-imported in __init__.py
set(GUDHI_PYTHON_MODULES_EXTRA "${GUDHI_PYTHON_MODULES_EXTRA}'representations', ")
set(GUDHI_PYTHON_MODULES_EXTRA "${GUDHI_PYTHON_MODULES_EXTRA}'tensorflow', ")
set(GUDHI_PYTHON_MODULES_EXTRA "${GUDHI_PYTHON_MODULES_EXTRA}'wasserstein', ")
set(GUDHI_PYTHON_MODULES_EXTRA "${GUDHI_PYTHON_MODULES_EXTRA}'point_cloud', ")
set(GUDHI_PYTHON_MODULES_EXTRA "${GUDHI_PYTHON_MODULES_EXTRA}'weighted_rips_complex', ")
Expand Down Expand Up @@ -289,7 +290,8 @@ if(PYTHONINTERP_FOUND)
# Other .py files
file(COPY "gudhi/persistence_graphical_tools.py" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/gudhi")
file(COPY "gudhi/representations" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/gudhi/")
file(COPY "gudhi/wasserstein" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/gudhi")
file(COPY "gudhi/wasserstein" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/gudhi")
file(COPY "gudhi/tensorflow" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/gudhi")
file(COPY "gudhi/point_cloud" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/gudhi")
file(COPY "gudhi/clustering" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/gudhi" FILES_MATCHING PATTERN "*.py")
file(COPY "gudhi/weighted_rips_complex.py" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/gudhi")
Expand Down Expand Up @@ -562,6 +564,11 @@ if(PYTHONINTERP_FOUND)
add_gudhi_py_test(test_representations)
endif()

# Differentiation
if(TENSORFLOW_FOUND)
add_gudhi_py_test(test_diff)
endif()

# Betti curves
if(SKLEARN_FOUND AND SCIPY_FOUND)
add_gudhi_py_test(test_betti_curve_representations)
Expand Down
25 changes: 14 additions & 11 deletions src/python/doc/cubical_complex_sum.inc
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
.. table::
:widths: 30 40 30

+--------------------------------------------------------------------------+----------------------------------------------------------------------+-----------------------------+
| .. figure:: | The cubical complex represents a grid as a cell complex with | :Author: Pawel Dlotko |
| ../../doc/Bitmap_cubical_complex/Cubical_complex_representation.png | cells of all dimensions. | |
| :alt: Cubical complex representation | | :Since: GUDHI 2.0.0 |
| :figclass: align-center | | |
| | | :License: MIT |
| | | |
+--------------------------------------------------------------------------+----------------------------------------------------------------------+-----------------------------+
| * :doc:`cubical_complex_user` | * :doc:`cubical_complex_ref` |
| | * :doc:`periodic_cubical_complex_ref` |
+--------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+
+--------------------------------------------------------------------------+----------------------------------------------------------------------+---------------------------------------------------------+
| .. figure:: | The cubical complex represents a grid as a cell complex with | :Author: Pawel Dlotko |
| ../../doc/Bitmap_cubical_complex/Cubical_complex_representation.png | cells of all dimensions. | |
| :alt: Cubical complex representation | | :Since: GUDHI 2.0.0 |
| :figclass: align-center | | |
| | | :License: MIT |
| | | |
+--------------------------------------------------------------------------+----------------------------------------------------------------------+---------------------------------------------------------+
| * :doc:`cubical_complex_user` | * :doc:`cubical_complex_ref` |
| | * :doc:`periodic_cubical_complex_ref` |
+--------------------------------------------------------------------------+----------------------------------------------------------------------+---------------------------------------------------------+
| | * :doc:`cubical_complex_tflow_itf_ref` | :requires: `TensorFlow <installation.html#tensorflow>`_ |
| | | |
+--------------------------------------------------------------------------+----------------------------------------------------------------------+---------------------------------------------------------+
40 changes: 40 additions & 0 deletions src/python/doc/cubical_complex_tflow_itf_ref.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
:orphan:

.. To get rid of WARNING: document isn't included in any toctree

TensorFlow layer for cubical persistence
########################################

.. include:: differentiation_sum.inc

Example of gradient computed from cubical persistence
-----------------------------------------------------

.. testcode::

from gudhi.tensorflow import CubicalLayer
import tensorflow as tf

X = tf.Variable([[0.,2.,2.],[2.,2.,2.],[2.,2.,1.]], dtype=tf.float32, trainable=True)
cl = CubicalLayer(homology_dimensions=[0])

with tf.GradientTape() as tape:
dgm = cl.call(X)[0][0]
loss = tf.math.reduce_sum(tf.square(.5*(dgm[:,1]-dgm[:,0])))
VincentRouvreau marked this conversation as resolved.
Show resolved Hide resolved

grads = tape.gradient(loss, [X])
print(grads[0].numpy())

.. testoutput::

[[ 0. 0. 0. ]
[ 0. 0.5 0. ]
[ 0. 0. -0.5]]

Documentation for CubicalLayer
------------------------------

.. autoclass:: gudhi.tensorflow.CubicalLayer
:members:
:special-members: __init__
:show-inheritance:
12 changes: 12 additions & 0 deletions src/python/doc/differentiation_sum.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. list-table::
:widths: 40 30 30
:header-rows: 0

* - :Since: GUDHI 3.5.0
- :License: MIT
- :Requires: `TensorFlow <installation.html#tensorflow>`_

We provide TensorFlow 2 models that can handle automatic differentiation for the computation of persistence diagrams from complexes available in the Gudhi library.
This includes simplex trees, cubical complexes and Vietoris-Rips complexes. Detailed example on how to use these layers in practice are available
in the following `notebook <https://github.com/GUDHI/TDA-tutorial/blob/master/Tuto-GUDHI-optimization.ipynb>`_. Note that even if TensorFlow GPU is enabled, all
internal computations using Gudhi will be done on CPU.
6 changes: 5 additions & 1 deletion src/python/doc/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,11 @@ mathematics, science, and engineering.
TensorFlow
----------

`TensorFlow <https://www.tensorflow.org>`_ is currently only used in some automatic differentiation tests.
The :doc:`cubical complex </cubical_complex_tflow_itf_ref>`, :doc:`simplex tree </ls_simplex_tree_tflow_itf_ref>`
and :doc:`Rips complex </rips_complex_tflow_itf_ref>` modules require `TensorFlow <https://www.tensorflow.org>`_
for incorporating them in neural nets.

`TensorFlow <https://www.tensorflow.org>`_ is also used in some automatic differentiation tests.

Bug reports and contributions
*****************************
Expand Down
53 changes: 53 additions & 0 deletions src/python/doc/ls_simplex_tree_tflow_itf_ref.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
:orphan:

.. To get rid of WARNING: document isn't included in any toctree

TensorFlow layer for lower-star persistence on simplex trees
############################################################

.. include:: differentiation_sum.inc

Example of gradient computed from lower-star filtration of a simplex tree
-------------------------------------------------------------------------

.. testcode::

from gudhi.tensorflow import LowerStarSimplexTreeLayer
import tensorflow as tf
import gudhi as gd

st = gd.SimplexTree()
st.insert([0, 1])
st.insert([1, 2])
st.insert([2, 3])
st.insert([3, 4])
st.insert([4, 5])
st.insert([5, 6])
st.insert([6, 7])
st.insert([7, 8])
st.insert([8, 9])
st.insert([9, 10])

F = tf.Variable([6.,4.,3.,4.,5.,4.,3.,2.,3.,4.,5.], dtype=tf.float32, trainable=True)
sl = LowerStarSimplexTreeLayer(simplextree=st, homology_dimensions=[0])

with tf.GradientTape() as tape:
dgm = sl.call(F)[0][0]
loss = tf.math.reduce_sum(tf.square(.5*(dgm[:,1]-dgm[:,0])))
VincentRouvreau marked this conversation as resolved.
Show resolved Hide resolved

grads = tape.gradient(loss, [F])
print(grads[0].indices.numpy())
print(grads[0].values.numpy())

.. testoutput::

[2 4]
[-1. 1.]

Documentation for LowerStarSimplexTreeLayer
-------------------------------------------

.. autoclass:: gudhi.tensorflow.LowerStarSimplexTreeLayer
:members:
:special-members: __init__
:show-inheritance:
5 changes: 4 additions & 1 deletion src/python/doc/rips_complex_sum.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@
| | | |
+----------------------------------------------------------------+------------------------------------------------------------------------+----------------------------------------------------------------------------------+
| * :doc:`rips_complex_user` | * :doc:`rips_complex_ref` |
+----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
+----------------------------------------------------------------+------------------------------------------------------------------------+----------------------------------------------------------------------------------+
| | * :doc:`rips_complex_tflow_itf_ref` | :requires: `TensorFlow <installation.html#tensorflow>`_ |
| | | |
+----------------------------------------------------------------+------------------------------------------------------------------------+----------------------------------------------------------------------------------+
48 changes: 48 additions & 0 deletions src/python/doc/rips_complex_tflow_itf_ref.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
:orphan:

.. To get rid of WARNING: document isn't included in any toctree

TensorFlow layer for Vietoris-Rips persistence
##############################################

.. include:: differentiation_sum.inc

Example of gradient computed from Vietoris-Rips persistence
-----------------------------------------------------------

.. testsetup::

import numpy
numpy.set_printoptions(precision=4)

.. testcode::

from gudhi.tensorflow import RipsLayer
import tensorflow as tf

X = tf.Variable([[1.,1.],[2.,2.]], dtype=tf.float32, trainable=True)
rl = RipsLayer(maximum_edge_length=2., homology_dimensions=[0])

with tf.GradientTape() as tape:
dgm = rl.call(X)[0][0]
loss = tf.math.reduce_sum(tf.square(.5*(dgm[:,1]-dgm[:,0])))
VincentRouvreau marked this conversation as resolved.
Show resolved Hide resolved

grads = tape.gradient(loss, [X])
print(grads[0].numpy())

.. testcleanup::

numpy.set_printoptions(precision=8)

.. testoutput::

[[-0.5 -0.5]
[ 0.5 0.5]]
mglisse marked this conversation as resolved.
Show resolved Hide resolved

Documentation for RipsLayer
---------------------------

.. autoclass:: gudhi.tensorflow.RipsLayer
:members:
:special-members: __init__
:show-inheritance:
23 changes: 13 additions & 10 deletions src/python/doc/simplex_tree_sum.inc
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
.. table::
:widths: 30 40 30

+----------------------------------------------------------------+------------------------------------------------------------------------+-----------------------------+
| .. figure:: | The simplex tree is an efficient and flexible data structure for | :Author: Clément Maria |
| ../../doc/Simplex_tree/Simplex_tree_representation.png | representing general (filtered) simplicial complexes. | |
| :alt: Simplex tree representation | | :Since: GUDHI 2.0.0 |
| :figclass: align-center | The data structure is described in | |
| | :cite:`boissonnatmariasimplextreealgorithmica` | :License: MIT |
| | | |
+----------------------------------------------------------------+------------------------------------------------------------------------+-----------------------------+
| * :doc:`simplex_tree_user` | * :doc:`simplex_tree_ref` |
+----------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
+----------------------------------------------------------------+------------------------------------------------------------------------+---------------------------------------------------------+
| .. figure:: | The simplex tree is an efficient and flexible data structure for | :Author: Clément Maria |
| ../../doc/Simplex_tree/Simplex_tree_representation.png | representing general (filtered) simplicial complexes. | |
| :alt: Simplex tree representation | | :Since: GUDHI 2.0.0 |
| :figclass: align-center | The data structure is described in | |
| | :cite:`boissonnatmariasimplextreealgorithmica` | :License: MIT |
| | | |
+----------------------------------------------------------------+------------------------------------------------------------------------+---------------------------------------------------------+
| * :doc:`simplex_tree_user` | * :doc:`simplex_tree_ref` |
+----------------------------------------------------------------+------------------------------------------------------------------------+---------------------------------------------------------+
| | * :doc:`ls_simplex_tree_tflow_itf_ref` | :requires: `TensorFlow <installation.html#tensorflow>`_ |
| | | |
+----------------------------------------------------------------+------------------------------------------------------------------------+---------------------------------------------------------+
5 changes: 5 additions & 0 deletions src/python/gudhi/tensorflow/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .cubical_layer import CubicalLayer
from .lower_star_simplex_tree_layer import LowerStarSimplexTreeLayer
from .rips_layer import RipsLayer
Comment on lines +1 to +3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it is impossible to import say just CubicalLayer without also importing all the other tensorflow layers?
That's a possible choice, I am just wondering if that's deliberate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not really deliberate, I just don't know how to avoid this -_-'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh? You mean what happens if you remove those 3 lines? 😕
Or are you asking how to have CubicalLayer directly in gudhi.tensorflow but still require some import gudhi.tensorflow.cubical_layer or something?
(again, I am not asking you to change that, just discussing what we want in the end)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I wanted to be able to do from gudhi.tensorflow import *, but I don't know if it is possible to do from gudhi.tensorflow import CubicalLayer without also importing the other two. That being said, I do not really care about this __init__ file, if there is a better, more consistent way of writing it, I'll be happy to use it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what you describe forces to load everything. To be able to load only some, I think it would need to be from gudhi.tensorflow.cubical_layer import CubicalLayer (there could still be a short from gudhi.tensorflow.all import * for those who want everything). I don't know if doing that would be useful, or if we should stick with loading everything, which is simpler, if a bit wasteful.


__all__ = ["LowerStarSimplexTreeLayer", "RipsLayer", "CubicalLayer"]
Loading