漫威超级英雄的命中率低

时间:2019-07-28 13:09:10

标签: machine-learning keras deep-learning computer-vision conv-neural-network

我正在尝试使用卷积神经网络训练我的模型,但是准确率很低,如下所示

  

Epoch 1/25 2584/2584 [=============================]-3383s 1s / step   -损失:1.5456-acc:0.3907-val_loss:2.0794-val_acc:0.1221

     

Epoch 2/25 2584/2584 [=============================]-2641s 1s / step   -损失:2.0794-acc:0.1238-val_loss:2.0794-val_acc:0.1218

     

Epoch 3/25 2584/2584 [==============================-2614s 1s / step   -损失:2.0794-acc:0.1239-val_loss:2.0794-val_acc:0.1218

     

Epoch 4/25 2584/2584 [=============================]-2655s 1s / step   -损失:2.0794-acc:0.1240-val_loss:2.0794-val_acc:0.1221

它包含2584张来自8个类别的图像,用于训练数据。 并对属于8类的451张图像进行测试。

任何人都可以帮助我,如何获得良好的准确率。

最好的问候

这是我的代码

import tensorflow as tf

# Adding first convolutional and max pooling layer
convo1 = tf.keras.layers.Conv2D(16, (3,3), activation = 'relu', input_shape = (300, 300, 3))

maxpool1 = tf.keras.layers.MaxPooling2D(2,2)

# Adding second convolutional and max pooling layer

convo2 = tf.keras.layers.Conv2D(32, (3,3), activation  = 'relu')

maxpooling = tf.keras.layers.MaxPooling2D(2,2)

# Adding third convolutional and max pooling layer

convo3 = tf.keras.layers.Conv2D(64, (3,3), activation = 'relu')

maxpooling3 = tf.keras.layers.MaxPooling2D(2,2)

# Adding fourth convolutional and max pooling layer

convo4 = tf.keras.layers.Conv2D(64, (3,3), activation = 'relu')

maxpooling = tf.keras.layers.MaxPooling2D(2,2)

# Adding fifth convolutional and max pooling layer

convo5 = tf.keras.layers.Conv2D(64, (3,3), activation= 'relu')

maxpooling = tf.keras.layers.MaxPooling2D(2,2)

# Adding the flattend layer

flattend = tf.keras.layers.Flatten()

# Adding the 512 neuron hidden layer

hidden = tf.keras.layers.Dense(512, activation='relu')

# Adding the output layer

output = tf.keras.layers.Dense(8, activation = 'sigmoid')




#Intializing the neural network

classifier = tf.keras.models.Sequential([convo1, maxpool1, convo2, maxpooling, convo3, maxpooling3, convo4, maxpooling, convo5, maxpooling, flattend, hidden, output])

classifier.compile(optimizer = 'adam', loss = 'categorical_crossentropy', metrics = ['accuracy'])

from tensorflow.keras.preprocessing.image import ImageDataGenerator

train_datagen = ImageDataGenerator(rescale=1./255, shear_range=0.2, zoom_range=0.2, horizontal_flip=True)

test_datagen = ImageDataGenerator(rescale=1./255)

training_data = train_datagen.flow_from_directory( '/content/drive/My Drive/marvel/train', target_size=(300, 300), batch_size=32, class_mode='categorical')

test_data = test_datagen.flow_from_directory('/content/drive/My Drive/marvel/valid', target_size=(300, 300), batch_size=32,class_mode='categorical')

classifier.fit_generator( training_data, steps_per_epoch=2584 , epochs=25, validation_data=test_data, validation_steps=451)

如果我的得分超过90%,那就太好了

0 个答案:

没有答案