当前位置: 首页>>代码示例>>Python>>正文


Python reuters.load_data方法代码示例

本文整理汇总了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 
开发者ID:XifengGuo,项目名称:DEC-keras,代码行数:22,代码来源:datasets.py

示例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) 
开发者ID:lllcho,项目名称:CAPTCHA-breaking,代码行数:23,代码来源:test_datasets.py

示例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() 
开发者ID:lllcho,项目名称:CAPTCHA-breaking,代码行数:5,代码来源:test_datasets.py

示例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 
开发者ID:XifengGuo,项目名称:DEC-keras,代码行数:20,代码来源:datasets.py

示例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() 
开发者ID:lllcho,项目名称:CAPTCHA-breaking,代码行数:5,代码来源:test_datasets.py

示例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) 
开发者ID:lllcho,项目名称:CAPTCHA-breaking,代码行数:9,代码来源:test_datasets.py

示例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 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:16,代码来源:test_datasets.py

示例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) 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:16,代码来源:test_datasets.py

示例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 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:10,代码来源:test_datasets.py

示例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) 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:13,代码来源:test_datasets.py

示例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) 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:10,代码来源:test_datasets.py


注:本文中的keras.datasets.reuters.load_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。