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

Function sample_encoded_context

demo/birds_skip_thought_demo.py:35–48  ·  view source on GitHub ↗

Helper function for init_opt

(embeddings, model, bAugmentation=True)

Source from the content-addressed store, hash-verified

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