summaryrefslogtreecommitdiffstats
path: root/src/Python
diff options
context:
space:
mode:
authorEdoardo Pasca <edo.paskino@gmail.com>2017-10-25 12:25:59 +0100
committerEdoardo Pasca <edo.paskino@gmail.com>2017-10-25 12:25:59 +0100
commit7033c692bd836ca300fc6d91ce7cd733a2342cde (patch)
tree048c488a00235674f63662b79c1c2af690551edf /src/Python
parentc21df8581e052541a2dd39a46a4c1f50e335fd9e (diff)
downloadregularization-7033c692bd836ca300fc6d91ce7cd733a2342cde.tar.gz
regularization-7033c692bd836ca300fc6d91ce7cd733a2342cde.tar.bz2
regularization-7033c692bd836ca300fc6d91ce7cd733a2342cde.tar.xz
regularization-7033c692bd836ca300fc6d91ce7cd733a2342cde.zip
Added print to screen to debug faulty FGP_TV
Bug #2 came from not initializing lambda but mu.
Diffstat (limited to 'src/Python')
-rw-r--r--src/Python/fista_module.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/Python/fista_module.cpp b/src/Python/fista_module.cpp
index c36329e..f8fd812 100644
--- a/src/Python/fista_module.cpp
+++ b/src/Python/fista_module.cpp
@@ -338,7 +338,7 @@ bp::list FGP_TV(np::ndarray input, double d_mu, int iter, double d_epsil, int me
A = reinterpret_cast<float *>(input.get_data());
//mu = (float)mxGetScalar(prhs[1]); /* regularization parameter */
- mu = (float)d_mu;
+ lambda = (float)d_mu;
//iter = 35; /* default iterations number */
@@ -408,15 +408,17 @@ bp::list FGP_TV(np::ndarray input, double d_mu, int iter, double d_epsil, int me
/* begin iterations */
for (ll = 0; ll<iter; ll++) {
-
+ std::cout << "iteration " << ll << " D[0]" << D[0] << std::endl;
/* computing the gradient of the objective function */
Obj_func2D(A, D, R1, R2, lambda, dimX, dimY);
+ std::cout << "Obj_func2D D[0] " << D[0]<< " A[0]" << A[0] << " R1[0] " << R1[0] << " R2[0] " << R2[0] << " lambda " << lambda << " dimX " << dimX << " dimY " << dimY << std::endl;
/*Taking a step towards minus of the gradient*/
Grad_func2D(P1, P2, D, R1, R2, lambda, dimX, dimY);
+ std::cout << "Grad_func2D D[0] " << D[0]<< " P1[0]" << P1[0] << " P2[0] " << P2[0] << " R1[0] " << R1[0] << " R2[0] " << R2[0] << " lambda " << lambda << " dimX " << dimX << " dimY " << dimY << std::endl;
+
+
- /* projection step */
- Proj_func2D(P1, P2, methTV, dimX, dimY);
/*updating R and t*/
tkp1 = (1.0f + sqrt(1.0f + 4.0f*tk*tk))*0.5f;
@@ -433,6 +435,7 @@ bp::list FGP_TV(np::ndarray input, double d_mu, int iter, double d_epsil, int me
if (re < epsil) count++;
if (count > 3) {
Obj_func2D(A, D, P1, P2, lambda, dimX, dimY);
+ std::cout << "Obj_func2D D[0] " << D[0]<< " A[0]" << A[0] << " R1[0] " << R1[0] << " R2[0] " << R2[0] << " lambda " << lambda << " dimX " << dimX << " dimY " << dimY << std::endl;
funcval = 0.0f;
for (j = 0; j<dimX*dimY*dimZ; j++) funcval += pow(D[j], 2);
//funcvalA[0] = sqrt(funcval);
@@ -445,6 +448,7 @@ bp::list FGP_TV(np::ndarray input, double d_mu, int iter, double d_epsil, int me
if (ll > 2) {
if (re > re_old) {
Obj_func2D(A, D, P1, P2, lambda, dimX, dimY);
+ std::cout << "Obj_func2D D[0] " << D[0]<< " A[0]" << A[0] << " R1[0] " << R1[0] << " R2[0] " << R2[0] << " lambda " << lambda << " dimX " << dimX << " dimY " << dimY << std::endl;
funcval = 0.0f;
for (j = 0; j<dimX*dimY*dimZ; j++) funcval += pow(D[j], 2);
//funcvalA[0] = sqrt(funcval);
@@ -465,6 +469,7 @@ bp::list FGP_TV(np::ndarray input, double d_mu, int iter, double d_epsil, int me
/* calculating the objective function value */
if (ll == (iter - 1)) {
Obj_func2D(A, D, P1, P2, lambda, dimX, dimY);
+ std::cout << "Obj_func2D D[0] " << D[0]<< " A[0]" << A[0] << " R1[0] " << R1[0] << " R2[0] " << R2[0] << " lambda " << lambda << " dimX " << dimX << " dimY " << dimY << std::endl;
funcval = 0.0f;
for (j = 0; j<dimX*dimY*dimZ; j++) funcval += pow(D[j], 2);
//funcvalA[0] = sqrt(funcval);
@@ -1048,4 +1053,4 @@ BOOST_PYTHON_MODULE(cpu_regularizers)
def("LLT_model", LLT_model);
def("PatchBased_Regul", PatchBased_Regul);
def("TGV_PD", TGV_PD);
-} \ No newline at end of file
+}