Table of contents

  1. PyTorch find minimum of a custom function with an optimiser (Adam)

    March 2022

  2. Binary Cross-Entropy vs Mean Squared Error

    March 2022

  3. Binary heap tree proof: index of left child is doubled index of parent + 1

    January 2022

  4. My experience of targeted ads in VK

    March 2021

  5. FreeMind TODO intro!

    April 2017

  6. Normal Mapping Visualisation video

    March 2017

  7. AndroidStudio bug-report. Can’t use debugger with NDK library

    March 2016


PyTorch find minimum of a custom function with an optimiser (Adam)

I caught myself thinking, that most of the tutorial on PyTorch are about neural networks, meanwhile it’s a quite general optimisation framework. There’s a tutorial about how to use autograd, but, still, using autograd is not the same as using an already written high-quality optimiser like, Adam, Adagrad, etc.

So I decided to start with a minimum example and find minimum of x^2 + 1. Weird, but I have not found many tutorials and got stuck with that simple problem. Conor Mc wrote an article, but, still, it uses some custom class based on nn.Model. There also was an article by Bijay Kumar, yet, still, it used nn.Linear layer! 🙂 So, yeah, it took me some time to figure out a working solution and here it is:

from matplotlib.pyplot import *
from torch.optim import Adam
from torch import Tensor
from torch.nn import Parameter

X = Parameter(Tensor([10]))

opt = Adam([X], lr=1)
losses = []
for i_step in range(10):
    y = X ** 2 + 1


Binary Cross-Entropy vs Mean Squared Error

In this post I’m trying better understand Cross-Entropy loss and why it is better than Mean-Squared Error.

On the plot below you can see, that, Mean Squared Error may provide just inadequate and, sometimes, unoptimisable values on low amount of noised data.

TODO: non-noised data, big amount of data, non-linearly separable data.

My experience of targeted ads in VK

1. Small ads (on a side-bar)

Noone sees small ads in a sidebar. Yes, it costs 0.015$/1000 views, but the ad appeared 207 605 times and only 2 people clicked on it. So effective Cost Per Click is ~1.85$ for such ads. So I’d probably have tried to use it to spread some info:

VK Ads 2021-03-24 18-02-49.png

2. Promoted post’s

I had a WAY bigger success in comparison with small ads. It a way more effectively attracted people. More people joined overall and a cost per click was only 66% of the CPC for a small ad. Not bad! Big ads / promoted posts work A WAY better. This time I decided also to follow a bit different approach. Instead of just saying, ‘Hey, community is here’, I decided to describe profits for a potential member.

I created two variations for two different auditories:

b) I just searched all the ‘programming’/’python’ groups and decided to target only users of those groups. It’s only 1000 users, by the way. Though! People tend to join the community with 10 times less ad demonstrations! CTR is 10 times higher! Cost Per Click is almost 4 times cheaper!
a) shown to ‘filtered’ people: by gender/marital status (focus on singles) and whose interests were determined by the social platform as “IT”:

VK Ads 2021-03-24 17-58-03.png

But it’s not the most important difference between them!

People from a first (a broader) group are completely dissatisfied/disappointed:

VK Ads 2021-03-24 18-08-54.png

People from the first group tried to ‘join’ the group to be able to get rid off the ad and, then, they also hid all the group posts.

People from the second group are totally different:

VK Ads 2021-03-24 18-42-48.png

Noone hid any post, nobody reported. People just join! Seems like a perfect ad!

First impressions/emotions/thoughts:

  1. People would like to have an active community. So it’s hard to start, really. People expect there are ALREADY other people to talk to or some services offered. So it’s not enough to buy an ad. There probably should be some waiting list, so people wouldn’t see that the group is empty unless it grows to some size.
  2. To find an audience, I believe, I need to find an audience: communities, concerts/shows, local events, etc. It’s not effective to broadcast/shout: people avoid ads at all cost.
  3. Audiences are small. I need to search for more and more people. It probably, should be like a life style: to look for more and more people.
  4. I can easily hit the limit: there is only 26k people who are even somehow about IT in the whole town. These 26k are not only devs. They may be accountants who needed some IT support in the past, etc. So there are just no programmers in my town. They all go Moscow/big cities. So the rest of those who didn’t leave, just can’t build a community. So it’s not obvious for a beginner, but it’s quite obvious fact if you think about it: but sometimes the goal to make a local community / start a business is just unreachable. 
  5. Looking for people doesn’t take too much time basically.. I’m not sure that I need a dedicated marketer/partner for that.
  6. It’s also good to to it on my own, since I know my auditory better and it would allow me to focus on a product/my clients needs better. I also know about failed strategies. So I know not only people who need my stuff, but also who don’t need.
  7. Without content — a group is empty. But I hate content, to be honest. It looks like communication surrogate. But it is what it is. It seems people won’t stay without it. At least that what I can extrapolate by 9 cases.

FreeMind TODO intro!

Yahoo! 🙂 FreeMind TODO finally goes live! I spent two days to understand basics of Blender video editing and record this video. Finally, I’ve produced the first part of an intro to FreeMind TODO.

I hope somebody finds FreeMind TODO useful. Any feedback is appreciated. If it’s useful, I’m planning to record another one with the actual application description.

And, yes, it doesn’t have an aim of Trello/Coggle/so on. It’s just a quick and easy TODO-generator from HUGE and COMPLEX mindmaps.


The github link is also available:

Normal Mapping Visualisation video

Yesterday I published my first video 🙂 It’s about processes that happen in normal mapping shader.

All sources for that video are available here:

Stars and likes are very welcome 🙂 It’s my very first video editing experience and I’m glad that I’ve managed to get that done.

AndroidStudio bug-report. Can’t use debugger with NDK library

Yes, it’s. If you’re researching about how to use native debugger with Android studio there’re no so many decisions of your problem. You shouldn’t use native libraries. Just integrate your C++ sources into main project – so debugger would work.

I’ve created bug-report so, I hope, Google will close it. But there’s still no any info.