@@ -0,0 +1,2046 @@
+import numpy as np%0Afrom keras.datasets import mnist%0Afrom keras.models import Sequential%0Afrom keras.layers.core import Dense, Dropout, Activation%0Afrom keras.optimizers import SGD%0Afrom keras.utils import np_utils%0Aimport keras.callbacks%0Aimport keras.backend.tensorflow_backend as KTF%0Aimport tensorflow as tf%0A%0Abatch_size = 128%0Anb_classes = 10%0Anb_epoch   = 20%0Anb_data    = 28*28%0Alog_filepath = '/tmp/keras_log'%0A%0A# load data%0A(X_train, y_train), (X_test, y_test) = mnist.load_data()%0A%0A# reshape%0AX_train = X_train.reshape(X_train.shape%5B0%5D, X_train.shape%5B1%5D*X_train.shape%5B2%5D)%0AX_test = X_test.reshape(X_test.shape%5B0%5D, X_test.shape%5B1%5D*X_test.shape%5B2%5D)%0A%0A# rescale%0AX_train = X_train.astype(np.float32)%0AX_train /= 255%0A%0AX_test = X_test.astype(np.float32)%0AX_test /= 255%0A%0A# convert class vectors to binary class matrices (one hot vectors)%0AY_train = np_utils.to_categorical(y_train, nb_classes)%0AY_test = np_utils.to_categorical(y_test, nb_classes)%0A%0Aold_session = KTF.get_session()%0A%0Awith tf.Graph().as_default():%0A    session = tf.Session('')%0A    KTF.set_session(session)%0A    KTF.set_learning_phase(1)%0A    # build model%0A    model = Sequential()%0A    model.add(Dense(512, input_shape=(nb_data,), init='normal',name='dense1'))%0A    model.add(Activation('relu', name='relu1'))%0A    model.add(Dropout(0.2, name='dropout1'))%0A    model.add(Dense(512, init='normal', name='dense2'))%0A    model.add(Activation('relu', name='relu2'))%0A    model.add(Dropout(0.2, name='dropout2'))%0A    model.add(Dense(10, init='normal', name='dense3'))%0A    model.add(Activation('softmax', name='softmax1'))%0A    model.summary()%0A%0A    model.compile(loss='categorical_crossentropy', optimizer=SGD(lr=0.001), metrics=%5B'accuracy'%5D)%0A%0A    tb_cb = keras.callbacks.TensorBoard(log_dir=log_filepath, histogram_freq=1)%0A    cbks = %5Btb_cb%5D%0A%0A    history = model.fit(X_train, Y_train, batch_size=batch_size, nb_epoch = nb_epoch, verbose=1, callbacks=cbks)%0A%0A    score = model.evaluate(X_test, Y_test, verbose=0)%0A    print('Test score:', score%5B0%5D)%0A    print('Test accuracy;', score%5B1%5D)%0A%0A%0AKTF.set_session(old_session)%0A

Add keras sample