Created
February 4, 2018 11:34
-
-
Save rakuishi/52e1a860f0d09dd2ce76d38a12d263d8 to your computer and use it in GitHub Desktop.
72%
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def homework(train_X, train_y, test_X): | |
import keras | |
from keras.models import Sequential | |
from keras.layers import Dense, Conv2D, MaxPooling2D, Flatten, Input, Activation, Dropout | |
from keras.layers.normalization import BatchNormalization | |
from keras import optimizers | |
from keras.preprocessing.image import ImageDataGenerator | |
gcn_whitening = ImageDataGenerator(samplewise_center=True, samplewise_std_normalization=True) | |
gcn_whitening.fit(train_X) | |
model = Sequential() | |
model.add(Conv2D(3, kernel_size=(3, 3), activation='relu', input_shape=(32, 32, 3))) | |
model.add(BatchNormalization()) | |
for i in range(3): | |
model.add(Conv2D(32, kernel_size=(3, 3), activation='relu')) | |
model.add(MaxPooling2D(pool_size=(2, 2))) | |
model.add(BatchNormalization()) | |
model.add(Flatten()) | |
model.add(Dense(units=512, activation='relu')) | |
model.add(Dropout(0.25)) | |
model.add(Dense(10, activation='softmax')) | |
model.compile(loss=keras.losses.categorical_crossentropy, optimizer='adam') | |
model.fit(x=train_X, y=train_y, batch_size=128, epochs=100, validation_split=0.1) | |
pred_y = model.predict(test_X) | |
pred_y = np.argmax(pred_y, 1) | |
return pred_y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment