Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在class_模式下,二进制、稀疏和分类有什么区别_Python_Keras_Cnn - Fatal编程技术网

Python 在class_模式下,二进制、稀疏和分类有什么区别

Python 在class_模式下,二进制、稀疏和分类有什么区别,python,keras,cnn,Python,Keras,Cnn,下面是理解代码 当我使用稀疏/分类时。它显示相同的输出 低于输出, Found 214 images belonging to 5 classes. Found 20 images belonging to 5 classes. 注意:此代码用于训练数据集,但不幸的是,它没有训练数据集 因此需要帮助他们与之相关 'binary'类模式为您提供每个类的编号。例如,如果您的数据集有3个类别A、B、C,则目标数据将为0(类别A)、1(类别B)和2(类别C) 对于A,(0,1,0),对于B,(0,1,

下面是理解代码

当我使用稀疏/分类时。它显示相同的输出

低于输出,

Found 214 images belonging to 5 classes.
Found 20 images belonging to 5 classes.
注意:此代码用于训练数据集,但不幸的是,它没有训练数据集

因此需要帮助

他们与之相关

'binary'
类模式为您提供每个类的编号。例如,如果您的数据集有3个类别A、B、C,则目标数据将为0(类别A)、1(类别B)和2(类别C)

对于A,
(0,1,0)
,对于B,
(0,1,0)
,对于C,
(0,0,1)

你可以用这个来寻找不同的

test_set = test_datagen.flow_from_directory(
    'dataset/test_set',
    target_size = (64,64),
    batch_size = 32,
    class_mode = 'binary'
)
x, y = test_set[0]
print(y.shape)  # (32,)
print(y)

test_set = test_datagen.flow_from_directory(
    'dataset/test_set',
    target_size = (64,64),
    batch_size = 32,
    class_mode = 'categorical'
)
x, y = test_set[0]
print(y.shape)  # (32, n) where n is equal to how many folder you have in 'dataset/test_set'
print(y)

sparse
不用于
flow\u from\u目录
中,通常在图像可以是多个类时使用。例如,如果图像可以是A和C,则目标将是
(1,0,1)

二进制的原因实际上是这样的,因为在早期版本中,它只给你1和0

'binary'
类模式为您提供每个类的编号。例如,如果您的数据集有3个类别A、B、C,则目标数据将为0(类别A)、1(类别B)和2(类别C)

对于A,
(0,1,0)
,对于B,
(0,1,0)
,对于C,
(0,0,1)

你可以用这个来寻找不同的

test_set = test_datagen.flow_from_directory(
    'dataset/test_set',
    target_size = (64,64),
    batch_size = 32,
    class_mode = 'binary'
)
x, y = test_set[0]
print(y.shape)  # (32,)
print(y)

test_set = test_datagen.flow_from_directory(
    'dataset/test_set',
    target_size = (64,64),
    batch_size = 32,
    class_mode = 'categorical'
)
x, y = test_set[0]
print(y.shape)  # (32, n) where n is equal to how many folder you have in 'dataset/test_set'
print(y)

sparse
不用于
flow\u from\u目录
中,通常在图像可以是多个类时使用。例如,如果图像可以是A和C,则目标将是
(1,0,1)

二进制的原因实际上是这样调用的,因为在早期版本中,它只提供1和0