0

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
  • post full code. Commented May 2, 2020 at 4:11

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.