Skip to content

Writing

Don't Bask in Reflected Glory

Irshad Kamil

ये जो लोग-बाग हैं, जंगल की आग हैं Ye jo log baag hain, Jungle ki aag hain The people, are jungle fire

क्यूँ आग में जलूँ... Kyun aag mein jalun Why should I burn in the fire?

ये नाकाम प्यार में, खुश हैं ये हार में Ye nakaam pyaar mein, Khush hai yeh haar mein Defeated in love, they're happy in defeat

इन जैसा क्यूँ बनूँ... Inn jaisa kyun banun Why should I be like them?

Identity

I am here to tell you how to keep your identity small. I'll share what I think is the bare minimum context you need to have:

Why should I keep my Identity small?

Paul Graham explains how keeping your identity small can be a competitive advantage:

The most intriguing thing about this theory, if it's right, is that it explains not merely which kinds of discussions to avoid, but how to have better ideas. If people can't think clearly about anything that has become part of their identity, then all other things being equal, the best plan is to let as few things into your identity as possible.

  1. If you know what is part of someone’s identity, you can avoid inflammatory discussions. This can be as simple as avoiding discussions about which shoe brand is the best?

  2. The bigger advantage is this: Better ideas. The ability to think with lucidity, without biases is an unfair advantage. If you act on rational decisions without attacking someone's identity, it's an even bigger advantage which few can compete with.

What do you mean by Identity?

Identity, in the crudest sense are the words (and ideas) that you use to describe yourself - in your head. For instance, while you might be someone who build rocket ships, your identity might be "I am a family man". Or “I am a craftsman engineer making ships for space travel”

Here is a short mental exercise. Fill this blank with at least 3 small phrases:

Your Identity

I am ___

Done?

Awesome. Let's carry on:

Here is what I came up with a few years ago:

My Identity

I am {Indian, guy, techie}

The labels in {} are (in the very crude sense) - my identity. Notice that these labels do not always have to be professional, personal or even Truth in the strictest sense.

They don't have to align with reality in any meaningful way. They simply describe how you perceive yourself.

Want another example? Here is what a friend filled:

My Identity

I am {smart, get things done, make no excuses}

If you have not filled in your three, please pause - take a quick second and type it down somewhere. I'll wait.


Cool, I hope you have your three written or typed somewhere accessible. Let's carry on. We'll come back to it, I promise.

Don't Bask in Reflected Glory

That's it. That is the only thing I want you to do and you will be on your way to learning how do I avoid these labels?

Reflected Glory is the invisible demon which will lead you to the butcher, chop you up into pieces, then slow barbecue you in open air. All this while you and the Demon, both laugh and make merry.

Reflected glory is how Satan wins over honest, smart and hard working people. It is insidious. Sinister. Subtle.

In Professional Circles

Even in certain careers, labeling yourself can be a career limiting move:

Don't Call Yourself a Programmer

If you call yourself a programmer, someone is already working on a way to get you fired - from Don't Call Yourself a Programmer by @patio11

And why are otherwise honest people, so deeply tempted to label themselves professionally?

The best people in most professions are incredibly talented and (often enough) make good money. The professional label is aspirational.

The worse off are your professional skills, the more you need to riff on the shared professional identity of amazing folk in your profession.

Here is an important nuance which I constantly remind myself of:

Stop calling yourself a programmer

Don't bask in Reflected Glory

Keep your identity small

In Politics

Politician's Trick

"People like us ... " - wait, go deeper and think. Your mental dialog will begin: "What does he mean by us? I am nobody. Why does a nobody matter? Is he using my emotions as a stepping stone to get where he wants to go?"

The politician is tricking you into filling in the gaps he left. What do you will fill this with? What makes best sense for you, from your own identity.

He is hacking your identity to make most profit for him. Don't waste your energy. When making rich people richer, get something in return.

But why does this trope work in the first place?

Well, because somewhere in your identity - you allowed words like Indian, American, Patriot or Nationalist to creep in.

Why did you allow them in the first place? Because there are actually positive connotations of being a part of the world's largest and most powerful democracy respectively.

Stop

You walked into my trap.

You basked in the reflected glory of your ancestors.

Both America and India are countries born of blood, sweat and tears. Not enough of which is yours. You haven't done anything meaningfully large to contribute to democracy.

You are basking in the reflected glory of your dead ancestors

Be grateful. Use them as your ideals.

For the sake of good that is oft interred with bones, don't bask in glory of your dead ancestors

Do the work that when you meet your ideals, they can be proud

Do the work such that you can be proud

Don't bask in reflected glory

Keep your identity small

In Casual Conversation

Bragging

"Look at Michael, an Olympic athlete, I knew him in college" - wait, and think. You might end up going this way: "Why is that relevant in this conversation? Is this an offer to make an intro to the Olympian, so that I improve my game? Or is this just banter-bragging? And why brag?"

Brag about achievements of someone you know. Or worked with. Or went to school with.

Everyone around you looks at you for a brief moment of envy, or pride if they love you.

They could have been proud of something you did. And instead they're proud that you know people who do things. You are basking in the reflected glory of others.

The first time I internalized this perspective, I was deeply embarrassed.

Given that you've read this piece so far, I hope something for you.

I hope that when you go to sleep tonight - you will sleep with the resolution to not bask in reflected glory of your friends and family.

No matter how much you love them. You will be proud of them. And you will not bask in their glory. Don't bask in their reflected glory.

It's their spotlight and you will not even a light a candle to steal that

Your Three

Remember the three blanks we filled? Those are the your borrowed labels. No matter how innocent, they cloud your judgment.

Those are the ideas - and people whose reflected glory you are stealing unknowingly

Even the Get things done is basking under the reflected glory of people who actually get things done. It clutters your thinking by making you swing for the extremes. By not letting you slow down.

It might be quite some time before my friend sees that it's about the getting the right things done.

That we are human beings, not human doings.

The moon waxes and wanes because it basks in reflected glory - but even the darkest clouds cannot hide the glory of sun

Borrowed Glory

When your contributions are meaningful enough, you don't need borrowed glory. The sun shines it's own light, it's the moon that steals light

Best of Python 3 f-strings

This piece is primarily meant for those new to Python. These include mathematicians, economists, and so on who want to use Python within a Jupyter environment. Here is a quick guide on how to make Best of Jupyter.

Quick Primer

If you are familiar with earlier Python versions, here are my top picks on how to move from .format () to this new one:

{{< highlight python >}}

_fstring = f'Total: {one + two}' # Go f-string! _format = 'Total: {}'.format(one + two) _percent = 'Total: %s' % (one + two) _concatenation = 'Total: ' + str(one + two) assert _fstring == _format == _percent == _concatenation {{< /highlight >}}

f-string Magic

f-strings are how you should use print statements in Python. It is fairly reminiscent of LaTeX in it’s inline notation: {{< highlight python >}}

inline variables, similar to LaTeX

name = "Fred" print(f"He said his name is {name}.")

'He said his name is Fred.'

{{< /highlight >}}

Notice how the variable name can now be used inline. This is a simple and easy to use syntax: just include the variable in surrounding {} while marking the string type as f-string using the ‘f’ in the beginning.

Note to the advanced programmer:

‘f’ may be combined with ‘r’ to produce raw f-string which can be used inside regex or similar functions. ‘f’ may not be combined with ‘u’, this is because all Python3.6+ strings are Unicode by default now. This means, you can write fstrings in Hindi, Chinese, French, Korean and atleast 10 other languages.

You can write fstrings in Hindi, Chinese, French, Korean and any language covered by Unicode.

But why are these called formatted-strings in the first place? Because you can use with some cool formatting hacks.

Simplified Alignment and Spacing

Have you ever tried creating a table such as that for logging or visualization? Arranging the elements becomes a nightmare with several \t tab characters flying around.

This is much easier with Python f-strings using the colon ‘:’ operator, followed by a an alignment operator and field width value.

There are atleast 3 alignment operator: < for left aligned, > for right aligned, and ^ for center aligned. Refer the code example:

{{< highlight python >}} correct = 'correct' phonetic_correct = 'phonetic_correct' typo = 'typo' phonetic_typo = 'phonetic_typo' phonetic_distance = 'phonetic_distance'

{{< /highlight >}} {{< highlight python >}}

print(f'No Spacing:') print(f'{correct}|{phonetic_correct}|{typo}|{phonetic_typo}|{phonetic_distance}|\n')

No Spacing:

correct|phonetic_correct|typo|phonetic_typo|phonetic_distance|

{{< /highlight >}} {{< highlight python >}}

print(f'Right Aligned:') print(f'{correct:>10}|{phonetic_correct:>20}|{typo:>10}|{phonetic_typo:>20}|{phonetic_distance:>20}|\n')

Right Aligned:

correct| phonetic_correct| typo| phonetic_typo| phonetic_distance|

{{< /highlight >}} {{< highlight python >}}

print(f'Left Aligned:') print(f'{correct:<10}|{phonetic_correct:<20}|{typo:<10}|{phonetic_typo:<20}|{phonetic_distance:<20}|\n')

Left Aligned:

correct |phonetic_correct |typo |phonetic_typo |phonetic_distance |

{{< /highlight >}} {{< highlight python >}}

print(f'Centre Aligned:') print(f'{correct:10}|{phonetic_correct:20}|{typo:10}|{phonetic_typo:20}|{phonetic_distance:^20}|')

Centre Aligned:

correct | phonetic_correct | typo | phonetic_typo | phonetic_distance |

{{< /highlight >}}

You also have support for decimal truncation and similar standard formatting utilities: {{< highlight python >}}

auto-resolve variable scope when nested

width = 10 precision = 4 value = decimal.Decimal("12.34567") print(f"result: {value:{width}.{precision}}") # nested fields

'result: 12.35'

{{< /highlight >}}

You might notice something interesting here: width and precision are automatically picked up from the scope. This means you can calculate width and precision using screen width or other inputs from system and use that.

Full Python Expressions Support

The above is only possible because the expression inside {} is actually being evaluated, or in programming terms: being executed.

This implies, that you can make any function call from within those {}.

Though, you should avoid doing this in practice very often because it might make your debugging very difficult. Instead, store the returned value from function in a variable and then add the variable in a fstring print statement.

Those coming from functional programming might miss their lambda functions. Don’t worry, Python has you covered:

Lambda Functions in f-strings

{{< highlight python >}}

If you feel you must use lambdas, they may be used inside of parentheses:

print(f'{(lambda x: x*3)(3)}')

'9'

note that this returned a and not

{{< /highlight >}}

Summary

  • f strings mean you can include variables and function calls inside your print statements
  • Inline variables: these are easier to read and debug for the developer
  • Use f-strings when you can!

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