Live data from Hacker News

Fastai: A Layered API for Deep Learning

arxiv.org

31–40 of 43 posts

Re: Fastai: A Layered API for Deep Learning

#33
I really like the fastai abstractions and their attention to detail. Also their callbacks are amazing. I always look at their implementations for inspiration.

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.

Re: Fastai: A Layered API for Deep Learning

#35
post #33

I really like the fastai abstractions and their attention to detail. Also their callbacks are amazing. I always look at their implementations for inspiration. 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.

Ufff that's rough to read. Totally. The only one I agree with is the one that says:

    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.

Re: Fastai: A Layered API for Deep Learning

#36
post #27

Nice to see our paper on HN! FYI the paper covers v2, which is a from-scratch rewrite that introduces a new layered API. 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".

My team and I are huge fans of you and Rachel's work!

I've recently begun to experiment with nbdev. Really like the concept.

Re: Fastai: A Layered API for Deep Learning

#37
post #6

My small complaint is that there seems to be no backwards compatibility whatsoever between fastai versions. 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…

Yeah it was a conscious decision, but it's certainly not the only "one right way". I saw when Keras had an API freeze a few years ago, and thought that it didn't really make sense to me when the field is changing so much. I can certainly see that there will be people for whom that is what they want, however.

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.

Re: Fastai: A Layered API for Deep Learning

#38
post #33

I really like the fastai abstractions and their attention to detail. Also their callbacks are amazing. I always look at their implementations for inspiration. 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.

Ufff that's rough to read. Totally. The only one I agree with is the one that says: 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.b…

I've long wished black would do this!

Re: Fastai: A Layered API for Deep Learning

#39
post #33

I really like the fastai abstractions and their attention to detail. Also their callbacks are amazing. I always look at their implementations for inspiration. 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.

Ufff that's rough to read. Totally. The only one I agree with is the one that says: 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.b…

It's certainly unpythonic - as the link explains, it's based on research that goes back many more decades than Python has existed, and that PEP 8 entirely ignored.

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.

Re: Fastai: A Layered API for Deep Learning

#40
post #33

I really like the fastai abstractions and their attention to detail. Also their callbacks are amazing. I always look at their implementations for inspiration. 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.

Even the creator of Python says "Black is good for large projects, but I find it uglifies all code compared to manually formatting..."
Post reply on HN