Exemplo n.º 1
0
    def declare_parameters(self):
        opts = self.opts
        with tf.variable_scope('params') as scope:
            self.L_init = tf.get_variable(name="L_init",
                                          initializer=tf.random_normal(
                                              [1, self.opts.d]))
            self.C_init = tf.get_variable(name="C_init",
                                          initializer=tf.random_normal(
                                              [1, self.opts.d]))

            self.LC_msg = MLP(opts,
                              opts.d,
                              repeat_end(opts.d, opts.n_msg_layers, opts.d),
                              name=("LC_msg"))
            self.CL_msg = MLP(opts,
                              opts.d,
                              repeat_end(opts.d, opts.n_msg_layers, opts.d),
                              name=("CL_msg"))

            self.L_update = tf.contrib.rnn.LayerNormBasicLSTMCell(
                self.opts.d,
                activation=decode_transfer_fn(opts.lstm_transfer_fn))
            self.C_update = tf.contrib.rnn.LayerNormBasicLSTMCell(
                self.opts.d,
                activation=decode_transfer_fn(opts.lstm_transfer_fn))

            self.L_vote = MLP(opts,
                              opts.d,
                              repeat_end(opts.d, opts.n_vote_layers, 1),
                              name=("L_vote"))
            self.vote_bias = tf.get_variable(
                name="vote_bias", shape=[], initializer=tf.zeros_initializer())
Exemplo n.º 2
0
    def __init__(self, opts, d_in, d_outs, name):

        (self.ws, self.bs) = init_ws_bs(opts, name, d_in, d_outs)

        self.opts = opts
        self.name = name
        self.transfer_fn = decode_transfer_fn(opts.mlp_transfer_fn)
        self.output_size = d_outs[-1]