本文整理匯總了Python中keras.datasets.cifar100.load_data方法的典型用法代碼示例。如果您正苦於以下問題:Python cifar100.load_data方法的具體用法?Python cifar100.load_data怎麽用?Python cifar100.load_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類keras.datasets.cifar100
的用法示例。
在下文中一共展示了cifar100.load_data方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_imdb
# 需要導入模塊: from keras.datasets import cifar100 [as 別名]
# 或者: from keras.datasets.cifar100 import load_data [as 別名]
def test_imdb(self):
print('imdb')
(X_train, y_train), (X_test, y_test) = imdb.load_data()
示例2: test_cifar
# 需要導入模塊: from keras.datasets import cifar100 [as 別名]
# 或者: from keras.datasets.cifar100 import load_data [as 別名]
def test_cifar(self):
print('cifar10')
(X_train, y_train), (X_test, y_test) = cifar10.load_data()
print(X_train.shape)
print(X_test.shape)
print(y_train.shape)
print(y_test.shape)
print('cifar100 fine')
(X_train, y_train), (X_test, y_test) = cifar100.load_data('fine')
print(X_train.shape)
print(X_test.shape)
print(y_train.shape)
print(y_test.shape)
print('cifar100 coarse')
(X_train, y_train), (X_test, y_test) = cifar100.load_data('coarse')
print(X_train.shape)
print(X_test.shape)
print(y_train.shape)
print(y_test.shape)
示例3: load_cifar10
# 需要導入模塊: from keras.datasets import cifar100 [as 別名]
# 或者: from keras.datasets.cifar100 import load_data [as 別名]
def load_cifar10() :
(train_data, train_labels), (test_data, test_labels) = cifar10.load_data()
# train_data = train_data / 255.0
# test_data = test_data / 255.0
train_data, test_data = normalize(train_data, test_data)
train_labels = to_categorical(train_labels, 10)
test_labels = to_categorical(test_labels, 10)
seed = 777
np.random.seed(seed)
np.random.shuffle(train_data)
np.random.seed(seed)
np.random.shuffle(train_labels)
return train_data, train_labels, test_data, test_labels
示例4: load_cifar100
# 需要導入模塊: from keras.datasets import cifar100 [as 別名]
# 或者: from keras.datasets.cifar100 import load_data [as 別名]
def load_cifar100() :
(train_data, train_labels), (test_data, test_labels) = cifar100.load_data()
# train_data = train_data / 255.0
# test_data = test_data / 255.0
train_data, test_data = normalize(train_data, test_data)
train_labels = to_categorical(train_labels, 100)
test_labels = to_categorical(test_labels, 100)
seed = 777
np.random.seed(seed)
np.random.shuffle(train_data)
np.random.seed(seed)
np.random.shuffle(train_labels)
return train_data, train_labels, test_data, test_labels
示例5: load_mnist
# 需要導入模塊: from keras.datasets import cifar100 [as 別名]
# 或者: from keras.datasets.cifar100 import load_data [as 別名]
def load_mnist() :
(train_data, train_labels), (test_data, test_labels) = mnist.load_data()
train_data = np.expand_dims(train_data, axis=-1)
test_data = np.expand_dims(test_data, axis=-1)
train_data, test_data = normalize(train_data, test_data)
train_labels = to_categorical(train_labels, 10)
test_labels = to_categorical(test_labels, 10)
seed = 777
np.random.seed(seed)
np.random.shuffle(train_data)
np.random.seed(seed)
np.random.shuffle(train_labels)
return train_data, train_labels, test_data, test_labels
示例6: load_fashion
# 需要導入模塊: from keras.datasets import cifar100 [as 別名]
# 或者: from keras.datasets.cifar100 import load_data [as 別名]
def load_fashion() :
(train_data, train_labels), (test_data, test_labels) = fashion_mnist.load_data()
train_data = np.expand_dims(train_data, axis=-1)
test_data = np.expand_dims(test_data, axis=-1)
train_data, test_data = normalize(train_data, test_data)
train_labels = to_categorical(train_labels, 10)
test_labels = to_categorical(test_labels, 10)
seed = 777
np.random.seed(seed)
np.random.shuffle(train_data)
np.random.seed(seed)
np.random.shuffle(train_labels)
return train_data, train_labels, test_data, test_labels
示例7: convert
# 需要導入模塊: from keras.datasets import cifar100 [as 別名]
# 或者: from keras.datasets.cifar100 import load_data [as 別名]
def convert():
train = 'train//'
val = 'validation//'
(X_train, y_train), (X_test, y_test) = cifar100.load_data(label_mode='fine')
for i in range(len(X_train)):
x = X_train[i]
y = y_train[i]
path = train + str(y[0])
x = cv2.resize(x, (224, 224), interpolation=cv2.INTER_CUBIC)
if not os.path.exists(path):
os.makedirs(path)
cv2.imwrite(path + '//' + str(i) + '.jpg', x)
for i in range(len(X_test)):
x = X_test[i]
y = y_test[i]
path = val + str(y[0])
x = cv2.resize(x, (224, 224), interpolation=cv2.INTER_CUBIC)
if not os.path.exists(path):
os.makedirs(path)
cv2.imwrite(path + '//' + str(i) + '.jpg', x)
示例8: test_reuters
# 需要導入模塊: from keras.datasets import cifar100 [as 別名]
# 或者: from keras.datasets.cifar100 import load_data [as 別名]
def test_reuters(self):
print('reuters')
(X_train, y_train), (X_test, y_test) = reuters.load_data()
示例9: test_mnist
# 需要導入模塊: from keras.datasets import cifar100 [as 別名]
# 或者: from keras.datasets.cifar100 import load_data [as 別名]
def test_mnist(self):
print('mnist')
(X_train, y_train), (X_test, y_test) = mnist.load_data()
print(X_train.shape)
print(X_test.shape)
print(y_train.shape)
print(y_test.shape)
示例10: test_cifar
# 需要導入模塊: from keras.datasets import cifar100 [as 別名]
# 或者: from keras.datasets.cifar100 import load_data [as 別名]
def test_cifar():
# only run data download tests 20% of the time
# to speed up frequent testing
random.seed(time.time())
if random.random() > 0.8:
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
assert len(x_train) == len(y_train) == 50000
assert len(x_test) == len(y_test) == 10000
(x_train, y_train), (x_test, y_test) = cifar100.load_data('fine')
assert len(x_train) == len(y_train) == 50000
assert len(x_test) == len(y_test) == 10000
(x_train, y_train), (x_test, y_test) = cifar100.load_data('coarse')
assert len(x_train) == len(y_train) == 50000
assert len(x_test) == len(y_test) == 10000
示例11: test_reuters
# 需要導入模塊: from keras.datasets import cifar100 [as 別名]
# 或者: from keras.datasets.cifar100 import load_data [as 別名]
def test_reuters():
# only run data download tests 20% of the time
# to speed up frequent testing
random.seed(time.time())
if random.random() > 0.8:
(x_train, y_train), (x_test, y_test) = reuters.load_data()
assert len(x_train) == len(y_train)
assert len(x_test) == len(y_test)
assert len(x_train) + len(x_test) == 11228
(x_train, y_train), (x_test, y_test) = reuters.load_data(maxlen=10)
assert len(x_train) == len(y_train)
assert len(x_test) == len(y_test)
word_index = reuters.get_word_index()
assert isinstance(word_index, dict)
示例12: test_mnist
# 需要導入模塊: from keras.datasets import cifar100 [as 別名]
# 或者: from keras.datasets.cifar100 import load_data [as 別名]
def test_mnist():
# only run data download tests 20% of the time
# to speed up frequent testing
random.seed(time.time())
if random.random() > 0.8:
(x_train, y_train), (x_test, y_test) = mnist.load_data()
assert len(x_train) == len(y_train) == 60000
assert len(x_test) == len(y_test) == 10000
示例13: test_imdb
# 需要導入模塊: from keras.datasets import cifar100 [as 別名]
# 或者: from keras.datasets.cifar100 import load_data [as 別名]
def test_imdb():
# only run data download tests 20% of the time
# to speed up frequent testing
random.seed(time.time())
if random.random() > 0.8:
(x_train, y_train), (x_test, y_test) = imdb.load_data()
(x_train, y_train), (x_test, y_test) = imdb.load_data(maxlen=40)
assert len(x_train) == len(y_train)
assert len(x_test) == len(y_test)
word_index = imdb.get_word_index()
assert isinstance(word_index, dict)
示例14: test_boston_housing
# 需要導入模塊: from keras.datasets import cifar100 [as 別名]
# 或者: from keras.datasets.cifar100 import load_data [as 別名]
def test_boston_housing():
# only run data download tests 20% of the time
# to speed up frequent testing
random.seed(time.time())
if random.random() > 0.8:
(x_train, y_train), (x_test, y_test) = boston_housing.load_data()
assert len(x_train) == len(y_train)
assert len(x_test) == len(y_test)