Keras: Error after model training was forcefully terminated. ValueError: Initializer for variable lstm_7/Variable/ is from inside a control-flow construct, such as a loop or conditional.

Created on 17 Aug 2017  路  1Comment  路  Source: rstudio/keras

Hi,
I have been following this example https://rstudio.github.io/keras/articles/examples/stateful_lstm.html.

When model training was in process, I forcefully stopped execution. And thereafter no matter how many times i tried to retrain the model I keep getting this error.
Even after removing model variable from the environment/ completely removing all objects from environment the following error persisted.

Error in py_call_impl(callable, dots$args, dots$keywords) :
ValueError: Initializer for variable lstm_7/Variable/ is from inside a control-flow construct, such as a loop or conditional. When creating a variable inside a loop or conditional, use a lambda as the initializer.
Detailed traceback:
File "E:ANACON~1envsR-TENS~1libsite-packageskerasmodels.py", line 436, in add
layer(x)
File "E:ANACON~1envsR-TENS~1libsite-packageskeraslayersrecurrent.py", line 262, in __call__
return super(Recurrent, self).__call__(inputs, **kwargs)
File "E:ANACON~1envsR-TENS~1libsite-packageskerasenginetopology.py", line 569, in __call__
self.build(input_shapes[0])
File "E:ANACON~1envsR-TENS~1libsite-packageskeraslayersrecurrent.py", line 1015, in build
self.reset_states()
File "E:ANACON~1envsR-TENS~1libsite-packageskeraslayersrecurrent.py", line 385, in reset_states
for _ in self.states]
File "E:ANACON~1envsR-TENS~1libsite-packageskeraslayersrecurrent.py", line 385, in

Most helpful comment

I have a feeling that you might need to clear the session before retraining, you can do that as described here: https://keras.io/backend/#clear_session

K <- backend()
K$clear_session()

>All comments

I have a feeling that you might need to clear the session before retraining, you can do that as described here: https://keras.io/backend/#clear_session

K <- backend()
K$clear_session()
Was this page helpful?
0 / 5 - 0 ratings

Related issues

gundalav picture gundalav  路  3Comments

pbhogale picture pbhogale  路  5Comments

MaximilianPi picture MaximilianPi  路  5Comments

leonjessen picture leonjessen  路  4Comments

qade544 picture qade544  路  5Comments