Commit c86aeb71 authored by Stefan Ziehe's avatar Stefan Ziehe
Browse files

Added separate tolerance for inner iterations when blocking is activated

parent 043d91c9
......@@ -51,30 +51,29 @@ class PALM(Algorithm):
ignore_error = self.ignore_error;
iters = 0;
current_change = tol+1;
change = zeros(maxiter+1);
change[0] = tol+1;
if ignore_error == False:
change = zeros(maxiter+1);
num_custom_errors = len(self.custom_error.customerror(u,u))
custom_errors = zeros((num_custom_errors,maxiter+1));
tmp_u = u;
while iters < maxiter and current_change > tol:
while iters < maxiter and change[iters] > tol:
iters += 1;
for p in projs:
tmp_u = p.work(tmp_u);
current_change = self.custom_error.change(u,tmp_u);
change[iters] = self.custom_error.change(u,tmp_u);
if ignore_error == False:
change[iters] = current_change;
custom_errors[:,iters] = self.custom_error.customerror(u,tmp_u);
u = tmp_u;
change = current_change if ignore_error else change[1:iters+1];
change = change[1:iters+1];
custom_errors = numpy.empty((5,0)) if ignore_error else custom_errors[:,1:iters+1];
return tmp_u, tmp_u.copy(), iters, change, custom_errors;
......@@ -1241,7 +1241,8 @@ class Blocking_meta(Algorithm):
self.positions = config['positions'];
self.amp_exp_norm = config['amp_exp_norm'];
self.block_maxiter = config['block_maxiter'];
self.block_tol = config['block_tol'];
self.N_pie = config['N_pie'];
self.pool = Pool();
......@@ -1312,7 +1313,7 @@ class Blocking_meta(Algorithm):
if within_blocks_scheme == 'none':
_u, sub_u_final, _iters, _change, _gap = \
sub_algorithm.run(sub_u, tol, block_maxiter);
sub_algorithm.run(sub_u, self.block_tol, block_maxiter);
_block_iters = _iters;
elif within_blocks_scheme == 'sequential':
views_in_block = numpy.arange(N_pie)[B];
......@@ -1371,16 +1372,16 @@ class Blocking_meta(Algorithm):
between_blocks_scheme = self.between_blocks_scheme;
iters = 0;
current_change = tol+1;
change = numpy.zeros(maxiter+1);
change[0] = tol+1;
if ignore_error == False:
change = numpy.zeros(maxiter+1);
num_custom_errors = len(self.custom_error.customerror(u,u))
custom_errors = numpy.zeros((num_custom_errors,maxiter+1));
tmp_u = u.copy();
while iters < maxiter and current_change > tol:
while iters < maxiter and change[iters] > tol:
iters += 1;
if between_blocks_scheme == 'sequential':
......@@ -1405,15 +1406,14 @@ class Blocking_meta(Algorithm):
else:
raise NotImplementedError('NYI')
current_change = self.custom_error.change(u,tmp_u);
change[iters] = self.custom_error.change(u,tmp_u);
if ignore_error == False:
change[iters] = current_change;
custom_errors[:,iters] = self.custom_error.customerror(u,tmp_u);
u = tmp_u.copy();
change = current_change if ignore_error else change[1:iters+1];
change = change[1:iters+1];
custom_errors = numpy.empty((5,0)) if ignore_error else custom_errors[:,1:iters+1];
return u, u.copy(), iters, change, custom_errors;
......@@ -1493,30 +1493,29 @@ class PALM(Algorithm):
ignore_error = self.ignore_error;
iters = 0;
current_change = tol+1;
change = numpy.zeros(maxiter+1);
change[0] = tol+1;
if ignore_error == False:
change = numpy.zeros(maxiter+1);
num_custom_errors = len(self.custom_error.customerror(u,u))
custom_errors = numpy.zeros((num_custom_errors,maxiter+1));
tmp_u = u;
while iters < maxiter and current_change > tol:
while iters < maxiter and change[iters] > tol:
iters += 1;
for p in projs:
tmp_u = p.work(tmp_u);
current_change = self.custom_error.change(u,tmp_u);
change[iters] = self.custom_error.change(u,tmp_u);
if self.ignore_error == False:
change[iters] = current_change;
custom_errors[:,iters] = self.custom_error.customerror(u,tmp_u);
u = tmp_u;
u = tmp_u;
change = current_change if ignore_error else change[1:iters+1];
change = change[1:iters+1];
custom_errors = numpy.empty((5,0)) if ignore_error else custom_errors[:,1:iters+1];
return tmp_u, tmp_u.copy(), iters, change, custom_errors;
......@@ -1590,16 +1589,16 @@ class RAAR_PALM(Algorithm):
ignore_error = self.ignore_error;
iters = 0
current_change = tol+1
change = numpy.zeros(maxiter+1)
change[0] = tol+1
if ignore_error == False:
change = numpy.zeros(maxiter+1)
num_custom_errors = len(self.custom_error.customerror(u,u,u))
custom_errors = numpy.zeros((num_custom_errors,maxiter+1))
tmp_u1 = projs[0].work(u)
while iters < maxiter and current_change > tol:
while iters < maxiter and change[iters] > tol:
iters += 1
tmp = exp((-iters/self.beta_switch)**3)
beta = (tmp*self.beta0) + ((1-tmp)*self.beta_max)
......@@ -1613,16 +1612,15 @@ class RAAR_PALM(Algorithm):
tmp_u2 = projs[0].work(tmp_u)
current_change = self.custom_error.change(tmp_u1,tmp_u2)
change[iters] = self.custom_error.change(tmp_u1,tmp_u2)
if self.ignore_error == False:
change[iters] = current_change
custom_errors[:,iters] = self.custom_error.customerror(tmp_u1,tmp_u2,tmp_u4)
u = tmp_u
tmp_u1 = tmp_u2
change = current_change if ignore_error else change[1:iters+1]
change = change[1:iters+1]
custom_errors = numpy.empty((5,0)) if ignore_error else custom_errors[:,1:iters+1]
return tmp_u1, tmp_u1.copy(), iters, change, custom_errors
......@@ -1674,6 +1672,7 @@ class Ptychography(Problem):
'block_rows':2,
'block_cols':2,
'block_maxiter':1,
'block_tol':1.0,
'rodenburg_inner_it':1,
'beta0':1,
'beta_max':1,
......@@ -2419,6 +2418,7 @@ class Ptychography_NTT_01_26210(Ptychography):
'block_rows':2,
'block_cols':2,
'block_maxiter':1,
'block_tol':1.0,
'rodenburg_inner_it':1,
'beta0':1,
'beta_max':1,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment