def __init__(self, args):
with tf.device(args.device):
def circle(x):
spherenet = tf.square(x)
spherenet = tf.reduce_sum(spherenet, 1)
lam = tf.sqrt(spherenet)
return x/tf.reshape(lam,[int(lam.get_shape()[0]), 1])
def modes(x):
return tf.round(x*2)/2.0
if args.distribution == 'circle':
x = tf.random_normal([args.batch_size, 2])
x = circle(x)
elif args.distribution == 'modes':
x = tf.random_uniform([args.batch_size, 2], -1, 1)
x = modes(x)
elif args.distribution == 'sin':
x = tf.random_uniform((1, args.batch_size), -10.5, 10.5 )
x = tf.transpose(x)
r_data = tf.random_normal((args.batch_size,1), mean=0, stddev=0.1)
xy = tf.sin(0.75*x)*7.0+x*0.5+r_data*1.0
x = tf.concat([xy,x], 1)/16.0
elif args.distribution == 'arch':
offset1 = tf.random_uniform((1, args.batch_size), -10, 10 )
xa = tf.random_uniform((1, 1), 1, 4 )
xb = tf.random_uniform((1, 1), 1, 4 )
x1 = tf.random_uniform((1, args.batch_size), -1, 1 )
xcos = tf.cos(x1*np.pi + offset1)*xa
xsin = tf.sin(x1*np.pi + offset1)*xb
x = tf.transpose(tf.concat([xcos,xsin], 0))/16.0
self.x = x
self.xy = tf.zeros_like(self.x)
评论列表
文章目录