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

How to export weights from Python? #2

Closed
ivanmkc opened this issue Jun 29, 2016 · 2 comments
Closed

How to export weights from Python? #2

ivanmkc opened this issue Jun 29, 2016 · 2 comments

Comments

@ivanmkc
Copy link

ivanmkc commented Jun 29, 2016

This is a pretty awesome project. I've trained some models on Tensorflow and want to export to the format you use loadFloatArray with. Any chance you can post some example Python code to export those weights?

Thanks for building this btw!

@ivanmkc ivanmkc changed the title Just what I'm looking for. How to export weights from Python? Jun 30, 2016
@koher
Copy link
Member

koher commented Jun 30, 2016

Hi. I did something like the following, though I'm not sure if it is the best way because I'm not so familiar with Python.

import struct

ndarray = W_conv1.eval(session=sess)
list = ndarray.reshape([-1]).tolist()
f = open("W_conv1", "wb")
f.write(struct.pack("%df" % len(list), *list))
f.close()

@ivanmkc
Copy link
Author

ivanmkc commented Jun 30, 2016

Thanks, that looks easy enough. I'm going to try this out on the iPad and let you know how it goes.

@koher koher closed this as completed Jul 29, 2016
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