def create_lstm(l_incoming, l_mask, hidden_units, cell_parameters, gate_parameters, name):
if cell_parameters is None:
cell_parameters = Gate()
if gate_parameters is None:
gate_parameters = Gate()
l_lstm = LSTMLayer(
l_incoming, hidden_units,
# We need to specify a separate input for masks
mask_input=l_mask,
# Here, we supply the gate parameters for each gate
ingate=gate_parameters, forgetgate=gate_parameters,
cell=cell_parameters, outgate=gate_parameters,
# We'll learn the initialization and use gradient clipping
learn_init=True, grad_clipping=5., name='f_{}'.format(name))
return l_lstm
评论列表
文章目录