Esempio n. 1
0

location = T.fmatrix()
scale = T.fmatrix()
alpha = T.fmatrix()
x = T.fvector()
batch_size = 1
num_channel = 1
patch_shape = (28, 28)
image_shape = (100, 100)
hyperparameters = {}
hyperparameters["cutoff"] = 3000
hyperparameters["batched_window"] = True

# tds, _ = get_cooking_streams(batch_size)
tds, _ = get_bmnist_streams(1)
res = tds.get_epoch_iterator(as_dict=True).next()['features']
# shape: 3 x 125 x 200
img = res[5, 0]
draw(img)
plt.savefig('img.png')

cropper = LocallySoftRectangularCropper(patch_shape=patch_shape,
                                        hyperparameters=hyperparameters,
                                        kernel=Gaussian())

patch1, matrix, dx2 = cropper.apply(
    x.reshape((
        batch_size,
        num_channel,
    ) + image_shape), np.array([list(image_shape)]), location, scale, alpha)
Esempio n. 2
0
cropper = LocallySoftRectangularCropper(
    patch_shape=(28, 28),
    hyperparameters={'cutoff': 3000, 'batched_window': True},
    kernel=Gaussian())

down, W, dx2 = cropper.apply(
    input_,
    np.array([list((100, 100))]),
    T.constant(
        99 *
        [[80, 70]]).astype('float32'),
    T.constant(
        99 *
        [[0.28, 0.28]]).astype('float32'),
    T.constant(
        99 *
        [[0.001, ] * 2]).astype('float32'))

f = theano.function([input_], [down, W, dx2])

data = get_bmnist_streams(99)[0].get_epoch_iterator().next()
res = f(data[0][0])

print np.min(res[2][0], axis=0)
print np.sum(res[1][0], axis=0)
plt.imshow(res[1][0], interpolation='nearest')
plt.savefig('w.png')


import ipdb; ipdb.set_trace()
Esempio n. 3
0
# shape: B x C x X x Y
input_ = tensor5('features')

cropper = LocallySoftRectangularCropper(patch_shape=(28, 28),
                                        hyperparameters={
                                            'cutoff': 3000,
                                            'batched_window': True
                                        },
                                        kernel=Gaussian())

down, W, dx2 = cropper.apply(
    input_, np.array([list((100, 100))]),
    T.constant(99 * [[80, 70]]).astype('float32'),
    T.constant(99 * [[0.28, 0.28]]).astype('float32'),
    T.constant(99 * [[
        0.001,
    ] * 2]).astype('float32'))

f = theano.function([input_], [down, W, dx2])

data = get_bmnist_streams(99)[0].get_epoch_iterator().next()
res = f(data[0][0])

print np.min(res[2][0], axis=0)
print np.sum(res[1][0], axis=0)
plt.imshow(res[1][0], interpolation='nearest')
plt.savefig('w.png')

import ipdb
ipdb.set_trace()
Esempio n. 4
0
                   interpolation='nearest')

location = T.fmatrix()
scale = T.fmatrix()
alpha = T.fmatrix()
x = T.fvector()
batch_size = 1
num_channel = 1
patch_shape = (28, 28)
image_shape = (100, 100)
hyperparameters = {}
hyperparameters["cutoff"] = 3000
hyperparameters["batched_window"] = True

# tds, _ = get_cooking_streams(batch_size)
tds, _ = get_bmnist_streams(1)
res = tds.get_epoch_iterator(as_dict=True).next()['features']
# shape: 3 x 125 x 200
img = res[5, 0]
draw(img)
plt.savefig('img.png')

cropper = LocallySoftRectangularCropper(
    patch_shape=patch_shape,
    hyperparameters=hyperparameters,
    kernel=Gaussian())

patch1, matrix, dx2 = cropper.apply(
    x.reshape((batch_size, num_channel,) + image_shape),
    np.array([list(image_shape)]),
    location,