How to import keras from tf.keras in Tensorflow?

前端 未结 8 1493
隐瞒了意图╮
隐瞒了意图╮ 2020-12-12 22:55
import tensorflow as tf
import tensorflow 

from tensorflow import keras
from keras.layers import Dense

I am getting the below error



        
8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-12 23:13

    Use the keras module from tensorflow like this:

    import tensorflow as tf

    Import classes

    from tensorflow.python.keras.layers import Input, Dense

    or use directly

    dense = tf.keras.layers.Dense(...)

    EDIT Tensorflow 2

    from tensorflow.keras.layers import Input, Dense

    and the rest stays the same.

提交回复
热议问题