image_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

import matplotlib.pyplot as plt

train_datagen = ImageDataGenerator(rescale=1.0 / 255, horizontal_flip=True, vertical_flip=True, validation_split=0.2)
def get_generator(path, subset):
    return train_datagen.flow_from_directory(path, target_size=(200, 400), batch_size=32, class_mode='categorical', subset=subset, color_mode='grayscale')
train_generator = get_generator('../input/transmittancy/transmittancy/', 'training')
validation_generator = get_generator('../input/transmittancy/transmittancy/', 'validation')

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=3, activation='relu', strides=(2, 4), input_shape=(200, 400, 1)))
model.add(Conv2D(64, kernel_size=3, activation='relu', strides=(2, 4)))
model.add(Conv2D(32, kernel_size=3, activation='relu', strides=(2, 4)))
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=validation_generator, validation_steps=15)

import matplotlib.pyplot as plt
plt.plot(history.history['acc'])
plt.plot(history.history['val_acc'])
plt.title('Model accuracy')
plt.ylabel('Accuracy')
plt.xlabel('Epoch')
plt.legend(['train', 'validation'], loc='upper left')
plt.show()