Skip to content

Commit

Permalink
Fix module import and naming in MNIST CNN example
Browse files Browse the repository at this point in the history
Was found after reading through: keras-team#12379

Seems quite a straightforward thing to fix, not sure why nobody has committed patches.

Tested with Python 3.6.7, Tensorflow 2.0.0a0 and CUDA 10.1
  • Loading branch information
srkiNZ84 committed May 14, 2019
1 parent 747ef0f commit 518e155
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions examples/mnist_cnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
'''

from __future__ import print_function
import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.layers import Conv2D, MaxPooling2D
from keras import backend as K
import tensorflow.keras
from tensorflow.keras.datasets import mnist
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout, Flatten
from tensorflow.keras.layers import Conv2D, MaxPooling2D
from tensorflow.keras import backend as K

batch_size = 128
num_classes = 10
Expand Down Expand Up @@ -41,8 +41,8 @@
print(x_test.shape[0], 'test samples')

# convert class vectors to binary class matrices
y_train = keras.utils.to_categorical(y_train, num_classes)
y_test = keras.utils.to_categorical(y_test, num_classes)
y_train = tensorflow.keras.utils.to_categorical(y_train, num_classes)
y_test = tensorflow.keras.utils.to_categorical(y_test, num_classes)

model = Sequential()
model.add(Conv2D(32, kernel_size=(3, 3),
Expand All @@ -56,8 +56,8 @@
model.add(Dropout(0.5))
model.add(Dense(num_classes, activation='softmax'))

model.compile(loss=keras.losses.categorical_crossentropy,
optimizer=keras.optimizers.Adadelta(),
model.compile(loss=tensorflow.keras.losses.categorical_crossentropy,
optimizer=tensorflow.keras.optimizers.Adadelta(),
metrics=['accuracy'])

model.fit(x_train, y_train,
Expand Down

0 comments on commit 518e155

Please sign in to comment.