Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can we train bidirectional model? #6

Closed
akshayuppal3 opened this issue May 15, 2019 · 3 comments
Closed

can we train bidirectional model? #6

akshayuppal3 opened this issue May 15, 2019 · 3 comments

Comments

@akshayuppal3
Copy link

is it possible to train the bilsmt mode, does it require changing the model file with new weights?

@ArrasL
Copy link
Owner

ArrasL commented Jun 12, 2019

Hi,

Yes you can train the bi-LSTM model with whatever neural network toolbox you like (Tensorflow, Pytorch, Keras, Dynet...).

Then you just need to save the trained model's weights as numpy arrays to use the LRP code (and check the ordering of the gates in your weights to make them compatible with the LRP code, here are some hints how to do this).

@ArrasL ArrasL closed this as completed Jun 12, 2019
@akshayuppal3
Copy link
Author

Also what happens if I think of changing the classes to binary intstead of multiclass?

@ArrasL
Copy link
Owner

ArrasL commented Jun 13, 2019

Binary classification is just a special case of multiclass classification. So there is nothing you need to care about or change in the code if you want to apply it to a binary prediction task (the number of classes is not hard coded).

Just save your weights in a python dict of numpy arrays (akin model in the __init__ method of the class LSTM_bidi). The input, hidden layer and output dimensions will then be inferred from the weights' shapes.

Typically, the only places where you need to adapt the code, will be the __init__ and set_inputmethods, where you load your trained model, and define the input sequence x (x_rev).
The other methods don't need to be changed, if your model is a standard LSTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants