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

Fix #161: support save/load BiRNNBuilder #163

Merged
merged 1 commit into from
Nov 17, 2016
Merged

Conversation

danielhers
Copy link
Collaborator

@danielhers danielhers commented Nov 13, 2016

I implemented a separate case in _save_one and _load_one for the BiRNNBuilder, but I think it might be more elegant to make it extend the Saveable interface instead. The problem with this is that the builder layer sub-components are saved in a list of tuples rather than directly as attributes, and Saveable assumes that any non-picklable sub-component is a direct attribute of the object.
A possible way to go around this is to replace the above assumption with a decorator that would declare an attribute as non-picklable (explicit is better than implicit), and add this decorator to the builder_layers attribute. The Saveable interface methods can be implemented like so:

def get_components(self):
    return [x for (f,b) in self.builder_layers for x in (f,b)]

def restore_components(self, components):
    self.builder_layers = zip(components[0::2], components[1::2])

@yoavg yoavg merged commit 587059d into clab:master Nov 17, 2016
@danielhers danielhers deleted the birnn_save branch November 18, 2016 06:21
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

Successfully merging this pull request may close these issues.

2 participants