我有3400张图片(单词)的数据集我正在使用Conv2D
来训练我的数据集我知道它不是大数据集,但我的val_Acc=0.5624
无论多少num_filter
它都没有增加我增加有没有办法改善我的模型。如果我做错了什么,请指导我。完整的代码如下。
batch_size=100
num_classes=37
epochs=30
os.chdir("E:");
path="E:/Dummy/Level-1";
classes=os.listdir(path)
x=[]#Datapoints
y=[]#labels
for fol in classes:
imgfiles=os.listdir(path+u'\\'+fol);
for img in imgfiles:
im=mpimg.imread(path+u'\\'+fol+u'\\'+img);
x.append(im)
y.append(fol)
x=numpy.array(x)
y=numpy.array(y)
print(x.shape)
print(y.shape)
x=x.reshape((-1,100,100,1))
n=x.shape[0]
randomize=numpy.arange(n)
numpy.random.shuffle(randomize)
randomize
x=x[randomize]
y=y[randomize]
test_split=round(n*2/3)
x_train=x[:test_split]
y_train=y[:test_split]
x_test=x[test_split:]
y_test=y[test_split:]
y_train=keras.utils.to_categorical(y_train, num_classes)
y_test=keras.utils.to_categorical(y_test, num_classes)
inputs=Input(shape=(100,100,1))
x=Conv2D(16, (3, 3), padding='same')(inputs)
x=Conv2D(16, (3, 3), padding='same')(x)
x=MaxPooling2D(pool_size=(2,2))(x)
x=SReLU()(x)
x=Conv2D(32, (3, 3), padding='same')(x)
x=Conv2D(32, (3, 3), padding='same')(x)
x=MaxPooling2D(pool_size=(2,2))(x)
x=SReLU()(x)
x=Conv2D(64, (3, 3), padding='same')(x)
x=Conv2D(64, (3, 3), padding='same')(x)
x=MaxPooling2D(pool_size=(2,2))(x)
x=SReLU()(x)
x=Conv2D(128, (3, 3), padding='same')(x)
x=Conv2D(128, (3, 3), padding='same')(x)
x=MaxPooling2D(pool_size=(2,2))(x)
x=Dropout(0.2)(x)
x=SReLU()(x)
x=Flatten()(x)
x=Dense(num_classes)(x)
output=Activation('softmax')(x)
model=Model([inputs], output)
opt=keras.optimizers.RMSprop(lr=1e-3)
model.compile(loss='categorical_crossentropy', optimizer=opt, metrics=['accuracy'])
答案 0 :(得分:1)
模型似乎正确你的输入中必定存在问题(图像)我使用CNN
对300张灰度图像进行了处理,如果你正在执行任何执行,它就不会预处理。