简体   繁体   English

CNN模型准确率波动

[英]CNN model accuracy fluctuates

Tensorflow/Keras张量流/Keras

I have developed a CNN model to classify images as circle, triangle or square.我开发了一个 CNN 模型来将图像分类为圆形、三角形或正方形。 However, my accuracy values have wide fluctuations.但是,我的准确度值波动很大。 Is it something to do with my data preprocessing?这与我的数据预处理有关吗?

This is my code for data preprocessing:这是我的数据预处理代码:

Edit: I am using this folder Folder structure Edit2: I am using this model Model编辑:我正在使用这个文件夹文件夹结构编辑2:我正在使用这个模型模型

input_folder = r"C:\Users\User\OneDrive\Documents\Trimester_2 2022 (6 Subjects)\AI\Assignment\three_shapes"
output_folder = r"C:\Users\User\OneDrive\Documents\Trimester_2 2022 (6 Subjects)\AI\Assignment\splited_data"
splitfolders.ratio(input_folder, output_folder, seed = 42, ratio = (.7, .2, .1),)


os.chdir(r"C:\Users\User\OneDrive\Documents\Trimester_2 2022 (6 Subjects)\AI\Assignment\splited_data")

os.makedirs("train/circle")
os.makedirs("train/square")
os.makedirs("train/triangle")
os.makedirs("val/circle")
os.makedirs("val/square")
os.makedirs("val/triangle")
os.makedirs("test/circle")
os.makedirs("test/square")
os.makedirs("test/triangle")

list = ["train/", "test/", "val/"]
for i in list:
    for name in glob.glob(i + "triangle*"):
        shutil.move(name, i + "triangle")
    for name in glob.glob(i + "circle*"):
        shutil.move(name, i + "circle")
    for name in glob.glob(i + "square*"):
        shutil.move(name, i + "square")



IMAGE_WIDTH = 200
IMAGE_HEIGHT = 200

train_gen = ImageDataGenerator(rescale = 1/255).flow_from_directory(
    directory=r"train", # the path to the 'shapes' directory.
    target_size=(IMAGE_WIDTH, IMAGE_HEIGHT),
    classes=["circle", "square", "triangle"],
    batch_size=200,
    class_mode="categorical",
)

test_gen = ImageDataGenerator(rescale = 1/255).flow_from_directory(
    directory=r"test", # the path to the 'shapes' directory.
    target_size=(IMAGE_WIDTH, IMAGE_HEIGHT),
    classes=["circle", "square", "triangle"],
    batch_size=200,
    class_mode="categorical",
)

val_gen = ImageDataGenerator(rescale = 1/255).flow_from_directory(
    directory=r"val", # the path to the 'shapes' directory.
    target_size=(IMAGE_WIDTH, IMAGE_HEIGHT),
    classes=["circle", "square", "triangle"],
    batch_size=200,
    class_mode="categorical",
)

It is easy, I am trying to generate those inputs but my work also indicates shapes-sensitive categories such as Galaxy games.这很容易,我正在尝试生成这些输入,但我的工作也表明了形状敏感的类别,例如 Galaxy 游戏。 Your models do not need anything special excepts matching on target responsive and layers.您的模型不需要任何特殊的,除了在目标响应和层上匹配。 ( You see when training of the good response from model training ) (你看到训练时模型训练的良好反应)

[ Sample ]: [ 样本 ]:

identity_cell = tf.image.flip_up_down( cropped_image ).numpy()
identity_cell = identity_cell + cropped_image.numpy()

identity_cell = tf.where( tf.greater_equal( identity_cell, np.ones((n_yaxis, n_xais, channel)) * 0.300 ), [1], [0], name=None ).numpy()
identity_cell = tf.math.count_nonzero(identity_cell)

... ... 样本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM