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)
1 Answer
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