fastbook icon indicating copy to clipboard operation
fastbook copied to clipboard

NB 15_arch_details: Use resnet34() to instantiate model

Open gunchu opened this issue 2 years ago • 1 comments

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'

gunchu avatar Mar 30 '23 05:03 gunchu

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB