<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Machine Learning on Bharath's Blog</title><link>https://bharathbhushan1.github.io/blog/tags/machine-learning/</link><description>Recent content in Machine Learning on Bharath's Blog</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sat, 15 Aug 2026 09:00:00 +0530</lastBuildDate><atom:link href="https://bharathbhushan1.github.io/blog/tags/machine-learning/index.xml" rel="self" type="application/rss+xml"/><item><title>Model Distillation</title><link>https://bharathbhushan1.github.io/blog/posts/2026-08-15-model-distillation/</link><pubDate>Sat, 15 Aug 2026 09:00:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-08-15-model-distillation/</guid><description>&lt;p&gt;Model distillation is a model training/fine-tuning process where a smaller
student model is trained from a teacher model. The evolution of distillation
goes from model compression to knowledge/behaviour transfer to transfer
of reasoning abilities. The student could have better generalization depending
on how the distillation was done. So you end up with a smaller, faster,
cheaper model with better generalization while needing fewer training samples
during training and you can use a higher learning rate.&lt;/p&gt;</description></item><item><title>Vision Language Models</title><link>https://bharathbhushan1.github.io/blog/posts/2026-08-13-vision-language-models/</link><pubDate>Thu, 13 Aug 2026 09:00:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-08-13-vision-language-models/</guid><description>&lt;p&gt;Vision Language Models are a class of large multimodal neural networks.
They take images and text as input and generate text as output. The typical
tasks involve jointly reasoning over both images and text to generate
useful results.&lt;/p&gt;
&lt;p&gt;The joint reasoning is interesting. Basically visual semantic concepts and
textual semantic concepts (and speech and video) are mapped to the same
embedding/latent space. Then the model processes the embeddings. The joint
training has the advantage that there is genuine grounding of visual concepts
in text and vice-versa. In practice a &amp;ldquo;modality gap&amp;rdquo; persists even after joint
training — embeddings of different modalities cluster in distinct regions of the
shared space rather than fully overlapping — but the gap is far smaller than
between independently trained encoders. Parameters are shared across modalities,
reducing model size. The caveats are careful data mixing during training: a good
mixture of images, text and image+text, staged training, basically all to avoid
catastrophic forgetting.&lt;/p&gt;</description></item><item><title>World Models</title><link>https://bharathbhushan1.github.io/blog/posts/2026-08-12-world-models/</link><pubDate>Wed, 12 Aug 2026 09:00:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-08-12-world-models/</guid><description>&lt;p&gt;This short note is based on an article by Dr. Fei-Fei Li (see References).&lt;/p&gt;
&lt;p&gt;World models allow you to view, generate, interact with, reason about
and manipulate virtual worlds. I think spatial intelligence is an
important component of human intelligence and will likely become part
of artificial intelligence too, over time.&lt;/p&gt;
&lt;p&gt;LLMs only deal with text. VLMs deal with images. There are models to
generate images and short videos. But we need so much more to claim
spatial intelligence.&lt;/p&gt;</description></item><item><title>Reasoning Models</title><link>https://bharathbhushan1.github.io/blog/posts/2026-07-05-reasoning-models/</link><pubDate>Sun, 05 Jul 2026 17:00:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-07-05-reasoning-models/</guid><description>&lt;p&gt;&lt;img alt="Reasoning models mindmap" loading="lazy" src="https://bharathbhushan1.github.io/blog/images/reasoning-models.svg"&gt;&lt;/p&gt;
&lt;p&gt;Source: &lt;a href="https://www.ibm.com/think/topics/reasoning-model"&gt;What is a reasoning model?&lt;/a&gt; (IBM)&lt;/p&gt;
&lt;p&gt;I was reading the above article and made a simple mindmap of the material. It is a huge
topic which I plan to read more about, but this is just a start.&lt;/p&gt;
&lt;p&gt;It is hard to believe that just a prompt for chain-of-thought could unlock reasoning
behaviours in a pre-trained model. But that seems to underpin all the developments
in reasoning LLMs, at least the popular ones. Of course, search-based and majority-based
approaches exist too.&lt;/p&gt;</description></item><item><title>Image Generation Models</title><link>https://bharathbhushan1.github.io/blog/posts/2026-07-03-image-generation-models/</link><pubDate>Fri, 03 Jul 2026 19:00:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-07-03-image-generation-models/</guid><description>&lt;p&gt;&lt;img alt="Latent diffusion inference (SD 1.5)" loading="lazy" src="https://bharathbhushan1.github.io/blog/images/latent_diffusion_inference_sd15.svg"&gt;&lt;/p&gt;
&lt;p&gt;I saw the &lt;a href="https://blog.google/innovation-and-ai/models-and-research/gemini-models/gemini-omni-flash-nano-banana-2-lite/"&gt;launch announcement&lt;/a&gt;
of Google&amp;rsquo;s Nano Banana 2, and this piqued my interest
in image generation models. These are models that take a textual prompt, and with a
few optional reference images, generate a new image. The main criteria are cost of
generation, speed of generation, prompt adherence, consistency of the characters in
the image, and style manipulation ability.&lt;/p&gt;
&lt;p&gt;The most popular type of image generation model is a latent diffusion model based on
a Diffusion Transformer (DiT) for noise prediction. Earlier, a U-Net was used for
noise prediction instead.&lt;/p&gt;</description></item><item><title>Qwen-AgentWorld: A Language World Model for Agents</title><link>https://bharathbhushan1.github.io/blog/posts/2026-06-30-qwen-agentworld/</link><pubDate>Tue, 30 Jun 2026 08:30:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-06-30-qwen-agentworld/</guid><description>&lt;p&gt;The Qwen team &lt;a href="https://qwen.ai/blog?id=qwen-agentworld"&gt;released&lt;/a&gt; Qwen-AgentWorld
on 2026-06-24. I came to know more about language world models via this post. It is
also related to &lt;a href="https://bharathbhushan1.github.io/blog/posts/2026-06-24-ai-agents/"&gt;agents&lt;/a&gt;, and
&lt;a href="https://bharathbhushan1.github.io/blog/posts/2026-06-13-offline-rl/"&gt;offline RL&lt;/a&gt;. This post is a short summary
of my understanding.&lt;/p&gt;
&lt;h2 id="context"&gt;Context&lt;/h2&gt;
&lt;p&gt;To train an agent with RL, you need an environment in which it can learn by trying
out various actions and observing the result. But real environments are slow and
sometimes irreversible.&lt;/p&gt;
&lt;p&gt;A &lt;strong&gt;language world model&lt;/strong&gt; predicts the new state of the environment given
(current-state, agent-action). Interestingly, the observation is emitted as XML/HTML
allow even GUI environments to be modelled by a text-only LLM.&lt;/p&gt;</description></item><item><title>AI Agents</title><link>https://bharathbhushan1.github.io/blog/posts/2026-06-24-ai-agents/</link><pubDate>Wed, 24 Jun 2026 09:00:00 +0530</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-06-24-ai-agents/</guid><description>&lt;p&gt;&lt;img alt="AI Agents" loading="lazy" src="https://bharathbhushan1.github.io/blog/images/ai-agents.svg"&gt;&lt;/p&gt;
&lt;p&gt;This is the architecture of a typical AI Agent. There is a user operating the agent in order to get his/her task done. There is some local state which the agent can read and write. The agent itself has the following components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The control loop or the agentic loop allows the user to interact with agent. It also orchestrates the complete user interaction flow. Along with this it also handles compaction behaviour, hooks, etc.&lt;/li&gt;
&lt;li&gt;The system prompt, other prompts and skills comprise the instructions and code needed for the agent to work.&lt;/li&gt;
&lt;li&gt;Together the above two sets of components can be called the &amp;ldquo;harness&amp;rdquo;.&lt;/li&gt;
&lt;li&gt;Code sandbox allows execution of code generated by the LLM. Tools allow various kinds of processing. MCP server and client allow connecting to various sources of data.&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>The Bitter Lesson</title><link>https://bharathbhushan1.github.io/blog/posts/2026-06-17-bitter-lesson/</link><pubDate>Wed, 17 Jun 2026 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-06-17-bitter-lesson/</guid><description>&lt;p&gt;This post is a short summary of Rich Sutton&amp;rsquo;s &lt;a href="http://www.incompleteideas.net/IncIdeas/BitterLesson.html"&gt;Bitter Lesson&lt;/a&gt; essay.&lt;/p&gt;
&lt;h3 id="context"&gt;Context&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Cost of computation reduces exponentially with time.&lt;/li&gt;
&lt;li&gt;&amp;ldquo;Brute force&amp;rdquo; approaches which use compute win over human-aided or human-like problem solving over a medium/long time horizon.&lt;/li&gt;
&lt;li&gt;Search is one such computation technique. This helped in Deep Blue winning chess.&lt;/li&gt;
&lt;li&gt;Learning is another. Learning with self-play is yet another. This helped in AlphaGo winning in Go.&lt;/li&gt;
&lt;li&gt;A Hidden Markov model which models sequential processes is yet another computation technique. This helped in speech recognition.&lt;/li&gt;
&lt;li&gt;Deep learning for speech recognition is another step in this direction of using computation instead of human-modeled features.&lt;/li&gt;
&lt;li&gt;Convolutional Neural networks solved image recognition and other vision problems.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="bitter-lesson"&gt;Bitter Lesson&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;The bitter lesson is that building systems based on our understanding of
human knowledge and specifics of problem solving does not work in the long
run. AI researchers build knowledge into their agents and this helps in the
short term. In the long term, progress plateaus and even slows down. A
breakthrough happens by using search/learning along with scaled compute.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="learnings"&gt;Learnings&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Learning 1: General methods like &lt;code&gt;search&lt;/code&gt; and &lt;code&gt;learning&lt;/code&gt; are very powerful and highly scalable with compute.&lt;/li&gt;
&lt;li&gt;Learning 2: The world is very complex. The content of our minds reflects this
extreme complexity. But the mental processes and meta-methods that we use to
capture and represent this arbitrary complexity should we built into AI
systems. We want AI agents to use our discovering process and not need the
knowledge we have discovered.&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Offline Reinforcement Learning</title><link>https://bharathbhushan1.github.io/blog/posts/2026-06-13-offline-rl/</link><pubDate>Sat, 13 Jun 2026 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2026-06-13-offline-rl/</guid><description>&lt;p&gt;A really nice insight about offline RL algorithms is that off-policy (but online)
algorithms can also be used for offline RL use cases. Structurally they have the same
inputs and same kind of outputs. But there is a fatal flaw.&lt;/p&gt;
&lt;p&gt;For out-of-distribution (OOD) actions, the estimated Q value for off-policy algorithms
can never be corrected. These actions are never present in the dataset and can never
really be learnt from. So there is catastrophic overestimation for OOD actions.&lt;/p&gt;</description></item><item><title>fast.ai course</title><link>https://bharathbhushan1.github.io/blog/posts/2019-06-16-fast-ai/</link><pubDate>Sun, 16 Jun 2019 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-06-16-fast-ai/</guid><description>&lt;p&gt;I have started working on the &lt;a href="https://course.fast.ai"&gt;fast.ai course&lt;/a&gt;. This is the Practical Deep Learning for Coders, v3 course. Strangely the 7 lessons made this course more approachable than others on Coursera/Stanford. Jeremy Howard, the creator of the course, is a brilliant guy and it shows in the way the course is presented. Lots of intuition and tuning knowledge has been embedded in the fast.ai library with the various default hyperparameter values being carefully chosen after a lot of experimentation.&lt;/p&gt;</description></item><item><title>Random stuff</title><link>https://bharathbhushan1.github.io/blog/posts/2019-05-03-random-stuff/</link><pubDate>Fri, 03 May 2019 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-05-03-random-stuff/</guid><description>&lt;ul&gt;
&lt;li&gt;A new paper &lt;a href="https://twitter.com/DeepMindAI/status/1123979484485570566"&gt;Reinforcement Learning, Fast and Slow&lt;/a&gt; from DeepMind reviews recent techniques and improvements in deep Reinforcement Learning. This paper talks about eposodic-RL, meta-RL and its combination.&lt;/li&gt;
&lt;li&gt;A &lt;a href="https://www.nature.com/articles/s41586-019-1119-1"&gt;paper&lt;/a&gt; on technology that can translate neural activity into speech. Mind-blowing.&lt;/li&gt;
&lt;li&gt;Style transfer is such an interesting topic. The seminal &lt;a href="https://arxiv.org/abs/1508.06576"&gt;paper&lt;/a&gt; on this is from the &lt;a href="http://bethgelab.org"&gt;Bethge Lab&lt;/a&gt; and is titled &lt;em&gt;A Neural Algorithm of Artistic Style&lt;/em&gt;. A summary article is &lt;a href="https://towardsdatascience.com/towards-fast-neural-style-transfer-191012b86284"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Decision Trees</title><link>https://bharathbhushan1.github.io/blog/posts/2019-04-22-decision-trees/</link><pubDate>Mon, 22 Apr 2019 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-04-22-decision-trees/</guid><description>&lt;p&gt;This is a short post on decision trees based on my reading of Chapter 6 of &lt;a href="https://www.amazon.in/Hands-Machine-Learning-Scikit-Learn-TensorFlow/dp/1491962291"&gt;Hands–On Machine Learning with Scikit–Learn and TensorFlow &lt;/a&gt;. I am just listing out some interesting points. The book is really good; so please refer to it.&lt;/p&gt;
&lt;h3 id="basics"&gt;Basics&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Decision trees do not require much data preparation (feature scaling, centering etc).&lt;/li&gt;
&lt;li&gt;Gini score indicates impurity of a decision tree node (do all training examples belong to a single class or not)&lt;/li&gt;
&lt;li&gt;CART algorithm to produce a decision tree produces binary trees. ID3 produces trees whose nodes can have more than 2 children.&lt;/li&gt;
&lt;li&gt;Decision trees are white box models because it is easy to see why the decisions were made. Neural networks / Random forests are black box because of the lack of interpretability.&lt;/li&gt;
&lt;li&gt;Decision trees are very easy to apply manually.&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Playing with LSTM</title><link>https://bharathbhushan1.github.io/blog/posts/2019-04-20-playing-with-lstm/</link><pubDate>Sat, 20 Apr 2019 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-04-20-playing-with-lstm/</guid><description>&lt;p&gt;I was trying to learn the basics of LSTM and found this &lt;a href="https://pytorch.org/tutorials/beginner/nlp/sequence_models_tutorial.html"&gt;pytorch tutorial&lt;/a&gt;. Starting from there I tried out the parts-of-speech tagger with minor modifications.&lt;/p&gt;
&lt;h3 id="1-import-the-necessary-libraries"&gt;1. Import the necessary libraries&lt;/h3&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import numpy as np
torch.manual_seed(1)
&lt;/code&gt;&lt;/pre&gt;</description></item><item><title>Summary of a blog post by Kyunghyun Cho</title><link>https://bharathbhushan1.github.io/blog/posts/2019-04-19-summary-of-blog-post/</link><pubDate>Fri, 19 Apr 2019 20:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-04-19-summary-of-blog-post/</guid><description>&lt;p&gt;&lt;a href="https://twitter.com/kchonyc"&gt;Kyunghyun Cho&lt;/a&gt; had written (in 2015) a &lt;a href="https://sites.google.com/site/deepernn/home/blog/briefsummaryofthepaneldiscussionatdlworkshopicml2015"&gt;blog post&lt;/a&gt; titled &lt;em&gt;Brief Summary of the Panel Discussion at DL Workshop @ICML 2015&lt;/em&gt;. I found the post interesting and below is a quick summary.&lt;/p&gt;
&lt;p&gt;The panelists talked about the following topics as the future of deep learning.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Deep learning for NLP&lt;/li&gt;
&lt;li&gt;Unsupervised learning&lt;/li&gt;
&lt;li&gt;Medical image analysis&lt;/li&gt;
&lt;li&gt;Drug discovery&lt;/li&gt;
&lt;li&gt;Q&amp;amp;A systems&lt;/li&gt;
&lt;li&gt;Sequential decision making&lt;/li&gt;
&lt;li&gt;DL for Non-cognitive tasks&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Also there was some content about AI hype, General AI, academia vs industry etc.&lt;/p&gt;</description></item><item><title>Video summary: Adaptive Communication Strategies in Local-Update SGD</title><link>https://bharathbhushan1.github.io/blog/posts/2019-04-19-video-summary-adaptive-communication/</link><pubDate>Fri, 19 Apr 2019 12:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-04-19-video-summary-adaptive-communication/</guid><description>&lt;p&gt;This is a summary of the video &lt;a href="https://youtu.be/RTGb-sbK19s"&gt;Adaptive Communication Strategies in Local-Update SGD&lt;/a&gt; from &lt;a href="https://www.sysml.cc"&gt;SysML 2019&lt;/a&gt; conference.&lt;/p&gt;
&lt;p&gt;Datasets as well as ML models are becoming larger. So SGD on a single machine is slow. Generally we need to optimise &lt;em&gt;Error Convergence&lt;/em&gt; (actual training progress per iteration). But in a distributed setting we also need to optimise &lt;em&gt;System Throughput&lt;/em&gt; (iterations per unit of wall-clock time). Ideally we need to focus on both (actually the product of the two, which is training progress per unit of wall-clock time).&lt;/p&gt;</description></item><item><title>Paper summary: Document Expansion by Query Prediction</title><link>https://bharathbhushan1.github.io/blog/posts/2019-04-19-paper-summary-document-expansion/</link><pubDate>Fri, 19 Apr 2019 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-04-19-paper-summary-document-expansion/</guid><description>&lt;p&gt;This is a short summary of the paper &lt;a href="https://arxiv.org/abs/1904.08375"&gt;Document Expansion by Query Prediction&lt;/a&gt; by Rodrigo Nogueira, Wei Yang, Jimmy Lin, and Kyunghyun Cho.&lt;/p&gt;
&lt;p&gt;When a search engine wants to find a document, it uses its index. The costly parts of the ranking algorithm are usually implemented as re-rankers which take the top-n search results and then reorder them (or re-rank them).&lt;/p&gt;
&lt;p&gt;This paper has a doc2query ML model which takes a document and comes up with queries which are well answered by the document. Then the query is attached to the document as metadata.&lt;/p&gt;</description></item><item><title>Alternatives to SGD</title><link>https://bharathbhushan1.github.io/blog/posts/2019-04-19-alternatives-to-sgd/</link><pubDate>Tue, 05 Mar 2019 20:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2019-04-19-alternatives-to-sgd/</guid><description>&lt;p&gt;&lt;img alt="SGD" loading="lazy" src="https://sebastianraschka.com/images/faq/closed-form-vs-gd/ball.png"&gt;&lt;/p&gt;
&lt;p&gt;Mini-batch SGD has been the mainstay of algorithms to optimise the cost function in neural networks. But there are multiple alternatives.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Hessian optimization&lt;/li&gt;
&lt;li&gt;Momentum based techniques&lt;/li&gt;
&lt;li&gt;BFGS and its variants&lt;/li&gt;
&lt;li&gt;Nesterov&amp;rsquo;s accelerated gradient&lt;/li&gt;
&lt;li&gt;&amp;hellip;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>GPU: CUDA architecture</title><link>https://bharathbhushan1.github.io/blog/posts/2017-11-02-cuda-architecture/</link><pubDate>Thu, 02 Nov 2017 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2017-11-02-cuda-architecture/</guid><description>&lt;p&gt;CUDA is Nvidia’s initiative to define a programming model and hardware architecture which aims to allow GPUs to be unified with CPUs for compute. There are various aspects of CUDA and we will try to gain an appreciation for it in this article.&lt;/p&gt;
&lt;p&gt;An application which wants to use GPU for some general purpose compute has to define a kernel function (C interface). This kernel function is run on lots of data elements in parallel. Each GPU can run different kernels, possibly from different applications. One kernel submitted to the GPU runs as a grid. Each grid consists of many thread blocks. Each thread block consists of many threads.&lt;/p&gt;</description></item><item><title>GPU: Nvidia architectures</title><link>https://bharathbhushan1.github.io/blog/posts/2017-11-01-gpu-nvidia-architectures/</link><pubDate>Wed, 01 Nov 2017 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2017-11-01-gpu-nvidia-architectures/</guid><description>&lt;p&gt;GPU microarchitectures: Tesla -&amp;gt; Fermi -&amp;gt; Kepler -&amp;gt; Maxwell -&amp;gt; Pascal -&amp;gt; Volta&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;AWS P3 uses Tesla V100 cards — Volta microarchitecture.&lt;/li&gt;
&lt;li&gt;AWS G3 uses Tesla M60 cards — Maxwell microarchitecure.&lt;/li&gt;
&lt;li&gt;AWS G2 uses Tesla GRID K520 cards — Kepler microarchitecture.&lt;/li&gt;
&lt;li&gt;AWS P2 uses Tesla K80 cards (GK210 GPU) — Kepler microarchitecture.&lt;/li&gt;
&lt;li&gt;AWS CG1 uses Tesla M2050 cards — Fermi microarchitecture.&lt;/li&gt;
&lt;li&gt;GCE provides K80 and P100.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A tensorcore is a logic circuit which allows 16x16 matrix multiplication followed by addition as a primitive. This speeds up the inner loops of deep learning programs.&lt;/p&gt;</description></item><item><title>Tensorflow — Simple Transformations</title><link>https://bharathbhushan1.github.io/blog/posts/2016-11-23-tensorflow-simple-transformations/</link><pubDate>Wed, 23 Nov 2016 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2016-11-23-tensorflow-simple-transformations/</guid><description>&lt;p&gt;I am trying out stuff from &lt;a href="http://learningtensorflow.com/lesson3/"&gt;http://learningtensorflow.com/lesson3/&lt;/a&gt; which talks about simple image transformations using tensorflow. I am trying this out in zeppelin + pyspark.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;sh&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;wget&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;learningtensorflow&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;MarshOrchid&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;jpg&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;readlink&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="n"&gt;MarshOrchid&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;jpg&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;--------------------------------------------------------------------&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;pyspark&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;np&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;StringIO&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;matplotlib&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;matplotlib&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Agg&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# turn off interactive charting so this works for server side SVG rendering&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;matplotlib&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;matplotlib.image&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;mpimg&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;img&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;StringIO&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StringIO&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;savefig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;svg&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;seek&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;%html &amp;lt;div style=&amp;#39;width:600px&amp;#39;&amp;gt;&amp;#34;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;&amp;lt;/div&amp;gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;--------------------------------------------------------------------&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;pyspark&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clf&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;filename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="n"&gt;MarshOrchid&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;jpg&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mpimg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;imread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;tf&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reset_default_graph&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tf&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Variable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;init&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tf&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;initialize_all_variables&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;tf&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Session&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;sess&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;rotate1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tf&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transpose&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;perm&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;sess&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;init&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;result1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sess&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rotate1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;121&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;imshow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;122&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;imshow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;show&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Tensorflow — Order of fetches</title><link>https://bharathbhushan1.github.io/blog/posts/2016-11-21-tensorflow-order-of-fetches/</link><pubDate>Mon, 21 Nov 2016 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2016-11-21-tensorflow-order-of-fetches/</guid><description>&lt;p&gt;I am playing with Tensorflow and found this interesting effect. The following code fragment gives different results each time you run it.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;tf.reset_default_graph()
state = tf.Variable(2.0, name=”state”)
one = tf.constant(1.0, name=”one”)
update = tf.assign(state, tf.add(state, one))
init = tf.initialize_all_variables()
with tf.Session(config=config) as sess:
sess.run(init)
result = sess.run([update, state])
print(result)
result = sess.run([update, state])
print(result)
[3.0, 2.0]
[4.0, 3.0]
[3.0, 2.0]
[4.0, 4.0]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It looks like the order of fetches in Tensorflow is not fixed. For tensors, they might be evaluated after the ops or before the ops. Depending on the actual order the fetch result will be different.&lt;/p&gt;</description></item><item><title>g2.2xlarge GPU basics</title><link>https://bharathbhushan1.github.io/blog/posts/2016-11-12-g2-2xlarge-gpu-basics/</link><pubDate>Sat, 12 Nov 2016 12:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2016-11-12-g2-2xlarge-gpu-basics/</guid><description>&lt;p&gt;A Graphics Processing Unit is a specialized processor usually sitting on a special card with its own memory. It does not have interrupts or virtual memory.&lt;/p&gt;
&lt;p&gt;For example EC2&amp;rsquo;s g2.2xlarge machine has the following graphics card.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;00:03.0 VGA compatible controller: nVidia Corporation GK104GL [GRID K520] (rev a1)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href="https://www.techpowerup.com/gpudb/2312/grid-k520"&gt;GRID K520&lt;/a&gt; belongs to Nvidia&amp;rsquo;s Tesla card series and has GRID support (which allows GPU sharing). It plugs into a PCI slot on the motherboard. Each such card has 2 GK104GL GPUs, two 4GB RAM units, and 2x1536 CUDA cores. I will explain in detail below.&lt;/p&gt;</description></item><item><title>What is Machine Learning: Part 2</title><link>https://bharathbhushan1.github.io/blog/posts/2016-11-12-what-is-machine-learning-part-2/</link><pubDate>Sat, 12 Nov 2016 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2016-11-12-what-is-machine-learning-part-2/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Arthur Samuel described it as: &amp;ldquo;the field of study that gives computers the ability to learn without being explicitly programmed.&amp;rdquo;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Basically the computer can be taught to do a particular task and once the learning is complete the computer can do that task well on its own. So the programming was not task specific, only the learning process was task specific. Something like public key encryption - the algorithms are public but the key ensures confidentiality and integrity.&lt;/p&gt;</description></item><item><title>Machine Learning Course: Part 1</title><link>https://bharathbhushan1.github.io/blog/posts/2016-11-11-machine-learning-course-part-1/</link><pubDate>Fri, 11 Nov 2016 10:00:00 +0000</pubDate><guid>https://bharathbhushan1.github.io/blog/posts/2016-11-11-machine-learning-course-part-1/</guid><description>&lt;p&gt;I just started the online Coursera course for &lt;a href="https://www.coursera.org/learn/machine-learning/lecture/RKFpn/welcome"&gt;Machine Learning&lt;/a&gt; by Andrew Ng. For the past couple of years I waded through the big data world a bit. Now I am trying to understand a bit of machine learning. (Also this &lt;a href="http://cs229.stanford.edu/materials.html"&gt;page&lt;/a&gt; has lot of material).&lt;/p&gt;
&lt;p&gt;What hit me was the broad scope of machine learning. So it is really exciting and interesting to start on this journey which will hopefully wake me up from my lazy technical hibernation.&lt;/p&gt;</description></item></channel></rss>