コード例 #1
0
    X, Y, testX, testY = mnist.load_data(one_hot=True)
elif jdata.model == "cifar10":  # input 1024 - output 10
    print("https://www.cs.toronto.edu/~kriz/cifar.html")
    from tflearn.datasets import cifar10
    (X, Y), (testX, testY) = cifar10.load_data()
    X, Y = shuffle(X, Y)
    Y = to_categorical(Y)
    testY = to_categorical(testY)
    X = shapeToOneD(X)
    Y = shapeToOneD(Y)
    testX = shapeToOneD(testX)
    testY = shapeToOneD(testY)
elif jdata.model == "cifar100":  # input 1024 - output 100
    print("https://www.cs.toronto.edu/~kriz/cifar.html")
    from tflearn.datasets import cifar100
    (X, Y), (testX, testY) = cifar100.load_data()
elif jdata.model == "oxflower17.py": # input 50176 - output 17
    print("http://www.robots.ox.ac.uk/~vgg/data/flowers/17/")
    from tflearn.datasets import oxflower17
    (X, Y) = oxflower17.load_data()
elif jdata.model == "svhn":  # input 1024 - output 10
    print("http://ufldl.stanford.edu/housenumbers")
    from tflearn.datasets import svhn
    X, Y, testX, testY = svhn.load_data()
else:
    sys.exit(1)

# Building deep neural network
net = tflearn.input_data(shape=[None, inputlayer], name='input')

modelFilename = ""
コード例 #2
0
from __future__ import division, print_function, absolute_import

import tflearn
from tflearn.data_utils import shuffle, to_categorical
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.estimator import regression
from tflearn.data_preprocessing import ImagePreprocessing
from tflearn.data_augmentation import ImageAugmentation

from tflearn.datasets import cifar100
(X, Y), (X_test, Y_test) = cifar100.load_data()
X, Y = shuffle(X, Y)
Y = to_categorical(Y, 100)
Y_test = to_categorical(Y_test, 100)

img_prep = ImagePreprocessing()
img_prep.add_featurewise_zero_center()
img_prep.add_featurewise_stdnorm()

img_aug = ImageAugmentation()
img_aug.add_random_flip_leftright()
img_aug.add_random_rotation(max_angle=25.)

network = input_data(shape=[None, 32, 32, 3],
                     data_preprocessing=img_prep,
                     data_augmentation=img_aug)
network = conv_2d(network, 32, 3, activation='relu')
network = max_pool_2d(network, 2)
network = conv_2d(network, 64, 3, activation='relu')
network = conv_2d(network, 64, 3, activation='relu')
コード例 #3
0
ファイル: model6.py プロジェクト: alesyavt/cifar-classifier
import tflearn
from tflearn.data_utils import shuffle, to_categorical
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.normalization import batch_normalization as batch_norm
from tflearn.layers.estimator import regression
from tflearn.data_preprocessing import ImagePreprocessing
from tflearn.data_augmentation import ImageAugmentation
from tflearn import optimizers
import tensorflow as tf
import numpy as np

# Data loading and preprocessing
from tflearn.datasets import cifar100
(X, Y), (X_test, Y_test) = cifar100.load_data(dirname='../cifar-100-python')
X, Y = shuffle(X, Y)
#Y = to_categorical(Y, 100)
#Y_test = to_categorical(Y_test, 100)

num_classes = 100
print('X', X.shape)
print('Y', Y.shape)
Y_test = np.array(Y_test)

train_ind = np.load('train-ind.pkl')
val_ind = np.load('val-ind.pkl')
print('train ind', train_ind.shape)
print('val ind', val_ind.shape)

num_train = len(train_ind)
コード例 #4
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#tensoflow 1.x 版本

from __future__ import division, print_function, absolute_import
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import tflearn
import numpy as np
from tflearn.layers.conv import conv_2d

#cifar-10数据集下载
from tflearn.datasets import cifar100
(x, y), (testx, testy) = cifar100.load_data()

#cifar10数据集进行噪声添加
x = x + np.random.random((50000, 32, 32, 3)) * 0.1
testx = testx + np.random.random((10000, 32, 32, 3)) * 0.1

#cifar10数据集中标签转换
y = tflearn.data_utils.to_categorical(y, 100)
testy = tflearn.data_utils.to_categorical(testy, 100)


def residual_shrinkage_block(incoming,
                             nb_blocks,
                             out_channels,
                             downsample=False,
                             downsample_strides=2,
                             activation='relu',