Skip to content
Snippets Groups Projects
Commit d49e6060 authored by Silas Dohm's avatar Silas Dohm
Browse files

better cnn, 81.4% acc, but confusion matrix isnt great)

parent 75174575
No related branches found
No related tags found
No related merge requests found
...@@ -10,16 +10,16 @@ from tensorflow.keras.layers import Conv1D,MaxPooling1D,GlobalMaxPooling1D ...@@ -10,16 +10,16 @@ from tensorflow.keras.layers import Conv1D,MaxPooling1D,GlobalMaxPooling1D
from tensorflow import keras from tensorflow import keras
modelNN = Sequential() modelNN = Sequential()
#input_shape=((72, 100)))
modelNN.add(Conv1D(50,kernel_size=5, activation='relu',input_shape=((72, 100)))) modelNN.add(Conv1D(150,kernel_size=5, activation='relu',input_shape=((72, 100))))
#modelNN.add(MaxPooling1D(pool_size=4)) #modelNN.add(MaxPooling1D(pool_size=4))
#modelNN.add(Conv1D(250,kernel_size=4, activation='relu')) #modelNN.add(Conv1D(250,kernel_size=4, activation='relu'))
modelNN.add(MaxPooling1D(pool_size=4)) modelNN.add(MaxPooling1D(pool_size=4))
modelNN.add(Conv1D(25,kernel_size=3, activation='relu')) modelNN.add(Conv1D(100,kernel_size=3, activation='relu'))
modelNN.add(MaxPooling1D(pool_size=4)) modelNN.add(MaxPooling1D(pool_size=4))
modelNN.add(Flatten()) modelNN.add(Flatten())
modelNN.add(Dense(25,activation='relu')) modelNN.add(Dense(300,activation='relu'))
modelNN.add(Dense(100,activation='relu'))
#modelNN.add(Dense(50,activation='relu')) #modelNN.add(Dense(50,activation='relu'))
modelNN.add(Dense(10,activation='relu')) modelNN.add(Dense(10,activation='relu'))
modelNN.add(Dense(3,activation='softmax')) modelNN.add(Dense(3,activation='softmax'))
...@@ -30,7 +30,7 @@ from hdf5 import hdf5Generator ...@@ -30,7 +30,7 @@ from hdf5 import hdf5Generator
path = "G:\\ml\\" path = "G:\\ml\\"
num_rows = 4.8E6 num_rows = 4.8E6
#num_rows = 1E5 #num_rows = 1E5
batchSize = 2048 batchSize = 256
steps = num_rows/batchSize steps = num_rows/batchSize
#early stop #early stop
earlystop = keras.callbacks.EarlyStopping(monitor='val_sparse_categorical_accuracy',patience=5,verbose=False,restore_best_weights=True) earlystop = keras.callbacks.EarlyStopping(monitor='val_sparse_categorical_accuracy',patience=5,verbose=False,restore_best_weights=True)
...@@ -41,8 +41,8 @@ valData = hdf5Generator(path + "w2vCNN.hdf5", batchSize, "Val") ...@@ -41,8 +41,8 @@ valData = hdf5Generator(path + "w2vCNN.hdf5", batchSize, "Val")
#%% #%%
cW = {0:4.18,1:9.53,2:1.52} cW = {0:4.18,1:9.53,2:1.52}
hist = modelNN.fit(trainData, validation_data=valData, epochs=100,class_weight=cW, steps_per_epoch=steps, validation_steps=steps,callbacks=cbList) hist = modelNN.fit(trainData, validation_data=valData, epochs=100,class_weight=cW, steps_per_epoch=steps, validation_steps=int(steps/3),callbacks=cbList)
modelNN.save("D:\\ml\\CNN-Classfication-5") modelNN.save("D:\\ml\\CNN-Classfication-6")
#modelNN.fit(train,epochs=12,validation_data=val,batch_size=batchSize,steps_per_epoch= num_rows/batchSize,callbacks=cbList,validation_steps=num_rows/batchSize) #modelNN.fit(train,epochs=12,validation_data=val,batch_size=batchSize,steps_per_epoch= num_rows/batchSize,callbacks=cbList,validation_steps=num_rows/batchSize)
# %%eval # %%eval
testData = hdf5Generator(path + "w2vCNN.hdf5", batchSize, "Test",loop=False) testData = hdf5Generator(path + "w2vCNN.hdf5", batchSize, "Test",loop=False)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment