I am following a tutorial for TensorFlow and Keras.
When I run the following syntax:
from keras.models import Sequential
from keras.layers import Dense
model = Sequential()
model.add(Dense(units=64, activation='relu', input_dim=100))
model.add(Dense(units=10, activation='softmax'))
(This is not full stacktrace as StackOverflow wont let me saying it has code only) I get following error:
--------------------------------------------------------------------
UnboundLocalError Traceback (most recent call last)
<ipython-input-49-30ebc8793948> in <module>()
5 from keras.layers import Dense
6
----> 7 model.add(Dense(units=64, activation='relu', input_dim=100))
--> 164 layer(x)
165 set_inputs = True
166 else:
/usr/local/lib/python3.7/site-packages/keras/initializers.py in __call__(self, shape, dtype)
self._message_listener.Modified()
UnboundLocalError: local variable 'self' referenced before assignment
Could this be because of python 3.7?
Yes, I had to uninstall and reinstall Python 3.6. Python 3.7 looks like it introduces unexpected behavior. Thankfully, my issue is now resolved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With