#lstm #pytorch #candle

candle-birnn

implement Pytorch LSTM and BiDirectional LSTM with Candle

5 releases

0.2.3 Sep 25, 2024
0.2.2 Aug 17, 2024
0.2.1 Aug 13, 2024
0.2.0 Aug 12, 2024
0.1.0 Aug 11, 2024

#410 in Machine learning

Download history 61/week @ 2024-08-05 279/week @ 2024-08-12 13/week @ 2024-08-19 2/week @ 2024-08-26 1/week @ 2024-09-02 154/week @ 2024-09-23 18/week @ 2024-09-30 8/week @ 2024-10-07 10/week @ 2024-10-14

190 downloads per month

Custom license

42KB
295 lines

Contains (Zip file, 29KB) bi_lstm_test.pt, (Zip file, 16KB) lstm_test.pt

Candle BiRNN

Implementing PyTorch LSTM inference using Candle, including the implementation of bidirectional LSTM inference.

Test Data

  1. lstm_test.pt: Results generated using a PyTorch demo program. The code is as follows:

    import torch
    import torch.nn as nn
    
    rnn = nn.LSTM(10, 20, 1)
    input = torch.randn(5, 3, 10)
    output, (hn, cn) = rnn(input)
    
    state_dict = rnn.state_dict()
    state_dict['input'] = input
    state_dict['output'] = output
    state_dict['hn'] = hn
    state_dict['cn'] = cn
    torch.save(state_dict, "lstm_test.pt")
    
  2. bi_lstm_test.pt: Results generated using a PyTorch demo program. The code is as follows:

    import torch
    import torch.nn as nn
    
    rnn = nn.LSTM(10, 20, 1, bidirectional=True)
    input = torch.randn(5, 3, 10)
    output, (hn, cn) = rnn(input)
    
    state_dict = rnn.state_dict()
    state_dict['input'] = input
    state_dict['output'] = output
    state_dict['hn'] = hn
    state_dict['cn'] = cn
    torch.save(state_dict, "bi_lstm_test.pt")
    

Dependencies

~9–19MB
~311K SLoC