Akshay ๐Ÿš€ Profile picture
Dec 18 โ€ข 8 tweets โ€ข 3 min read Twitter logo Read on Twitter
Decorators are one of the most powerful feature of Python! ๐Ÿ”ฅ

However, understanding them can be a bit overwhelming!

Today, I'll clearly explain how decorators work!

Let's go! ๐Ÿš€ Image
Before we jump onto decorator, we must understand that functions in python are "first-class" objects!

It means that a function can be:

- passed around as an argument
- used in expressions
- returned as values of other functions

Just like integers or string!

Check this out๐Ÿ‘‡ Image
To get the essence of Decorators, let's imagine it's your friend's birthday, you're giving them a gift.

But before you do, you wrap it in a fancy gift paper to enhance its look, right?

Decorators do the same thing but with functions. โœจ

Let's see how ... ๐Ÿ‘‡
Decorators are a bit like wrapping paper.

They're functions that take another function, add some functionality, and return the new "decorated" function.

Check this out๐Ÿ‘‡ Image
The syntax we saw above is a bit clumsy.

However Python has a subtle way to do it! ๐Ÿ’ซ

We can use the `@` symbol along with the decorator name right before the function definition.

It does exactly the same thing as before but looks cleaner!โœจ

Check this out๐Ÿ‘‡ Image
Now if you are wondering, what happens when my function takes an argument!

Here'a an illustration of how decoration works when the function being greeted takes an argument!

Check this out๐Ÿ‘‡ Image
Decorators are powerful and flexible.

They can be used to:
- log function calls
- check function arguments
- run code before and after functions,
- and much more ...

They allow us to add functionality in a clean, consistent way.

Here's an interesting & generic use-case ๐Ÿ‘‡ Image
That's a wrap!

If you interested in:

- Python ๐Ÿ
- Maths for ML ๐Ÿงฎ
- ML/MLOps ๐Ÿ› 
- CV/NLP ๐Ÿ—ฃ
- LLMs ๐Ÿง 
- Ai Engineering โš™๏ธ

Find me โ†’ @akshay_pachaar โœ”๏ธ

I also write a technical newsletter on AI Engineering!

Join 4.5K+ readers: mlspring.beehiiv.com/subscribe
Image

โ€ข โ€ข โ€ข

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

Keep Current with Akshay ๐Ÿš€

Akshay ๐Ÿš€ 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 @akshay_pachaar

Dec 15
I have been coding in Python for 8 years now. โณ

If I were to start over in 2024, here's a roadmap: ๐Ÿงต๐Ÿ‘‡ Image
1๏ธโƒฃ freeCodeCamp

4 hours Python bootcamp!!

What you'll learn:
- Installing Python
- Setting up an IDE
- Basics Syntax
- Variables & Datatypes
- Looping in Python
- Exception handling
- Modules & pip
- Mini hands-on projects ๐Ÿ”ฅ

Check this out ๐Ÿ‘‡
2๏ธโƒฃ CS50p: Harvard University

There isn't a better place to learn #Python than @davidjmalan 's CS50p.

Beautiful explanations and great projects.
It's a complete package.

Highly recommended!!

Check this out ๐Ÿ‘‡
cs50.harvard.edu/python/2022/
Read 6 tweets
Dec 2
Microsoft, Google, Harvard, MIT and DeepLearningAI are offering FREE courses on AI!

To stay ahead of the curve, here are some of the best courses that you can take today: Image
1๏ธโƒฃ Harvard CS50 AI

Harvard's introduction to AI with Python.

It is taught by David J Malan, who is renowned for his work on the legendary CS50 program.

pll.harvard.edu/course/cs50s-iโ€ฆ
2๏ธโƒฃ DeepLearning AI's Generative AI for Everyone.

Best place to understand & get started with AI, irrespective of your background knowledge.

Check this out๐Ÿ‘‡
deeplearning.ai/courses/generaโ€ฆ
Read 11 tweets
Nov 28
We've all dealt with activation functions while working with neural nets.

- Sigmoid
- Tanh
- ReLu & Leaky ReLu
- Gelu

Ever wondered why they are so importantโ“๐Ÿค”

Let me explain it to you today...๐Ÿ‘‡ Image
Before we proceed I want you to understand something!

You can think of a layer in neural net as a function & multiple layers makes the network a composite function.

Now, a composite function consisting of individual linear functions is also linear.

Check this ๐Ÿ‘‡ Image
We have a simple neural net that does binary classification.

Scenario 1:
- Linear decision boundary
- Linear Activation function

Observe how the neural net is able to quickly learn & loss converges to zero.

Watch this ๐Ÿ‘‡
Read 7 tweets
Nov 26
I started my career in Data Science back in 2016 โณ

Here's a list of Tech YouTube Channels I've ardently followed...๐Ÿ‘‡
1๏ธโƒฃ Corey Schafer

Arguably the best python channel on YouTube ๐Ÿ”ฅ

I have personally learned a lot from him โœ…

Check this out ๐Ÿ‘‡
youtube.com/@coreyms
2๏ธโƒฃ Andrej Karpathy

He's not only a pioneer but the best teacher in the world of AI.

If you are interested in LLMs, his is latest series on makemore is something you don't want to miss.

Check this out๐Ÿ‘‡
youtube.com/c/AndrejKarpatโ€ฆ
Read 10 tweets
Nov 24
Self-attention as a directed graph!

Self-attention is at the heart of transformers, the architecture that led to the LLM revolution that we see today.

In this post, I'll clearly explain self-attention & how it can be thought of as a directed graph.

Read more...๐Ÿ‘‡ Image
Before we start a quick primer on tokenization!

Raw text โ†’ Tokenization โ†’ Embedding โ†’ Model

Embedding is a meaningful representation of each token (roughly a word) using a bunch of numbers.

This embedding is what we provide as an input to our language models.

Check this๐Ÿ‘‡ Image
The core idea of Language modelling is to understand the structure and patterns within language.

By modeling the relationships between words (tokens) in a sentence, we can capture the context and meaning of the text. Image
Read 10 tweets
Nov 19
I have been coding in Python for 8 years now.โณ

Here are 7๏ธโƒฃ amazing Python libraries not known to many...๐Ÿ‘‡
1๏ธโƒฃ PivotTableJS

๐๐ข๐ฏ๐จ๐ญ๐“๐š๐›๐ฅ๐ž๐‰๐’ lets you interactively analyse your data in Jupyter Notebooks without any code ๐Ÿ”ฅ

Check this out ๐Ÿ‘‡
๐Ÿ”— โ†’ pypi.org/project/pivottโ€ฆ
2๏ธโƒฃ PyTube

Download Youtube videos in 5 lines of code!

Check this out ๐Ÿ‘‡
๐Ÿ”— โ†’ pytube.io/en/latest/
Image
Read 9 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

Don't want to be a Premium member but still want to support us?

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

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(