Skip to content

Instantly share code, notes, and snippets.

@akashgit
Created November 7, 2017 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akashgit/c7ccba789623429589a58f628a0e4c78 to your computer and use it in GitHub Desktop.
Save akashgit/c7ccba789623429589a58f628a0e4c78 to your computer and use it in GitHub Desktop.
def ring(batchsize, num_cluster=8, scale=1, std=.01,**kwargs):
pi_= tf.constant(np.pi)
rand_indices = tf.random_uniform([batchsize], minval=0, maxval=num_cluster, dtype=tf.int32)
base_angle = pi_ * 2 / num_cluster
angle = (base_angle * tf.cast(rand_indices,dtype=float32)) - (pi_ / 2)
mean_0 = tf.expand_dims(scale*tf.cos(angle),1)
mean_1 = tf.expand_dims(scale*tf.sin(angle),1)
mean = tf.concat([mean_0, mean_1], 1)
return ds.Normal(mean, (std**2)*tf.ones_like(mean))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment