# TMVA keras bug of LearningRateSchedule

**URL:** <https://root-forum.cern.ch/t/tmva-keras-bug-of-learningrateschedule/37291>\
**Category:** TMVA\
**Created:** [December 21, 2019, 5:21pm UTC](https://root-forum.cern.ch/t/tmva-keras-bug-of-learningrateschedule/37291 "2019-12-21T17:21:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cxwx](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/cxwx/32/22075_2.png) [@cxwx](https://root-forum.cern.ch/u/cxwx)\
**Post date:** [December 21, 2019, 5:21pm UTC](https://root-forum.cern.ch/t/tmva-keras-bug-of-learningrateschedule/37291/1 "2019-12-21T17:21:15Z")

</div>

It seems the method of below

```auto
TMVA.Types.kPyKeras

```

with option

```auto
LearningRateSchedule != ''

```

got the error as below

```auto
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/keras/engine/training.py", line 1239, in fit
    validation_freq=validation_freq)
  File "/usr/local/lib/python3.7/site-packages/keras/engine/training_arrays.py", line 146, in fit_loop
    callbacks.on_epoch_begin(epoch)
  File "/usr/local/lib/python3.7/site-packages/keras/callbacks/callbacks.py", line 136, in on_epoch_begin
    callback.on_epoch_begin(epoch, logs)
  File "/usr/local/lib/python3.7/site-packages/keras/callbacks/callbacks.py", line 930, in on_epoch_begin
    lr = self.schedule(epoch, lr)
  File "<string>", line 3, in schedule
AttributeError: 'float' object has no attribute 'optimizer'
<FATAL> : Failed to train model
***> abort program execution
Traceback (most recent call last):
  File "ClassificationKeras.py", line 69, in <module>
    factory.TrainAllMethods()
Exception: void TMVA::Factory::TrainAllMethods() =>
    FATAL error (C++ exception of type runtime_error)

```

the pyKeras need to be updated

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [January 6, 2020, 3:42pm UTC](https://root-forum.cern.ch/t/tmva-keras-bug-of-learningrateschedule/37291/2 "2020-01-06T15:42:12Z")

</div>

May be a more complete reproducer will help to understand better the problem ?

---

<div class="post-metadata">

**Author:** ![cxwx1](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/cxwx1/32/22433_2.png) [@cxwx1](https://root-forum.cern.ch/u/cxwx1)\
**Post date:** [July 23, 2020, 8:16pm UTC](https://root-forum.cern.ch/t/tmva-keras-bug-of-learningrateschedule/37291/3 "2020-07-23T20:16:22Z")

</div>

TMVA method pykeras with option LearningRateSchedule show the errors showing upper

using tutorial tmva/keras/RegressionKeras.py

modify adding LearningRateSchedule bug

```auto
factory.BookMethod(dataloader, TMVA.Types.kPyKeras, 'PyKeras', 'H:!V:VarTransform=D,G:FilenameModel=model.h5:NumEpochs=20:BatchSize=32:LearningRateSchedule=50,0.001;100,0.0001')

```
