Ejemplo n.º 1
0
def network(x_dim, scope, factor):
    with tf.variable_scope(scope):
        net = Sequential([
            Zip([
                Linear(x_dim, 10, scope='embed_1', factor=1.0 / 3),
                Linear(x_dim, 10, scope='embed_2', factor=factor * 1.0 / 3),
                Linear(2, 10, scope='embed_3', factor=1.0 / 3),
                lambda _: 0.,
            ]),
            sum,
            tf.nn.relu,
            Linear(10, 10, scope='linear_1'),
            tf.nn.relu,
            Parallel([
                Sequential([
                    Linear(10, x_dim, scope='linear_s', factor=0.001),
                    ScaleTanh(x_dim, scope='scale_s')
                ]),
                Linear(10, x_dim, scope='linear_t', factor=0.001),
                Sequential([
                    Linear(10, x_dim, scope='linear_f', factor=0.001),
                    ScaleTanh(x_dim, scope='scale_f'),
                ])
            ])
        ])

    return net
Ejemplo n.º 2
0
 def net_factory(x_dim, scope, factor):
     with tf.variable_scope(scope):
         net = Sequential([
             Zip([
                 Linear(hps.latent_dim, size1, scope='embed_1', factor=0.33),
                 Linear(hps.latent_dim, size1, scope='embed_2', factor=factor * 0.33),
                 Linear(2, size1, scope='embed_3', factor=0.33),
                 encoder_sampler,
             ]),
             sum,
             tf.nn.relu,
             Linear(size1, size2, scope='linear_1'),
             tf.nn.relu,
             Parallel([
                 Sequential([
                     Linear(size2, hps.latent_dim, scope='linear_s', factor=0.01),
                     ScaleTanh(hps.latent_dim, scope='scale_s')
                 ]),
                 Linear(size2, hps.latent_dim, scope='linear_t', factor=0.01),
                 Sequential([
                     Linear(size2, hps.latent_dim, scope='linear_f', factor=0.01),
                     ScaleTanh(hps.latent_dim, scope='scale_f'),
                 ])
             ])
         ])