Keras is now fully intregrated into Tensorflow. So, importing only Keras causes error.
It should be imported as:
from tensorflow.keras.utils import to_categorical
Avoid importing as:
from keras.utils import to_categorical
It is safe to use
from tensorflow.keras. instead of from keras. while importing all the necessary modules.
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D, MaxPooling2D,Dropout
from tensorflow.keras.layers import Dense, Activation, Flatten
from tensorflow.keras.utils import to_categorical
from tensorflow.keras import backend as K
from sklearn.model_selection import train_test_split
from tensorflow.keras import callbacks