How to use the sru.sru_functional.SRU function in sru

To help you get started, we’ve selected a few sru examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github asappresearch / sru / sru / sru_functional.py View on Github external
hidden_size,
                 num_layers=2,
                 dropout=0,
                 rnn_dropout=0,
                 bidirectional=False,
                 projection_size=0,
                 use_tanh=False,
                 layer_norm=False,
                 #is_input_normalized=False,
                 highway_bias=0,
                 has_skip_term=True,
                 rescale=False,
                 v1=False,
                 nn_rnn_compatible_return=False):

        super(SRU, self).__init__()
        self.input_size = input_size
        self.hidden_size = hidden_size
        self.output_size = hidden_size * 2 if bidirectional else hidden_size
        self.num_layers = num_layers
        self.dropout = dropout
        self.rnn_dropout = rnn_dropout
        self.projection_size = projection_size
        self.rnn_lst = nn.ModuleList()
        self.bidirectional = bidirectional
        self.use_layer_norm = layer_norm
        self.has_skip_term = has_skip_term
        self.num_directions = 2 if bidirectional else 1
        self.nn_rnn_compatible_return = nn_rnn_compatible_return

        for i in range(num_layers):
            l = SRUCell(