简体   繁体   English

如何更改 CIFAR-10 数据集标签?

[英]How can I change the CIFAR-10 dataset labels?

I want to change some labels of dataset CIFAR-10.我想更改数据集 CIFAR-10 的一些标签。 That mean, I want to train my networks with some wrongs labels in this dataset.这意味着,我想用这个数据集中的一些错误标签来训练我的网络。

After change the dataset labels, I need it in some format like:更改数据集标签后,我需要某种格式,例如:

dataset_cifar_with_some_wrongs_labels = (amount of pictures, label, image)

image.shape=(32,32,3)

I know I can download it as:我知道我可以将其下载为:

https://www.cs.toronto.edu/~kriz/cifar.html https://www.cs.toronto.edu/~kriz/cifar.html

Someone know how can i do it?有人知道我该怎么做吗?

You can use keras internal cifar10 dataset.您可以使用keras内部cifar10数据集。 I have implemented a noise mechanism via permutation but there are probably many other choices.我已经通过排列实现了噪声机制,但可能还有许多其他选择。

import keras
import numpy as np
(x_train, y_train), (x_test, y_test) = keras.datasets.cifar10.load_data()
n = 1000
y_train_ = y_train.copy()
idx_to_shuffle = np.random.choice(y_train.shape[0], n)
y_train[idx_to_shuffle] = np.random.permutation(y_train[idx_to_shuffle])

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

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