I had same problem and resolve it by adding .python in between tensorflow an keras. so instead of tensorflow.keras, I wrote : tensorflow.python.keras