MCPcopy
hub / github.com/hanzhanggit/StackGAN / sample_encoded_context

Function sample_encoded_context

demo/demo.py:36–49  ·  view source on GitHub ↗

Helper function for init_opt

(embeddings, model, bAugmentation=True)

Source from the content-addressed store, hash-verified

34
35
36def sample_encoded_context(embeddings, model, bAugmentation=True):
37 '''Helper function for init_opt'''
38 # Build conditioning augmentation structure for text embedding
39 # under different variable_scope: 'g_net' and 'hr_g_net'
40 c_mean_logsigma = model.generate_condition(embeddings)
41 mean = c_mean_logsigma[0]
42 if bAugmentation:
43 # epsilon = tf.random_normal(tf.shape(mean))
44 epsilon = tf.truncated_normal(tf.shape(mean))
45 stddev = tf.exp(c_mean_logsigma[1])
46 c = mean + stddev * epsilon
47 else:
48 c = mean
49 return c
50
51
52def build_model(sess, embedding_dim, batch_size):

Callers 1

build_modelFunction · 0.70

Calls 1

generate_conditionMethod · 0.45

Tested by

no test coverage detected