示例#1
0
    def __init__(self, num_layers, hidden_size):
        self.num_layers = num_layers
        self.hidden_size = hidden_size
        self.lstm_cells = []

        param_attr = ParamAttr(
            initializer=uniform_initializer(1.0 / math.sqrt(hidden_size)))
        bias_attr = ParamAttr(
            initializer=uniform_initializer(1.0 / math.sqrt(hidden_size)))
        for i in range(num_layers):
            self.lstm_cells.append(LSTMCell(hidden_size, param_attr,
                                            bias_attr))
示例#2
0
文件: model.py 项目: wbj0110/models
    def __init__(self,
                 num_layers,
                 hidden_size,
                 param_attr_initializer,
                 param_attr_scale,
                 dropout_prob=0.):
        self.num_layers = num_layers
        self.hidden_size = hidden_size
        self.dropout_prob = dropout_prob
        self.lstm_cells = []

        for i in range(num_layers):
            lstm_name = "enc_layers_" + str(i)
            self.lstm_cells.append(
                LSTMCell(hidden_size, forget_bias=0., name=lstm_name))
示例#3
0
 def __init__(self,
              num_layers,
              hidden_size,
              dropout_prob=0.,
              init_scale=0.1):
     self.num_layers = num_layers
     self.hidden_size = hidden_size
     self.dropout_prob = dropout_prob
     self.lstm_cells = []
     self.init_scale = init_scale
     param_attr = ParamAttr(initializer=uniform_initializer(init_scale))
     bias_attr = ParamAttr(initializer=zero_constant)
     for i in range(num_layers):
         self.lstm_cells.append(LSTMCell(hidden_size, param_attr,
                                         bias_attr))
示例#4
0
 def __init__(self,
              num_layers,
              hidden_size,
              dropout_prob=0.,
              init_scale=0.1):
     self.num_layers = num_layers
     self.hidden_size = hidden_size
     self.dropout_prob = dropout_prob
     self.lstm_cells = []
     self.init_scale = init_scale
     param_attr = ParamAttr(
         initializer=fluid.initializer.UniformInitializer(low=-init_scale,
                                                          high=init_scale))
     bias_attr = ParamAttr(initializer=fluid.initializer.Constant(0.0))
     for i in range(num_layers):
         self.lstm_cells.append(LSTMCell(hidden_size, param_attr,
                                         bias_attr))
示例#5
0
文件: model.py 项目: wbj0110/models
    def __init__(self,
                 num_layers,
                 hidden_size,
                 latent_z,
                 param_attr_initializer,
                 param_attr_scale,
                 dropout_prob=0.):
        self.num_layers = num_layers
        self.hidden_size = hidden_size
        self.dropout_prob = dropout_prob
        self.latent_z = latent_z
        self.lstm_cells = []

        param_attr = ParamAttr(
            initializer=param_attr_initializer(param_attr_scale))

        for i in range(num_layers):
            lstm_name = "dec_layers_" + str(i)
            self.lstm_cells.append(
                LSTMCell(hidden_size,
                         param_attr,
                         forget_bias=0.,
                         name=lstm_name))