I'm new to Deep Neural Network libraries in python. I've installed Theano & keras in my windows system by following these steps(I already had anaconda):
Install TDM GCC x64.
Run the below code from command prompt
conda update conda
conda update --all
conda install mingw libpython
pip install git+git://github.com/Theano/Theano.git
pip install git+git://github.com/fchollet/keras.git
When I'm running the following code in Ipython,
import numpy as np
import keras.models
from keras.models import Sequential
model = Sequential()
model.add(Dense(32, input_shape=(784,)))
model.add(Activation('relu'))
it is showing the following error:
NameError
Traceback (most recent call last)
----> 1 model.add(Dense(32, input_shape=(784,)))
NameError: name 'Dense' is not defined
Here is the error message screenshot.
How come sequential was imported successfully and 'Dense' was not defined?
You need from keras.layers import Activation, Dense
.
I had a similar problem in tensorflow 2.0 and solved it by using
from tensorflow.keras.layers import Dense
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