Reputation: 11
AttributeError: module 'tensorflow_core.python.keras.api._v2.keras' has no attribute 'Dense' in model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu)) model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu))model.add(tf.keras.Dense(10, activation=tf.nn.softmax)
Upvotes: 0
Views: 4810
Reputation: 745
In your last model.add()
call, you try to use tf.keras.Dense
instead of tf.keras.layers.Dense
. Modify you code to the following:
model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(10, activation=tf.nn.softmax) # <-- your typo was in this line
Upvotes: 3