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

PQKmeans can be pickled! #18

Merged
merged 5 commits into from Dec 30, 2017
Merged

Conversation

kogaki
Copy link
Member

@kogaki kogaki commented Dec 29, 2017

Implemented __getstate__ and __setstate__ on PQKmeans following the way #17 .
So now we can pickle PQKmeans.


# save current engine and recover from savedata
engine_savedata = pickle.dumps(engine)
engine_recovered = pickle.loads(engine_savedata)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pickle the trained engine instead of creating new class

init_centers = []
self._impl = _pqkmeans.PQKMeans(encoder.codewords, k, iteration, verbose, init_centers)
self.encoder = encoder
self._impl = _pqkmeans.PQKMeans(self.encoder.codewords, k, iteration, verbose)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I removed init_centers to unify the way of loading trained instance. @insikk

return PQKMeansSavedata(
encoder=self.encoder,
k=self._impl.k_,
iteration=self._impl.k_,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be self._impl.iteration_

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, i've fixed it.

@matsui528 matsui528 merged commit 60ccb4b into DwangoMediaVillage:master Dec 30, 2017
@matsui528
Copy link
Collaborator

Now we finally solved #12 and #16 . I'll update a README and a tutorial then. Thanks again for @insikk !

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.

None yet

3 participants