THREAD: Imagine Python aspiring to be all that it could be... ๐Ÿฅฐ What would it look like?

All of this is well-tested code you can use in your projects today by importing from ๐š๐šŠ๐šœ๐š๐šŒ๐š˜๐š›๐šŽ by @fastdotai.

๐š๐šŠ๐šœ๐š๐šŒ๐š˜๐š›๐šŽ can make your code cleaner and easier to maintain...
2/ We will go through the functionality in the order it is defined in ๐š๐šŠ๐šœ๐š๐šŒ๐š˜๐š›๐šŽ.

Let's start with __๐š›๐šŽ๐š™๐š›__

Tired of its output containing very little information useful to a human being?

Here is what you can use instead!
3/ Need to chunk that list into multiple sublists? Maybe you are attempting to run calculations in parallel or doing something even more tricky?

No need to look for that stackoverflow post ever again ๐Ÿ˜„

The functionality that you need is right here!
4/ How about a dict that you can access without those pesky brackets?
5/ And for all your casting needs...

This example is trivial, but just imagine how much more concise and easy to read your code could be if you could use type annotations in this additional way!
6/ ๐šœ๐š๐š˜๐š›๐šŽ_๐šŠ๐š๐š๐š› ๐Ÿฅฐ Dataclasses that do not introduce new syntax + that allow you to define your own init!
7/ Composition plays an important role in OOP, but how do we make it play nice? ๐Ÿค” How do we compose our objects to our heart's desire and still deliver a nice UX?

Delegated composition is the answer!

You can read more on this here: fast.ai/2019/08/06/delโ€ฆ
8/ TIL Python only started to have a construct for merging dicts in 3.5!

๐š๐šŠ๐šœ๐š๐šŒ๐š˜๐š›๐šŽ's merge gets an honorable mention here (works across multiple dicts)
8/ The functions that follow are tiny but can be super useful for so many things ๐Ÿฅฐ.
9/ ๐š๐šŠ๐šœ๐š๐šž๐š™๐š•๐šŽ - a whole new, awesome, take on the tuple

(this is a screenshot of a notebook where this functionality is defined)
10/ ๐š™๐šŠ๐š›๐š๐š’๐šŠ๐š• but where you can move the arguments around, yesss!!!

(tiny example followed by a screenshot of the NB)
11/ Patching... in a language that does not allow for reopening a class, this is badly needed!

I want my tools to allow me to wield great power so that I can direct it at will. I do not want a 'dumbed down' API just because I can misuse it if I code without care...
12/ Runtime type validation!
This covers just ๐š๐šŠ๐šœ๐š๐šŒ๐š˜๐š›๐šŽ.๐š‹๐šŠ๐šœ๐š’๐šŒ๐šœ - more to come! ๐Ÿ˜Š

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with Radek Osmulski

Radek Osmulski Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @radekosmulski

18 Feb
THREAD: How is it possible to train a well-performing, advanced Computer Vision model ๐—ผ๐—ป ๐˜๐—ต๐—ฒ ๐—–๐—ฃ๐—จ? ๐Ÿค”

At the heart of this lies the most important technique in modern deep learning - transfer learning.

Let's analyze how it works...

2/ For starters, let's look at what a neural network (NN for short) does.

An NN is like a stack of pancakes, with computation flowing up when we make predictions.

How does it all work?
3/ We show an image to our model.

An image is a collection of pixels. Each pixel is just a bunch of numbers describing its color.

Here is what it might look like for a black and white image
Read 17 tweets
17 Feb
โœ๏ธ not sure if this can be helpful to you, but here is how I configure my Ubuntu desktop after install:

โœ… use scripts to install a bunch of stuff
โœ… install i3 wm
โœ… make font not super tiny

Here is the doc: notion.so/How-I-configurโ€ฆ

More thoughts (+ a demo!) in tweets below ๐Ÿ˜‰
If you do decide to follow through with this approach, you are opening yourself up to a world of hurt ๐Ÿ™‚

But with time, this will allow you to work on your computer faster and in an (IMHO) much more pleasant way.

Here is a teaser (I am not using the mouse for any of this).
Quick howto:

โœ… alt-d and start typing to start a program
โœ… alt-enter opens terminal
โœ… ctrl-f c creates a new tmux pane
โœ… ctrl-f x closes current pane
โœ… ctrl-f n, ctrl-f p, ctrl-f <pane num> switches between panes
โœ… shift-alt q closes current program
Read 4 tweets
12 Feb
THREAD: Sometimes code can seem impenetrable. But there are various ways we can make our life easier.

A common pattern is a function or an object accepting a function. Here is an example.

A ๐šœ๐š™๐š•๐š’๐š๐š๐šŽ๐š› can be a thing that can be called.

But what inputs will it receive? Image
2/ This is not a straightforward question to answer.

But we can learn so much more about what is going on right here in our Jupyter notebook!

Enter ๐šœ๐šŽ๐š_๐š๐š›๐šŠ๐šŒ๐šŽ.

We can manufacture an anonymous function and have ๐šœ๐šŽ๐š_๐š๐š›๐šŠ๐šŒ๐šŽ called from inside the ๐™ณ๐šŠ๐š๐šŠ๐™ฑ๐š•๐š˜๐šŒ๐š”! Image
3/ We can now query the actors.

๐š‚๐š˜๐š–๐šŽ๐š๐š‘๐š’๐š—๐š turns out to be an ๐™ป (a ๐š•๐š’๐šœ๐š with superpowers).

It also seems to consist of ๐™ฟ๐š˜๐šœ๐š’๐šก๐™ฟ๐šŠ๐š๐š‘๐šœ.

So we now know what whatever is passed as ๐šœ๐š™๐š•๐š’๐š๐š๐šŽ๐š› should take.

But we can do better. Image
Read 5 tweets
12 Feb
THREAD: How does machine learning ๐Ÿค– differ from regular programming? ๐Ÿง‘โ€๐Ÿ’ป

In both, we tell the computer ๐—ฒ๐˜…๐—ฎ๐—ฐ๐˜๐—น๐˜† what to do.

But there is one important difference...
2/ In regular programming, we describe each step the computer will take.

In machine learning, we write a program where the computer can alter some parameters based on the training examples.

How does this work?
3/ Our model has a lot of tiny knobs, known as weights or parameters, that control the functioning of the program.

We show the computer a lot of examples with correct labels.

Here is how this can play out...
Read 6 tweets
11 Feb
THREAD: Can you start learning cutting-edge deep learning without specialized hardware? ๐Ÿค–

In this thread, we will train an advanced Computer Vision model on a challenging dataset. ๐Ÿ•๐Ÿˆ Training completes in 25 minutes on my 3yrs old Ryzen 5 CPU.

Let me show you how...
2/ We will train on the challenging Oxford-IIIT Pet Dataset.

It consists of 37 classes, with very few examples (around 200) per class. These breeds are hard to tell apart for machines and humans alike!

Such problems are called fine-grained image classification tasks.
3/ These are all the lines of code that we will need!

Our model trains to a very good accuracy of 92%! This is across 37 classes!

How many people do you know who would be as good at telling dog and cat breeds apart?

Let's reconstruct how we did it...
Read 17 tweets
5 Feb
THREAD: Can you go from being a treasurer to doing cutting edge DL research through the power of the community? โœจ

Sarada Lee (@moodymwlee) is the founder of the Perth ML Group and a Scholar @DataInstituteSF and @Uni_Newcastle.

Her amazing journey began with a selfless act...
2/ In 2016 Sarada founded the Perth ML Group to help others learn.

How can the community support you? ๐Ÿค—

It can...

โœ… help you set up your environments ๐Ÿง‘โ€๐Ÿ’ป
โœ… provide technically-sound answers to challenging questions ๐Ÿ’ก
โœ… make learning more fun! ๐Ÿฅณ
3/ What are some tips for community participation?

โœ… explaining things to others will help you learn ๐Ÿฆ‰
โœ… it's okay to be anxious about sharing your answers publicly - DMs are always an option ๐Ÿ“จ
โœ… experiment with various approaches and learn in a way that suits you best ๐Ÿ’ก
Read 4 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!