Skip to content

Writing

The Silent Rise of PyTorch Ecosystem

While Tensorflow has made peace with Keras as it’s high level API and mxNet now support Gluon — PyTorch is the bare matrix love.

PyTorch has seen rapid adoption in academia and all the industrial labs that I have spoken to as well. One of the reasons people (specially engineers doing experiments) like PyTorch is the ease of debugging.

What I don’t like about PyTorch is it’s incessant requirement of debugging because of inconsistent dimensions problems. In fact, one of the most recommended speed hacks for faster development: assert tensor shapes!

This is something which Keras abstracts out really well. Additionally, PyTorch has no high level abstractions which picks good defaults for most common problems.

This leads us to the observation that there are three niche problems unsolved in the PyTorch ecosystem:

Unsolved Problems

  • General Purpose Abstraction: Over PyTorch similar to Keras or tf.learn
  • Adoption: Something to help traditional ML practitioners adopt PyTorch more easily
  • Production Use Cases: Something which allows engineers to take Pytorch code as-is in production or port to Caffe2 with minimal effort. I like Gluon for this, it has no community support but is backed by MSFT and AWS both.

Few specialized efforts like AllenAI’s NLP though built for NLP, or PyTorch torchvision & torchtext are domain specific instead of a generic abstraction similar to Keras. They deserve their own discussion space, separate from here.

The Better Alternatives

fast.ai

fastai has outrageously good defaults for both vision and NLP. They have several amazing implementations for Cyclic Learning Rate, learning rate schedulers, data augmentation, decent API design, interesting dataloaders, and most important: extremely extensible!

It as seen some rather great adoption among Kagglers and beginners alike for faster experimentation. It is also helped by their amazing MOOC course.

Ignite

Ignite helps you write compact but full-featured training loops in a few lines of code. It is fairly extensible, and results in a lot of compact code. There is no peeking under the hood. This is the best contender for Keras for PyTorch power users.

I do not know of any power users of Ignite, despite their elegant design. Nor have I seen it’s adoption in the wild.

PTL: PyTorch-Lightning

Built by folks over at NYU and FAIR, Lightning is gives you the skeleton to flesh our your experiments. The best contender to Keras for Researchers. The built in mixed precision support (via apex) and distributed training is definitely helpful.

The biggest value add I guess will be explicit decision, all in one class— instead of the scattered pieces we see with PyTorch. Yay Reproducibility!

The lib is still very new, and that shows up in it’s lack of adoption but is getting a lot of star counts in first week of launch!

Check out detailed comparison between Lightning and Ignite from the creator of Lightning

Skorch

skorch is attacking the bringing ML people to Deep Learning problem above

skorch is a scikit-learn style wrapper (with metrics and pipelines support!) for Pytorch by a commercial entity invested in it’s adoption. It is being developed fairly actively (most recent master commit is less than 15 days old) and marching to v1.

Summary

fast.ai: researchers, rapid iterators like Kagglers skorch: welcome people coming from more traditional Machine learning backgrounds PyTorch Lightning: custom built for DL experts looking for experimentation tooling

Ending Note: What are using for deep learning experiments? Have you seen the light with PyTorch or still going with Tensorflow? Tell me @nirantk

Tech Talk Tips

Collection of the Best Advice on Internet that I know about on giving a tech talk. Based on responses from my question on Twitter.

{{< figure src="/images/meghanaTalk.jpg" caption="Meghana gave a talk based on these tips at PyData Bengaluru" >}}

You: Hey, I know something better!

Me: Please tell me about it! Raise a PR. Or reply to the tweet above!

The Mindset

How to structure and style the talk?

Everyone's experiences are different so not sure how well mine generalise. But: find someone whose style of presentation you like & take some inspiration. There are soo many different ways of delivering a talk & it's all about finding the one that works best for your personality.

IMO, slides shouldn't contain everything that's being said in the talk. They should provide an overview of the main points and complement them visually – e.g. with diagrams, illustrations, small code examples. Also, people LOVE taking pics of slides.

I typically practice my talks in logical units, then practice the transitions, then put it all together at the end. I find that much easier and more efficient than only ever doing full run-throughs. But then again, people have different preferences here.

  • From Ines, the co-creator of spaCy

On how to start the talk:

Give an outline to the audience about the topics that will be addressed. More importantly, gauge the existing level of understanding of the subject of the audience and modify the presentation accordingly. Best way is to ask questions before starting the presentation.

On what is important

Holding the attention of the audience is v important. You are easier to pay attention to when you are * entertaining to the audience * telling a story * telling the truth

For every point of truth you want to cover, wrap it with an entertaining story arc. One are per point.

List all your points. Then list all the stories you could tell per point. Then sort the stories by entertainment value to the audience. Assume one story arc is approx per 10 mins of speaking. A mental model of "telling a fun story to someone you've met a few times" helps. - From Sidu Ponappa (@ponappa), GoJek India MD

Don’t fear live coding or live demos

For technical talks, I’m a big fan of live coding or live demos, as opposed to presenting all the material on slides. Audiences like live coding better than slides, because they actually get to see how the system works, as opposed to looking at static snapshots of a perfect working system. Have all my live coding talks gone perfectly? No, but I’ve found audiences to be very understanding when things go awry. Everyone knows that there is risk involved, and I’ve even had people tell me they learned more when they watched the recovery from (or explanation of) an error than they would have by watching glossy slides fly by. Audience attention is definitely higher for live coding talks.

More good

Diwali 2018: Annual Letter

How are you?

I send these letters every year. This is a way for me to send thanks to all the mentors and friends who've been part of my journey so far. And I wanted to drop by and say

Happy Diwali :)

What is up with you? Is there something I can do for you?

For what is up with me?

Health & Wealth

Health

Since the beginning of this year, I have tried 'building better healthy habits'. Progress so far:

  1. Have spent 5000+ minutes working out
  2. Improved my BMI from 32.4 to 30.1 (lost 7 kg)

I am going to spend the next 12-24 months on health. Particularly learning to manage my allergy and asthmatic conditions better. This will be my top non-work priority.

Work

A Year with Soroco I completed a year with Soroco. I have a sense that my strengths are probably not in core AI/software. Yet to figure out where they are. What do you think?

Reading (Learning?)

Last year, I wrote how When Breath Becomes Air has been very influential to me. This year, I've been into online blogs such as:

  • Thinking Better: Farnam Street (mental models), Morgan Housel (Different Kinds of Smart), Ribbon Farm (Premium Mediocre), Derek Sivers (Obvious to You, Amazing to Others) - which resulted in me contributing to open source
  • Dreaming Better: I binge-read through a few books by author's like Dushka Zapata, and Javed Akhtar. Reading Hindi, specially poetry - strung a new chord with me. It instantly brought black flashes of memory fro my early teens which I had all but forgotten. If you have any scifi recommendations - I'd love to read 1-2 this year.

The other essay which I mentioned last year was The Case Against Work Life Balance. The core idea? As long as you're fit, it's better to strive to improve work to the point where it fills your life with contentment. An year of experimentation later - I have a better handle of when this may or may not apply. It seems to be mostly true, except when it's not.

Outside Work

Owing to about 2% better mental discipline and focus, I had a lot more free cycles since March. This resulted in me spending less time with my phone (and laptop) but mostly thinking deeply and creating something:

  • Economics Nobel Laureate, Dr. Paul M Romer (2018) found my notes on programming tools helpful (link to his Tweet)
  • Writing a book on Natural Language Processing, for software engineers - and comes out before Christmas on Amazon!
  • Won an International Fellowship with Fast AI for their advanced AI (deep learning) course

Few more small wins slightly more technical:

  • Won the first ever Natural Language Processing themed Kaggle Kernel award - that's about $500 in cash, $390 in software (Twitter link)
  • State of the Art results on Language Modeling for Hindi: Github Repo
  • Finished in Top 10 at the Global AI for Education Hackathon (link)
  • Lead Maintainer to the Github's Official Natural Language Processing Repo, featured in their ML Collection too (NLP Repo link, ML Collection link)

What's Next?

I'm still working out the chinks, on the wetware that I am - and I'm eager to hear any feedback that you might've.

Cheers, Nirant