Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ mark_as_advanced( ELASTIX_BUILD_EXECUTABLE )
option( ELASTIX_BUILD_EXECUTABLE "Generate executable or library?" ON )

if( NOT ELASTIX_BUILD_EXECUTABLE )
add_definitions( -D_ELASTIX_BUILD_LIBRARY )

# The following may make smaller and quicker loading libraries,
# that hides unnecessary symbols. Available from CMake 3.0.0.
Expand Down
24 changes: 11 additions & 13 deletions Components/Optimizers/AdaGrad/elxAdaGrad.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -837,13 +837,9 @@ AdaGrad< TElastix >

} // end if NewSamplesEveryIteration.

#ifndef _ELASTIX_BUILD_LIBRARY
/** Prepare for progress printing. */
ProgressCommandPointer progressObserver = ProgressCommandType::New();
progressObserver->SetUpdateFrequency(
this->m_NumberOfGradientMeasurements, this->m_NumberOfGradientMeasurements );
progressObserver->SetStartString( " Progress: " );
#endif
const auto progressObserver = BaseComponent::IsElastixLibrary() ?
nullptr : ProgressCommandType::CreateAndSetUpdateFrequency( this->m_NumberOfGradientMeasurements );
elxout << " Sampling gradients ..." << std::endl;

/** Initialize some variables for storing gradients and their magnitudes. */
Expand All @@ -860,10 +856,11 @@ AdaGrad< TElastix >
/** Compute gg for some random parameters. */
for( unsigned int i = 0; i < this->m_NumberOfGradientMeasurements; ++i )
{
#ifndef _ELASTIX_BUILD_LIBRARY
/** Show progress 0-100% */
progressObserver->UpdateAndPrintProgress( i );
#endif
if ( progressObserver != nullptr )
{
/** Show progress 0-100% */
progressObserver->UpdateAndPrintProgress( i );
}
/** Generate a perturbation, according to:
* \mu_i ~ N( \mu_0, perturbationsigma^2 I ).
*/
Expand Down Expand Up @@ -914,9 +911,10 @@ AdaGrad< TElastix >

} // end for loop over gradient measurements

#ifdef _ELASTIX_BUILD_LIBARY
progressObserver->PrintProgress( 1.0 );
#endif
if ( progressObserver != nullptr )
{
progressObserver->PrintProgress( 1.0 );
}

/** Compute means. */
exactgg /= this->m_NumberOfGradientMeasurements;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -906,13 +906,9 @@ AdaptiveStochasticGradientDescent< TElastix >

} // end if NewSamplesEveryIteration.

#ifndef _ELASTIX_BUILD_LIBRARY
/** Prepare for progress printing. */
ProgressCommandPointer progressObserver = ProgressCommandType::New();
progressObserver->SetUpdateFrequency(
this->m_NumberOfGradientMeasurements, this->m_NumberOfGradientMeasurements );
progressObserver->SetStartString( " Progress: " );
#endif
const auto progressObserver = BaseComponent::IsElastixLibrary() ?
nullptr : ProgressCommandType::CreateAndSetUpdateFrequency( this->m_NumberOfGradientMeasurements );
elxout << " Sampling gradients ..." << std::endl;

/** Initialize some variables for storing gradients and their magnitudes. */
Expand All @@ -927,10 +923,11 @@ AdaptiveStochasticGradientDescent< TElastix >
/** Compute gg for some random parameters. */
for( unsigned int i = 0; i < this->m_NumberOfGradientMeasurements; ++i )
{
#ifndef _ELASTIX_BUILD_LIBRARY
/** Show progress 0-100% */
progressObserver->UpdateAndPrintProgress( i );
#endif
if ( progressObserver != nullptr )
{
/** Show progress 0-100% */
progressObserver->UpdateAndPrintProgress( i );
}
/** Generate a perturbation, according to:
* \mu_i ~ N( \mu_0, perturbationsigma^2 I ).
*/
Expand Down Expand Up @@ -981,9 +978,10 @@ AdaptiveStochasticGradientDescent< TElastix >

} // end for loop over gradient measurements

#ifdef _ELASTIX_BUILD_LIBARY
progressObserver->PrintProgress( 1.0 );
#endif
if ( progressObserver != nullptr )
{
progressObserver->PrintProgress( 1.0 );
}

/** Compute means. */
exactgg /= this->m_NumberOfGradientMeasurements;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1399,13 +1399,9 @@ AdaptiveStochasticLBFGS<TElastix>
} // end for loop over metrics
} // end if NewSamplesEveryIteration.

#ifndef _ELASTIX_BUILD_LIBRARY
/** Prepare for progress printing. */
ProgressCommandPointer progressObserver = ProgressCommandType::New();
progressObserver->SetUpdateFrequency(
this->m_NumberOfGradientMeasurements, this->m_NumberOfGradientMeasurements );
progressObserver->SetStartString( " Progress: " );
#endif
const auto progressObserver = BaseComponent::IsElastixLibrary() ?
nullptr : ProgressCommandType::CreateAndSetUpdateFrequency( this->m_NumberOfGradientMeasurements );
//elxout << " Sampling gradients ..." << std::endl;

/** Initialize some variables for storing gradients and their magnitudes. */
Expand All @@ -1420,10 +1416,11 @@ AdaptiveStochasticLBFGS<TElastix>
/** Compute gg for some random parameters. */
for( unsigned int i = 0 ; i < this->m_NumberOfGradientMeasurements; ++i )
{
#ifndef _ELASTIX_BUILD_LIBRARY
/** Show progress 0-100% */
progressObserver->UpdateAndPrintProgress( i );
#endif
if ( progressObserver != nullptr )
{
/** Show progress 0-100% */
progressObserver->UpdateAndPrintProgress( i );
}
/** Generate a perturbation, according to:
* \mu_i ~ N( \mu_0, perturbationsigma^2 I ).
*/
Expand Down Expand Up @@ -1473,9 +1470,10 @@ AdaptiveStochasticLBFGS<TElastix>
} // end else: no stochastic gradients

} // end for loop over gradient measurements
#ifdef _ELASTIX_BUILD_LIBARY
progressObserver->PrintProgress( 1.0 );
#endif
if ( progressObserver != nullptr )
{
progressObserver->PrintProgress( 1.0 );
}
/** Compute means. */
exactgg /= this->m_NumberOfGradientMeasurements;
diffgg /= this->m_NumberOfGradientMeasurements;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1188,13 +1188,9 @@ AdaptiveStochasticVarianceReducedGradient<TElastix>
} // end for loop over metrics
} // end if NewSamplesEveryIteration.

#ifndef _ELASTIX_BUILD_LIBRARY
/** Prepare for progress printing. */
ProgressCommandPointer progressObserver = ProgressCommandType::New();
progressObserver->SetUpdateFrequency(
this->m_NumberOfGradientMeasurements, this->m_NumberOfGradientMeasurements );
progressObserver->SetStartString( " Progress: " );
#endif
const auto progressObserver = BaseComponent::IsElastixLibrary() ?
nullptr : ProgressCommandType::CreateAndSetUpdateFrequency( this->m_NumberOfGradientMeasurements );
elxout << " Sampling gradients ..." << std::endl;

/** Initialize some variables for storing gradients and their magnitudes. */
Expand All @@ -1209,10 +1205,11 @@ AdaptiveStochasticVarianceReducedGradient<TElastix>
/** Compute gg for some random parameters. */
for( unsigned int i = 0 ; i < this->m_NumberOfGradientMeasurements; ++i )
{
#ifndef _ELASTIX_BUILD_LIBRARY
/** Show progress 0-100% */
progressObserver->UpdateAndPrintProgress( i );
#endif
if ( progressObserver != nullptr )
{
/** Show progress 0-100% */
progressObserver->UpdateAndPrintProgress( i );
}
/** Generate a perturbation, according to:
* \mu_i ~ N( \mu_0, perturbationsigma^2 I ).
*/
Expand Down Expand Up @@ -1263,9 +1260,10 @@ AdaptiveStochasticVarianceReducedGradient<TElastix>
} // end else: no stochastic gradients

} // end for loop over gradient measurements
#ifdef _ELASTIX_BUILD_LIBARY
progressObserver->PrintProgress( 1.0 );
#endif
if ( progressObserver != nullptr )
{
progressObserver->PrintProgress( 1.0 );
}
/** Compute means. */
exactgg /= this->m_NumberOfGradientMeasurements;
diffgg /= this->m_NumberOfGradientMeasurements;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,13 +843,9 @@ PreconditionedStochasticGradientDescent< TElastix >

} // end if NewSamplesEveryIteration.

#ifndef _ELASTIX_BUILD_LIBRARY
/** Prepare for progress printing. */
ProgressCommandPointer progressObserver = ProgressCommandType::New();
progressObserver->SetUpdateFrequency(
this->m_NumberOfGradientMeasurements, this->m_NumberOfGradientMeasurements );
progressObserver->SetStartString( " Progress: " );
#endif
const auto progressObserver = BaseComponent::IsElastixLibrary() ?
nullptr : ProgressCommandType::CreateAndSetUpdateFrequency( this->m_NumberOfGradientMeasurements );
elxout << " Sampling gradients ..." << std::endl;

/** Initialize some variables for storing gradients and their magnitudes. */
Expand All @@ -866,10 +862,11 @@ PreconditionedStochasticGradientDescent< TElastix >
/** Compute gg for some random parameters. */
for( unsigned int i = 0; i < this->m_NumberOfGradientMeasurements; ++i )
{
#ifndef _ELASTIX_BUILD_LIBRARY
/** Show progress 0-100% */
progressObserver->UpdateAndPrintProgress( i );
#endif
if ( progressObserver != nullptr )
{
/** Show progress 0-100% */
progressObserver->UpdateAndPrintProgress( i );
}
/** Generate a perturbation, according to:
* \mu_i ~ N( \mu_0, perturbationsigma^2 I ).
*/
Expand Down Expand Up @@ -928,9 +925,10 @@ PreconditionedStochasticGradientDescent< TElastix >

} // end for loop over gradient measurements

#ifdef _ELASTIX_BUILD_LIBARY
progressObserver->PrintProgress( 1.0 );
#endif
if ( progressObserver != nullptr )
{
progressObserver->PrintProgress( 1.0 );
}

/** Compute means. */
exactgg /= this->m_NumberOfGradientMeasurements;
Expand Down
Loading