[Insight-users] LBFGSB optimizer number of iterations printout error
Emma Saunders
emmasaunders123 at gmail.com
Tue Oct 1 05:18:55 EDT 2013
Hi all,
Im printing out values of metric following Bspline registrations, using an
observer connected to the optimizer.
However when using boptimizer->SetMaximumNumberOfIterations( 2 );
I actually get 8 values printed out: see below. The command iteration
update code is also attched. At first I thought it was because I use
multiple observers during each multiresolution step but also
removeallobservers() between each multi layer step. Any suggestions
appreciated?
Starting Registration with Medium resolution transform
1.07399e+06
bspline
1.06241e+06
bspline
1.01962e+06
bspline
1.01962e+06
bspline
895448
bspline
895448
bspline
878673
bspline
878673
bspline
//This is for B spline
class BCommandIterationUpdate : public itk::Command
{
public:
typedef BCommandIterationUpdate Selfb;
typedef itk::Command Superclassb;
typedef itk::SmartPointer<Selfb> Pointerb;
itkNewMacro( Selfb );
protected:
BCommandIterationUpdate() {};
public:
typedef itk::LBFGSBOptimizer bOptimizerType;
typedef const bOptimizerType * bOptimizerPointer;
void Execute(itk::Object *caller, const itk::EventObject & event)
{
Execute( (const itk::Object *)caller, event);
}
void Execute(const itk::Object * object, const itk::EventObject & event)
{
bOptimizerPointer boptimizer =
dynamic_cast< bOptimizerPointer >( object );
if( ! itk::IterationEvent().CheckEvent( &event ) )
{
return;
}
//std::cout << optimizer->GetCurrentIteration() << " ";
std::cout << boptimizer->GetValue() << " " <<std::endl;
std::cout << "bspline" <<std::endl;
//std::cout << optimizer->GetCurrentPosition() << std::endl;
}
};
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20131001/8ee755c4/attachment.htm>
More information about the Insight-users
mailing list