<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Petr Houška's devblog</title>
    <description>Blog of a human being from Europe.</description>
    <link>http://devblog.petrroll.cz/</link>
    <atom:link href="http://devblog.petrroll.cz/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Sun, 14 Aug 2022 20:23:34 +0000</pubDate>
    <lastBuildDate>Sun, 14 Aug 2022 20:23:34 +0000</lastBuildDate>
    <generator>Jekyll v3.9.2</generator>
    
      <item>
        <title>SWE notes 02: SIFT - detect features regardless of scale without DNNs</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;This post if from a series of quick notes written primarily for personal usage while reading random ML/SWE/CS papers. As such they might be incomprehensible and/or flat out wrong.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;sift-scale-invariant-feature-transform&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=KgsHoJYJ4S8&amp;amp;list=PL2zRqk16wsdqXEMpHrc4Qnb5rA1Cylrhx&amp;amp;index=13&quot;&gt;SIFT: Scale invariant feature transform&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Interest point:
    &lt;ul&gt;
      &lt;li&gt;Rich content (brightness and color variation, …)&lt;/li&gt;
      &lt;li&gt;Well defined representation for matching comparison with other points&lt;/li&gt;
      &lt;li&gt;Well defined position in the image&lt;/li&gt;
      &lt;li&gt;Scale, orientation, brightness, … invariant&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;What are good interest points?
    &lt;ul&gt;
      &lt;li&gt;Not edges -&amp;gt; not descriptive / unique enough&lt;/li&gt;
      &lt;li&gt;Corners only good for simpler images&lt;/li&gt;
      &lt;li&gt;“Blobls” actually relatively good: location, orientation, size &amp;amp; possible to assign signature&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Detecting blobs
    &lt;ul&gt;
      &lt;li&gt;Detecting edges: first/second derivative of gaussian convolution (removes noise)
        &lt;ul&gt;
          &lt;li&gt;Extrema locations correspond to position of a blobs (edges on either side)&lt;/li&gt;
          &lt;li&gt;The larger the extrema the more prominent blob&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;table&gt;
          &lt;tbody&gt;
            &lt;tr&gt;
              &lt;td&gt;Changing sigma (for the gaussian): changing detection scale (Detecting Blobs&lt;/td&gt;
              &lt;td&gt;SIFT Detector 6:20)&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
      &lt;/li&gt;
      &lt;li&gt;Try multiple sigmas -&amp;gt; create stack of feature maps, each corresponding of trying to find blobs at different scale&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Extracting interest points
    &lt;ul&gt;
      &lt;li&gt;Get stack of feature maps per blob scale&lt;/li&gt;
      &lt;li&gt;Compute differences of all two adjacent scale feature maps (smaller and bigger)&lt;/li&gt;
      &lt;li&gt;Find extrema across all difference-featuremap featuremaps (3d max operator; 2d across space, 1d across scales)&lt;/li&gt;
      &lt;li&gt;Filter one only high extrema (threshold)&lt;/li&gt;
      &lt;li&gt;-&amp;gt; SIFT interest points&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Scale invariance:
    &lt;ul&gt;
      &lt;li&gt;We know the scale of interest points -&amp;gt; rescale them&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Orientation invariance:
    &lt;ul&gt;
      &lt;li&gt;For every pixel compute gradient (edge)&lt;/li&gt;
      &lt;li&gt;Look just at orientation (magnitude is about lightning), create histogram&lt;/li&gt;
      &lt;li&gt;Take principal (largest) orientation and use it to normalize location (rotate the patch through the orientation)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;SIFT descriptor
    &lt;ul&gt;
      &lt;li&gt;Create histogram per normalized (orientation, scaling) point of interest (usually divided into 4 subplots)&lt;/li&gt;
      &lt;li&gt;Distance between histograms can be normalized correlation / L2 / …&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Allows many applications: s.a. matching features from one picture to another picture (different scale/orientation, …)&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Sat, 30 Apr 2022 21:53:40 +0000</pubDate>
        <link>http://devblog.petrroll.cz/swe-notes-02-sift-detect-features-regardless-of-scale-without-dnns/</link>
        <guid isPermaLink="true">http://devblog.petrroll.cz/swe-notes-02-sift-detect-features-regardless-of-scale-without-dnns/</guid>
        
        
        <category>swe</category>
        
      </item>
    
      <item>
        <title>Deep learning notes 11: All is Kernels - but not those in ring0</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;This post if from a series of quick notes written primarily for personal usage while reading random ML/SWE/CS papers. As such they might be incomprehensible and/or flat out wrong.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;deep-networks-are-kernel-machines&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=ahRPdiCop3E&quot;&gt;Deep Networks Are Kernel Machines&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Deep learning success is attributed to automatic discovery of new data representation&lt;/li&gt;
  &lt;li&gt;Paper’s proposal:
    &lt;ul&gt;
      &lt;li&gt;Deep learning training: stores training data&lt;/li&gt;
      &lt;li&gt;Deep learning inference: compares with stored data -&amp;gt; outputs closest -&amp;gt; ~kernel machine&lt;/li&gt;
      &lt;li&gt;-&amp;gt; Deep network weights ~ superposition of training examples&lt;/li&gt;
      &lt;li&gt;-&amp;gt; Network architecture incorporates knowledge of target function into kernel (similarity function)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Kernel machine: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;y = g ( sum_i: ai * K(x, xi) + b)&lt;/code&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;K&lt;/code&gt;: similarity kernel function&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xi&lt;/code&gt;: remembered training set&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ai&lt;/code&gt;: gold labels&lt;/li&gt;
      &lt;li&gt;-&amp;gt; essentially global nearest neighbor classifier&lt;/li&gt;
      &lt;li&gt;The biggest question is how to choose the Kernel function&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Gradient descent NN is equivalent to path-kernel Kernel machine
    &lt;ul&gt;
      &lt;li&gt;Two datapoints are similar if gradients of the (network) output w.r.t to weights are similar (similar - inner product)&lt;/li&gt;
      &lt;li&gt;Gradient of the (network) output w.r.t to weights: for particular input &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xi&lt;/code&gt;, how to change the weights to e.g. increase output&lt;/li&gt;
      &lt;li&gt;Classify a datapoint
        &lt;ul&gt;
          &lt;li&gt;Retrace along all versions of the network (after each GD update)&lt;/li&gt;
          &lt;li&gt;Classify by whichever training datapoints had similar effect on the network (sensitivity) over the course of training&lt;/li&gt;
          &lt;li&gt;Get output of initial model and accumulate differences made by each GD step -&amp;gt; output of final&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Proof datapoint &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x&lt;/code&gt;, its classification &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;y&lt;/code&gt;, training datapoints &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xi -&amp;gt; yi&lt;/code&gt;, weights &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wj&lt;/code&gt;, loss &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;L&lt;/code&gt;:
        &lt;ul&gt;
          &lt;li&gt;Change in output for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x&lt;/code&gt; w.r.t to steps of GD:&lt;/li&gt;
          &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dy/dt = sum_j..d dy/dwj * dwj/dt&lt;/code&gt; | GSD’ed NN outputs change over time&lt;/li&gt;
          &lt;li&gt;= &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sum_j..d dy/dwj * (-dL/dwj)&lt;/code&gt; | Each wight changes according to Loss derivative&lt;/li&gt;
          &lt;li&gt;= &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sum_j..d dy/dwj (-sum_i..m dL/dyi * dyi/dwj)&lt;/code&gt; | Loss derivative over all data is sum over each data&lt;/li&gt;
          &lt;li&gt;= &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-sum_i..m dL/dyi * sum_j..d dy/dwj * dyi*dwj&lt;/code&gt;| Chain rule&lt;/li&gt;
          &lt;li&gt;= &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-sum_i..m L'(yi, yi) K_{f, w(t)}(x, xi)&lt;/code&gt; | re-arrange&lt;/li&gt;
          &lt;li&gt;=&amp;gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;y = y0 - Integral_t sum_i..m L'(yi, yi) K_f,w(t) (x, xi) dt&lt;/code&gt; | output of NN &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;y=&lt;/code&gt;&lt;/li&gt;
          &lt;li&gt;…some normalization…&lt;/li&gt;
          &lt;li&gt;= &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sum_i..m ai * K(x, xi) + b&lt;/code&gt; | output of Kernel machine&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Notes: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ai&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b&lt;/code&gt; depends on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x,&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Another way of looking at DNNs, also connects to boosting
    &lt;ul&gt;
      &lt;li&gt;General statement: all learning methods will incorporate data&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;kernels&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=y_RjsDHl5Y4&quot;&gt;Kernels!&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Refresher on concepts:
    &lt;ul&gt;
      &lt;li&gt;Kernel functions: symmetric, positive semi-definitive ~ similarity measure&lt;/li&gt;
      &lt;li&gt;Kernel matrix (e.g. gram matrix): pairwise distances of all points in dataset&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Kernel: get kernel matrix without doing explicit feature map expansion on each datapoint and then dot product
    &lt;ul&gt;
      &lt;li&gt;E.g. using simple elementwise kernel function -&amp;gt; way cheaper (or even actually possible) to evaluate&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;E.g.: Polynomial expansion with polynomial dimensionality &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p&lt;/code&gt; and datapoint dimensionality &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;d&lt;/code&gt;:
    &lt;ul&gt;
      &lt;li&gt;Full expansion: each datapoint &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;d&lt;/code&gt; expanded to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;d*p&lt;/code&gt; (could be worse, inf. for other kernels), then dot product on these&lt;/li&gt;
      &lt;li&gt;Kernel method: immediately computes the same kernel matrix out of two raw &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;d&lt;/code&gt;-dim inputs&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Hilbert spaces: imagine vector spaces but with generalized base vectors (functions, polynomials, …)
    &lt;ul&gt;
      &lt;li&gt;Vector space needs to be linear and have scalar inner product&lt;/li&gt;
      &lt;li&gt;~Space of functions where the point evaluation functional is linear and continuous&lt;/li&gt;
      &lt;li&gt;When converging in the function space -&amp;gt; also converging in outputs&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Reproducing kernel, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;F&lt;/code&gt; set of functions &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fi: E-&amp;gt;C&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;F&lt;/code&gt; is Hilbert space; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;K: ExE-&amp;gt;C&lt;/code&gt; is reproducing kernel when:
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;K(., t) € H&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Vt€E&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;fi, K(., t)&amp;gt; = fi(t)&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Vt€E, Vfi € H&lt;/code&gt; | the value of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fi(t)&lt;/code&gt; is reproduced by inner product of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fi&lt;/code&gt; with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;K(., t)&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;https://www.intechopen.com/chapters/59898&quot;&gt;Reproducing Kernel Functions | IntechOpen&lt;/a&gt;, &lt;a href=&quot;https://people.eecs.berkeley.edu/~bartlett/courses/281b-sp08/7.pdf&quot;&gt;7.pdf (berkeley.edu)&lt;/a&gt;, &lt;a href=&quot;https://people.eecs.berkeley.edu/~jordan/courses/281B-spring04/lectures/rkhs2.pdf&quot;&gt;rkhs2.pdf (berkeley.edu)&lt;/a&gt;, &lt;a href=&quot;https://stats.stackexchange.com/questions/246255/connection-between-svm-and-representer-theorem&quot;&gt;optimization - Connection between SVM and Representer theorem - Cross Validated (stackexchange.com)&lt;/a&gt;, &lt;a href=&quot;https://math.stackexchange.com/questions/3535962/connection-between-representer-theorem-and-mercers-theorem&quot;&gt;functional analysis - Connection between Representer Theorem and Mercer’s Theorem? - Mathematics Stack Exchange&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;Two reproducing kernels for two points -&amp;gt; equivalence between inner product of their reproducing kernels and its single evaluation
        &lt;ul&gt;
          &lt;li&gt;E.g.: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;k(.,x), k(.,x')&amp;gt; = k(x, x')&lt;/code&gt; | for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;f, g&amp;gt; = sum_i,j ai * bj * k(xi, xj)&lt;/code&gt; | &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;H = ( f(x) = sum_i..m ai * k(xi, x) )&lt;/code&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Every reproducing kernel induces unique reproducing-kernel Hilbert space, and vice versa&lt;/li&gt;
      &lt;li&gt;Every reproducing kernel is positive definite, and every positive definite kernel function defines unique reproducing kernel Hilbert space&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Kernel methods ~ soft nearest neighbor&lt;/li&gt;
  &lt;li&gt;Any matrix of inner products (style transfer, attention, …) can be exploited through kernel lens&lt;/li&gt;
  &lt;li&gt;Various ways of looking at things
    &lt;ul&gt;
      &lt;li&gt;SVM: Learn global separation planes&lt;/li&gt;
      &lt;li&gt;DNN: Learn sequence of processing&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Ridge regression with kernels: RBF, …
    &lt;ul&gt;
      &lt;li&gt;Does regression in transformed space instead of original efficiently&lt;/li&gt;
      &lt;li&gt;Seems to work good because regressing in those spaces seems to be good/better than original spaces&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Representor theorem:
    &lt;ul&gt;
      &lt;li&gt;~Optimal function &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;f*: x-&amp;gt;y&lt;/code&gt; can be represented as linear comb. on the kernel functions &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;k(x1, .)&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;k(x2, .)&lt;/code&gt; of the dataset&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;f*(.) = sum_1..n ai * k(., xi)&lt;/code&gt;
        &lt;ul&gt;
          &lt;li&gt;To get optimal &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ai&lt;/code&gt; coefficient: Take kernel products of our data (kernel matrix) &amp;amp; linear regression&lt;/li&gt;
          &lt;li&gt;Across all training points: find combination of similarities with all others that produces lowest error to its output&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Even assuming all possible datapoints, solution still lives in linear combination of only points from dataset&lt;/li&gt;
      &lt;li&gt;Kernel method allows us to do this effectively -&amp;gt; coefficient on datapoints (their kernels) instead of their feature(s| maps)
        &lt;ul&gt;
          &lt;li&gt;Datapoints are the model&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Usages:
    &lt;ul&gt;
      &lt;li&gt;Style transfer: gram matrix in style&lt;/li&gt;
      &lt;li&gt;Super-resolution: similarity patches&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;You could view DNN as implicit kernel method, indirectly also learns the similarity matrix&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Tue, 22 Mar 2022 21:26:37 +0000</pubDate>
        <link>http://devblog.petrroll.cz/deep-learning-notes-11-all-is-kernels-but-not-those-in-ring0/</link>
        <guid isPermaLink="true">http://devblog.petrroll.cz/deep-learning-notes-11-all-is-kernels-but-not-those-in-ring0/</guid>
        
        
        <category>papers</category>
        
      </item>
    
      <item>
        <title>Deep learning notes 10: Diffusion models - noise to nice in few steps</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;This post if from a series of quick notes written primarily for personal usage while reading random ML/SWE/CS papers. As such they might be incomprehensible and/or flat out wrong.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;ddpm---diffusion-models-beat-gans-on-image-synthesis&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=W-O7AZNzbzQ&quot;&gt;DDPM - Diffusion Models Beat GANs on Image Synthesis&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Input + sampled little bit of noise; repeated multiple times (~1000s) -&amp;gt; pure noise
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x_0 = x&lt;/code&gt;; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;noise(x_t+1|x_t)&lt;/code&gt;; process input image from data distr.: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x&lt;/code&gt;, applied &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;noise(…)&lt;/code&gt; multiple times -&amp;gt; image of noise&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;If we could invert this process -&amp;gt; generative model: random normal noise image -&amp;gt; original image
    &lt;ul&gt;
      &lt;li&gt;Learn to undo one “little bit of noise” step at a time: distribution &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;noise(x_t-1|x_t)&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;Sample random noise image, undo noise 1000s times (each time get one step cleaner image) -&amp;gt; sample clean data distr.&lt;/li&gt;
      &lt;li&gt;Reversal gives us process of normal noise to data distribution&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Noising up: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;q&lt;/code&gt;: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;noise(x_t+1|x_t)&lt;/code&gt; well-defined process of adding noise from Normal distribution
    &lt;ul&gt;
      &lt;li&gt;Each step depends only on output of previous step&lt;/li&gt;
      &lt;li&gt;Added noise has diagonal covariance matrix, is centered at last sample but down-scaled&lt;/li&gt;
      &lt;li&gt;Given large &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;T&lt;/code&gt; and well behaved schedule, last step is nearly isotropic Gaussian distribution&lt;/li&gt;
      &lt;li&gt;Produces vast amount of data pairs of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x_t-1&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x_t&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Denoising: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p&lt;/code&gt;: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;noise(x_t-1|x_t)&lt;/code&gt; requires entire data distribution -&amp;gt; approximated via neural network
    &lt;ul&gt;
      &lt;li&gt;Reversal doesn’t predict single image but a whole distribution of images (that could’ve been previous step)&lt;/li&gt;
      &lt;li&gt;The output distribution is assumed to be gaussian (mean, covariance)&lt;/li&gt;
      &lt;li&gt;The gaussian distribution assumption is maintained for small noise-up steps&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Combination of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;q&lt;/code&gt; is ~VAE (variational auto-encoder) -&amp;gt; just train it
    &lt;ul&gt;
      &lt;li&gt;The true distribution can be easily computed out of the both known training pairs&lt;/li&gt;
      &lt;li&gt;Loss forces the denoising network predicted distribution to be close do the true distribution&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;The predicted covariance can be either statically set (actually doesn’t work super-bad) or also predicted
    &lt;ul&gt;
      &lt;li&gt;If fixed: can be fixed based on the forward noise-up step parameters&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Combination of two loss functions are used, for stability also resampled (early noise-up steps are more impactful)
    &lt;ul&gt;
      &lt;li&gt;Simple objective: L2 difference between true and predicted picture / noise&lt;/li&gt;
      &lt;li&gt;Variational loss: proper KL divergence VAE loss, including variance, …&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Class-label guided generation can improve performance
    &lt;ul&gt;
      &lt;li&gt;Train class classifier not only for clean images, but also for noised images -&amp;gt; use them to steer the generation&lt;/li&gt;
      &lt;li&gt;Analogous to ~GANs; ~shifts the predicted distribution of the step-denoised-images to where specified label is likelier&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Idea: Have GANs that have multiple discriminators along the path from noise to final image ~ merge these two approaches&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;autoregressive-diffusion-models&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=2h4tRsQzipQ&quot;&gt;Autoregressive Diffusion Models&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;New type of auto-regressive models: variables can be decoded in arbitrary order&lt;/li&gt;
  &lt;li&gt;Autoregressive models: produces tokens (words/patches/pixels) one after another
    &lt;ul&gt;
      &lt;li&gt;E.g. First word, based on priming with it a second word, based on first two a third, …&lt;/li&gt;
      &lt;li&gt;Usually a fixed order, for sentences starts with a first one, …&lt;/li&gt;
      &lt;li&gt;Repeat until the whole output has been generated&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;ARDMs: Don’t have to go first to last, order could be arbitrary
    &lt;ul&gt;
      &lt;li&gt;Can also produce multiple tokens at once reducing number of steps for lower accuracy&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;At the beginning all tokens are initialized (?randomly/zero?)
    &lt;ul&gt;
      &lt;li&gt;DNN (usually transformer) processes them -&amp;gt; per token output (e.g. distribution over categories)&lt;/li&gt;
      &lt;li&gt;A portion of them are sampled and decoded (argmax for categorization) -&amp;gt; concrete outputs for few tokens&lt;/li&gt;
      &lt;li&gt;Concrete outputs replace random inputs for the sampled tokens, DNN, new subset of tokens are decoded, …&lt;/li&gt;
      &lt;li&gt;Repeat until all tokens are sampled &amp;amp; set&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;~Similar to BERT
    &lt;ul&gt;
      &lt;li&gt;Trained with random word within sentence masking -&amp;gt; predicts distribution over words for masked tokens&lt;/li&gt;
      &lt;li&gt;Training is similar to BERT, just with non-fixed blanked tokens ratio&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;During training: mask a portion of tokens, average losses for all at once
    &lt;ul&gt;
      &lt;li&gt;Sampling one timestep of one ordering where we decode &amp;amp; loss all of the remaining/maked tokens&lt;/li&gt;
      &lt;li&gt;Left to right allows taking only the next (one) tokens’s loss -&amp;gt; less noisy&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Why can’t we sample all tokens at once?
    &lt;ul&gt;
      &lt;li&gt;Tokens aren’t independent -&amp;gt; argmax on one token (collapsing its distribution) influences other tokens’ disr.&lt;/li&gt;
      &lt;li&gt;Sampling multiple at once is faster (less steps necessary) but possibly less ideal outputs&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Extensions:
    &lt;ul&gt;
      &lt;li&gt;Tokens could be re-sampled&lt;/li&gt;
      &lt;li&gt;Multiple pixels at a time can be sampled -&amp;gt; to get the order/token groups dynamic programming&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Initially sample only more rough values (e.g. out of few colors), only later revisit &amp;amp; predict specific color&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Sun, 20 Feb 2022 22:10:35 +0000</pubDate>
        <link>http://devblog.petrroll.cz/deep-learning-notes-10-diffusion-models-noise-to-nice-in-few-steps/</link>
        <guid isPermaLink="true">http://devblog.petrroll.cz/deep-learning-notes-10-diffusion-models-noise-to-nice-in-few-steps/</guid>
        
        
        <category>papers</category>
        
      </item>
    
      <item>
        <title>Deep learning notes 09: Grokking - overfit into generalization</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;This post if from a series of quick notes written primarily for personal usage while reading random ML/SWE/CS papers. As such they might be incomprehensible and/or flat out wrong.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;grokking-generalization-beyond-overfitting-on-small-algorithmic-datasets&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=dND-7llwrpw&quot;&gt;Grokking: Generalization beyond Overfitting on small algorithmic datasets&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Neural network suddenly generalizes way beyond the point of overfitting with proper regularization
    &lt;ul&gt;
      &lt;li&gt;Train accuracy rises with training steps, eventually NN overfits on training data, training continues…&lt;/li&gt;
      &lt;li&gt;After orders of magnitude more steps, the network suddenly generalizes and test accuracy shoots up as well&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Similar to the idea of double descent, just with training steps instead of number of parameters&lt;/li&gt;
  &lt;li&gt;In DD - when trained to convergence the relationship between test accuracy and number of parameters
    &lt;ul&gt;
      &lt;li&gt;With higher capacity models test accuracy first increases as the model is becoming capable&lt;/li&gt;
      &lt;li&gt;Then it starts going down when the network is big enough to remember dataset -&amp;gt; overfitting&lt;/li&gt;
      &lt;li&gt;Increasing the number of parameters further leads to increase of accuracy again, surpassing previous best&lt;/li&gt;
      &lt;li&gt;Interpretation: at some point there are enough parameters to nicely match all datapoints but smoothy (with proper regularization)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;This paper dataset: variables + binary operation (e.g. polynomial operations) without any noise
    &lt;ul&gt;
      &lt;li&gt;Dataset is a table of all pairs of variables + the result of the operation&lt;/li&gt;
      &lt;li&gt;The network predicts the result of the operation for specific variables (portion blanked for trained data)&lt;/li&gt;
      &lt;li&gt;Dataset is very specific &amp;amp; without noise, on real world issues the phenomena is hard to induce / see&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Multiple variables of the dataset
    &lt;ul&gt;
      &lt;li&gt;Size of the dataset&lt;/li&gt;
      &lt;li&gt;Complexity of the operation&lt;/li&gt;
      &lt;li&gt;Train dataset ratio&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Training accuracy shoots to 100 % soon (10^2 steps), test accuracy to 100 % also but later (10^5)
    &lt;ul&gt;
      &lt;li&gt;The higher the train set ratio, the faster the snap on test accuracy happens&lt;/li&gt;
      &lt;li&gt;The easier the operation is (e.g. there are symmetries) the easier it happens&lt;/li&gt;
      &lt;li&gt;The bigger the dataset, the harder it is to induce the phenomena&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Weight decay seems to be very important to make the phenomena appear faster
    &lt;ul&gt;
      &lt;li&gt;? Prefers simple solutions vs remembering whole dataset&lt;/li&gt;
      &lt;li&gt;So many train steps that a good solution is eventually discovered &amp;amp; then preferred because ^^&lt;/li&gt;
      &lt;li&gt;Maybe weight decay is good-ish but not the best regularization&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Visualization of the weights (t-SNE) shows structure that could be interpreted via the operation&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Sat, 20 Nov 2021 15:49:59 +0000</pubDate>
        <link>http://devblog.petrroll.cz/deep-learning-notes-09-grokking-overfit-into-generalization/</link>
        <guid isPermaLink="true">http://devblog.petrroll.cz/deep-learning-notes-09-grokking-overfit-into-generalization/</guid>
        
        
        <category>papers</category>
        
      </item>
    
      <item>
        <title>Deep learning notes 08: Fastformer - additive or static (self)attention?</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;This post if from a series of quick notes written primarily for personal usage while reading random ML/SWE/CS papers. As such they might be incomprehensible and/or flat out wrong.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;fastformer---additive-attention-cannot-be-all-you-need&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=qgUegkefocg&quot;&gt;Fastformer - Additive attention can(not) be all you need&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Modeling pairwise interaction between all pairs of tokens is expensive&lt;/li&gt;
  &lt;li&gt;Fastformer promises to use “additive attention” that’s linear in complexity via tokens-global aggregation&lt;/li&gt;
  &lt;li&gt;Presented in terms of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;queries&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;keys&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;values&lt;/code&gt; but could be just in terms of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;n&lt;/code&gt; (in this case 3) columns: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b&lt;/code&gt;, …, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;z&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Computation goes sequentially, starts with computing the output of the second column, then third, …, last
    &lt;ul&gt;
      &lt;li&gt;For each column, create per-token input values, e.g. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a1&lt;/code&gt;..&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;an&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b1…bn&lt;/code&gt;; the same way &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;q&lt;/code&gt;,&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;k&lt;/code&gt;,&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;v&lt;/code&gt; are produced in transformer&lt;/li&gt;
      &lt;li&gt;For computing the per-token outputs of second column &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Bi&lt;/code&gt;, start with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ai&lt;/code&gt; = &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ai&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;For each &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ai&lt;/code&gt; value, produce &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;αi&lt;/code&gt; weight via softmax after transformation with learned &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wa&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;αi= exp(wa*Ai)/∑exp(wa*Aj)&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;Produce global &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;A&lt;/code&gt; as weighted average of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ai&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;A = ∑ αi * Ai&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;The output of column b is then pointwise multiplication, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Bi = bi x A&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;In case there’s column c, we aggregate &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Bi&lt;/code&gt; to a single &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;B&lt;/code&gt;, pointwise multiply with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ci&lt;/code&gt; to get &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ci&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Still essentially quadratic &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;i=0..n&lt;/code&gt;: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Bi = bi x A = bi x ∑ αi * Ai = ∑ bi x αi * Ai&lt;/code&gt;
    &lt;ul&gt;
      &lt;li&gt;Given there’s no softmax -&amp;gt; global a can be computed first -&amp;gt; linear in computation&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;The aggregation weights &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;αi&lt;/code&gt; are essentially self-attention with per-column/layer static learned query &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wa&lt;/code&gt;
    &lt;ul&gt;
      &lt;li&gt;Also could be viewed as soft classification according to learned static separation boundary vector &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wa&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;No information sharing between tokens apart from pointwise multiplication between global aggregate of prev. column
    &lt;ul&gt;
      &lt;li&gt;Not really a proper attention; sort-of static query self-attention in the aggregation step&lt;/li&gt;
      &lt;li&gt;It is statically learned what sort of tokens each layer/column should globally attend to; not dynamic per each token&lt;/li&gt;
      &lt;li&gt;Good for tasks with global information, e.g. topic classification&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Seems to just be framed in terms of the words of attention mechanism&lt;/li&gt;
  &lt;li&gt;In practice fast and with relatively good results on certain NLP tasks&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 11 Oct 2021 20:12:40 +0000</pubDate>
        <link>http://devblog.petrroll.cz/deep-learning-notes-08-fastformer-additive-attention-or-weird-static-selfattention/</link>
        <guid isPermaLink="true">http://devblog.petrroll.cz/deep-learning-notes-08-fastformer-additive-attention-or-weird-static-selfattention/</guid>
        
        
        <category>papers</category>
        
      </item>
    
      <item>
        <title>Deep learning notes 07: PonderNet - Learn when to stop thinking</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;This post if from a series of quick notes written primarily for personal usage while reading random ML/SWE/CS papers. As such they might be incomprehensible and/or flat out wrong.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;pondernet---learn-when-to-stop-thinking&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=nQDZmf2Yb9k&quot;&gt;PonderNet - Learn when to stop thinking&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Recurrent(ly run) network that can decide when to stop computation&lt;/li&gt;
  &lt;li&gt;In standard NN the amount of computation grows with size of input/output and/or is static; not with problem complexity&lt;/li&gt;
  &lt;li&gt;End-to-end trained to compromise between: computation cost (# of steps), training prediction accuracy, and generalization
    &lt;ul&gt;
      &lt;li&gt;Halting node: predicts probability of halting on conditional of not halting before&lt;/li&gt;
      &lt;li&gt;The rest of the network can be any architecture (rnn, cnn, transformer, …, capsule network, …)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Input &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x&lt;/code&gt;; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x&lt;/code&gt; processed to hidden state &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;h_i&lt;/code&gt;; processed via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;s(...)&lt;/code&gt; function; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(h_i+1, y_i, λ_i) = s(h_i)&lt;/code&gt;
    &lt;ul&gt;
      &lt;li&gt;Each steps returns next hidden state (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;h_i+1&lt;/code&gt;), output (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;y_i&lt;/code&gt;), and probability of stopping (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;λ_i&lt;/code&gt;)&lt;/li&gt;
      &lt;li&gt;Probability to stop at step n: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p_n = λ_n * TT_1..n-1 (1- λ_i)&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;At inference &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;λ&lt;/code&gt; is used probabilistically (i.e. the probability is sampled)&lt;/li&gt;
  &lt;li&gt;Training loop:
    &lt;ul&gt;
      &lt;li&gt;Input &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x&lt;/code&gt; into encoder, get &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;h_0&lt;/code&gt;, … unroll the network for n steps regardless of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;λ&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;Consider all outputs at the same time; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;loss = p_1*L(y_1)+p_2*L(y_2)+...+p_n*L(y_n)&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;-&amp;gt; Possibly unstable -&amp;gt; two goals: make &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;y_i&lt;/code&gt; better or make &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;p_i&lt;/code&gt; smaller&lt;/li&gt;
      &lt;li&gt;Regularization for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;KL(p_i || geometricDistirbution(λp))&lt;/code&gt; -&amp;gt; forces lambdas to be similar to hyperparameter&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Contrast vs ACT:
    &lt;ul&gt;
      &lt;li&gt;Considers the output a weighted average of outputs: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;loss = L(p_1 * y_1 + ... + p_n * y_n)&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;Early results need to be compatible with later results&lt;/li&gt;
      &lt;li&gt;Less dynamic; needs more steps in experiments, worse in extrapolation&lt;/li&gt;
      &lt;li&gt;Pondernet correctly needs more steps for more complex problems&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

</description>
        <pubDate>Fri, 27 Aug 2021 19:49:51 +0000</pubDate>
        <link>http://devblog.petrroll.cz/deep-learning-notes-07-pondernet-learn-when-to-stop-thinking/</link>
        <guid isPermaLink="true">http://devblog.petrroll.cz/deep-learning-notes-07-pondernet-learn-when-to-stop-thinking/</guid>
        
        
        <category>papers</category>
        
      </item>
    
      <item>
        <title>Deep learning notes 06: Part-whole hierarchies with GLOM</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;This post if from a series of quick notes written primarily for personal usage while reading random ML/SWE/CS papers. As such they might be incomprehensible and/or flat out wrong.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;glom-how-to-represent-part-whole-hierarchies-in-a-neural-network&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=cllFzkvrYmE&quot;&gt;GLOM: How to represent part-whole hierarchies in a neural network&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;Idea paper, not an actual implementation
    &lt;ul&gt;
      &lt;li&gt;How does fixed architecture parse various pictures into part/whole hierarchy that’s different for each input
        &lt;ul&gt;
          &lt;li&gt;E.g. car is made of cabin, motor, …, cabin out of windows, doors, …&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Dynamic image parsing sort-of handled by capsule networks
    &lt;ul&gt;
      &lt;li&gt;First layer capsules represent/recognize lowest level features; capsule for window, door, …; second layer cabin, …&lt;/li&gt;
      &lt;li&gt;Door and window activates cabin capsule, …&lt;/li&gt;
      &lt;li&gt;~discretization (active/nonactive) over implicit feature hierarchy of CNNs&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;GLOM architecture: large number of same weights columns, one for each spatial location&lt;/li&gt;
  &lt;li&gt;Each column is stack of spatially local autoencoders
    &lt;ul&gt;
      &lt;li&gt;Each vertically divided into multiple (~5) levels&lt;/li&gt;
      &lt;li&gt;Each level represents patch of image at different resolution/abstraction level
        &lt;ul&gt;
          &lt;li&gt;Cat’s ear -&amp;gt;  furr, part of ear, cat’s head, cat, … ; neck -&amp;gt; furr, part of neck, cat’s neck, cat&lt;/li&gt;
          &lt;li&gt;All locations of cat’s ear will have similar second level activation, all locations in image similar last level activation&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;At each level the activation is embedding vector of that feature at that location ~ CNNs but differently implemented&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Communication/inference is iterative
    &lt;ul&gt;
      &lt;li&gt;Between levels (layers) of each column through explicit neural networks&lt;/li&gt;
      &lt;li&gt;Between columns through attention mechanism&lt;/li&gt;
      &lt;li&gt;Iterative approach/eventual consistency forces all locations of a feature to share&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;For layer &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;l&lt;/code&gt;, location &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x&lt;/code&gt;, timestep  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;t+1&lt;/code&gt; embedding is:
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;e_t+1,l,x = e_t,l,x + f_td(e_t,l+1,x) f_bu(e_t,l-1,x)&lt;/code&gt; + &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;acrossLoc::below&amp;gt;&lt;/code&gt;
        &lt;ul&gt;
          &lt;li&gt;Last timestep + through NN (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;f_td&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;f_bu&lt;/code&gt;) above and below level&lt;/li&gt;
          &lt;li&gt;NN functions (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;f_td&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;f_bu&lt;/code&gt;) weights shared for the same level of all locations&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Positional encoding added to each input (similar to transformers)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Through message passing all locations for certain feature (e.g. Cat’s ear locations) converge on ~appropriate level activation
    &lt;ul&gt;
      &lt;li&gt;Multiple locations sharing n-th level activation -&amp;gt; an island&lt;/li&gt;
      &lt;li&gt;Following islands from topmost level to the bottom gives us parse hierarchy
        &lt;ul&gt;
          &lt;li&gt;The higher the bigger features -&amp;gt; the bigger islands; topmost: one island represents the whole image: class&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;For across-location/cross columns information sharing: attention over the same level of all columns
    &lt;ul&gt;
      &lt;li&gt;Attends not using keys/queries but similarity: Instead of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sm(QK^T)V&lt;/code&gt; -&amp;gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sm(XX^T)X&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;-&amp;gt; attends within islands -&amp;gt; converges towards clustering -&amp;gt; similar vectors forced toward similar vectors&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Issue: on lower level similar things can share information even if they are in different parts of parse tree higher
    &lt;ul&gt;
      &lt;li&gt;Possible solution: Module attention based on closeness in higher levels of parse tree (higher levels of columns) as well&lt;/li&gt;
      &lt;li&gt;~the further the less influential: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sm(SUM_k=0..L-l  λ^k X_l+k * X_l+k^T)X&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Iterative algorithm, eventual consensus -&amp;gt; embeddings also update -&amp;gt; doesn’t  discover clusters but creates them&lt;/li&gt;
  &lt;li&gt;Designed decisions:
    &lt;ul&gt;
      &lt;li&gt;Locations per patches (CNN) or even per pixel&lt;/li&gt;
      &lt;li&gt;Bottom-up network could look at nearby location but spatial locality could also be done only by the attention mechanism&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Training
    &lt;ul&gt;
      &lt;li&gt;Denoising autoencoder: reconstructing corrupted image (missing certain regions)&lt;/li&gt;
      &lt;li&gt;To encourage islands of new identity: regularizer based on contrast learning
        &lt;ul&gt;
          &lt;li&gt;Crops from same image should agree, from different images disagree -&amp;gt; needs to be done on scene level not lower&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Represent coordinate transformations: it’s not necessary to have explicit part-whole coordinate transformations
    &lt;ul&gt;
      &lt;li&gt;Better have it implicit in higher dimensional embedding than explicit in low level (can’t model uncertainty)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;For video: don’t need to converge for each frame, can move in time within video during convergence
    &lt;ul&gt;
      &lt;li&gt;I.e. Few iteration steps per each video frame, if changes not too rapid -&amp;gt; should still reach stable higher levels&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Tue, 13 Jul 2021 20:34:27 +0000</pubDate>
        <link>http://devblog.petrroll.cz/deep-learning-notes-06-part-whole-hierarchies-with-GLOM/</link>
        <guid isPermaLink="true">http://devblog.petrroll.cz/deep-learning-notes-06-part-whole-hierarchies-with-GLOM/</guid>
        
        
        <category>papers</category>
        
      </item>
    
      <item>
        <title>Deep learning notes 05: Unsupervised vision with DINO</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;This post if from a series of quick notes written primarily for personal usage while reading random ML/SWE/CS papers. As such they might be incomprehensible and/or flat out wrong.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;dino-emerging-properties-in-self-supervised-vision-transformers&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=h3ij3F3cPIk&quot;&gt;DINO: Emerging Properties in Self-Supervised Vision Transformers&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Unsupervised learning regime for vision (self attention, 8x8 patches) transformers
    &lt;ul&gt;
      &lt;li&gt;Intermediate representation clusters pictures of similar labels together (without seeing labels)&lt;/li&gt;
      &lt;li&gt;Capable of object detection and masking (attention mask segments objects very well)&lt;/li&gt;
      &lt;li&gt;Capable of classification (output KNN to known labeled examples)&lt;/li&gt;
      &lt;li&gt;Copy detection, image retrieval, … -&amp;gt; good similarity measure&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Attention masks for CLS token: the token that contains final representation (doesn’t have image patch on input, to not bias)&lt;/li&gt;
  &lt;li&gt;Self-supervised learning: self-distillation without labels&lt;/li&gt;
  &lt;li&gt;Negative samples learning:
    &lt;ul&gt;
      &lt;li&gt;Take anchor patch and patch A from one image, and patch B from second image&lt;/li&gt;
      &lt;li&gt;Give all three patches to the model, tell it which is anchor patch&lt;/li&gt;
      &lt;li&gt;Ask whether A or B is from the same as anchor&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Self-supervised without negative samples learning
    &lt;ul&gt;
      &lt;li&gt;Use only one image, augment in multiple ways (BYOL) -&amp;gt; produce two versions for teacher and student
        &lt;ul&gt;
          &lt;li&gt;Global crops: &amp;gt; 50 % of the image&lt;/li&gt;
          &lt;li&gt;Local crops: &amp;lt; 50 % of the image&lt;/li&gt;
          &lt;li&gt;Rotations, color-jitters, …&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Pass each one version through teacher, one through student
        &lt;ul&gt;
          &lt;li&gt;Note: Actually pass both through both, loss is combination of cross-difference&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Loss is the difference between end image representations (CLS output)
        &lt;ul&gt;
          &lt;li&gt;Same image, only differently augmented -&amp;gt; should have similar representation&lt;/li&gt;
          &lt;li&gt;To mitigate collapse to single repre. -&amp;gt; different models for teacher and student&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Only train (backprop) student, build teacher as exponential average of students&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Teacher only uses global cropping
    &lt;ul&gt;
      &lt;li&gt;If student has local crop -&amp;gt; student learns that its patch should match the whole with more context&lt;/li&gt;
      &lt;li&gt;-&amp;gt; forces the model to learn part-whole relationship &amp;amp; representing the whole image&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Teacher maintains running average of all representations it sees -&amp;gt; subtracts it from its representation
    &lt;ul&gt;
      &lt;li&gt;~normalization, helps against collapse&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Representation has softmax with temperature at the end
    &lt;ul&gt;
      &lt;li&gt;Dimensionality of softmax is arbitrary: don’t have explicit labels (unsupervised) -&amp;gt; who knows how many&lt;/li&gt;
      &lt;li&gt;Teacher has sharpening -&amp;gt; more peaked distribution -&amp;gt; forcer larger differences between diff. outputs&lt;/li&gt;
      &lt;li&gt;Softmax is not common in unsupervised -&amp;gt; forces model to come up with “its own classes”&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Versus supervised learning
    &lt;ul&gt;
      &lt;li&gt;Supervised has way more noisy / overfitted attention mask -&amp;gt; hyper optimization on the task at hand&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Why does it work?
    &lt;ul&gt;
      &lt;li&gt;Augmentations: in computer vision they’re super important ~ that’s where the human prior is
        &lt;ul&gt;
          &lt;li&gt;What’s augmented away doesn’t matter&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Dataset: there’s always an explicit object of interest -&amp;gt; how we take pictures brings prior&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Tue, 11 May 2021 19:50:44 +0000</pubDate>
        <link>http://devblog.petrroll.cz/deep-learning-notes-05-unsupervised-vision-with-dino/</link>
        <guid isPermaLink="true">http://devblog.petrroll.cz/deep-learning-notes-05-unsupervised-vision-with-dino/</guid>
        
        
        <category>papers</category>
        
      </item>
    
      <item>
        <title>SWE notes 01: Types as weather</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;This post if from a series of quick notes written primarily for personal usage while reading random ML/SWE/CS papers. As such they might be incomprehensible and/or flat out wrong.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;types-are-like-the-weather-type-systems-are-like-weathermen---matthias-felleisen&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=XTl7Jn_kmio&quot;&gt;Types are like the Weather, Type Systems are like Weathermen - Matthias Felleisen&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Types are language of prediction by the programmer what the program will do&lt;/li&gt;
  &lt;li&gt;Type systems check these prediction&lt;/li&gt;
  &lt;li&gt;Code is written for others to understand but also to be run on computers&lt;/li&gt;
  &lt;li&gt;All developers think types while their create code (more or less precise, but still)
    &lt;ul&gt;
      &lt;li&gt;Capturing these thoughts in comments is problematic -&amp;gt; not checked -&amp;gt; become wrong&lt;/li&gt;
      &lt;li&gt;Types are checked automatically&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Only type inference added to untyped language fundamentally doesn’t work
    &lt;ul&gt;
      &lt;li&gt;If things go wrong -&amp;gt; super-hard to have reasonable error messages&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Instead add gradual typing system
    &lt;ul&gt;
      &lt;li&gt;Allow adding types incrementally throughout codebase&lt;/li&gt;
      &lt;li&gt;Idiomatic: just adding types, not changing code&lt;/li&gt;
      &lt;li&gt;Strive for reasonable error messages&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;What should happen when part is types and there’s error in untyped land
    &lt;ul&gt;
      &lt;li&gt;In typed racket: It tells user what happened on the typed/untyped boundary (through value proxies)&lt;/li&gt;
      &lt;li&gt;Can also provide profiling info w.r.t to specific values&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Contracts are good but they are very much not free during runtime
    &lt;ul&gt;
      &lt;li&gt;Problem with higher order objects (lazy streams, first class functions, …) -&amp;gt; need to allocate&lt;/li&gt;
      &lt;li&gt;Good for more complex checking hard to encode in types&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Idea: JITs could exploit dependent types (just like compilers exploit static types)&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Tue, 11 May 2021 19:50:42 +0000</pubDate>
        <link>http://devblog.petrroll.cz/swe-notes-01-types-as-weather/</link>
        <guid isPermaLink="true">http://devblog.petrroll.cz/swe-notes-01-types-as-weather/</guid>
        
        
        <category>swe</category>
        
      </item>
    
      <item>
        <title>Deep learning notes 04: Perceivers and Branch specialization</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;This post if from a series of quick notes written primarily for personal usage while reading random ML/SWE/CS papers. As such they might be incomprehensible and/or flat out wrong.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;perceiver-general-perception-with-iterative-attention-arxiv&quot;&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=P_xeshTnPZg&quot;&gt;Perceiver: General Perception with Iterative Attention&lt;/a&gt; (&lt;a href=&quot;https://arxiv.org/abs/2103.03206&quot;&gt;arxiv&lt;/a&gt;)&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;CNN: Locality exploited by sliding window&lt;/li&gt;
  &lt;li&gt;ViT: Divide picture into (local) patches, attend over them&lt;/li&gt;
  &lt;li&gt;Traditional: self-attention computation and memory &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;n^2&lt;/code&gt; in the number of tokens (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;|K|*|Q|&lt;/code&gt;)
    &lt;ul&gt;
      &lt;li&gt;NLP: 1000s tokens&lt;/li&gt;
      &lt;li&gt;CV: ideally » 50k pixels&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Originally NLP transformers: encoder (cross attention) &amp;amp; decoder (self attention)
    &lt;ul&gt;
      &lt;li&gt;Encoder on input: attends only to input tokens, same number of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;keys&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;values&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;queries&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;Decoder on output: attends to both input and output tokens, input only produces keys and values; not queries&lt;/li&gt;
      &lt;li&gt;-&amp;gt; different amount of (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;keys&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;values&lt;/code&gt;) and (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;queries&lt;/code&gt;): computational requirements are not strictly quadratic&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Perceiver: split (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;queries&lt;/code&gt;) and (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;keys&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;values&lt;/code&gt;) for vision classification models
    &lt;ul&gt;
      &lt;li&gt;Stack of cross-attention (with input), and few self-attentions (mix, compute) repeated multiple times&lt;/li&gt;
      &lt;li&gt;
        &lt;table&gt;
          &lt;tbody&gt;
            &lt;tr&gt;
              &lt;td&gt;Cross-attention: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;queries&lt;/code&gt; not based on input, but with arbitrarily smaller dimension &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;N*D&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;N is ~1000&lt;/code&gt;&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/tbody&gt;
        &lt;/table&gt;
        &lt;ul&gt;
          &lt;li&gt;Dim of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;N*M&lt;/code&gt;: way smaller than &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;M^2&lt;/code&gt;, only linearly on input -&amp;gt; allows video, not-patched images, sound, …&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;Self-attention: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;queries&lt;/code&gt; as well as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;keys&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;values&lt;/code&gt; based on cross-att.’s &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;queries&lt;/code&gt; dim -&amp;gt; arbitrarily small
        &lt;ul&gt;
          &lt;li&gt;Dim of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;N^2&lt;/code&gt;: independent on input dimensions; uses output of prev. step for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;values&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;keys&lt;/code&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Multiple layers of this cross attentions, self-attentions stack
    &lt;ul&gt;
      &lt;li&gt;Each cross-attention uses the same input image for calculating (using different weights) &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;keys&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;values&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;Weights for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;keys&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;values&lt;/code&gt; (from input), and queries can be shared across repeats -&amp;gt; essentially recurrent neural network&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Initial &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;queries&lt;/code&gt; can be random or learned; queries in later layers are calculated based on earlier layer results&lt;/li&gt;
  &lt;li&gt;Interpretation:
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Queries&lt;/code&gt;: what we would want to know; represent channels&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Keys&lt;/code&gt;: what each pixel represents/offers&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Fourier features for positional encoding, not learned&lt;/li&gt;
  &lt;li&gt;Results comparable to ResNet without any picture assumptions (apart from 2d positional encoding)
    &lt;ul&gt;
      &lt;li&gt;~50 layers, number of parameters comparable to ResNet&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Attention maps possibly static / dependent only on location instead of input content&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;branch-specialization-similar-features-cluster-together&quot;&gt;&lt;a href=&quot;https://distill.pub/2020/circuits/branch-specialization/&quot;&gt;Branch specialization&lt;/a&gt;: Similar features cluster together&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;When CNNs are branched into multiple sets of channels that don’t allow cross-information sharing -&amp;gt; specialization
    &lt;ul&gt;
      &lt;li&gt;E.g. on initial portion of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AlexNet&lt;/code&gt; (split into streams two due to GPU memory limits)&lt;/li&gt;
      &lt;li&gt;Features are not organized randomly as within a normal layer, but grouped/clustered for each branch&lt;/li&gt;
      &lt;li&gt;First group: Black and white Gabor filters, second group: low frequency color detectors&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Possible explanation:
    &lt;ul&gt;
      &lt;li&gt;First part of branch is incentivized to form features relevant to second part&lt;/li&gt;
      &lt;li&gt;&amp;lt;=&amp;gt;&lt;/li&gt;
      &lt;li&gt;Second part prefers features which the first half provides primitives for&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Inception (multiple parallel blocks) and residual networks (unroll parallelly) also feature separate sets of channels
    &lt;ul&gt;
      &lt;li&gt;Residual networks sidestep requirement to have a lot of parameters to mix values between branches&lt;/li&gt;
      &lt;li&gt;Bigger convolution (i.e. smaller branches) tend to be more specialized (e.g. 5x5 for Inception)&lt;/li&gt;
      &lt;li&gt;Inception happens even across multiple depths:
        &lt;ul&gt;
          &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mixed3a_5x5&lt;/code&gt;: BW vs Color, brightness, …&lt;/li&gt;
          &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mixed3b_5x5&lt;/code&gt;: curve related, boundary detectors, fur/eye/face detectors, …&lt;/li&gt;
          &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mixed4a_5x5&lt;/code&gt;: complex 3D shapes/geometry&lt;/li&gt;
          &lt;li&gt;-&amp;gt; Very unlikely to happen by chance e.g. for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mixed3a_5x5&lt;/code&gt; ~ 1/10^8&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Specialization is consistent across architectures and tasks
    &lt;ul&gt;
      &lt;li&gt;The two groups on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Alexnet&lt;/code&gt; no matter what you train it on (Places, …)&lt;/li&gt;
      &lt;li&gt;Specialized curvature group also common across architectures / datasets&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Hypothesis: Branching just surfaces structure that already exists
    &lt;ul&gt;
      &lt;li&gt;Test: weights between 1st and 2nd conv layers -&amp;gt; SVD -&amp;gt; singular vectors: frequency and colors&lt;/li&gt;
      &lt;li&gt;The largest dimension of variation in which neurons connect to which in the next layer&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Idea: parallels to neuroscience and brain region specialization&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Wed, 14 Apr 2021 21:10:21 +0000</pubDate>
        <link>http://devblog.petrroll.cz/deep-learning-notes-04-perceivers-and-branch-specialization/</link>
        <guid isPermaLink="true">http://devblog.petrroll.cz/deep-learning-notes-04-perceivers-and-branch-specialization/</guid>
        
        
        <category>papers</category>
        
      </item>
    
  </channel>
</rss>
