Exemple #1
0
 def _init_pars(self):
     spec = rnn.parameters(
         self.n_inpt, self.n_hiddens, self.n_output, self.skip_to_out,
         self.hidden_transfers)
     self.parameters = ParameterSet(**spec)
     self.parameters.data[:] = np.random.standard_normal(
         self.parameters.data.shape).astype(theano.config.floatX)
Exemple #2
0
def parameters(n_inpt,
               n_hiddens,
               n_output,
               skip_to_out=False,
               hidden_transfers=None,
               out_transfer=None,
               prefix=''):
    spec = rnn.parameters(n_inpt, n_hiddens, n_output, skip_to_out,
                          hidden_transfers, out_transfer, prefix)

    if hidden_transfers is not None:
        hiddens_inoutsizes = [rnn.inout_size(i) for i in hidden_transfers]
    else:
        hiddens_inoutsizes = [(1, 1) for _ in n_hiddens]

    hiddens_insizes, hiddens_outsizes = zip(*hiddens_inoutsizes)
    total_hidden_outsizes = [
        i * j for i, j in zip(n_hiddens, hiddens_outsizes)
    ]

    for i, j in enumerate(total_hidden_outsizes):
        spec['initial_hidden_means_%i' % i] = j
        spec['initial_hidden_vars_%i' % i] = j
        del spec['initial_hiddens_%i' % i]

    return spec
Exemple #3
0
def parameters(n_inpt, n_hiddens, n_output, skip_to_out=False,
               hidden_transfers=None, out_transfer=None, prefix=''):
    spec = rnn.parameters(n_inpt, n_hiddens, n_output, skip_to_out,
                          hidden_transfers, out_transfer, prefix)

    if hidden_transfers is not None:
        hiddens_inoutsizes = [rnn.inout_size(i) for i in hidden_transfers]
    else:
        hiddens_inoutsizes = [(1, 1) for _ in n_hiddens]

    hiddens_insizes, hiddens_outsizes = zip(*hiddens_inoutsizes)
    total_hidden_outsizes = [i * j for i, j in zip(n_hiddens, hiddens_outsizes)]

    for i, j in enumerate(total_hidden_outsizes):
        spec['initial_hidden_means_%i' % i] = j
        spec['initial_hidden_vars_%i' % i] = j
        del spec['initial_hiddens_%i' % i]

    return spec
Exemple #4
0
 def _gen_par_spec(self):
     """Return the parameter specification of the generating model."""
     n_output = self.assumptions.visible_layer_size(self.n_inpt)
     return rnn.parameters(
         self.n_latent + self.n_inpt, self.n_hiddens_gen,
         n_output)
Exemple #5
0
 def _init_pars(self):
     spec = rnn.parameters(self.n_inpt, self.n_hiddens, self.n_output,
                           self.skip_to_out, self.hidden_transfers)
     self.parameters = ParameterSet(**spec)
     self.parameters.data[:] = np.random.standard_normal(
         self.parameters.data.shape).astype(theano.config.floatX)