# Can I use conjugate gradient optimizer for registration in python?How can I do ?

**URL:** https://discourse.itk.org/t/can-i-use-conjugate-gradient-optimizer-for-registration-in-python-how-can-i-do/2561
**Category:** Beginner Questions
**Created:** [December 21, 2019, 2:28pm UTC](https://discourse.itk.org/t/can-i-use-conjugate-gradient-optimizer-for-registration-in-python-how-can-i-do/2561 "2019-12-21T14:28:38Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![tvercaut](https://discourse.itk.org/user_avatar/discourse.itk.org/tvercaut/32/1455_2.png) [@tvercaut](https://discourse.itk.org/u/tvercaut)
#### Post date: [May 8, 2020, 2:34pm UTC](https://discourse.itk.org/t/can-i-use-conjugate-gradient-optimizer-for-registration-in-python-how-can-i-do/2561/3 "2020-05-08T14:34:45Z")

</div>

Through another thread ([Monitoring registration progress in python - and status of itk vs simpleitk for registration](https://discourse.itk.org/t/monitoring-registration-progress-in-python-and-status-of-itk-vs-simpleitk-for-registration/3051)) I realised that switching to LBFGS or Conjugate Gradient is at least easy in simpleitk (where additionally there is no question of v4 or no v4):  
[https://simpleitk.readthedocs.io/en/master/registrationOverview.html#optimizer](https://simpleitk.readthedocs.io/en/master/registrationOverview.html#optimizer)

In the example [https://simpleitk.readthedocs.io/en/master/link\_ImageRegistrationMethod1\_docs.html](https://simpleitk.readthedocs.io/en/master/link_ImageRegistrationMethod1_docs.html), just use `R.SetOptimizerAsLBFGSB()` or `R.SetOptimizerAsConjugateGradientLineSearch()`

---

_[View the full topic](https://discourse.itk.org/t/can-i-use-conjugate-gradient-optimizer-for-registration-in-python-how-can-i-do/2561)._
