Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.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
Tensorflow 如何增加KERA中的数据训练偏差?_Tensorflow_Machine Learning_Keras - Fatal编程技术网

Tensorflow 如何增加KERA中的数据训练偏差?

Tensorflow 如何增加KERA中的数据训练偏差?,tensorflow,machine-learning,keras,Tensorflow,Machine Learning,Keras,我目前正在使用大约15k的图像(50%的好图像和坏图像)进行使用Keras的二元模型训练。然而,我的坏数据集是有限的。所以我增加了增强功能。尽管如此,我还是想强迫模型将好的识别为坏的,如果是轻微的或接近坏的 Y_train = train_generator.classes from sklearn.utils import class_weight class_weight = class_weight.compute_class_weight('balanced'

我目前正在使用大约15k的图像(50%的好图像和坏图像)进行使用Keras的二元模型训练。然而,我的坏数据集是有限的。所以我增加了增强功能。尽管如此,我还是想强迫模型将好的识别为坏的,如果是轻微的或接近坏的

Y_train = train_generator.classes
from sklearn.utils import class_weight
class_weight = class_weight.compute_class_weight('balanced'
                                               ,np.unique(Y_train)
                                               ,Y_train)
class_weight
class_weight = dict(zip(np.unique(Y_train), class_weight))
class_weight
输出:

{0: 1.0015690376569037, 1: 0.9984358706986444}
我想在坏数据集上比在好数据集上进行更多的训练。是否可以将等级(0-坏)权重增加到10

培训:

print(colored('Training initiaited. please wait........', 'blue',))
model.fit_generator(train_generator,
                         epochs = epochs,
                         validation_data = validation_generator,
                         class_weight = class_weight, 
                         steps_per_epoch=int(train_generator.samples/batch_size),
                         callbacks=callbacks_list, 
                         validation_steps = int(validation_generator.samples/batch_size)
                           ) 
强迫模型在坏数据集上进行更多训练的最佳方法是什么?(如果这不是最好的方法(不幸的是,我没有任何不好的数据,但我有很多好的数据点))

有什么我可以做以下“平衡”


对误报有更严格限制的一个简单方法是在分类过程中增加阈值。也就是说,假设您的模型抛出的输出值为
0.65
,同时为图像类做出决策,这通常类似于

threshold = 0.5
if output<threshold:
    print("Class 0")
else:
    print("Class 1")
阈值=0.5
中频输出
threshold = 0.5
if output<threshold:
    print("Class 0")
else:
    print("Class 1")