summaryrefslogtreecommitdiff
path: root/cli/app
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-01-08 18:35:12 +0100
committerJules Laplace <julescarbon@gmail.com>2020-01-08 18:35:12 +0100
commit4f79595d83f6885bf648db9043e26196281a35f4 (patch)
tree84de2b9886017c6e13a3bf5aecc78910aafc40da /cli/app
parent8fc7f19a632408a59134ecc092d21d6a31fbb723 (diff)
dont clip so much - clip even less
Diffstat (limited to 'cli/app')
-rw-r--r--cli/app/search/search_class.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/cli/app/search/search_class.py b/cli/app/search/search_class.py
index a41a141..139ca36 100644
--- a/cli/app/search/search_class.py
+++ b/cli/app/search/search_class.py
@@ -100,11 +100,12 @@ def find_nearest_vector(sess, generator, opt_fp_in, opt_dims, out_images, out_la
## clip the Z encoding
- opt_clip = 1.0
+ opt_clip = 1.5
- clipped_encoding = tf.where(tf.abs(input_z) >= opt_clip,
+ clipped_latent = tf.where(tf.abs(input_z) >= opt_clip,
tf.random.uniform([batch_size, z_dim], minval=-opt_clip, maxval=opt_clip), input_z)
- clip_latent = tf.assign(input_z, clipped_encoding)
+ clipped_alpha = tf.compat.v1.placeholder(dtype=np.float32, shape=())
+ clip_latent = tf.assign(input_z, clipped_latent * (1 - normalized_alpha) + input_z * normalized_alpha)
## normalize the Y encoding
# normalized_labels = tf.nn.l2_normalize(input_y)
@@ -189,7 +190,7 @@ def find_nearest_vector(sess, generator, opt_fp_in, opt_dims, out_images, out_la
if i % 20 == 0:
print('iter: {}, loss: {}'.format(i, curr_loss))
if i > 0:
- if opt_stochastic_clipping and (i % opt_clip_interval) == 0:
+ if opt_stochastic_clipping and (i % opt_clip_interval) == 0 and i < opt_steps * 0.45:
sess.run(clip_latent, { normalized_alpha: i / opt_steps })
if opt_label_clipping and (i % opt_clip_interval) == 0:
sess.run(clip_labels, { normalized_alpha: i / opt_steps })