fastai / fastbook

The fastai book, published as Jupyter Notebooks
Other
21.51k stars 8.33k forks source link

NB 15_arch_details: Use resnet34() to instantiate model #571

Open gunchu opened 1 year ago

gunchu commented 1 year ago

Current call passes the function directly, which fails with message:

---------------------------------------------------------------------------

AttributeError                            Traceback (most recent call last)

[<ipython-input-10-78f6e5fc4f58>](https://localhost:8080/#) in <cell line: 1>()
----> 1 encoder = create_body(resnet34, cut=-2)

1 frames

[/usr/local/lib/python3.9/dist-packages/fastai/vision/learner.py](https://localhost:8080/#) in cut_model(model, cut)
     69 def cut_model(model, cut):
     70     "Cut an instantiated model"
---> 71     if   isinstance(cut, int): return nn.Sequential(*list(model.children())[:cut])
     72     elif callable(cut): return cut(model)
     73     raise NameError("cut must be either integer or a function")

AttributeError: 'function' object has no attribute 'children'
review-notebook-app[bot] commented 1 year ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB