<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aniruddha Kembhavi on Medium]]></title>
        <description><![CDATA[Stories by Aniruddha Kembhavi on Medium]]></description>
        <link>https://medium.com/@anikembhavi?source=rss-a67b0d005653------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*7NGeOGrWsEUrBgtejtWoIA.png</url>
            <title>Stories by Aniruddha Kembhavi on Medium</title>
            <link>https://medium.com/@anikembhavi?source=rss-a67b0d005653------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 13:34:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anikembhavi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Test comment from Ani]]></title>
            <link>https://medium.com/@anikembhavi/test-comment-from-ani-459396507aa4?source=rss-a67b0d005653------2</link>
            <guid isPermaLink="false">https://medium.com/p/459396507aa4</guid>
            <dc:creator><![CDATA[Aniruddha Kembhavi]]></dc:creator>
            <pubDate>Tue, 26 Jan 2021 22:35:06 GMT</pubDate>
            <atom:updated>2021-01-26T22:35:06.562Z</atom:updated>
            <content:encoded><![CDATA[<p>Test comment from Ani</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=459396507aa4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The lure of the outer product]]></title>
            <link>https://medium.com/ai2-blog/the-lure-of-the-outer-product-4addd2e7f95e?source=rss-a67b0d005653------2</link>
            <guid isPermaLink="false">https://medium.com/p/4addd2e7f95e</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[visual-question-answering]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Aniruddha Kembhavi]]></dc:creator>
            <pubDate>Sun, 16 Jun 2019 21:16:49 GMT</pubDate>
            <atom:updated>2019-06-16T21:16:49.703Z</atom:updated>
            <content:encoded><![CDATA[<h4>Bilinear pooling and its approximations for Visual Question Answering</h4><p><a href="https://medium.com/ai2-blog/vanilla-vqa-adcaaaa94336">Vanilla architectures for Visual Question Answering (VQA)</a> represent the image by a feature vector known as an <em>image embedding</em>, embed the question into a <em>question embedding</em> and then combine the two modalities using simple element-wise operations. This aggregated vector is then provided to a multilayer perceptron to obtain a distribution over the set of possible answers.</p><p>A common extension to these vanilla models is to add an attention module that computes an affinity referred to as an <em>attention score</em> between the question and each region in the image. The resulting <em>attention vector</em> dictates which regions of the image the model should focus on, in order to answer the given question. This affinity computation is usually done using element-wise operations between the two modalities. Learn more about attention modules for VQA in a <a href="https://medium.com/ai2-blog/may-i-have-your-attention-please-eb6cfafce938">previous post</a>.</p><p>The key element in both the above cases is the nature of interaction between a question embedding and an image embedding. Modeling these interactions as element-wise operations works well but only models a subset of the interactions that are possible between two vectors. A far more powerful interaction is the outer product of the two vectors. In this post, I will discuss the outer product interaction applied to VQA, the practical difficulties in modeling this and the approximations used instead.</p><h3>The outer product</h3><p>Given an image embedding v_I ∈ ℝ^<em>(d</em>x<em>1)</em> and a question embedding v_Q ∈ ℝ^<em>(d</em>x<em>1)</em>, a simple way to combine them is using a Hadamard product, i.e. an element-wise multiplication. This allow elements in the same position within each embedding to interact in a multiplicative fashion, resulting in the aggregated vector z ∈ ℝ^<em>(d</em>x<em>1)</em>.</p><blockquote><em>z =v_I ⊙ v_Q</em></blockquote><p>Another method is to learn this affinity via a parametric neural network. This network typically projects the embeddings into a lower dimensional space and then combines them using an element-wise multiplication operation.</p><blockquote><em>𝕫 = ( W_I × v_I+b_I ) ⊙ ( W_Q × v_Q + b_Q )</em></blockquote><blockquote><em>z = W_z × 𝕫 + b_z</em></blockquote><p>where W_I ∈ ℝ^<em>(k </em>x <em>d)</em> and W_Q ∈ ℝ^<em>(k </em>x <em>d)</em> project the embeddings into a <em>k</em> dimensional space before the element-wise multiplicative interaction and then <em>W_z </em>∈ ℝ^<em>(k </em>x <em>θ) </em>is used to project the resulting vector into the desired dimension.</p><p>The above methods of interaction only allow elements in the same position within the two input embeddings to interact in a multiplicative fashion. A far more powerful mechanism results when each element in the first embedding interacts multiplicatively with every element in the second embedding. The outer product of the two embeddings, represented as ⊗ does precisely this; and results in a matrix P ∈ ℝ^<em>(d </em>x d<em>)</em>.</p><blockquote><em>P = v_I ⊗ v_Q = v_I × v^T_Q</em></blockquote><p><em>Note: In the above equation, ^T refers to the matrix transpose and × refers to the regular matrix multiplication.</em></p><p>A common mechanism to incorporate the outer product into an interaction between the two embeddings is via the mechanism of bilinear pooling. This is essentially an outer product</p><blockquote><em>P = v_I ⊗ v_Q</em></blockquote><p>followed by a reshaping of the matrix <em>P</em> into <em>ℙ </em>∈ ℝ^<em>(d² </em>x<em> 1)</em></p><blockquote>ℙ <em>= reshape(P)</em></blockquote><p>followed by a linear projection of the result to obtain the output of the interaction <em>z</em> ∈ ℝ^<em>(θ </em>x<em> 1)</em></p><blockquote>z = W_P × ℙ</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*3edtzVxZ0srN2eyzm7ontw.png" /></figure><p><strong>Bilinear pooling</strong> using the outer product is an incredibly powerful way to model the interaction between two input vectors but it requires learning the large parameter matrix <em>W_P</em>. For instance, if the dimensionality <em>d</em> of the input embeddings is 1024 and the dimensionality θ of the output embedding is 2000, <em>W_P</em> has 1024 * 1024 * 2000 = 2 billion parameters! Representing this matrix would require a large amount of memory and learning these parameters would require a lot of training data and would be very slow. This is clearly infeasible and impractical.</p><p>Below, I will outline a few methods that have been proposed over the last couple of years to approximate this outer product for VQA, so as to harness most of its power while still keeping the memory footprint manageable.</p><h3>Multimodal Compact Bilinear Pooling</h3><p>One of the first successful uses of the outer product (or rather, an approximation of it) in VQA was Multimodal Compact Bilinear Pooling (MCB). At the heart of the MCB technique is a probabilistic data structure called the Count Sketch. To understand MCB, we need to digress into the world of Sketching.</p><h4>Sketches</h4><p>Sketches are data structures that allow you to represent a very large stream of numbers (or a vector) in a highly compact fashion. These data structures are lossy and not reversible, in that the original data cannot be exactly recovered from them. However, they are capable of answering a class of queries about the stream of data <em>(for example: Counts of unique objects present in the input stream) </em>while providing accuracy guarantees.</p><p>Let’s say we wanted to maintain the counts of numbers seen in the large array named input_stream. A trivial and lossless method to do this would be using a dictionary.</p><pre>// Using a dictionary to count items</pre><pre>count_store = dict()</pre><pre>def process_stream(input_stream):<br>  for element in input_stream:<br>      if element not in count_store:<br>          count_store[element] = 1<br>      else:<br>          count_store[element] += 1</pre><pre>def query_element_count(element):<br>  if element in count_store:<br>    return count_store[element]<br>  else:<br>    return 0</pre><p>If the number of unique elements η in the stream is very large, this dictionary (which stores the hash of each item and its count) becomes very large and may become infeasible in many applications.</p><p>Instead, let’s initialize an array (counter_array)with κ counters, each one initially set to 0. As we read each element in input_stream, we map it to a position in counter_arrayvia a hash function, and then increment the corresponding counter by 1. Now, when we want to query the count of an entity, we simply map it to a location using the same hash function and read out the value stored in the counter at that location.</p><p>If κ = η, this is equivalent to the dictionary method of storing counts and is infeasible. However, if κ &lt;&lt; η, the memory footprint of this storage system gets much smaller and becomes manageable. The problem with this scenario is that multiple elements in input_streamwill begin mapping to the same position within counter_array (also known as hash collisions). This will lead to over estimating the counts of elements, since a given counter will actually return a sum of the counts for a few different elements. This is clearly problematic and won’t work.</p><p>To alleviate this, one uses N counter arrays, each with its corresponding hash function mapping elements to positions. When an element is encountered within input_stream, it gets mapped to a unique location within each counter array and the counters at those location gets incremented by 1. Now, when we want to query the count of an entity we use the same hash functions to retrieve a set of values, one from each counter array; and return the minimum value. While there will still be errors in the count, using multiple arrays provides far better results with theoretical guarantees. This simple algorithm is known as the Count-Min Sketch.</p><pre>// Count_Min algorithm</pre><pre># N = number of counter arrays<br># kappa = number of counters in each array<br>counter_matrix = np.zeros([N, kappa])</pre><pre>def process_stream(input_stream):<br>  for element in input_stream:<br>    for counter_id in range(N):<br>      position = hash_function(counter_id, element)<br>      counter_matrix[counter_id, position] += 1</pre><pre>def query_element_count(element):<br>  counts = np.zeros(N)  <br>  for counter_id in range(N):<br>    position = hash_function(counter_id, element)<br>    counts[counter_id] = counter_matrix[counter_id, position]<br>  return np.min(counts)</pre><p>The Count Sketch is very similar to Count-Min Sketch with 2 differences: (a) Each time an element is processed, two hash functions are invoked: One determines the position within the counter array. The other chooses between incrementing the counter by 1 vs decrementing the counter by 1. (b) At query time, given an element, we first retrieve the set of counts as before, but we now use the median instead of the min.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*2XgfyAq8aZbPeo9UaZpkKw.png" /></figure><p>The counter arrays produced by these algorithms are very compact and yet quite informative. They can be thought of as a compact lossy representation of the input stream that can be used in other downstream tasks.</p><h4>Back to the VQA world</h4><p>MCB employs Count Sketch to represent its question and image embeddings and then processes these representations to obtain the answer. The input stream described above is a series of integers with repetitions where as the question and image embeddings are vectors with floating point entires. This requires modifying the Count Sketch algorithm slightly, resulting in <a href="http://chbrown.github.io/kdd-2013-usb/kdd/p239.pdf">Tensor Sketch</a>. The main difference is that counters are now updated by the magnitude of the floating point element instead of by 1.</p><p>However, one key question remains unanswered: <strong><em>Why does MCB use Count Sketch as a representation and not some other ?</em></strong></p><p>An interesting property of the Count Sketch representation, proven by <a href="http://chbrown.github.io/kdd-2013-usb/kdd/p239.pdf">Pham et al.</a> is that the count sketch <em>(represented by ℂ)</em> of the outer product of two vectors is equivalent to the convolution (denoted as <em>*</em>) of their count sketches.</p><blockquote>ℂ(v_I ⊗ v_Q) = ℂ(v_I) * ℂ(v_Q)</blockquote><p>Furthermore, convolution in the time domain is equivalent to element-wise multiplication in the frequency domain. This results in:</p><blockquote>ℂ(v_I ⊗ v_Q) = IFFT( FFT(ℂ(v_I)) ⊙ FFT(ℂ(v_Q)) )</blockquote><p>As a result of this, one can now allow <em>v_I </em>and <em>v_Q</em> to interact via an outer product by simply computing their Count Sketch vectors which is straightforward, followed by 2 FFT transforms, 1 IFFT transform and a point-wise multiplication.</p><p>The entire VQA pipeline with the MCB module enabling a rich interaction between the input embeddings is shown below. This pipeline is quite powerful and it outperforms models that only employ point-wise multiplication as an interaction mechanism between the two modalities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*NRIiTx1RGXfxcd-H4XzpXg.png" /></figure><p>However, MCB does have a critical shortcoming: As described above, the errors introduced by the Count Sketch operation are a result of hash collisions. Larger the counter array, smaller the probability of a collision. It turns out that for MCB to be effective, the length of the Count Sketch vector needs to be very large. In the MCB paper, they employed a dimensionality of 16000, resulting in a very large memory footprint. While still smaller than the memory required to perform a full outer product based interaction, this large footprint is cumbersome, especially when multiple MCB modules might need to be inserted into a single neural pipeline.</p><p>Learn more about Tensor Sketch here:</p><blockquote><strong>Fast and Scalable Polynomial Kernels via Explicit Feature Maps</strong></blockquote><blockquote>Ninh Pham, Rasmus Pagh</blockquote><blockquote>KDD 2013</blockquote><p>Learn more about MCB here:</p><blockquote><a href="https://arxiv.org/pdf/1606.01847"><strong>Multimodal Compact Bilinear Pooling for Visual Question Answering and Visual Grounding</strong></a></blockquote><blockquote>Akira Fukui, Dong Huk Park, Daylen Yang, Anna Rohrbach, Trevor Darrell, Marcus Rohrbach</blockquote><blockquote>EMNLP 2016</blockquote><h3>Multimodal Factorized Bilinear Pooling</h3><p>Another mechanism to exploit the power of bilinear pooling without a surge in the memory footprint of the model is to employ some matrix factorization tricks, as was done in work named <a href="http://openaccess.thecvf.com/content_ICCV_2017/papers/Yu_Multi-Modal_Factorized_Bilinear_ICCV_2017_paper.pdf">Multimodal Factorized Bilinear Pooling</a> (MFB).</p><p>Given an image embedding v_I ∈ ℝ^<em>(d</em>x<em>1)</em> and a question embedding v_Q ∈ ℝ^<em>(d</em>x<em>1), </em>the outer product described above can be concisely written as:</p><blockquote>z_i = v^T_I × W_i × v_Q</blockquote><p>where<em> z_i</em> is the i-th element of <em>z</em> ∈ ℝ^<em>(θ </em>x<em> 1), × </em>denotes regular matrix multiplication and ^T refers to a matrix transpose. <em>W_i</em> ∈ ℝ^<em>(d </em>x<em> d) </em>and we need to learn θ of them which results in learning d x d x θ parameters, clearly a daunting task.</p><p>This can be simplified by factorizing <em>W_i</em> into two low rank matrices L and M.</p><blockquote>z_i = v^T_I × <strong>(L_i × M^T_i)</strong> × v_Q</blockquote><p>where L_i ∈ ℝ^<em>(d </em>x<em> k) </em>and M_i ∈ ℝ^<em>(d </em>x<em> k) </em>with k representing the latent dimensionality of these matrices. A lower value of <em>k</em> leads to fewer parameters but adds more constraints on the resulting <em>W_i</em> and thus may lead to a less powerful model.</p><p>This can further be rewritten as</p><blockquote>z_i = <strong>1</strong>^T<strong> ( </strong>(L^T_i × v_I) ⊙ (M^T_i × v_Q) <strong>)</strong></blockquote><p>The number of parameters now reduces from the enormous d x d x θ to a more manageable d x k x θ for <em>L^T</em> and d x k x θ for <em>M^T.</em></p><p>In fact MFB with a fewer number of parameters than MCB, performs better than MCB on standard benchmarks.</p><p><strong><em>Another take:</em></strong> Looking at the above equation, it’s interesting to note that MFB starts to look quite different from an outer product, and in fact starts resembling a point-wise operation between the two modalities. The <em>L_i</em> and <em>M_i </em>can be thought of as simple projection matrices to project the input embeddings into a k dimensional space. This is followed by a point-wise operation and an element summation operation. But this only results in a single element in the output vector <em>z</em>. This is repeated θ number of times. Hence one can think of this technique as a <strong><em>multi-head point-wise operation</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*fxKp6_mt3SBVJXDfpYKjaA.png" /></figure><p>Learn more about Multimodal Factorized Bilinear Pooling here:</p><blockquote><strong>Multi-modal Factorized Bilinear Pooling with Co-Attention Learning for Visual Question Answering</strong></blockquote><blockquote>Zhou Yu, Jun Yu, Jianping Fan, Dacheng Tao</blockquote><blockquote>ICCV 2017</blockquote><h3>Multimodal Tucker Fusion</h3><p>Another method to incorporate the outer product operation without leading to a huge increase in parameters is to use the Tucker decomposition of the parameter matrix, as was done in the work <a href="https://arxiv.org/pdf/1705.06676">Multimodal Tucker Fusion (MUTAN)</a>.</p><p>The full bilinear pooling operation described above between the image and question embedding can be written as</p><blockquote>z = ( W ×:1 v_Q ) ×:2 v_I</blockquote><p>where <em>×: i </em>refers to the i-mode product between a tensor and a matrix. <em>W</em> ∈ ℝ^<em>(d </em>x<em> d </em>x<em> θ) </em>is the large parameter matrix that needs to be learnt.</p><p>W can be decomposed into a tensor ψ ∈ ℝ^<em>(k </em>x<em> k </em>x<em> o) </em>and 3 factor matrices <em>W_q </em>∈ ℝ^<em>(d </em>x<em> k)</em>, <em>W_i </em>∈ ℝ^<em>(d </em>x<em> k)</em> and <em>W_z </em>∈ ℝ^<em>(θ </em>x<em> o) </em>using a Tucker decomposition.</p><blockquote>W = ((ψ ×:1 W_q) ×:2 W_i) ×:3 W_z</blockquote><p>The bilinear pooling operation can then be rewritten as:</p><blockquote>z = ( (ψ ×:1 (𝕧_Q)) ×:2 𝕧_I )^T W_z</blockquote><p>where 𝕧_Q = v^T_Q × W_q is the projection of v_Q using W_q and 𝕧_I = v^T_I × W_i is the projection of v_I using W_i. The above equation represents a full bilinear pooling operation between 𝕧_Q and 𝕧_I followed by a projection using W_z. The number of parameters reduces from the enormous d x d x θ to a more manageable d x k for <em>W_q</em> , d x k for W_i, o x θ for W_z and k x k x o for ψ<em>.</em></p><p>To summarize the MUTAN method, the question and image embeddings are projected onto lower dimensions followed by a full bilinear pooling operation and then projected into the desired output dimension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*1MXD_aR1RqVsSieEFS0Peg.png" /></figure><p>MUTAN also outperforms the expensive MCB method but results on standard benchmarks show that it does not outperform MFB. It is still an interesting method as it incorporates a full bilinear pooling, albeit at lower dimensions.</p><p>Learn more about MUTAN here:</p><blockquote><strong>MUTAN: Multimodal Tucker Fusion for Visual Question Answering</strong></blockquote><blockquote>Hedi Ben-younes, Rémi Cadene, Matthieu Cord, Nicolas Thome</blockquote><blockquote>ICCV 2017</blockquote><h3>Incorporating bilinear pooling into attention mechanisms</h3><p>The bilinear pooling operations described above enable rich interactions between two input embeddings and generate a resultant output embedding. Hence they can be applied in different parts of a VQA architecture, wherever a multimodal interaction takes place. In particular, there are two points in an attention based VQA architecture where bilinear pooling is usually employed.</p><ol><li>The core part of VQA attention is interaction between a question embedding and different image region embeddings. This is a perfect match for bilinear pooling. The result of the pooling operation is a tensor with an embedding for each attention. This tensor is then passed through convolution layers to finally result in the attention weight vector.</li><li>After the attention weights are used to linearly combine image embeddings into a final image embedding, this embedding undergoes an interaction with the question embedding to form the aggregated information vector. This interaction is also modeled by bilinear pooling.</li></ol><p>These applications of bilinear pooling to the attention based VQA architecture are shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*y8dO6LIXDyxWLREvvB17Hw.png" /></figure><h3>Conclusion</h3><p>To summarize, an outer product between two vectors is an extremely rich and powerful mechanism to combine them, in contrast to simple element wise operations. However, the raw outer product is prohibitively expensive and impractical to incorporate into VQA models.</p><p>To overcome this deficiency and yet extract some power from it, several versions of bilinear pooling have been proposed over the past few years. These have led to accuracy improvements over simpler interaction methods. I discussed some of the more prominent ones in this post.</p><p><em>Follow AI2 on Twitter </em><a href="http://twitter.com/allen_ai"><em>@allen_ai</em></a><em> | Follow Ani Kembhavi </em><a href="http://twitter.com/anikembhavi"><em>@anikembhavi</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4addd2e7f95e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ai2-blog/the-lure-of-the-outer-product-4addd2e7f95e">The lure of the outer product</a> was originally published in <a href="https://medium.com/ai2-blog">Ai2 Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[May I have your attention please ?]]></title>
            <link>https://medium.com/ai2-blog/may-i-have-your-attention-please-eb6cfafce938?source=rss-a67b0d005653------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb6cfafce938</guid>
            <category><![CDATA[attention-mechanism]]></category>
            <category><![CDATA[visual-question-answering]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Aniruddha Kembhavi]]></dc:creator>
            <pubDate>Thu, 13 Jun 2019 22:16:01 GMT</pubDate>
            <atom:updated>2019-06-14T00:25:50.718Z</atom:updated>
            <content:encoded><![CDATA[<h3>May I have your attention please?</h3><h4>The attention mechanism and its numerous variants explored in Visual Question Answering</h4><p><a href="https://medium.com/ai2-blog/vanilla-vqa-adcaaaa94336">Vanilla architectures for Visual Question Answering (VQA)</a> represent the question into a single question embedding vector, represent the entire contents of the image into a single image embedding vector, combine the two and then pass this into a multilayer perceptron to produce a distribution over all the answer choices. This works reasonably well over a wide variety of questions on standard VQA benchmarks.</p><p>Many questions however, require one to focus on specific parts of the image or certain words in the question or a combination of both. For example, consider the image and question below. Answering this question requires the model to focus on the tennis racket and tennis ball. The vanilla VQA model struggles to focus on such small yet relevant regions in images, primarily because the contents of the two modalities (image and text) get compressed into single vector representations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*uwXuho7OAxuBqdNBjari6w.png" /></figure><p>The attention mechanism is a clever architectural modification that enables neural networks to focus in onto small portions of the provided context. It was first proposed for the task of machine translation where the decoder could focus on relevant parts of the source language text as it generated the target language text. This improved the quality of machine translation beyond models that encoded the entire source text into a single embedding which was then provided to the decoder.</p><p>In the vision and language space, attention was first used for the task of image captioning and then quickly made its way to VQA models. In its early incarnations, it allowed the model to focus in onto small regions of the image, conditioned on the input question. In this post, I’ll discuss some basic methods to use attention mechanisms as well as discuss some advanced variations proposed over the past few years.</p><h3>Single Hop Attention</h3><p>There are many different ways to obtain embeddings for the question and the image for the purpose of VQA. I discuss some of those variations in a <a href="https://medium.com/ai2-blog/vanilla-vqa-adcaaaa94336">previous post</a>. For the purpose of this discussion, let’s assume the following embedding mechanisms (as shown in the figure below).</p><p><em>Question</em> : The question is passed through a bi-directional LSTM, following which the final hidden states from the two directions are concatenated to form the <em>d</em> dimensional question embedding. Let’s name this <em>v_Q</em> ∈ ℝ^<em>(d</em>x<em>1)</em>.</p><p><em>Image</em> : The image is passed through a CNN and the output of a late-stage convolution layer is extracted which results in a tensor of size <em>s×c×c</em>. One can think of this as dividing the image into a uniform grid of size <em>c×c</em> and then representing each of those regions with an <em>s</em> dimensional embedding. (Note: While this is a useful abstraction, it isn’t quite accurate since convolution and pooling operations lead to information transfer across spatial extents of tensors in a CNN which is dictated by the size of their receptive fields.)</p><p>In contrast to vanilla VQA architectures which represented the entire image as a single embedding, we now have a set of embeddings that represent different parts of the image. Representing the image as a set of region embeddings will allow the model to focus onto one or more of these regions. This tensor is reshaped and then projected via a linear transformation onto a <em>d</em> dimensional space, so as to match the dimensionality of the question embedding. Lets name the resultant matrix <em>v_I</em> ∈ ℝ^<em>(d</em>x<em>T)</em>, where <em>T=c </em>x <em>c</em>, and name the i-th column vector referring to the i-th region as <em>v_i</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*zBByJTP44a8lfADdixAT0Q.png" /></figure><p>The key element of the attention mechanism is the interaction between the question embedding and each of the image embeddings, that allows the network to focus on the different regions of image, conditioned on the question. Each interaction leads to a score referred to as an <em>attention weight</em> which signifies the relevance of that image region to the question, and the resulting vector of scores, <em>p_att</em>, is referred to as the <em>attention weight vector</em>. A <em>softmax</em> operation is applied to this vector which enforces that the attention weights sum to 1.</p><p>The interaction between the question and image regions can be modeled in several ways. One simple method is to compute the attention weight as a cosine similarity between the question and image embedding.</p><blockquote><em>p_att</em> = softmax(<strong>1 </strong>(<em>v_I</em> ⊙ <em>v_Q</em>))</blockquote><p>where ⊙ denotes the element-wise multiplication between each column of the matrix <em>v_I</em> and the column vector <em>v_Q</em>. <strong>1</strong> is a row vector of all ones and is used to sum the elements of the vector it is multiplied with.</p><p>This interaction is parameter free. A straightforward extension that works better is to make this interaction parametric such as:</p><blockquote>h_att = W_I × v_I ⊕ ( W_Q × v_Q + b_Q )</blockquote><blockquote>p_att = softmax( W_h × h_att + b_h)</blockquote><p>where <em>W_I</em> ∈ ℝ^<em>(k </em>x <em>d)</em> and <em>W_Q</em> ∈ ℝ^<em>(k </em>x <em>d)</em> project the embeddings into a <em>k </em>dimensional space, ⊕ denotes the element-wise addition between each column of the matrix and the full vector and <em>W_h</em> converts the <em>k</em>-dimensional attention values into a single score per interaction. (Note: × refers to regular matrix multiplication).</p><p>The attention weight vector <em>p_att</em>, that results from either of the above interaction methods, signifies the relevance of different parts of the image to the question. Higher the weight, more relevant the image region. Hence we use these attention weights to linearly combine the set of image embeddings are linearly to a single embedding vector. The resultant embedding <em>𝕧_I</em> can be thought of as a filtered version of the image contents that best help answer the question.</p><blockquote>𝕧_I = ∑_i (p_att[i] v_i)</blockquote><p>The rest of the VQA model resembles the vanilla architecture. The filtered image embedding is added to the question embedding to produce the aggregated vector <em>ϕ</em></p><blockquote>ϕ = 𝕧 + v_Q</blockquote><p>which is passed to a multi layer perceptron to obtain a distribution over the answer choices.</p><p>The entire network including the attention module is trained end-to-end by minimizing the cross entropy loss between the predicted answer distribution and the ground truth. This mechanism is depicted in the figure below. This is commonly known as single hop attention since the interaction between the question and image modalities occurs a single time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*mQ174rhjojTaruL7AIQh7g.png" /></figure><p>Attention mechanisms have been widely adopted in many different VQA architectures and have produced good gains in accuracy. Another interesting outcome of attention is the ability to visualize the attention weights. This is done by simply visualizing the weight vector as a heatmap, with large weights reflecting more relevant and small weights reflecting less relevant portions of the image.</p><p>The image below shows examples of the attention mechanism at work in a VQA model. (Note: The examples below are from a model that is a bit more sophisticated than a single hop attention model, but they still reveal the kinds of attention maps that result from such architectures.) It’s interesting to see that the model chooses to <em>attend</em> to the baseball glove to determine the sport, the sink to determine the room and the snow (essentially everywhere) to determine the season.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*TnxjIj77HiJJXbHr8LAZgQ.png" /></figure><h3>Multiple Hop Attention</h3><p>While a single attention hop allows models to focus on small regions of the image, certain questions may benefit from a series of attentions, each focussing on a different part of the image. For instance, consider the question: <em>What is the color of the bus next to the blue car ?</em>. This requires first localizing the blue car, and then subsequently finding a bus next to it and determining its color. This requires the model to focus on two parts of the image (the car and the bus). Research has shown that invoking the attention mechanism multiple times in a sequential fashion can improve the models performance.</p><p>Converting a single hop attention architecture to a two hop attention is conceptually straightforward. The output of the first attention hop is the aggregated information vector ϕ that is obtained as a sum of the question embedding and the filtered image embedding. ϕ which can be thought of as an augmented question given the first attention and is used as the question embedding for the next attention hop. The image embeddings are the same ones used in the first attention hop. This procedure can be repeated several times to produce a multi hop attention architecture as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*-pwo-JnXYoQsNLzOrQHFXQ.png" /></figure><p>This model can also be trained end to end using the same loss function as before. As before, the attention weights at each hop can be visualized as heatmaps. In the figure below, the model attends to several parts of the image (presumably to find the bicycle and basket) and then attends to the contents of the basket in the second hop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*8HsJpKyAaZepyPEL5U0FyQ.png" /></figure><p>Learn more about single and multi-hop VQA attention architectures here:</p><blockquote><a href="https://arxiv.org/pdf/1511.02274v2.pdf">Stacked Attention Networks for Image Question Answering</a></blockquote><blockquote>Zichao Yang, Xiaodong He, Jianfeng Gao, Li Deng, Alex Smola</blockquote><blockquote>CVPR 2016</blockquote><p>Two-hop architectures have shown improvements over single hop ones, but moving to more hops beyond two usually does not show significant gains. This is likely due to the fact that existing VQA datasets do not have many questions that require the model to hop around the image too many times and the fact that current mechanisms for adding hops aren’t capable enough to yield good results. More research efforts are needed in this direction.</p><h3>Attention as a conditional feature selection mechanism</h3><p>The process of attention between the question and image embeddings can be thought of as a conditional feature selection mechanism, where the set of features are the set of image region embeddings and the condition is the question embedding.</p><p>This idea can be applied to conditionally filter not just within the image regions but also within channels in the image embedding by computing an affinity matrix between the question and image embeddings, but then pooling across the spatial dimension to arrive at an attention weight for each channel of the image embedding tensor.</p><p>The standard VQA architectures use a single tensor extracted from the CNN as the image embedding, but the answer to the question may potentially lie in a different tensor in the network. For instance, if answering the question requires parsing the texture of an object, this information may potentially lie within a tensor in the earlier stages of the network. To account for this, one can use the attention mechanism to select amongst image embedding tensors at different layers of the CNN. The basic idea is to compute attention weights across all tensors, sum the weights within a tensor and then softmax across the layers to arrive at the attention weights (one for each layer of the CNN).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*nxHwHOsvgzgEnLuJVxRASA.png" /></figure><p>Learn more about similar ideas and their application to VQA and image captioning here:</p><blockquote><a href="http://openaccess.thecvf.com/content_cvpr_2018/papers/Nguyen_Improved_Fusion_of_CVPR_2018_paper.pdf">Improved Fusion of Visual and Language Representations by Dense Symmetric Co-Attention for Visual Question Answering</a></blockquote><blockquote>Duy-Kien Nguyen, Takayuki Okatani</blockquote><blockquote>CVPR 2018</blockquote><blockquote><a href="http://openaccess.thecvf.com/content_cvpr_2017/papers/Chen_SCA-CNN_Spatial_and_CVPR_2017_paper.pdf">SCA-CNN: Spatial and Channel-wise Attention in Convolutional Networks for Image Captioning</a></blockquote><blockquote>Long Chen, Hanwang Zhang, Jun Xiao, Liqiang Nie, Jian Shao, Wei Liu, Tat-Seng Chua</blockquote><blockquote>CVPR 2017</blockquote><h3>Attending to the image and question</h3><p>While the above VQA models are able to attend to specific portions of the image, it may also be useful to attend to certain words or phrases in the question as the model parses the image in search of the answer.</p><p>Conceptually, attending to the words in a question is similar to attending to the regions of an image. Just as the image is converted to a set of embeddings, one per region, the question is converted to a set of embeddings, one per word; and given a conditioning vector, the attention mechanism acts as a filter over the given set of word embeddings. There are several nuances to consider such as the nature of the conditioning vector, the order of the attention between the two modalities, etc. which lead to a few variations.</p><p>Some of these variations are discussed below and depicted in the following image.</p><p><em>Independent attention</em> : One method is to attend to the question words in a manner similar to the attention over image regions and do this independently at each attention hop. The question attends to the image regions, and the image attends to the question words and this is repeated across hops. The resultant aggregate vectors are from the two modalities are combined and processed to get the answer.</p><p><em>Independent attention with joint conditioning</em> : This method is similar to the above proposal but using an integrated conditioning vector, which is simply a sum of the two modal conditioning vectors at each attention hop.</p><p><em>Joint attention</em> : This method involves creating an affinity matrix C ∈ ℝ^<em>(T </em>x <em>N) </em>(T=number of image regions, N=number of words) that measures the relevance between every word in the question and every region in the image using a learnt affinity computation. <em>(Note: In the equation below ^T refers to a matrix transpose.)</em></p><blockquote>C = tanh(v_Q^T × W × v_I)</blockquote><p>This affinity matrix is transformed to a set of image attention weights (relevance scores per image region) either non parametrically by computing a max over each row or parametrically using a small neural network. Similarly, the affinity matrix is also transformed to a set of word attention weights (relevance scores per word). The attention weight vectors are finally used to obtain filtered versions of the image and word embeddings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*64Ed9UFTFjHw_w2x1aJ_Yg.png" /></figure><p>In each of the above methods, the result is a set of filtered embeddings. These vectors are combined and sent into an MLP to produce the answer distribution. Converting a model from a one side attention over image regions to a two sided attention over the question and image is a straightforward swap of the attention module and usually results in better performance.</p><p>Learn more about attending to the image region and question words here:</p><blockquote><a href="https://arxiv.org/pdf/1606.00061.pdf">Hierarchical Question-Image Co-Attention for Visual Question Answering</a></blockquote><blockquote>Jiasen Lu, Jianwei Yang, Dhruv Batra , Devi Parikh</blockquote><blockquote>Neurips 2016</blockquote><blockquote><a href="http://openaccess.thecvf.com/content_cvpr_2017/papers/Nam_Dual_Attention_Networks_CVPR_2017_paper.pdf">Dual Attention Networks for Multimodal Reasoning and Matching</a></blockquote><blockquote>Hyeonseob Nam, Jung-Woo Ha, Jeonghee Kim</blockquote><blockquote>CVPR 2017</blockquote><h3>Contextualizing image embeddings</h3><p>A common mechanism to contextualize word embeddings is to pass them through a bi-directional LSTM as is done with most present day VQA models. This adds context to each word embedding from its neighbors on both sides. Similarly, when the image is passed through a CNN, the receptive field of convolution and pooling operations adds a little bit of context to each image embedding from pixels in close proximity. Researchers have also experimented with more explicitly adding context to image embeddings.</p><p>An obvious way to add context to image embeddings is to pass them through a bi-directional LSTM (with 1 or more layers), in a manner very similar to word embeddings. Image embeddings obtained from a CNN represent information about regions that are uniformly spaced on a 2 dimensional grid. While passing them through a 1 dimensional recurrent model seems to break this assumption, many works (outside of VQA) have found that this works very well and does not degrade performance compared to a more complex 2-d network of processing units.</p><p>Another way to add neighboring context to image embeddings is to add self-attention layers to the image embeddings. This amounts to treating a single image embedding as a conditioning vector, use it to attend to the entire set of image embeddings and then create an aggregated vector that is a sum of the original embedding and the filtered embedding. The resulting aggregated vector now also contains information from the other regions in the image. This self attention is repeated for each image embedding, resulting in a set of contextualized image embeddings.</p><p>These methods are depicted in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*gR9ywqtXd11cJz2qYXIgcw.png" /></figure><p>Learn more about the effects of contextualizing image embeddings with recurrent models here:</p><blockquote><a href="https://www.microsoft.com/en-us/research/wp-content/uploads/2017/06/Multi-level-Attention-Networks-for-Visual-Question-Answering.pdf">Multi-level Attention Networks for Visual Question Answering</a></blockquote><blockquote>Dongfei Yu, Jianlong Fu, Tao Mei, Yong Rui</blockquote><blockquote>CVPR 2017</blockquote><p>Learn more about the effects of contextualizing image embeddings with self attention, including more sophisticated mechanisms than depicted above, in this paper:</p><blockquote><a href="https://arxiv.org/pdf/1812.05252.pdf">Dynamic Fusion with Intra- and Inter-modality Attention Flow for Visual Question Answering</a></blockquote><blockquote>Peng Gao, Zhengkai Jiang, Haoxuan You, Pan Lu, Steven Hoi, Xiaogang Wang, Hongsheng Li</blockquote><blockquote>CVPR 2019</blockquote><p>Also, a systematic architecture that incorporates multiple layers of self attention with cross attention is the Transformer architecture that has recently become quite popular in the vision and NLP communities. Learn more about Transformers here:</p><blockquote><a href="https://papers.nips.cc/paper/7181-attention-is-all-you-need.pdf">Attention Is All You Need</a></blockquote><blockquote>Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, Illia Polosukhin</blockquote><blockquote>NeurIPS 2017</blockquote><h3>Conclusion</h3><p>To summarize, the attention mechanism is a conceptually simple and effective mechanism to enable VQA models to focus on specific regions in an image and specific words in a question. Several variations have been proposed over the years, which has led to a gradual improvement in the performance of these models; and I have covered some key ones in the above discussion.</p><p>All the methods discussed above divide the image into a uniform grid of pixels and use their embeddings for attention. But recent works have created embeddings for non uniform segmentation masks obtained from an image as well as objects detected in the image, with the latter approach particularly effective and popular. I’ll discuss these approaches and more fun aspects of VQA in future blog posts. Stay tuned!</p><p><em>Follow AI2 on Twitter </em><a href="http://twitter.com/allen_ai"><em>@allen_ai</em></a><em> | Follow Ani Kembhavi </em><a href="http://twitter.com/anikembhavi"><em>@anikembhavi</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb6cfafce938" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ai2-blog/may-i-have-your-attention-please-eb6cfafce938">May I have your attention please ?</a> was originally published in <a href="https://medium.com/ai2-blog">Ai2 Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vanilla VQA]]></title>
            <link>https://medium.com/ai2-blog/vanilla-vqa-adcaaaa94336?source=rss-a67b0d005653------2</link>
            <guid isPermaLink="false">https://medium.com/p/adcaaaa94336</guid>
            <category><![CDATA[visual-question-answering]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Aniruddha Kembhavi]]></dc:creator>
            <pubDate>Thu, 13 Jun 2019 17:16:51 GMT</pubDate>
            <atom:updated>2019-06-13T17:16:51.491Z</atom:updated>
            <content:encoded><![CDATA[<h4>An introduction to Visual Question Answering</h4><p>Visual Question Answering (VQA) is the task of answering questions about a given piece of visual content such as an image, video or infographic. As seen in the examples below, answering questions about visual content requires a variety of skills include recognizing entities and objects, reasoning about their interactions with each other, both spatially and temporally, reading text, parsing audio, interpreting abstract and graphical illustrations as well as using external knowledge not directly present in the given content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*jLshTllNrGvpXjJWkSDFSQ.png" /></figure><p>While seemingly an easy task for humans, VQA affords several challenges to AI systems spanning the fields of natural language processing, computer vision, audio processing, knowledge representation and reasoning. Over the past few years, the advent of deep learning, availability of large datasets to train VQA models as well as the hosting of a number of benchmarking contests have contributed to a surge of interest in VQA amongst researchers in the above disciplines.</p><h3>The VQA-v1 dataset and metric</h3><p>One of the early and popular datasets for this task was the <a href="http://arxiv.org/pdf/1505.00468.pdf">VQA-v1</a> dataset. The VQA-v1 dataset is a very large dataset consisting of two types of images: natural images (referred to as <em>real images</em>) as well as synthetic images (referred to as <em>abstract scenes</em>) and comes in two answering modalities: <em>multiple choice</em> question answering (the task of selecting the right answer amongst a set of choices) as well as <em>open ended</em> question answering (the task of generating an answer with an open ended vocabulary). Owing to its difficulty and real world applicability, <em>open ended</em> question answering about natural image content has become the most popular VQA task amongst the four dataset flavors.</p><p>The <em>real images</em> fraction of the VQA-v1 dataset consists of over 200,000 natural images sourced from the MS-COCO dataset, a large scale dataset of images used to benchmark tasks such as object detection, segmentation and image captioning. Each image is paired with 3 questions written down by crowdsourced annotators. The dataset contains a variety of question types such as: <em>What color</em>, <em>What kind</em>, <em>Why</em>, <em>How many</em>, <em>Is the</em>, etc. To account for potential disagreements between humans for some questions, as well as account for crowd sourcing noise, each question is accompanied by 10 answers. Most answers are short and to the point, such as <em>yes</em>, <em>no</em>, <em>red</em>, <em>dog</em> and <em>coca cola</em> with close to 99% of the answer containing 3 or fewer words.</p><p>Given an image and a question, the goal of a VQA system is to produce an answer that matches those provided by human annotators. For the <em>open ended</em> answering modality, the evaluation metric used is:</p><p><em>accuracy=min(# annotator answers matching the generated answer/3, 1)</em></p><p>The intuition behind this metric is as follows. If a system generated answer matches one produced by at least 3 unique annotators, it gets a maximum score of 1 on account of producing a popular answer. If it generates an answer that isn’t present amongst the 10 candidates, it gets a score of 0, and it is assigned a fractional score if it produces an answer that is deemed rare. If the denominator 3 is lowered, wrong and noisy answers in the dataset (often present due to annotation noise) will receive a high credit. Conversely, if it is raised towards 10, a system producing the right answer may only receive partial credit, if the answer choices consist of synonyms or happen to contain a few noisy answers.</p><p>Learn more about the VQA-v1 dataset here:</p><blockquote><a href="http://arxiv.org/pdf/1505.00468.pdf">VQA: Visual Question Answering</a></blockquote><blockquote>Stanislaw Antol, Aishwarya Agrawal, Jiasen Lu, Margaret Mitchell, Dhruv Batra, C. Lawrence Zitnick, Devi Parikh</blockquote><blockquote>ICCV 2015</blockquote><h3>When open ended isn’t really that open ended</h3><p>Generating answers for open ended questions requires training a model that inputs an image and corresponding question and outputs a sequence of words using a decoder. However, training decoders is often more cumbersome than training a system that simply picks amongst a pool of K possible answers. As it turns out, most answers in datasets such as VQA-v1 tend to cluster into a manageable set of a few thousand answers. For instance, the 1000 most common answers in VQA-v1 cover roughly 83% of all answers in the dataset. This allows us to reformulate the open ended question answering problem into a K-way multiple choice problem where K is a large number such as 1000 or 2000 that covers most answers in the dataset. This is akin to a multiple choice answering paradigm where the same K choices are presented for every question. As K increases, the number of answer choices that the model has to choose from increases. This allows the model to potentially answer a higher fraction of questions correctly, but also usually requires a larger model and more training data. Most VQA researchers work with the top 1000 answer classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*KlqB3rL0H4z2t45Hw-erpA.png" /></figure><h3>A baseline VQA model</h3><p>The image below shows the architecture of a simple VQA neural network. The image is fed into a convolutional neural network (CNN) such as ResNet-18 which outputs a feature vector encoding the contents of the image and is referred to as an <em>image embedding</em>. The question is featurized by computing an average of the word2vec vectors over all the words in the question, resulting in a <em>question embedding</em>. These embedding vectors, which compactly represent the image and question contents have different dimensions. Hence they are first projected into the same number of dimensions using corresponding fully connected layers (a linear transformation) and then combined using pointwise multiplication (multiplying values at corresponding dimensions). The final stage of the VQA model is a multilayer perceptron with a softmax non-linearity at the end that outputs a score distribution over each of the top K answers. Converting the open ended question answering to a K-way classification task allows us to train the VQA model using a cross entropy loss between the generated answer distribution and the ground truth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*xUgACct7Dfnqez5wXLXJzA.png" /></figure><p>The image backbone is initialized with weights obtained from a network such as ResNet-18, trained on the ImageNet classification dataset. This initialization provides several advantages: <em>First</em>, it leads to faster training, since training a large image CNN from scratch is usually quite expensive. <em>Second</em>, this allows the VQA model to exploit knowledge obtained from the ImageNet dataset, which may be very useful to answer questions about objects in images. <em>Third</em>, if the image CNN weights are not fine-tuned on the VQA dataset and instead frozen to the ImageNet ones, the image representations for the entire training dataset can be pre-computed and stored on disk, which results in less memory consumption while training the VQA model.</p><h3>Many simple variants of the baseline model</h3><p>One can easily tweak this simple VQA architecture in several ways to arrive at a bunch of different VQA models as shown in the image below.</p><p><em>Image Embedding</em> : The image can be passed through a variety of image embedding neural networks (each pre-initilaized with the corresponding ImageNet variant). Typically, VQA task accuracy correlates well with the accuracy obtained by the network architecture on the ImageNet classification task (for example, a VQA model with ResNet-50 does better than a model with AlexNet).</p><p>This suggests that (a) Network architectures that perform well at image classification also perform well at VQA, and (b) The knowledge obtained from ImageNet and encoded within the parameters of the image embedding network aids the task of VQA, and a better knowledge representation leads to improved metrics on VQA.</p><p><em>Text Embedding</em> : word2vec embeddings encode each word into a fixed dimensional vector which captures the syntax and semantics of that word. One can easily substitute this embedding by any other word embedding such as Glove. Word embeddings that work better on a variety of NLP tasks, typically work better for the VQA task.</p><p>Another simple variant, which is the de facto standard today, is to use a recurrent neural network such as an LSTM to encode the sequence of word embeddings, instead of simply averaging the word vectors. In contrast to averaging, using an LSTM preserves information regarding the order of the words in the question and leads to an improved VQA accuracy.</p><p><em>Combining the word vectors</em> : There are several easy and cheap ways of combining representations from the image and text modality: Pointwise operations as well as concatenation. Concatenation leads to an increase in the number of parameters for the ensuing network. There isn’t a clear winner amongst these simple variants, although pointwise multiplication tends to be the most common option across research papers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*OULUt5c9t_MvGMWLmnPGTA.png" /></figure><h3>Multiple choice VQA systems</h3><p>When the answer choices are known a-priori (such as in multiple choice settings), the above VQA network can be easily extended to also consume the embedding of a single answer choice. Instead of predicting an answer choice (as was done above), the network now predicts if the provided answer choice is True or False. A simple yet important modification involves replacing the final softmax function with a sigmoid function and predicting a single score. If M answer choices are provided in the multiple choice scenario, the network needs to be run M times, once for each answer choice and the final prediction involves choosing the answer choice that provided the highest score.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*8ROay1Yjc42UMjnBurYRrw.png" /></figure><p>When the answer choices are fed into the network, the resulting models obtain higher VQA accuracies. The disadvantage is that the network needs to be M times. Researchers have also used this variant in the open ended setting by running the model through K times, once each for the top K answers. This is slow, but it also provided improved performance.</p><p>Learn more about simple yet powerful VQA baselines for the multiple choice and open ended settings here:</p><blockquote><a href="https://arxiv.org/pdf/1606.08390.pdf">Revisiting Visual Question Answering Baselines</a></blockquote><blockquote>Allan Jabri, Armand Joulin, Laurens van der Maaten</blockquote><blockquote>ECCV 2016</blockquote><h3>How well do these simple models perform ?</h3><p>On the VQA-v1 dataset, a simple baseline similar to the one described above obtained an accuracy of 57.75 on the real images open ended question answering setting. This is a rather high accuracy when you consider that the number of answer choices in the open ended scenario is very large (the top 1000 answers cover roughly 83% of all answers).</p><p>However, this needs to be put into context by comparing the number to another simple baseline, the <em>question only baseline</em> which does not consider the image at all. Not looking at an image while answering a question about an image seems very counter intuitive right ? However, such a question only baseline (depicted in the image below) performs reasonably well on the VQA-v1 dataset. It obtains an accuracy of 50.39 on VQA-v1. How is this possible ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*L5af9gELW757qewxfvH6uw.png" /></figure><p>While the number of answer choices for the open ended scenario is very large, the inherent structure and regularities in the world result in just a few plausible answers given a question. For instance, the question “What color is the construction cone ?” can likely be answered by simply choosing a common color, reducing the space of answers from 1000s to roughly 10. Furthermore, construction cones are dominantly orange in the color in the world. Hence simply memorizing this fact and always answering “orange” for this question results in a reasonable VQA system that does not need to look at the image. Neural networks are very good at exploiting such data biases that can be learnt from the training set, and this is precisely what is happening with the <em>question only baseline</em>.</p><h3>Conclusion</h3><p>To summarize, Visual Question Answering (VQA), the task of answering questions about visual content, has received a lot of attention recently amongst researchers. In this blog post I described a few VQA baseline models that perform reasonably well on standard benchmarks. These models have been extended in many interesting ways including the use of visual attention modules, object detection frameworks, counting modules, methods to fuse multi-modal information, etc. which I shall discuss in future blog posts. Stay tuned!</p><p><em>Follow AI2 on Twitter </em><a href="http://twitter.com/allen_ai"><em>@allen_ai</em></a><em> | Follow Ani Kembhavi </em><a href="http://twitter.com/anikembhavi"><em>@anikembhavi</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=adcaaaa94336" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ai2-blog/vanilla-vqa-adcaaaa94336">Vanilla VQA</a> was originally published in <a href="https://medium.com/ai2-blog">Ai2 Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>