text_plain_output_1.png
from keras.callbacks import EarlyStopping, ModelCheckpoint, ReduceLROnPlateau

from keras.layers import Dense, Conv2D, Flatten

from keras.models import Sequential, Model

from keras.optimizers import Adagrad

from keras.preprocessing.image import ImageDataGenerator

train_datagen = ImageDataGenerator(rescale=1.0 / 255, horizontal_flip=True, vertical_flip=True)
def get_generator(path):
    return train_datagen.flow_from_directory(path, target_size=(40, 96), batch_size=32, class_mode='categorical', color_mode='grayscale')
train_generator = get_generator('../input/transmittancy/train/')
test_generator = get_generator('../input/transmittancy/test/')

from keras.optimizers import Adagrad
from keras.callbacks import EarlyStopping, ModelCheckpoint, ReduceLROnPlateau
adagrad = Adagrad(decay=0.001, lr=0.005)
earlyStopping = EarlyStopping(monitor='val_acc', patience=8, verbose=1, mode='min')
mcp_save = ModelCheckpoint('best_model.hdf5', save_best_only=True, monitor='val_loss', mode='min')

from keras.models import Sequential, Model
from keras.layers import Dense, Conv2D, Flatten
model = Sequential()
model.add(Conv2D(128, kernel_size=2, activation='relu', strides=(2, 2), input_shape=(40, 96, 1)))
model.add(Conv2D(64, kernel_size=2, activation='relu', strides=(2, 2)))
model.add(Conv2D(32, kernel_size=2, activation='relu', strides=(2, 2)))
model.add(Flatten())
model.add(Dense(256, activation='relu'))
model.add(Dense(64, activation='relu'))
model.add(Dense(3, activation='softmax'))

model.compile(loss='categorical_crossentropy', optimizer=adagrad, metrics=['acc'])
model.summary()
history = model.fit_generator(train_generator, steps_per_epoch=150, epochs=40, validation_data=test_generator, validation_steps=30)