diff options
author | Gard Spreemann <gspr@nonempty.org> | 2022-08-17 14:31:07 +0200 |
---|---|---|
committer | Gard Spreemann <gspr@nonempty.org> | 2022-08-17 14:31:07 +0200 |
commit | e65c2f6750eca50a2333801a25f401b318e49ef7 (patch) | |
tree | ea24364b96a3dafe237d21d836a0857675d257b1 /src/python/doc/cubical_complex_tflow_itf_ref.rst | |
parent | dbc404626955aee632fa47ee7a4d4c3add7d6188 (diff) | |
parent | de8bd5109fcdc6d4d200c74685bab031d953d2af (diff) |
Merge tag 'tags/gudhi-release-3.6.0' into dfsg/latest
Diffstat (limited to 'src/python/doc/cubical_complex_tflow_itf_ref.rst')
-rw-r--r-- | src/python/doc/cubical_complex_tflow_itf_ref.rst | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/python/doc/cubical_complex_tflow_itf_ref.rst b/src/python/doc/cubical_complex_tflow_itf_ref.rst new file mode 100644 index 00000000..b32f5e47 --- /dev/null +++ b/src/python/doc/cubical_complex_tflow_itf_ref.rst @@ -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]))) + + 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: |