def test_highlight(self): def test(G): s = np.arange(G.N) G.plot_signal(s, backend='matplotlib', highlight=0) G.plot_signal(s, backend='matplotlib', highlight=[0]) G.plot_signal(s, backend='matplotlib', highlight=[0, 1]) # Test for 1, 2, and 3D graphs. G = graphs.Ring() test(G) G = graphs.Ring() G.set_coordinates('line1D') test(G) G = graphs.Torus(Nv=5) test(G)
def test_indices(self): def test(G): G.plot(backend='matplotlib', indices=False) G.plot(backend='matplotlib', indices=True) # Test for 2D and 3D graphs. G = graphs.Ring(10) test(G) G = graphs.Torus(Nv=5) test(G)
def test_regression_tikhonov_1(self): """Solve a trivial regression problem.""" G = graphs.Ring(N=8) signal = np.array([0, np.nan, 4, np.nan, 4, np.nan, np.nan, np.nan]) mask = np.array([True, False, True, False, True, False, False, False]) truth = np.array([0, 2, 4, 4, 4, 3, 2, 1]) recovery = learning.regression_tikhonov(G, signal, mask, tau=0) np.testing.assert_allclose(recovery, truth) # Test the numpy solution. G = graphs.Graph(G.W.toarray()) recovery = learning.regression_tikhonov(G, signal, mask, tau=0) np.testing.assert_allclose(recovery, truth)
def test_ring(self): graphs.Ring() graphs.Ring(N=32, k=16) self.assertRaises(ValueError, graphs.Ring, 2) self.assertRaises(ValueError, graphs.Ring, 5, k=3)
def test_ring(self): graphs.Ring() graphs.Ring(N=32, k=16)
def test_Ring(): G = graphs.Ring()
""" Instantiate and plot wavelet filter banks on graphs Author: Shashwat Shukla Date: 2nd June 2020 """ # Import libraries import numpy as np import matplotlib.pyplot as plt from pygsp import graphs, filters, plotting, utils # Meyer wavelets on a ring G = graphs.Ring(400) G.estimate_lmax() g = filters.Meyer(G, Nf=6) fig, ax = plt.subplots(figsize=(10, 5)) g.plot(ax=ax) _ = ax.set_title('Filter bank of Meyer wavelets') DELTA = 255 s = g.localize(DELTA) fig = plt.figure(figsize=(10, 2.5)) for i in range(4): ax = fig.add_subplot(1, 4, i + 1, projection='3d') G.plot_signal(s[:, i], ax=ax) _ = ax.set_title('Wavelet {}'.format(i + 1)) ax.set_axis_off() fig.tight_layout() plt.show() # Mexican hat wavelets on a torus
return [X_out_, A_out_, I_out_] upsampling_from_mask_op = Lambda(upsampling_from_mask) upsampling_from_matrix_op = Lambda(upsampling_from_matrix) # HYPERPARAMS ITER = 10000 ACTIV = 'tanh' dataset = 'grid' gnn_channels = 32 es_patience = 1000 # LOAD DATASET if dataset == 'ring': G = graphs.Ring(N=200) elif dataset == 'grid': G = graphs.Grid2d(N1=30, N2=30) X = G.coords.astype(np.float32) A = G.W y = np.zeros(X.shape[0]) # X[:,0] + X[:,1] n_classes = np.unique(y).shape[0] n_feat = X.shape[-1] n_nodes = A.shape[0] # MODEL DEFINITION X_in = Input( tensor=tf.placeholder(tf.float32, shape=(None, n_feat), name='X_in')) A_in = Input(tensor=tf.sparse_placeholder(tf.float32, shape=(None, None)), name='A_in') I_in = Input(
def test_Ring(): G = graphs.Ring() needed_attributes_testing(G)