In [1]:
from __future__ import division, print_function, absolute_import
import tflearn
from tflearn.layers.core import input_data, dropout, fully_connected, flatten
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.normalization import local_response_normalization
from tflearn.layers.estimator import regression
import matplotlib.pyplot as plt
import random
import numpy as np
In [2]:
# Data loading and preprocessing
import tflearn.datasets.mnist as mnist
X, Y, testX, testY = mnist.load_data(one_hot=False)
X = X.reshape([-1, 28, 28])
testX = testX.reshape([-1, 28, 28])
In [3]:
indices = [1,2]
Y[indices]
Out[3]:
In [4]:
NUM_SAMPLES_TO_GEN = 100
WIDTH_SAMPLE = 3
NUM_IMGS_AVAILABLE = X.shape[0]
In [6]:
%matplotlib inline
asd = np.concatenate((X[0],X[1]), axis=1)
print (asd.shape)
plt.imshow (asd, cmap='Greys')
Out[6]:
In [7]:
asd = np.random.randint(0, NUM_IMGS_AVAILABLE, size=WIDTH_SAMPLE)
In [8]:
X_seq = np.empty(shape=(NUM_SAMPLES_TO_GEN, 28, 28 * WIDTH_SAMPLE),dtype='float32')
Y_seq = np.empty(shape=(NUM_SAMPLES_TO_GEN, WIDTH_SAMPLE),dtype='uint8')
for i in range(NUM_SAMPLES_TO_GEN): # For each sample to generate
indices = np.random.randint(0,NUM_IMGS_AVAILABLE - 1, size=WIDTH_SAMPLE) # generate indices for creating this wide image
X_seq[i] = np.concatenate(X[indices], axis=1)
Y_seq[i] = Y[indices]
In [9]:
print (Y_seq[99])
plt.imshow(X_seq[99], cmap='Greys')
Out[9]:
In [ ]: