As part of my effort to engage with the Open-source community I started answering Stackoverflow questions. I started by asking
a few decent questions and then answered some of my own questions and accepted them. Gradually I understood that this community site is not only about answering but also asking good questions that others can answer.
That is how one builds one’s reputation. I believe a key skill one develops by answering is the ability to clearly understand what is being asked.
Here I’ve collected some Tensorflow recipes most of which are my answers to Stackoverflow questions. Not all though. Some are code
samples I built for myself to understand Tensorflow. I plan to add more explanations and some diagrams to make the code clearer.
The Tensorflow version that I use is 1.xx. I mention this because the framework is under constant development.
How to get values of each row in a matrix according to the max and secondary value indexes which I got from another matrix ?
Finding roots of a polynomial by Halley’s method using tensorflow
How does tf.scan work ?
I will add more explanation in due time. But for now this code updates one row of a tf.zeros(5,5) tensor. But tf.scan is way more powerful than this.
The output is this.
0
0
0
0
0
3
2
4
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
How do you use TensorArray ?
Can variable initialization depend on the fed value of a placeholder ?
Even though we can initialize a variable that depends on a placeholder like this, independent variables like W will get initialized repeatedly. More checks are needed to initialize only variables like F which are dependent on placeholders.
This is so because everytime a value is fed to the placeholder the dependent variable F will be initialized. But other independent variables need not be.