# Warning with LBFGSB: does not support scaling

**URL:** https://discourse.itk.org/t/warning-with-lbfgsb-does-not-support-scaling/4614
**Category:** Beginner Questions
**Tags:** python, simpleitk
**Created:** [November 25, 2021, 5:39pm UTC](https://discourse.itk.org/t/warning-with-lbfgsb-does-not-support-scaling/4614 "2021-11-25T17:39:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![reox](https://discourse.itk.org/user_avatar/discourse.itk.org/reox/32/4490_2.png) [@reox](https://discourse.itk.org/u/reox)
#### Post date: [November 25, 2021, 5:39pm UTC](https://discourse.itk.org/t/warning-with-lbfgsb-does-not-support-scaling/4614/1 "2021-11-25T17:39:41Z")

</div>

Here is a very simple example of an image registration:

```auto
import SimpleITK as sitk

x = sitk.Image(50, 50, sitk.sitkFloat32)
x[10:40,10:40] = 1
y = sitk.Image(50, 50, sitk.sitkFloat32)
y[15:45,15:45] = 1

sitk.ProcessObject.SetGlobalWarningDisplay(True)

R = sitk.ImageRegistrationMethod()
R.SetInitialTransform(sitk.TranslationTransform(2))
R.SetMetricAsMeanSquares()
R.SetOptimizerAsLBFGSB()

print(R.Execute(x,y))

```

Unfortunately, it prints all the time this warning:

```auto
WARNING: In /tmp/SimpleITK-build/ITK/Modules/Numerics/Optimizersv4/src/itkLBFGSBOptimizerv4.cxx, line 99
LBFGSBOptimizerv4 (0x557d34e68130): LBFGSB optimizer does not support scaling. All scales are set to one.

```

I wondered why I get this, because I never set any scales myself.  
I think I followed the code correctly and this is where the `SetScales` member is called: [SimpleITK/sitkImageRegistrationMethod.cxx at cd7cd20bb1f5ed846ec5d4686a1e1997822521e2 · SimpleITK/SimpleITK · GitHub](https://github.com/SimpleITK/SimpleITK/blob/cd7cd20bb1f5ed846ec5d4686a1e1997822521e2/Code/Registration/src/sitkImageRegistrationMethod.cxx#L951)

However, it should not even be called because when I run `R.GetOptimizerScales()` it returns `()` and I can not see how it is set otherwise.  
Thus, I wonder why I see this warning? Is there anything I can do to get rid of it?  
Of course, I can turn off warnings, but that would also mean I might miss other warnings…

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [November 26, 2021, 1:44pm UTC](https://discourse.itk.org/t/warning-with-lbfgsb-does-not-support-scaling/4614/2 "2021-11-26T13:44:26Z")

</div>

> [@reox](#):
>
> Of course, I can turn off warnings, but that would also mean I might miss other warnings…

Could you please create a issue about this warning on SimpleITK’s [Github Issue tracker](https://github.com/SimpleITK/SimpleITK/issues)?

You can write a custom logger to filter warnings. Here is an example of adopting an ITK logger to be used with the Python `logging` module which should give some idea on how warnings could be filtered.

Adding missing example link: [Logging — SimpleITK 2.4.0 documentation](https://simpleitk.readthedocs.io/en/master/link_Logging_docs.html?highlight=logger)

---

<div class="post-metadata">

### Author: ![reox](https://discourse.itk.org/user_avatar/discourse.itk.org/reox/32/4490_2.png) [@reox](https://discourse.itk.org/u/reox)
#### Post date: [November 26, 2021, 1:52pm UTC](https://discourse.itk.org/t/warning-with-lbfgsb-does-not-support-scaling/4614/3 "2021-11-26T13:52:59Z")

</div>

I created an issue!

You mean this example code here: [SimpleITK: Logging/Logging.py](https://simpleitk.org/doxygen/latest/html/Logging_2Logging_8py-example.html) ?  
That looks good, I’ll look into that, thanks!
