本文整理匯總了Python中keras.datasets.reuters.load_data方法的典型用法代碼示例。如果您正苦於以下問題:Python reuters.load_data方法的具體用法?Python reuters.load_data怎麽用?Python reuters.load_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類keras.datasets.reuters
的用法示例。
在下文中一共展示了reuters.load_data方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: load_imdb
# 需要導入模塊: from keras.datasets import reuters [as 別名]
# 或者: from keras.datasets.reuters import load_data [as 別名]
def load_imdb():
from keras.preprocessing.text import Tokenizer
from keras.datasets import imdb
max_words = 1000
print('Loading data...')
(x1, y1), (x2, y2) = imdb.load_data(num_words=max_words)
x = np.concatenate((x1, x2))
y = np.concatenate((y1, y2))
print(len(x), 'train sequences')
num_classes = np.max(y) + 1
print(num_classes, 'classes')
print('Vectorizing sequence data...')
tokenizer = Tokenizer(num_words=max_words)
x = tokenizer.sequences_to_matrix(x, mode='binary')
print('x_train shape:', x.shape)
return x.astype(float), y
示例2: test_cifar
# 需要導入模塊: from keras.datasets import reuters [as 別名]
# 或者: from keras.datasets.reuters 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: test_imdb
# 需要導入模塊: from keras.datasets import reuters [as 別名]
# 或者: from keras.datasets.reuters import load_data [as 別名]
def test_imdb(self):
print('imdb')
(X_train, y_train), (X_test, y_test) = imdb.load_data()
示例4: load_retures_keras
# 需要導入模塊: from keras.datasets import reuters [as 別名]
# 或者: from keras.datasets.reuters import load_data [as 別名]
def load_retures_keras():
from keras.preprocessing.text import Tokenizer
from keras.datasets import reuters
max_words = 1000
print('Loading data...')
(x, y), (_, _) = reuters.load_data(num_words=max_words, test_split=0.)
print(len(x), 'train sequences')
num_classes = np.max(y) + 1
print(num_classes, 'classes')
print('Vectorizing sequence data...')
tokenizer = Tokenizer(num_words=max_words)
x = tokenizer.sequences_to_matrix(x, mode='binary')
print('x_train shape:', x.shape)
return x.astype(float), y
示例5: test_reuters
# 需要導入模塊: from keras.datasets import reuters [as 別名]
# 或者: from keras.datasets.reuters import load_data [as 別名]
def test_reuters(self):
print('reuters')
(X_train, y_train), (X_test, y_test) = reuters.load_data()
示例6: test_mnist
# 需要導入模塊: from keras.datasets import reuters [as 別名]
# 或者: from keras.datasets.reuters 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)
示例7: test_cifar
# 需要導入模塊: from keras.datasets import reuters [as 別名]
# 或者: from keras.datasets.reuters 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
示例8: test_reuters
# 需要導入模塊: from keras.datasets import reuters [as 別名]
# 或者: from keras.datasets.reuters 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)
示例9: test_mnist
# 需要導入模塊: from keras.datasets import reuters [as 別名]
# 或者: from keras.datasets.reuters 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
示例10: test_imdb
# 需要導入模塊: from keras.datasets import reuters [as 別名]
# 或者: from keras.datasets.reuters 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)
示例11: test_boston_housing
# 需要導入模塊: from keras.datasets import reuters [as 別名]
# 或者: from keras.datasets.reuters 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)