Fastai: A Layered API for Deep Learning
arxiv.org
arxiv.org
There are quite a few comments here pointing out (quite correctly!) that v1 was not at all easy to hack on. We've spent the last couple of years fixing that. Have a look at the paper to see what mean - especially the "mid-layer API".
I've recently begun to experiment with nbdev. Really like the concept.
TensorFlow is too low level. Fastai abstracts too much away and feels way too magical - once things start going wrong, or if you need to do something totally outside the bounds of the library, good luck.
Guess I’m mostly just a bit tired of frameworks for what feels like frameworks sake.
That being said, a current project I'm working on didn't really fit the fastai pipeline and I needed to drop into pytorch. It's a total shame since there are so many little niceties that make things easier.
My coworker recently completed a bootcamp using pytorch, and I am working through the fastai course, so it has been interesting to compare experiences.
Might give it another go if I decide to give it another refactor.
That being said, I admire the passion and effort that goes into FastAI and I think it does a great job at providing an entry point into the world of ML/deep learning that is far more accessible to people. I'll probably still read through the library because I always pick up interesting ideas and learn new things when reading other peoples code, especially when a lot of thought has been put into structuring a library.
I get it that it is supposed to be working on the very bleeding edge of deep learning technologies, but at the same time it is sold as "practical". At least I would be slightly uncomfortable doing anything in production with a library that is all but guaranteed to get no (compatible) development love whatsoever after a couple of months when the developers have started working on the next version.
But I guess it may just be a too tough nut to crack to provide a bleeding edge deep learning library with production quality life cycle support.
However, they would be anyway: Core models and algorithms are quickly outdated and any change that allows us to achieve similar or better results with less effort in creating training data is easily worth the engineering work.
That said, I really hope v2 feels a bit more like other libraries: extending v1 models has been pretty painful in several occasions. E.g. making some changes to the underlying pytorch models was very straightforward but still using all the goodies for training build into fastai (in particular all the stuff based on the work of Leslie Smith, tuned for best practices inside the fastai universe) was pretty painful. It is awesome to have a library actually implement best practices from latest research, but sometimes all this greatness was pretty hard for me to transfer to changed models.
That said, it has worked for us in v1 and the benefits outweighed the problems by far.
So instead we'll be maintaining fastai v1 as a separate branch and accepting PRs as long as people are using it. But v2 is designed to leverage a lot of the new ideas that have come up in the last couple of years, both in our research, and more widely.
Glad to see pandas support for tabular data.
I get it that for any serious use you'd want a GPU, but for learning and toying around you might want to be able to run and debug code on your freakin macbook! Is that too much to asks? (Some of us do code in IDEs, not in notebooks + vim on server, and we'd want at least our test suite to be able to run locally ffs!)
(Also, hopefully they've got rid of the lovecraftian architecture with methods that can mutate an object's class [?!] - I understood the practical appeal and why they did it, but as a software engineer with sympathy for functional-programming that almost made me wanna barf :|)
Anyway, fastai is awesome for learning and experimenting, keep up the good work! I just hate it that it's so obnoxious to use and learn for anyone with a more traditional software engineering background...
Every year it gets more accessible to a wider audience. Soon there will probably be frameworks that hide the complexity completely and you can just say here’s a massive dataset, I want to train it to be a conversation bot or cat pic classifier, go. But we’re not quite there yet.
Synchronizing local and remote code shouldn't take much time, but it's still at least a few seconds on the critical path for the run->fail->fix->rerun loop.
VSCode's remote mode might be a worth a try for people with such a setup.
It is not FastAI fault though.
But in fastai 1.0 it was all bundled together in one big yarn, with everything depending in the end on some data loading classes that depended on GPU driver etc.
Anyway, it was really bad architecture and dev practices in the codebase I was working though, the tested behavior would probably not have matched production one 100%... I don't blame fastai much for not helping with a broken workflow, but I prefer more barebones and less opinionated frameworks, aka using tf or pytorch directly, since some times you really need to get that "broken" thing running in production before you work on a refactored version of it :P Fastai seems very research-oriented and opinionated.
I'll definitely look into fastai 2.0 though :)
But my main issue with it is the code formatting (https://docs.fast.ai/dev/style.html#layout). Maybe I am too used to PEP-8 and black (https://github.com/psf/black) formatted code, but honestly I cannot stand the code format.
Aim to align statement parts that are conceptually similar. It allows the reader to quickly see how they’re different. E.g. in this code it’s immediately clear that the two parts call the same code with different parameter orders.
That'd turn something like this: class OneClass:
def __init__(self, a, b1, b2, c_long):
self.a = a
self.b1 = b1
self.b2 = b2
self.c_long = c_long
Into this: class OneClass:
def __init__(self, a, b1, b2, c_long):
self.a = a
self.b1 = b1
self.b2 = b2
self.c_long = c_long
(maybe not the greatest example, there are places where this helps much more)The others all are un-pythonic and make the code more unreadable.
But it only makes the code unreadable if you don't make a tiny effort to adjust. If you do make the effort, there's some great payoff, like this code:
try:
self._split(b); self('begin_batch')
self.pred = self.model(*self.xb); self('after_pred')
if len(self.yb) == 0: return
self.loss = self.loss_func(self.pred, *self.yb); self('after_loss')
if not self.training: return
self.loss.backward(); self('after_backward')
self.opt.step(); self('after_step')
self.opt.zero_grad()
except CancelBatchException: self('after_cancel_batch')
finally: self('after_batch')
That's the inner part of the training loop. You can see at a glance: what steps are in the loop; what callbacks are in the loop, in what order; what step corresponds to each callback. And you can see the whole training loop at once, which is great for getting a clear picture of what's going on.And while I can appreciate it can be quick to see where the signals are sent, the use of ; and having two things in a line still aren't convincing me.
Even more, if I were to run the line_profiler here, I know it'd report weird numbers precisely for having more than one thing per line.
The other thing that I dislike is opening blocks and closing them in the same line. It may be force of habit for me, but that screams unreadability at my face.
Rounding up, all I see is behaviour that can be achieved through other mechanisms, and dev/tools unfriendliness. And notice I'm not sayin anything about PEP-8, because:
a) There are parts of it with which I don't agree either.
b) Many people use PEP-8 as a sort of "silver bullet" and argument-ending-remark. That's not what it should be, it should be a _guide_ to be used when it helps, and ignored sparingly (with reason and consideration of _why_ you decide to ignore it, in the sake of readability).
https://www.fast.ai/2020/02/13/fastai-A-Layered-API-for-Deep...
Is this paper about version v1 or v2 of the API?