This file contains 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
train_df = pd.read_csv('PM_test.txt', sep=" ", header=None) | |
train_df.drop(train_df.columns[[26, 27]], axis=1, inplace=True) | |
train_df.columns = ['id', 'cycle', 'setting1', 'setting2', 'setting3', 's1', 's2', 's3', | |
's4', 's5', 's6', 's7', 's8', 's9', 's10', 's11', 's12', 's13', 's14', | |
's15', 's16', 's17', 's18', 's19', 's20', 's21'] | |
train_df = train_df.sort_values(['id','cycle']) | |
# read test data - It is the aircraft engine operating data without failure events recorded. | |
test_df = pd.read_csv('PM_test.txt', sep=" ", header=None) |
This file contains 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
import pandas as pd | |
import tensorflow as tf | |
from tensorflow.keras.models import Sequential | |
from tensorflow.keras.layers import Conv2D, MaxPooling2D | |
from tensorflow.keras.layers import Activation, Flatten, Dropout, Dense | |
from tensorflow.keras.layers import BatchNormalization | |
import seaborn as sns | |
%matplotlib inline | |
from matplotlib import pyplot as plt |
This file contains 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
train_fashion_data = pd.read_csv("fashion-mnist_train.csv") | |
test_fashion_data = pd.read_csv("fashion-mnist_test.csv") |
This file contains 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 preprocessing(raw): | |
label = tf.keras.utils.to_categorical(raw.label, 10) | |
num_of_images = raw.shape[0] | |
x_as_array = raw.values[:,1:] | |
x_shaped_array = x_as_array.reshape(num_of_images, 28, 28, 1) | |
image = x_shaped_array / 255 | |
return image, label | |
X, Y = preprocessing(train_fashion_data) | |
X_test, Y_test = preprocessing(test_fashion_data) |
This file contains 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
model = Sequential([ | |
#first convolution | |
Conv2D(32, (3,3), padding='same', activation='relu',kernel_initializer='he_normal', input_shape=(28,28, 1)), | |
MaxPooling2D(2,2), | |
#second convolution | |
Conv2D(64, (3,3),padding='same', activation='relu'), | |
MaxPooling2D(2,2), | |
Dropout(0.2), | |
This file contains 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
train_model = model.fit( | |
X_train, Y_train, | |
batch_size=128, | |
epochs=100, | |
verbose=1, | |
validation_data=(X_val, Y_val) | |
) |
This file contains 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
from tensorflow.keras.optimizers import Adam | |
model.compile( | |
loss="categorical_crossentropy", | |
optimizer=Adam(lr=0.001), | |
metrics=['accuracy'] | |
) |
This file contains 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
import numpy as np | |
import pandas as pd | |
import os | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
from pathlib import Path | |
from sklearn.preprocessing import LabelEncoder | |
import PIL | |
import cv2 | |
import shutil |
This file contains 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
os.mkdir('./images/') | |
alpha = 'a' | |
for i in range(0, 26): | |
os.mkdir('./images/' + alpha) | |
alpha = chr(ord(alpha) + 1) | |
for file in os.listdir(rootdir): | |
letter = file[0] | |
try: | |
shutil.copy(rootdir+file, './images/' + letter + '/' + file) |
This file contains 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
model_ckpt = ModelCheckpoint('BrailleNet.h5',save_best_only=True) | |
reduce_lr = ReduceLROnPlateau(patience=8,verbose=0) | |
early_stop = EarlyStopping(patience=15,verbose=1) | |
entry = layers.Input(shape=(28,28,3)) | |
x = layers.SeparableConv2D(64,(3,3),activation='relu')(entry) | |
x = layers.MaxPooling2D((2,2))(x) | |
x = layers.SeparableConv2D(128,(3,3),activation='relu')(x) | |
x = layers.MaxPooling2D((2,2))(x) | |
x = layers.SeparableConv2D(256,(2,2),activation='relu')(x) |
OlderNewer