Skip to content
Snippets Groups Projects
Commit 67d3b693 authored by Rickard Brüel Gabrielsson's avatar Rickard Brüel Gabrielsson
Browse files

Alpha but seems to be only for 3d

parent 082793d4
Branches
No related tags found
No related merge requests found
from __future__ import print_function from __future__ import print_function
import numpy as np import numpy as np
import sys import sys
sys.path.append('../Python') sys.path.append('../util')
from ..util.topologicalutilsRIPS import computePersistence #from ..util.topologicalutilsRIPS import computePersistence
from topologicalutilsRIPS import computePersistence
import dionysus as d import dionysus as d
import time import time
import torch import torch
...@@ -10,8 +11,14 @@ from torch.autograd import Variable, Function ...@@ -10,8 +11,14 @@ from torch.autograd import Variable, Function
dtype=torch.float32 # torch.double #torch.float32 dtype=torch.float32 # torch.double #torch.float32
PLOT = True PLOT = True
ALPHA = True
if ALPHA:
import diode
''' OBS: -1.0 are used as a token value for dgm values and indicies!!!!!! ''' ''' OBS: -1.0 are used as a token value for dgm values and indicies!!!!!! '''
class Diagramlayer(Function): class Diagramlayer(Function):
def __init__(self):
super(Diagramlayer, self).__init__()
# Note that both forward and backward are @staticmethods # Note that both forward and backward are @staticmethods
@staticmethod @staticmethod
...@@ -31,6 +38,10 @@ class Diagramlayer(Function): ...@@ -31,6 +38,10 @@ class Diagramlayer(Function):
function_useable = function_values.data.numpy() function_useable = function_values.data.numpy()
''' 2 is max homology dimension ''' ''' 2 is max homology dimension '''
''' returns (sorted) filtration filled with the k-skeleton of the clique complex built on the points at distance at most r from each other ''' ''' returns (sorted) filtration filled with the k-skeleton of the clique complex built on the points at distance at most r from each other '''
if ALPHA:
simplices = diode.fill_alpha_shapes(function_useable)
F = d.Filtration(simplices)
else:
F = d.fill_rips(function_useable, MAX_DIMENSION, SATURATION_VALUE) F = d.fill_rips(function_useable, MAX_DIMENSION, SATURATION_VALUE)
F.sort() F.sort()
...@@ -109,6 +120,7 @@ class Diagramlayer(Function): ...@@ -109,6 +120,7 @@ class Diagramlayer(Function):
return grad_input, None, None, None return grad_input, None, None, None
if __name__ == "__main__": if __name__ == "__main__":
# diagramlayer = Diagramlayer.apply
diagramlayer = Diagramlayer.apply diagramlayer = Diagramlayer.apply
from torch.autograd import gradcheck from torch.autograd import gradcheck
from utils_plot import plot_diagram2 from utils_plot import plot_diagram2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment