import pandas as pd
import numpy as np
train = pd.read_csv(r'sign-language-mnist\sign_mnist_train.csv')
train.head()
test = pd.read_csv(r'sign-language-mnist\sign_mnist_test.csv')
test.head()




y_train = train['label'].values
y_test = test['label'].values

X_train = train.drop(['label'],axis=1)
X_test = test.drop(['label'], axis=1)

X_train = np.array(X_train.iloc[:,:])
X_train = np.array([np.reshape(i, (28,28)) for i in X_train])

X_test = np.array(X_test.iloc[:,:])
X_test = np.array([np.reshape(i, (28,28)) for i in X_test])

num_classes = 26
y_train = np.array(y_train).reshape(-1)
y_test = np.array(y_test).reshape(-1)

y_train = np.eye(num_classes)[y_train]
y_test = np.eye(num_classes)[y_test]

X_train = X_train.reshape((27455, 28, 28, 1))
X_test = X_test.reshape((7172, 28, 28, 1))




from keras.models import Sequential 
from keras.layers import Conv2D,MaxPooling2D, Dense,Flatten, Dropout
from keras.utils import np_utils
from keras.optimizers import SGD, adam




classifier = Sequential()
classifier.add(Conv2D(filters=8, kernel_size=(3,3),strides=(1,1),padding='same',input_shape=(28,28,1),activation='relu', data_format='channels_last'))
classifier.add(MaxPooling2D(pool_size=(2,2)))
classifier.add(Conv2D(filters=16, kernel_size=(3,3),strides=(1,1),padding='same',activation='relu'))
classifier.add(Dropout(0.5))
classifier.add(MaxPooling2D(pool_size=(4,4)))
classifier.add(Dense(128, activation='relu'))
classifier.add(Flatten())
classifier.add(Dense(26, activation='softmax'))




classifier.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy'])
classifier.fit(X_train, y_train, epochs=50, batch_size=100)





accuracy = classifier.evaluate(x=X_test,y=y_test,batch_size=32)
print("Accuracy: ",accuracy[1])




classifier.summary()



classifier.save('CNNmodel.h5')


339ca7a9e4aa02d1e329ca1d1227b8a683d66e10
<mask token>

<mask token>
train.head()
<mask token>
test.head()
<mask token>
classifier.add(Conv2D(filters=8, kernel_size=(3, 3), strides=(1, 1),
    padding='same', input_shape=(28, 28, 1), activation='relu', data_format
    ='channels_last'))
classifier.add(MaxPooling2D(pool_size=(2, 2)))
classifier.add(Conv2D(filters=16, kernel_size=(3, 3), strides=(1, 1),
    padding='same', activation='relu'))
classifier.add(Dropout(0.5))
classifier.add(MaxPooling2D(pool_size=(4, 4)))
classifier.add(Dense(128, activation='relu'))
classifier.add(Flatten())
classifier.add(Dense(26, activation='softmax'))
classifier.compile(loss='mean_squared_error', optimizer='adam', metrics=[
    'accuracy'])
classifier.fit(X_train, y_train, epochs=50, batch_size=100)
<mask token>
print('Accuracy: ', accuracy[1])
classifier.summary()
classifier.save('CNNmodel.h5')

<mask token>
train = pd.read_csv('sign-language-mnist\\sign_mnist_train.csv')
train.head()
test = pd.read_csv('sign-language-mnist\\sign_mnist_test.csv')
test.head()
y_train = train['label'].values
y_test = test['label'].values
X_train = train.drop(['label'], axis=1)
X_test = test.drop(['label'], axis=1)
X_train = np.array(X_train.iloc[:, :])
X_train = np.array([np.reshape(i, (28, 28)) for i in X_train])
X_test = np.array(X_test.iloc[:, :])
X_test = np.array([np.reshape(i, (28, 28)) for i in X_test])
num_classes = 26
y_train = np.array(y_train).reshape(-1)
y_test = np.array(y_test).reshape(-1)
y_train = np.eye(num_classes)[y_train]
y_test = np.eye(num_classes)[y_test]
X_train = X_train.reshape((27455, 28, 28, 1))
X_test = X_test.reshape((7172, 28, 28, 1))
<mask token>
classifier = Sequential()
classifier.add(Conv2D(filters=8, kernel_size=(3, 3), strides=(1, 1),
    padding='same', input_shape=(28, 28, 1), activation='relu', data_format
    ='channels_last'))
classifier.add(MaxPooling2D(pool_size=(2, 2)))
classifier.add(Conv2D(filters=16, kernel_size=(3, 3), strides=(1, 1),
    padding='same', activation='relu'))
classifier.add(Dropout(0.5))
classifier.add(MaxPooling2D(pool_size=(4, 4)))
classifier.add(Dense(128, activation='relu'))
classifier.add(Flatten())
classifier.add(Dense(26, activation='softmax'))
classifier.compile(loss='mean_squared_error', optimizer='adam', metrics=[
    'accuracy'])
classifier.fit(X_train, y_train, epochs=50, batch_size=100)
accuracy = classifier.evaluate(x=X_test, y=y_test, batch_size=32)
print('Accuracy: ', accuracy[1])
classifier.summary()
classifier.save('CNNmodel.h5')

import pandas as pd
import numpy as np
train = pd.read_csv('sign-language-mnist\\sign_mnist_train.csv')
train.head()
test = pd.read_csv('sign-language-mnist\\sign_mnist_test.csv')
test.head()
y_train = train['label'].values
y_test = test['label'].values
X_train = train.drop(['label'], axis=1)
X_test = test.drop(['label'], axis=1)
X_train = np.array(X_train.iloc[:, :])
X_train = np.array([np.reshape(i, (28, 28)) for i in X_train])
X_test = np.array(X_test.iloc[:, :])
X_test = np.array([np.reshape(i, (28, 28)) for i in X_test])
num_classes = 26
y_train = np.array(y_train).reshape(-1)
y_test = np.array(y_test).reshape(-1)
y_train = np.eye(num_classes)[y_train]
y_test = np.eye(num_classes)[y_test]
X_train = X_train.reshape((27455, 28, 28, 1))
X_test = X_test.reshape((7172, 28, 28, 1))
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D, Dense, Flatten, Dropout
from keras.utils import np_utils
from keras.optimizers import SGD, adam
classifier = Sequential()
classifier.add(Conv2D(filters=8, kernel_size=(3, 3), strides=(1, 1),
    padding='same', input_shape=(28, 28, 1), activation='relu', data_format
    ='channels_last'))
classifier.add(MaxPooling2D(pool_size=(2, 2)))
classifier.add(Conv2D(filters=16, kernel_size=(3, 3), strides=(1, 1),
    padding='same', activation='relu'))
classifier.add(Dropout(0.5))
classifier.add(MaxPooling2D(pool_size=(4, 4)))
classifier.add(Dense(128, activation='relu'))
classifier.add(Flatten())
classifier.add(Dense(26, activation='softmax'))
classifier.compile(loss='mean_squared_error', optimizer='adam', metrics=[
    'accuracy'])
classifier.fit(X_train, y_train, epochs=50, batch_size=100)
accuracy = classifier.evaluate(x=X_test, y=y_test, batch_size=32)
print('Accuracy: ', accuracy[1])
classifier.summary()
classifier.save('CNNmodel.h5')

import pandas as pd
import numpy as np
train = pd.read_csv(r'sign-language-mnist\sign_mnist_train.csv')
train.head()
test = pd.read_csv(r'sign-language-mnist\sign_mnist_test.csv')
test.head()




y_train = train['label'].values
y_test = test['label'].values

X_train = train.drop(['label'],axis=1)
X_test = test.drop(['label'], axis=1)

X_train = np.array(X_train.iloc[:,:])
X_train = np.array([np.reshape(i, (28,28)) for i in X_train])

X_test = np.array(X_test.iloc[:,:])
X_test = np.array([np.reshape(i, (28,28)) for i in X_test])

num_classes = 26
y_train = np.array(y_train).reshape(-1)
y_test = np.array(y_test).reshape(-1)

y_train = np.eye(num_classes)[y_train]
y_test = np.eye(num_classes)[y_test]

X_train = X_train.reshape((27455, 28, 28, 1))
X_test = X_test.reshape((7172, 28, 28, 1))




from keras.models import Sequential 
from keras.layers import Conv2D,MaxPooling2D, Dense,Flatten, Dropout
from keras.utils import np_utils
from keras.optimizers import SGD, adam




classifier = Sequential()
classifier.add(Conv2D(filters=8, kernel_size=(3,3),strides=(1,1),padding='same',input_shape=(28,28,1),activation='relu', data_format='channels_last'))
classifier.add(MaxPooling2D(pool_size=(2,2)))
classifier.add(Conv2D(filters=16, kernel_size=(3,3),strides=(1,1),padding='same',activation='relu'))
classifier.add(Dropout(0.5))
classifier.add(MaxPooling2D(pool_size=(4,4)))
classifier.add(Dense(128, activation='relu'))
classifier.add(Flatten())
classifier.add(Dense(26, activation='softmax'))




classifier.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy'])
classifier.fit(X_train, y_train, epochs=50, batch_size=100)





accuracy = classifier.evaluate(x=X_test,y=y_test,batch_size=32)
print("Accuracy: ",accuracy[1])




classifier.summary()



classifier.save('CNNmodel.h5')

