Exemple #1
0
def load_data():
    # load mnist data
    (source_data, _), (test_source_data, _) = mnist.load_data()

    # pad with zeros 28x28 MNIST image to become 32x32
    # svhn is 32x32
    source_data = np.pad(source_data, ((0, 0), (2, 2), (2, 2)),
                         'constant',
                         constant_values=0)
    test_source_data = np.pad(test_source_data, ((0, 0), (2, 2), (2, 2)),
                              'constant',
                              constant_values=0)
    # input image dimensions
    # we assume data format "channels_last"
    rows = source_data.shape[1]
    cols = source_data.shape[2]
    channels = 1

    # reshape images to row x col x channels
    # for CNN output/validation
    size = source_data.shape[0]
    source_data = source_data.reshape(size, rows, cols, channels)
    size = test_source_data.shape[0]
    test_source_data = test_source_data.reshape(size, rows, cols, channels)

    # load SVHN data
    target_data = loadmat("datasets/train_32x32.mat")
    test_target_data = loadmat("datasets/test_32x32.mat")

    # source data, target data, test_source data
    data = (source_data, target_data, test_source_data, test_target_data)
    filenames = ('mnist_test_source.png', 'svhn_test_target.png')
    titles = ('MNIST test source images', 'SVHN test target images')

    return other_utils.load_data(data, titles, filenames)
def load_cifar10():
    (B_data, _), (test_B_data, _) = cifar10.load_data()
    A_data = other_utils.rgb2gray(B_data)
    test_A_data = other_utils.rgb2gray(test_B_data)
    A_data = A_data[:, :, :, np.newaxis]
    test_A_data = test_A_data[:, :, :, np.newaxis]
    data = (A_data, B_data, test_A_data, test_B_data)
    titles = ('CIFAR10 test_A_data images', 'CIFAR10 test_A_data images')
    return other_utils.load_data(data, titles)
Exemple #3
0
def load_mnist_svhn():
    (A_data, _), (test_A_data, _) = mnist.load_data()
    A_data = np.pad(A_data, ((0, 0), (2, 2), (2, 2)),
                    'constant',
                    constant_values=0)
    test_A_data = np.pad(test_A_data, ((0, 0), (2, 2), (2, 2)),
                         'constant',
                         constant_values=0)
    A_data = A_data[:, :, :, np.newaxis]
    test_A_data = test_A_data[:, :, :, np.newaxis]
    B_data_mat = io.loadmat(
        "C:/Users/ysp/Desktop/Deep Learning/train_32x32.mat")
    test_B_mat = io.loadmat(
        "C:/Users/ysp/Desktop/Deep Learning/test_32x32.mat")
    B_data = other_utils.loadmat(B_data_mat)
    test_B_data = other_utils.loadmat(test_B_mat)

    data = (A_data, B_data, test_A_data, test_B_data)
    titles = ('MNIST test_A_data images', 'SVHN test_B_data images')
    return other_utils.load_data(data, titles)
Exemple #4
0
def load_data():
    # load CIFAR10 data
    (target_data, _), (test_target_data, _) = cifar10.load_data()

    # input image dimensions
    # we assume data format "channels_last"
    rows = target_data.shape[1]
    cols = target_data.shape[2]
    channels = target_data.shape[3]

    # convert color train and test images to gray
    source_data = other_utils.rgb2gray(target_data)
    test_source_data = other_utils.rgb2gray(test_target_data)
    # reshape images to row x col x channel for CNN input
    source_data = source_data.reshape(source_data.shape[0], rows, cols, 1)
    test_source_data = test_source_data.reshape(test_source_data.shape[0],
                                                rows, cols, 1)

    # source data, target data, test_source data
    data = (source_data, target_data, test_source_data, test_target_data)
    filenames = ('cifar10_test_source.png', 'cifar10_test_target.png')
    titles = ('CIFAR10 test source images', 'CIFAR10 test target images')

    return other_utils.load_data(data, titles, filenames)