FastAI is too abstracted... how to create custom networks?

I’ve been looking through the notebooks for FastAI_v1, and the functions are way too abstracted for me to understand what’s going on. Can anyone recommend a guide on how to create custom network network that leverage as much as the fastai infrastructure as possible?

For example, let’s say I’m working on a Siamese network problem. I would want to use a pre-trained ResNet 34 as the backbone network, then add additional layers to concat the output, maybe a couple of dense layers after that (there’s lots of experimenting involved as to the actual architecture I need). I can easily do that in Keras with the functional API, but I’m still trying to navigate through fastai on this.

Thanks!

1 Like

Have you checked out the docs? https://docs.fast.ai/

You can also view the documentation for functions from notebooks by typing docs(create_cnn), for example.

I would want to use a pre-trained ResNet 34 as the backbone network

If you’re trying to create a convolutional network (which you may be, I don’t know), https://docs.fast.ai/vision.html#Minimal-training-example shows you how to load in a pre-trained model as the “backbone”.

I’d recommend watching the first video lecture to get a better idea of how some of the functions work. I’ve only watched that far, so I don’t have any other advice to give.

There’s a few fastai siamese nets around you can borrow from. Basically you just create a normal pytorch nn.Module containing the siamese head, then pass that as custom_head to cnn_learner.

7 Likes

Hei Derek,
thanks for the replay.
It seems your second link is broken.
Do you have access to the original content in some way?
Thanks

Simplest example:

learn = cnn_learner(dls, resnet34, metrics=error_rate)
learn.fine_tune(1)