这是我的代码:
我无法提高我的准确性,我只能得到10%的准确性。有人可以告诉我应该选择哪种激活功能或某些功能,这样我可以提高准确性。
from keras.models import Sequential
from keras.layers import Convolution2D
from keras.layers import MaxPooling2D
from keras.layers import Flatten
from keras.layers import Dense
初始化cnn
classifier = Sequential()
第1步
classifier.add(Convolution2D(32, 3 ,3 , input_shape = (64,64,3) ,
activation = 'relu'))
#step 2 pooling
classifier.add(MaxPooling2D(pool_size = (2,2)))
展平
classifier.add(Flatten())
classifier.add(Dense(output_dim = 64, activation = 'softmax'))
classifier.add(Dense(output_dim =10, activation = 'softmax'))
classifier.compile(optimizer = 'adam' , loss = 'categorical_crossentropy'
, metrics = ['accuracy'] )
from keras.preprocessing.image import ImageDataGenerator
train_datagen = ImageDataGenerator(rotation_range=90,
width_shift_range=0.1, height_shift_range=0.1,
horizontal_flip=True)
training_set = train_datagen.flow_from_directory('numbers/',
target_size = (64, 64),
batch_size = 64,
class_mode = 'categorical')
classifier.fit_generator(training_set,
samples_per_epoch = 2000,
nb_epoch = 25)