import tensorflow as tf
import tensorflow
from tensorflow import keras
from keras.layers import Dense
I am getting the below error
I have a similar problem importing those libs. I am using Anaconda Navigator 1.8.2 with Spyder 3.2.8.
My code is the following:
import matplotlib.pyplot as plt
import tensorflow as tf
import numpy as np
import math
#from tf.keras.models import Sequential # This does not work!
from tensorflow.python.keras.models import Sequential
from tensorflow.python.keras.layers import InputLayer, Input
from tensorflow.python.keras.layers import Reshape, MaxPooling2D
from tensorflow.python.keras.layers import Conv2D, Dense, Flatten
I get the following error:
from tensorflow.python.keras.models import Sequential
ModuleNotFoundError: No module named 'tensorflow.python.keras'
I solve this erasing tensorflow.python
With this code I solve the error:
import matplotlib.pyplot as plt
import tensorflow as tf
import numpy as np
import math
#from tf.keras.models import Sequential # This does not work!
from keras.models import Sequential
from keras.layers import InputLayer, Input
from keras.layers import Reshape, MaxPooling2D
from keras.layers import Conv2D, Dense, Flatten
Its not quite fine to downgrade everytime, you may need to make following changes as shown below:
import tensorflow as tf
#Keras
from tensorflow.keras.models import Sequential, Model, load_model, save_model
from tensorflow.keras.callbacks import ModelCheckpoint
from tensorflow.keras.layers import Dense, Activation, Dropout, Input, Masking, TimeDistributed, LSTM, Conv1D, Embedding
from tensorflow.keras.layers import GRU, Bidirectional, BatchNormalization, Reshape
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.layers import Reshape, Dropout, Dense,Multiply, Dot, Concatenate,Embedding
from tensorflow.keras import optimizers
from tensorflow.keras.callbacks import ModelCheckpoint
The point is that instead of using
from keras.layers import Reshape, Dropout, Dense,Multiply, Dot, Concatenate,Embedding
you need to add
from tensorflow.keras.layers import Reshape, Dropout, Dense,Multiply, Dot, Concatenate,Embedding