epfl-lts2 / pygsp

Graph Signal Processing in Python
https://pygsp.rtfd.io
BSD 3-Clause "New" or "Revised" License
483 stars 93 forks source link

Can't run the tutorials #62

Closed codenameAggie closed 4 years ago

codenameAggie commented 4 years ago

Howdy!

I am trying to run the tutorial as it is on the docs, and I get the following:

from pygsp import graphs, plotting 2 import numpy as np 3 ​ 4 G = graphs.Sensor(N=256, seed=42) 5 G.compute_fourier_basis() 6

Create label signal

7 label_signal = np.copysign(np.ones(G.N), G.U[:, 3]) 8 ​ 1 G.plot_signal(label_signal) (<Figure size 432x288 with 2 Axes>, <matplotlib.axes._subplots.AxesSubplot at 0x1e2feb61780>)

1 rs = np.random.RandomState(42) 2

Create the mask

3 M = rs.rand(G.N) 4 M = (M > 0.6).astype(float) # Probability of having no label on a vertex. 5

Applying the mask to the data

6 sigma = 0.1 7 subsampled_noisy_label_signal = M (label_signal + sigma rs.standard_normal(G.N)) 8 G.plot_signal(subsampled_noisy_label_signal) (<Figure size 432x288 with 2 Axes>, <matplotlib.axes._subplots.AxesSubplot at 0x1e2fee9a400>)

1 import pyunlocbox 2

Set the functions in the problem

3 gamma = 3.0 4 d = pyunlocbox.functions.dummy() 5 r = pyunlocbox.functions.norm_l1() 6 f = pyunlocbox.functions.norm_l2(w=M, y=subsampled_noisy_labelsignal, 7 lambda=gamma) 8

Define the solver

9 G.compute_differential_operator() 10 L = G.D.toarray() 11 step = 0.999 / (1 + np.linalg.norm(L)) 12 solver = pyunlocbox.solvers.mlfbf(L=L, step=step) 13

Solve the problem

14 x0 = subsampled_noisy_label_signal.copy() 15 prob1 = pyunlocbox.solvers.solve([d, r, f], solver=solver, x0=x0, rtol=0, maxit=1000) 16

17 G.plot_signal(prob1['sol'])

ValueError Traceback (most recent call last)

in 13 # Solve the problem 14 x0 = subsampled_noisy_label_signal.copy() ---> 15 prob1 = pyunlocbox.solvers.solve([d, r, f], solver=solver, x0=x0, rtol=0, maxit=1000) 16 17 G.plot_signal(prob1['sol']) c:\users\arash\anaconda3\envs\tf-gpu\lib\site-packages\pyunlocbox\solvers.py in solve(functions, x0, solver, atol, dtol, rtol, xtol, maxit, verbosity) 248 249 # Solver specific initialization. --> 250 solver.pre(functions, x0) 251 252 while not crit: c:\users\arash\anaconda3\envs\tf-gpu\lib\site-packages\pyunlocbox\solvers.py in pre(self, functions, x0) 376 self.smooth_funs = [] 377 self.non_smooth_funs = [] --> 378 self._pre(functions, self.sol) 379 self.accel.pre(functions, self.sol) 380 c:\users\arash\anaconda3\envs\tf-gpu\lib\site-packages\pyunlocbox\solvers.py in _pre(self, functions, x0) 840 841 def _pre(self, functions, x0): --> 842 super(mlfbf, self)._pre(functions, x0) 843 844 if len(functions) != 3: c:\users\arash\anaconda3\envs\tf-gpu\lib\site-packages\pyunlocbox\solvers.py in _pre(self, functions, x0) 781 # Dual variable. 782 if self.d0 is None: --> 783 self.dual_sol = self.L(x0) 784 else: 785 self.dual_sol = self.d0 c:\users\arash\anaconda3\envs\tf-gpu\lib\site-packages\pyunlocbox\solvers.py in (x) 761 else: 762 # Transform matrix form to operator form. --> 763 self.L = lambda x: L.dot(x) 764 765 if Lt is None: ValueError: shapes (256,916) and (256,) not aligned: 916 (dim 1) != 256 (dim 0) Any suggestions? Thank you, Arash
nperraud commented 4 years ago

Dear Arash,

I see that you are posting a few questions, which is good. However, it is difficult for us to help you with the way you are formulating your questions... What you should do is:

  1. Make a minimal working example such that we can reproduce your error
  2. Spend some a bit of time formulating your questions. You should check the markdown cheatsheet to make your post easier to read. https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet Please reformulate your question and we will try to help you Have a nice day
codenameAggie commented 4 years ago

Howdy!

I am so sorry! This is my first time posting on GitHub, and I didn't even know it was markdown enabled until I posted it! :)

I am working on formulating the problem in a smaller scale and will post it soon.

Thank you, Arash

codenameAggie commented 4 years ago

Howdy!

This issue was solved via the last post, "Problem With Interpolate".

Thank you, Arash