Helper function for init_opt
(embeddings, model, bAugmentation=True)
| 33 | |
| 34 | |
| 35 | def 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 | |
| 51 | def build_model(sess, embedding_dim, batch_size): |
no test coverage detected