Пример #1
0
logvar = enc[-1][latent_dim:]

divergence = -0.5 * (np.sum(T.exp(logvar) - logvar + mu**2, 1) - latent_dim)
rec = ((X - dec[-1])**2).sum(1)
elbo = tf.reduce_mean(rec - divergence)
loss = -elbo

BS = 100
lr = 0.001
DATA, _ = datasets.make_moons(1000)

X = T.Placeholder([BS, 2], 'float32')
Z = T.Placeholder([BS, 2], 'float32')

G_sample = generator(Z, 2)
logits = discriminator(T.concatenate([G_sample[-1], X]))
labels = T.concatenate([T.zeros(BS, dtype='int32'), T.ones(BS, dtype='int32')])

disc_loss = losses.sparse_crossentropy_logits(labels, logits[-1]).mean()
gen_loss = losses.sparse_crossentropy_logits(1 - labels[:BS],
                                             logits[-1][:BS]).mean()
masks = T.concatenate([G_sample[1] > 0, G_sample[3] > 0], 1)

A = T.stack([
    gradients(G_sample[-1][:, 0].sum(), [Z])[0],
    gradients(G_sample[-1][:, 1].sum(), [Z])[0]
], 1)
det = T.abs(T.det(A))

d_variables = sum([l.variables() for l in logits], [])
g_variables = sum([l.variables() for l in G_sample], [])
Пример #2
0
print(image)
print(q)
asdf
T.signal.fft(image, axes=(-1, ))
print(image)
print(image.get({}))

#print(T.gather(image, [0, 1]))
#print(T.gather(image, [0, 1]).get({}))

#patches = T.extract_image_patches(image, (2, 1))
print(patches.shape)
print(patches.get({})[0, 0, 0, 0])
sdf
tr = T.Placeholder((10, 10), 'float32')
tr2 = T.concatenate([tr, tr], 0)
tr3 = tr * 4
print(tr2.roots, tr3.roots)
asdf

print(patches.get({}))
asdf

a = T.Placeholder((4, 4), 'float32')
print(a.roots)
b = a * 3 + a
c = b + b + a + b * a
print(c.roots)
asdf

SHAPE = (4, 4)