Incase using latest version of tensorflow then try like -
from tensorflow import keras
from keras.api.layers import Dense