A use case of metaclass

There are many algorithms out there that uses some “magic constants”. An example is the S-box in most of the block ciphers, which we cannot possibly avoid from the implementation. In some languages, we can hide them in a namespace. For instance in JavaScript, we can put everything inside a... [more]

Modern Python concurrency

I gave a talk before on how to do concurrent processing in Python, with the focus on how to control the workers while they are running. As time passed, we now have concurrent.future and asyncio in Python 3. The following shows how these new features can help us to craft... [more]

JET color

I was not aware of the fact that the color spectrum used in many charts are called the “Jet palette”, named after how MATLAB calls it. This palette also available in matplotlib so it is quite ubiquitous. According to a post, the spectrum is based on a linear blending between... [more]

TF2 GloVe embedding layer

This is how to create an word2vec embedding layer in Tensorflow 2.x, using the GloVe vectors. Assume we downloaded the GloVe data from the web, for example glove.6B.zip of 6B tokens, 400K vocab from Wikipedia data, then we can build a matrix of floats and a word mapping dictionary from... [more]

keras port to tensorflow 2

I am working on some keras code but seems it is better to use tensorflow.keras for some reasons. So my problem is how to port keras.* into tensorflow.keras.* quick and easy, assuming Tensorflow 2 of course. [more]