candle-birnn

Crates.iocandle-birnn
lib.rscandle-birnn
version0.2.3
sourcesrc
created_at2024-08-11 11:25:22.664468
updated_at2024-09-25 06:53:57.080859
descriptionimplement Pytorch LSTM and BiDirectional LSTM with Candle
homepage
repositoryhttps://github.com/kigichang/candle-birnn
max_upload_size
id1333223
size61,895
kigi (kigichang)

documentation

README

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")
    
Commit count: 12

cargo fmt