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

Documentation of Model.from_disk #751

Open
frobnitzem opened this issue Aug 31, 2022 · 2 comments
Open

Documentation of Model.from_disk #751

frobnitzem opened this issue Aug 31, 2022 · 2 comments
Labels
docs Documentation

Comments

@frobnitzem
Copy link
Contributor

When I tried literally running

Model().from_disk('saved_model.bin')

I as referenced by the documentation, I got an error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() missing 2 required positional arguments: 'name' and 'forward'

So, the documentation needs be updated to note what kind of model instance has to be used for reading from disk. Can I use a generic Model("unknown", lambda x: None) or do I need a look-alike model to the one I'm reading?

@Zatteliet
Copy link

I'm standing before the same issue. I got the results I wanted (pending error analysis) by loading the model from the same config that I used when training, and calling from_disk on that.

config = Config().from_disk("config.cfg")
config = registry.resolve(config)
model = config["model"].from_disk("model")

So I get the feeling from_disk only reads the trained weights of the model, but not the model architecture? I also hope this can be clarified in the documentation.

@adrianeboyd adrianeboyd added the docs Documentation label Nov 28, 2022
@honnibal
Copy link
Member

Yes the .from_disk() method only reads binary weights. We don't want to invoke code during deserialisation, so you have to set up the model how you expect it to be on the other side. You can use the registry to help with this.

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

No branches or pull requests

4 participants