CNN basic
unknown
python
3 years ago
1.4 kB
36
Indexable
Never
batch_size = 21 epochs = 32 #Complete stock code model1 = Sequential() model1.add(Conv2D(32, kernel_size=(3,3),activation='relu',input_shape=(35,18,2),padding='valid')) model1.add(LeakyReLU(alpha=0.1)) model1.add(MaxPooling2D(2,padding='same')) model1.add(Dropout(0.25)) model1.add(Conv2D(64, (3,3), activation='relu',padding='same')) model1.add(LeakyReLU(alpha=0.1)) model1.add(MaxPooling2D(pool_size=2,padding='same')) model1.add(Dropout(0.25)) model1.add(Conv2D(128, (3,3), activation='relu',padding='same')) model1.add(LeakyReLU(alpha=0.1)) model1.add(MaxPooling2D(pool_size=2,padding='same')) model1.add(Dropout(0.4)) model1.add(Flatten()) model1.add(Dense(128, activation='relu')) model1.add(LeakyReLU(alpha=0.1)) model1.add(Dropout(0.3)) model1.add(Dense(num_classes, activation='softmax')) model1.compile(loss=keras.losses.categorical_crossentropy, optimizer=keras.optimizers.Adam(),metrics=['accuracy']) model1_train_dropout = model1.fit(train_X, train_Y_one_hot, batch_size=batch_size,epochs=epochs,verbose=1,validation_split=0.2) model1.save("sanjoukin_gt_train.h5py") #loadedmodel = .load("sanjoukin_gt_train.h5py") test_eval = model1.evaluate(test_X, test_Y_one_hot, verbose=11)