diff --git a/Dockerfile b/Dockerfile index 40237d0e..f24e6428 100644 --- a/Dockerfile +++ b/Dockerfile @@ -73,7 +73,6 @@ RUN apt-get install -y libfreetype6-dev && \ # Pinned to match GPU version. Update version together. pip install lightgbm==3.2.1 && \ pip install pydot && \ - pip install keras && \ pip install keras-tuner && \ pip install flake8 && \ # Pinned because it breaks theano test with the latest version (b/178107003). @@ -248,10 +247,6 @@ RUN pip install tensorpack && \ RUN pip install --upgrade cython && \ pip install --upgrade cysignals && \ pip install pyfasttext && \ - # ktext has an explicit dependency on Keras 2.2.4 which is not - # compatible with TensorFlow 2.0 (support was added in Keras 2.3.0). - # Add the package back once it is fixed upstream. - # pip install ktext && \ pip install fasttext && \ apt-get install -y libhunspell-dev && pip install hunspell && \ pip install annoy && \ @@ -450,7 +445,7 @@ ENV PYTHONPATH=$PYTHONPATH:/opt/facets/facets_overview/python/ ENV MKL_THREADING_LAYER=GNU # Temporary fixes and patches - # Temporary patch for Dask getting downgraded, which breaks Keras +# Temporary patch for Dask getting downgraded, which breaks Keras RUN pip install --upgrade dask && \ # Stop jupyter nbconvert trying to rewrite its folder hierarchy mkdir -p /root/.jupyter && touch /root/.jupyter/jupyter_nbconvert_config.py && touch /root/.jupyter/migrated && \ diff --git a/tests/test_keras.py b/tests/test_keras.py deleted file mode 100644 index de57de27..00000000 --- a/tests/test_keras.py +++ /dev/null @@ -1,82 +0,0 @@ -import unittest - -import keras -import numpy as np -import pandas as pd - -from keras.models import Sequential -from keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPooling2D, LSTM -from keras.optimizers import RMSprop, SGD -from keras.utils.np_utils import to_categorical - -from common import gpu_test - -class TestKeras(unittest.TestCase): - def test_train(self): - train = pd.read_csv("/input/tests/data/train.csv") - - x_train = train.iloc[:,1:].values.astype('float32') - y_train = to_categorical(train.iloc[:,0].astype('int32')) - - model = Sequential() - model.add(Dense(units=10, input_dim=784, activation='softmax')) - - model.compile( - loss='categorical_crossentropy', - optimizer=RMSprop(lr=0.001), - metrics=['accuracy']) - - model.fit(x_train, y_train, epochs=1, batch_size=32) - - # Uses convnet which depends on libcudnn when running on GPU - def test_conv2d(self): - # Generate dummy data - x_train = np.random.random((100, 100, 100, 3)) - y_train = keras.utils.to_categorical(np.random.randint(10, size=(100, 1)), num_classes=10) - x_test = np.random.random((20, 100, 100, 3)) - y_test = keras.utils.to_categorical(np.random.randint(10, size=(20, 1)), num_classes=10) - - model = Sequential() - # input: 100x100 images with 3 channels -> (100, 100, 3) tensors. - # this applies 32 convolution filters of size 3x3 each. - model.add(Conv2D(32, (3, 3), activation='relu', input_shape=(100, 100, 3))) - model.add(Conv2D(32, (3, 3), activation='relu')) - model.add(MaxPooling2D(pool_size=(2, 2))) - model.add(Dropout(0.25)) - - model.add(Conv2D(64, (3, 3), activation='relu')) - model.add(Conv2D(64, (3, 3), activation='relu')) - model.add(MaxPooling2D(pool_size=(2, 2))) - model.add(Dropout(0.25)) - - model.add(Flatten()) - model.add(Dense(256, activation='relu')) - model.add(Dropout(0.5)) - model.add(Dense(10, activation='softmax')) - - sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True) - - # This throws if libcudnn is not properly installed with on a GPU - model.compile(loss='categorical_crossentropy', optimizer=sgd) - model.fit(x_train, y_train, batch_size=32, epochs=1) - - model.evaluate(x_test, y_test, batch_size=32) - - def test_lstm(self): - x_train = np.random.random((100, 100, 100)) - y_train = keras.utils.to_categorical(np.random.randint(10, size=(100, 1)), num_classes=10) - x_test = np.random.random((20, 100, 100)) - y_test = keras.utils.to_categorical(np.random.randint(10, size=(20, 1)), num_classes=10) - - sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True) - - model = Sequential() - model.add(LSTM(32, return_sequences=True, input_shape=(100, 100))) - model.add(Flatten()) - model.add(Dense(10, activation='softmax')) - - - model.compile(loss='categorical_crossentropy', optimizer=sgd) - model.fit(x_train, y_train, batch_size=32, epochs=1) - model.evaluate(x_test, y_test, batch_size=32) -