(self, n_channels, hidden_size, cell_type='LSTM', bidirectional=True, n_layers=1)
Construct.
Construct.
Construct .
def __init__(self, n_channels, hidden_size, cell_type='LSTM', bidirectional=True, n_layers=1):
        """Construct."""
        super().__init__()

        if hidden_size % 2 != 0 and bidirectional:
            raise ValueError('Hidden size needs to be divisible by two for bidirectional RNNs.')

        hidden_size_one_direction = int(hidden_size // (1 + int(bidirectional)))  # only will work out for

        if cell_type == 'RNN':
            self.cell = torch.nn.RNN(n_channels, hidden_size_one_direction, bidirectional=bidirectional,
                                     num_layers=n_layers)

        elif cell_type == 'LSTM':
            self.cell = torch.nn.LSTM(n_channels, hidden_size_one_direction, bidirectional=bidirectional,
                                      num_layers=n_layers)

        else:
            raise ValueError('Unsupported cell_type {}'.format(cell_type))
def __init__ ( self , n_channels , hidden_size , cell_type = 'LSTM' , bidirectional = True , n_layers = 1 ) : super ( ) . __init__ ( ) if hidden_size % 2 != 0 and bidirectional : raise ValueError ( 'Hidden size needs to be divisible by two for bidirectional RNNs.' ) hidden_size_one_direction = int ( hidden_size // ( 1 + int ( bidirectional ) ) ) # only will work out for if cell_type == 'RNN' : self . cell = torch . nn . RNN ( n_channels , hidden_size_one_direction , bidirectional = bidirectional , num_layers = n_layers ) elif cell_type == 'LSTM' : self . cell = torch . nn . LSTM ( n_channels , hidden_size_one_direction , bidirectional = bidirectional , num_layers = n_layers ) else : raise ValueError ( 'Unsupported cell_type {}' . format ( cell_type ) )