I like using VS Code when working with Jupyter notebooks. One pain point has always been automatic code formatting, but now I have a good solution.
You need:
βͺοΈ VS Code 1.60 (August 2021)
βͺοΈ YAPF formatter
Details π
VS Code 1.60
The latest VS Code version from August 2021 contains many improvements for the native display of Jupyter notebooks (which came in July 2021). They now support the command Format Cell with which you can automatically format your code.
π
Keyboard shortcuts
You can quickly do it with a keyboard shortcut.
βͺοΈ Windows: Shift + Alt + F
βͺοΈ Mac: Shift + Option + F
βͺοΈ Linux: Ctrl + Shift + I
I had to remap Shift + Option + F on my Mac, because it seems to be a macOS shortcut for some strange character...
YAPF
I usually use black for formatting my Python code. The problem is that black adds an empty line at the end of each cell which is very annoying. Same for autopep8.
YAPF seems to work fine though, so make sure you set it as your formatter for the notebooks.
YAPF config
Here is also my settings.json file - I wanted to increase the line length of YAPF in order to avoid too many line breaks.
I couldn't yet make VS Code reformat the whole notebook automatically on save...
Do you have any other tips for using Jupyter in VS Code? Which other environment do you use to work with Jupyter notebooks?
This is a really cool tool, thanks for sharing!
I just tried it and it works like charm! It also doesn't add the trailing newline in each cell, so now I can use black
Here are some insights I found particulalry interesting π
"Neural networks are parallel computers"
That is why they are so powerful - you can train a generic computer to solve your problem. This is also the driver behind Software 2.0 - neural network are becoming more and more capable of solving all kinds of problems.
"Neural networks perform well on tasks that humans can perform very quickly"
Humans don't think much when listening, observing or performing simple tasks.
This means that a neural network can be trained to be good at it as well: NLP, computer vision and reinforcement learning.
My setup for recording videos for my machine learning course π₯
A lot of people asked about my setup the other day, so here a short thread on that. It's nothing fancy, but it does a good job π€·ββοΈ
Details π
Hardware βοΈ
βͺοΈ MacBook Pro (2015 model) - screen sharing and recording
βͺοΈ iPhone XS - using the back camera for video recording
βͺοΈ Omnidiretional external mic - connected to the iPhone
βͺοΈ Highly professional camera rig - books mostly about cooking and travel π
π
Software π»
βͺοΈ OBS Studio - recording of the screen and the camera image
βͺοΈ EpocCam - use your iPhone as a web cam. You can connect your iPhone both over WiFi and cable.
βͺοΈ Google Slides - for presentation
βͺοΈ Jupyter notebooks and Google Colab - for experimenting with code
Let's talk about a common problem in ML - imbalanced data βοΈ
Imagine we want to detect all pixels belonging to a traffic light from a self-driving car's camera. We train a model with 99.88% performance. Pretty cool, right?
Actually, this model is useless β
Let me explain π
The problem is the data is severely imbalanced - the ratio between traffic light pixels and background pixels is 800:1.
If we don't take any measures, our model will learn to classify each pixel as background giving us 99.88% accuracy. But it's useless!
What can we do? π
Let me tell you about 3 ways of dealing with imbalanced data:
βͺοΈ Choose the right evaluation metric
βͺοΈ Undersampling your dataset
βͺοΈ Oversampling your dataset
βͺοΈ Adapting the loss
βͺοΈ For beginners
βͺοΈ End-to-end
βͺοΈ Practice instead of theory
βͺοΈ Intuition instead of definition
βͺοΈ Minimum math
βͺοΈ Real-world dataset
βͺοΈ Flexible example applications
βͺοΈ Built with community feedback
Let's go through these points π
For beginners
Only Python knowledge will be required to do the course. No previous machine learning experience needed.
End-to-end
We will cover the whole pipeline - from collecting and cleaning data to deploying a trained model.
We will also discuss some topics like ethics and bias and problem framing.