Skip to content

Commit

Permalink
nngraph: fix definition of gaussian kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeff committed Feb 24, 2019
1 parent dad4105 commit f544e1e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions doc/tutorials/optimization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ We start with the graph TV regularization. We will use the :class:`pyunlocbox.so
>>> prob1 = pyunlocbox.solvers.solve([d, r, f], solver=solver,
... x0=x0, rtol=0, maxit=1000)
Solution found after 1000 iterations:
objective function f(sol) = 2.138668e+02
objective function f(sol) = 2.367630e+02
stopping criterion: MAXIT
>>>
>>> fig, ax = G.plot(prob1['sol'])
Expand All @@ -107,7 +107,7 @@ This figure shows the label signal recovered by graph total variation regulariza
>>> prob2 = pyunlocbox.solvers.solve([r, f], solver=solver,
... x0=x0, rtol=0, maxit=1000)
Solution found after 1000 iterations:
objective function f(sol) = 7.413918e+01
objective function f(sol) = 3.668690e+01
stopping criterion: MAXIT
>>>
>>> fig, ax = G.plot(prob2['sol'])
Expand Down
4 changes: 2 additions & 2 deletions pygsp/filters/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def filter(self, s, method='chebyshev', order=30):
>>> _ = G.plot(s1, ax=axes[0])
>>> _ = G.plot(s2, ax=axes[1])
>>> print('{:.5f}'.format(np.linalg.norm(s1 - s2)))
0.28049
0.27175
Perfect reconstruction with Itersine, a tight frame:
Expand Down Expand Up @@ -449,7 +449,7 @@ def estimate_frame_bounds(self, x=None):
A=1.708, B=2.359
>>> A, B = g.estimate_frame_bounds(G.e)
>>> print('A={:.3f}, B={:.3f}'.format(A, B))
A=1.712, B=2.348
A=1.720, B=2.355
The frame bounds can be seen in the plot of the filter bank as the
minimum and maximum of their squared sum (the black curve):
Expand Down
2 changes: 1 addition & 1 deletion pygsp/graphs/fourier.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def coherence(self):
>>> graph.compute_fourier_basis()
>>> minimum = 1 / np.sqrt(graph.n_vertices)
>>> print('{:.2f} in [{:.2f}, 1]'.format(graph.coherence, minimum))
0.93 in [0.12, 1]
0.91 in [0.12, 1]
>>>
>>> # Plot the most localized eigenvector.
>>> import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion pygsp/graphs/nngraphs/nngraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def __init__(self, features, standardize=False,
# Users can easily do the above.

def kernel(distance, width):
return np.exp(-distance**2 / width)
return np.exp(-distance**2 / width**2)

W.data = kernel(W.data, kernel_width)

Expand Down
4 changes: 2 additions & 2 deletions pygsp/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_frame(self):
def get_frame(freq_response):
return self._G.U.dot(np.diag(freq_response).dot(self._G.U.T))
gL = np.concatenate([get_frame(gl) for gl in g.evaluate(self._G.e)])
np.testing.assert_allclose(gL1, gL)
np.testing.assert_allclose(gL1, gL, atol=1e-10)
np.testing.assert_allclose(gL2, gL, atol=1e-10)

def test_complement(self, frame_bound=2.5):
Expand Down Expand Up @@ -228,7 +228,7 @@ def test_modulation_gabor(self):
f2 = filters.Gabor(self._G, f)
s1 = f1.filter(self._signal)
s2 = f2.filter(self._signal)
np.testing.assert_allclose(s1, s2, atol=1e-5)
np.testing.assert_allclose(s1, -s2, atol=1e-5)

def test_halfcosine(self):
f = filters.HalfCosine(self._G, Nf=4)
Expand Down

0 comments on commit f544e1e

Please sign in to comment.