Some exercises with keras

Exercice 1:

CIFAR10 small image classification

The dataset consist of 50,000 32x32 color training images, labeled over 10 categories, and 10,000 test images.


In [1]:
# Import MINST data
from keras.datasets import cifar10
from keras.utils import np_utils
from keras.models import Sequential
from keras.layers import Dense, Activation 
from keras.optimizers import Adam


Using TensorFlow backend.

In [ ]:

Exercice 2

The learning rate of the optimizer can be modified with the following function:

adam.lr.assign(learning_rate)

Modify the code in order to decrease the learning_rate value every 10 Epochs.

Exercice 3

First of all, let's play a little bit with http://playground.tensorflow.org/

Then create a mulitlayer perceptron with the following data and architecture you think is the best:

In [2]:
from sklearn.model_selection import train_test_split
# the data, shuffled and split between train and test sets
from sklearn.datasets import make_moons, make_circles, make_classification
X, y = make_moons(n_samples = 1000,noise=0.3, random_state=0)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=.4, random_state=42)
print X_train.shape


(600, 2)

In [ ]: