I am currently doing this:
import tensorflow as tf keras = tf.contrib.keras Sequential = keras.models.Sequential Dense = keras.layers.Dense Dropout = keras.layers.Dropout Flatten = keras.layers.Flatten Conv2D = keras.layers.Conv2D MaxPooling2D = keras.layers.MaxPooling2D
I would like to do something like this:
import tensorflow as tf keras = tf.contrib.keras from tf.contrib.keras import (Sequential, Dense, Dropout, Flatten, Conv2D, MaxPooling2D)
but when I try to do it, I get
ImportError: No module named tf.contrib.keras
Is there a shorter way than the first block of code to import these classes?
Other attempts
>>> from tensorflow.contrib.keras import (Sequential, Dense, Dropout, Flatten) Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name Sequential
Nr 2
>>> import tensorflow >>> from tensorflow.contrib.keras.models import Sequential Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named models >>> tensorflow.contrib.keras.models.Sequential <class 'tensorflow.contrib.keras.python.keras.models.Sequential'>
source share