http://wiki.math.uwaterloo.ca/statwiki/api.php?action=feedcontributions&user=Jmmoosa&feedformat=atom statwiki - User contributions [US] 2023-02-01T22:02:21Z User contributions MediaWiki 1.28.3 http://wiki.math.uwaterloo.ca/statwiki/index.php?title=learn_what_not_to_learn&diff=42487 learn what not to learn 2018-12-17T17:38:00Z <p>Jmmoosa: /* Related Work */</p> <hr /> <div>=Introduction=<br /> <br /> In reinforcement learning, it is often difficult for an agent to learn when the action space is large, especially the difficulties from function approximation and exploration. Some previous work has been trying to use Monte Carlo Tree Search to help address this problem. Monte Carlo Tree Search is a heuristic search algorithm that helps provides some indication of how good is an action, it works relatively well in a problem where the action space is large(like the one in this paper). One of the famous examples would be Google's Alphago that defeated the world champion in 2016, which uses MCTS in their reinforcement learning algorithm for the board game Go. When the action space is large, one com In some cases many actions are irrelevant and it is sometimes easier for the algorithm to learn which action not to take. The paper proposes a new reinforcement learning approach for dealing with large action spaces based on action elimination by restricting the available actions in each state to a subset of the most likely ones. There is a core assumption being made in the proposed method that it is easier to predict which actions in each state are invalid or inferior and use that information for control. More specifically, it proposes a system that learns the approximation of a Q-function and concurrently learns to eliminate actions. The method utilizes an external elimination signal which incorporates domain-specific prior knowledge. For example, in parser-based text games, the parser gives feedback regarding irrelevant actions after the action is played (e.g., Player: &quot;Climb the tree.&quot; Parser: &quot;There are no trees to climb&quot;). Then a machine learning model can be trained to generalize to unseen states. <br /> <br /> The paper focuses on tasks where both states and the actions are natural language. It introduces a novel deep reinforcement learning approach which has a Deep Q-Network (DQN) and an Action Elimination Network (AEN), both using the Convolutional Neural Networks (CNN) for Natural Language Processing (NLP) tasks. The AEN is trained to predict invalid actions, supervised by the elimination signal from the environment. The proposed method uses the final layer activations of AEN to build a linear contextual bandit model which allows the elimination of sub-optimal actions with high probability. '''Note that the core assumption is that it is easy to predict which actions are invalid or inferior in each state and leverage that information for control.'''<br /> <br /> The text-based game called &quot;Zork&quot;, which lets players to interact with a virtual world through a text-based interface is tested by using the elimination framework. <br /> In this game, the player explores an environment using imagination of the text he/she reads. For more info, you can watch this video: [https://www.youtube.com/watch?v=xzUagi41Wo0 Zork].<br /> <br /> The AEN algorithm has achieved a faster learning rate than the baseline agents by eliminating irrelevant actions.<br /> <br /> Below shows an example for the Zork interface:<br /> <br /> [[File:lnottol_fig1.png|500px|center]]<br /> <br /> All states and actions are given in natural language. Input for the game contains more than a thousand possible actions in each state since the player can type anything.<br /> <br /> =Related Work=<br /> <br /> '''Text-Based Games (TBG):''' The state of the environment in TBG is described by simple language. Players interact with the environment through text commands that<br /> respect a predefined grammar, which must be discovered in each game. A popular example is Zork which has been tested in the paper. TBG is a good research intersection of RL and NLP, it requires language understanding, long-term memory, planning, exploration, affordability extraction, and common sense. It also often introduce stochastic dynamics to increase randomness. They highlight several open problems for RL, mainly the combinatorial and compositional properties of the action space, and game states that are only partially observable. <br /> <br /> '''Representations for TBG:''' Good word representation is necessary in order to learn control policies from high-dimensional complex data such as text. Previous work on TBG used pre-trained embeddings directly for control, other works combined pre-trained embedding with neural networks. For example, He<br /> et al. (2015) proposed to consider an input as Bag Of Words features for a neural network, learned separately<br /> embeddings for states and actions, and then computed the Q function from autocorrelations between<br /> these embeddings.<br /> <br /> '''DRL with linear function approximation:''' DRL methods such as the DQN have achieved state-of-the-art results in a variety of challenging, high-dimensional domains. This success is mainly because neural networks can learn rich domain representations for value function and policy. On the other hand, linear representation batch reinforcement learning methods are more stable and accurate, while feature engineering is necessary.A natural attempt at getting the best of both worlds is to learn a linear control policy on top of the representation of the last layer of a DNN. This approach was shown to refine the performance of DQNs and improve exploration. Similarly, for contextual linear bandits, Riquelme et al. showed that a neuro-linear Thompson sampling approach outperformed deep<br /> and linear bandit algorithms in practice.<br /> <br /> '''RL in Large Action Spaces:''' Prior work concentrated on factorizing the action space into binary subspace(Pazis and Parr, 2011; Dulac-Arnold et al., 2012; Lagoudakis and Parr, 2003), other works proposed to embed the discrete actions into a continuous space, then choose the nearest discrete action according to the optimal actions in the continuous space(Dulac-Arnold et al., 2015; Van Hasselt and Wiering, 2009). He et. al. (2015)extended DQN to unbounded(natural language) action spaces.<br /> Learning to eliminate actions was first mentioned by (Even-Dar, Mannor, and Mansour, 2003). They proposed to learn confidence intervals around the value function in each state. Lipton et al.(2016a) proposed to learn a classifier that detects hazardous state and then use it to shape the reward. Fulda et al.(2017) presented a method for affordability extraction via inner products of pre-trained word embedding.<br /> <br /> =Action Elimination=<br /> <br /> The approach in the paper builds on the standard Reinforcement Learning formulation. At each time step &lt;math&gt;t&lt;/math&gt;, the agent observes state &lt;math display=&quot;inline&quot;&gt;s_t &lt;/math&gt; and chooses a discrete action &lt;math display=&quot;inline&quot;&gt;a_t\in\{1,...,|A|\} &lt;/math&gt;. Then, after action execution, the agent obtains a reward &lt;math display=&quot;inline&quot;&gt;r_t(s_t,a_t) &lt;/math&gt; and observes next state &lt;math display=&quot;inline&quot;&gt;s_{t+1} &lt;/math&gt; according to a transition kernel &lt;math&gt;P(s_{t+1}|s_t,a_t)&lt;/math&gt;. The goal of the algorithm is to learn a policy &lt;math display=&quot;inline&quot;&gt;\pi(a|s) &lt;/math&gt; which maximizes the expected future discounted cumulative return &lt;math display=&quot;inline&quot;&gt;V^\pi(s)=E^\pi[\sum_{t=0}^{\infty}\gamma^tr(s_t,a_t)|s_0=s]&lt;/math&gt;, where &lt;math&gt; 0&lt; \gamma &lt;1 &lt;/math&gt;. The Q-function is &lt;math display=&quot;inline&quot;&gt;Q^\pi(s,a)=E^\pi[\sum_{t=0}^{\infty}\gamma^tr(s_t,a_t)|s_0=s,a_0=a]&lt;/math&gt;, and it can be optimized by Q-learning algorithm.<br /> <br /> After executing an action, the agent observes a binary elimination signal &lt;math&gt;e(s, a)&lt;/math&gt; to determine which actions not to take. It equals 1 if action &lt;math&gt;a&lt;/math&gt; may be eliminated in state &lt;math&gt;s&lt;/math&gt; (and 0 otherwise). The signal helps mitigating the problem of large discrete action spaces. We start with the following definitions:<br /> <br /> '''Definition 1:''' <br /> <br /> Valid state-action pairs with respect to an elimination signal are state action pairs which the elimination process should not eliminate. <br /> <br /> The set of valid state-action pairs contains all of the state-action pairs that are a part of some optimal policy, i.e., only strictly suboptimal state-actions can be invalid.<br /> <br /> '''Definition 2:'''<br /> <br /> Admissible state-action pairs with respect to an elimination algorithm are state action pairs which the elimination algorithm does not eliminate.<br /> <br /> '''Definition 3:'''<br /> <br /> Action Elimination Q-learning is a Q-learning algorithm which updates only admissible state-action pairs and chooses the best action in the next state from its admissible actions. We allow the base Q-learning algorithm to be any algorithm that converges to &lt;math display=&quot;inline&quot;&gt;Q^*&lt;/math&gt; with probability 1 after observing each state-action infinitely often.<br /> <br /> ==Advantages of Action Elimination==<br /> <br /> The main advantage of action elimination is that it allows the agent to overcome some of the main difficulties in large action spaces which are Function Approximation and Sample Complexity. <br /> <br /> Function approximation: Errors in the Q-function estimates may cause the learning algorithm to converge to a suboptimal policy, this phenomenon becomes more noticeable when the action space is large. Action elimination mitigates this effect by taking the max operator only on valid actions, thus, reducing potential overestimation errors. Besides, by ignoring the invalid actions, the function approximation can also learn a simpler mapping (i.e., only the Q-values of the valid state-action pairs) leading to faster convergence and better solution.<br /> <br /> Sample complexity: The sample complexity measures the number of steps during learning, in which the policy is not &lt;math display=&quot;inline&quot;&gt;\epsilon&lt;/math&gt;-optimal. Assume that there are &lt;math&gt;A'&lt;/math&gt; actions that should be eliminated and are &lt;math&gt;\epsilon&lt;/math&gt;-optimal, i.e. their value is at least &lt;math&gt;V^*(s)-\epsilon&lt;/math&gt;. The invalid action often returns no reward and doesn't change the state, (Lattimore and Hutter, 2012)resulting in an action gap of &lt;math display=&quot;inline&quot;&gt;\epsilon=(1-\gamma)V^*(s)&lt;/math&gt;, and this translates to &lt;math display=&quot;inline&quot;&gt;V^*(s)^{-2}(1-\gamma)^{-5}log(1/\delta)&lt;/math&gt; wasted samples for learning each invalid state-action pair. Practically, elimination algorithm can eliminate these invalid actions and therefore speed up the learning process approximately by &lt;math display=&quot;inline&quot;&gt;A/A'&lt;/math&gt;.<br /> <br /> Because it is difficult to embed the elimination signal into the MDP, the authors use contextual multi-armed bandits to decouple the elimination signal from the MDP, which can correctly eliminate actions when applying standard Q learning into learning process.<br /> <br /> To embed the elimination signal, we can add an elimination penalty to shape rewards (e.g. decreasing the rewards when selecting the wrong actions). Due to the exploration of irrelevant actions during reward training/shaping, this becomes hard to tune, and slows down convergence/reduces efficiency. Another alternative is to design a policy using two interleaving signals (which are iteratively updated during policy gradient descent), maximizing the reward and minimizing the elimination signal error. This result unfortunately leads to high dependence and correlation between the two models, and each model affects the observations of the other model, which may make convergence difficult.<br /> <br /> ==Action elimination with contextual bandits==<br /> <br /> Contextual bandit problem is a famous probability problem and is a natural extension from the multi-arm bandit problem.<br /> <br /> Let &lt;math display=&quot;inline&quot;&gt;x(s_t)\in R^d &lt;/math&gt; be the feature representation of &lt;math display=&quot;inline&quot;&gt;s_t &lt;/math&gt;. We assume that under this representation there exists a set of parameters &lt;math display=&quot;inline&quot;&gt;\theta_a^*\in \mathbb{R}^d &lt;/math&gt; such that the elimination signal in state &lt;math display=&quot;inline&quot;&gt;s_t &lt;/math&gt; is &lt;math display=&quot;inline&quot;&gt;e_t(s_t,a) = \theta_a^{*T}x(s_t)+\eta_t &lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt; \Vert\theta_a^*\Vert_2\leq S&lt;/math&gt;. &lt;math display=&quot;inline&quot;&gt;\eta_t&lt;/math&gt; is an R-subgaussian random variable with zero mean that models additive noise to the elimination signal. When there is no noise in the elimination signal, R=0. Otherwise, &lt;math display=&quot;inline&quot;&gt;R\leq 1&lt;/math&gt; since the elimination signal is bounded in [0,1]. Assume the elimination signal satisfies: &lt;math display=&quot;inline&quot;&gt;0\leq E[e_t(s_t,a)]\leq l &lt;/math&gt; for any valid action and &lt;math display=&quot;inline&quot;&gt; u\leq E[e_t(s_t, a)]\leq 1&lt;/math&gt; for any invalid action. And &lt;math display=&quot;inline&quot;&gt; l\leq u&lt;/math&gt;. Denote by &lt;math display=&quot;inline&quot;&gt;X_{t,a}&lt;/math&gt; as the matrix whose rows are the observed state representation vectors in which action a was chosen, up to time t. &lt;math display=&quot;inline&quot;&gt;E_{t,a}&lt;/math&gt; as the vector whose elements are the observed state representation elimination signals in which action a was chosen, up to time t. Denote the solution to the regularized linear regression &lt;math display=&quot;inline&quot;&gt;\Vert X_{t,a}\theta_{t,a}-E_{t,a}\Vert_2^2+\lambda\Vert \theta_{t,a}\Vert_2^2 &lt;/math&gt; (for some &lt;math display=&quot;inline&quot;&gt;\lambda&gt;0&lt;/math&gt;) by &lt;math display=&quot;inline&quot;&gt;\hat{\theta}_{t,a}=\bar{V}_{t,a}^{-1}X_{t,a}^TE_{t,a} &lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;\bar{V}_{t,a}=\lambda I + X_{t,a}^TX_{t,a}&lt;/math&gt;.<br /> <br /> <br /> According to Theorem 2 in (Abbasi-Yadkori, Pal, and Szepesvari, 2011), &lt;math display=&quot;inline&quot;&gt;|\hat{\theta}_{t,a}^{T}x(s_t)-\theta_a^{*T}x(s_t)|\leq\sqrt{\beta_t(\delta)x(s_t)^T\bar{V}_{t,a}^{-1}x(s_t)}\ \forall t&gt;0&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;\sqrt{\beta_t(\delta)}=R\sqrt{2\ \text{log}(\text{det}(\bar{V}_{t,a})^{1/2}\text{det}(\lambda I)^{-1/2}/\delta)}+\lambda^{1/2}S&lt;/math&gt;, with probability of at least &lt;math display=&quot;inline&quot;&gt;1-\delta&lt;/math&gt;. If &lt;math display=&quot;inline&quot;&gt;\forall s\ ,\Vert x(s)\Vert_2 \leq L&lt;/math&gt;, then &lt;math display=&quot;inline&quot;&gt;\beta_t&lt;/math&gt; can be bounded by &lt;math display=&quot;inline&quot;&gt;\sqrt{\beta_t(\delta)} \leq R \sqrt{d\ \text{log}(1+tL^2/\lambda/\delta)}+\lambda^{1/2}S&lt;/math&gt;. Next, define &lt;math display=&quot;inline&quot;&gt;\tilde{\delta}=\delta/k&lt;/math&gt; and bound this probability for all the actions. i.e., &lt;math display=&quot;inline&quot;&gt;\forall a,t&gt;0&lt;/math&gt;<br /> <br /> &lt;math display=&quot;inline&quot;&gt;Pr(|\hat{\theta}_{t-1,a}^{T}x(s_t)-\theta_{t-1, a}^{*T}x(s_t)|\leq\sqrt{\beta_t(\tilde\delta)x(s_t)^T\bar{V}_{t - 1,a}^{-1}x(s_t)}) \leq 1-\delta&lt;/math&gt;<br /> <br /> Recall that &lt;math display=&quot;inline&quot;&gt;E[e_t(s,a)]=\theta_a^{*T}x(s_t)\leq l&lt;/math&gt; if a is a valid action. Then we can eliminate action a at state &lt;math display=&quot;inline&quot;&gt;s_t&lt;/math&gt; if it satisfies:<br /> <br /> &lt;math display=&quot;inline&quot;&gt;\hat{\theta}_{t-1,a}^{T}x(s_t)-\sqrt{\beta_{t-1}(\tilde\delta)x(s_t)^T\bar{V}_{t-1,a}^{-1}x(s_t)})&gt;l&lt;/math&gt;<br /> <br /> with probability &lt;math display=&quot;inline&quot;&gt;1-\delta&lt;/math&gt; that we never eliminate any valid action. Note that &lt;math display=&quot;inline&quot;&gt;l, u&lt;/math&gt; are not known. In practice, choosing &lt;math display=&quot;inline&quot;&gt;l&lt;/math&gt; to be 0.5 should suffice.<br /> <br /> ==Concurrent Learning==<br /> In fact, Q-learning and contextual bandit algorithms can learn simultaneously, resulting in the convergence of both algorithms, i.e., finding an optimal policy and a minimal valid action space. <br /> <br /> If the elimination is done based on the concentration bounds of the linear contextual bandits, it can be ensured that Action Elimination Q-learning converges, as shown in Proposition 1.<br /> <br /> '''Proposition 1:'''<br /> <br /> Assume that all state action pairs (s,a) are visited infinitely often, unless eliminated according to &lt;math display=&quot;inline&quot;&gt;\hat{\theta}_{t-1,a}^Tx(s)-\sqrt{\beta_{t-1}(\tilde{\delta})x(s)^T\bar{V}_{t-1,a}^{-1}x(s))}&gt;l&lt;/math&gt;. Then, with a probability of at least &lt;math display=&quot;inline&quot;&gt;1-\delta&lt;/math&gt;, action elimination Q-learning converges to the optimal Q-function for any valid state-action pairs. In addition, actions which should be eliminated are visited at most &lt;math display=&quot;inline&quot;&gt;T_{s,a}(t)\leq 4\beta_t/(u-l)^2<br /> +1&lt;/math&gt; times.<br /> <br /> Notice that when there is no noise in the elimination signal(R=0), we correctly eliminate actions with probability 1. so invalid actions will be sampled a finite number of times.<br /> <br /> =Method=<br /> <br /> The assumption that &lt;math display=&quot;inline&quot;&gt;e_t(s_t,a)=\theta_a^{*T}x(s_t)+\eta_t &lt;/math&gt; generally does not hold when using raw features like word2vec. So the paper proposes to use the neural network's last layer as feature representation of states. A practical challenge here is that the features must be fixed over time when used by the contextual bandit. So batch-updates framework(Levine et al., 2017;Riquelme, Tucker, and Snoek, 2018) is used, where a new contextual bandit model is learned for every few steps that uses the last layer activation of the AEN as features.<br /> <br /> ==Architecture of action elimination framework==<br /> <br /> [[File:lnottol_fig1b.png|300px|center]]<br /> <br /> After taking action &lt;math display=&quot;inline&quot;&gt;a_t&lt;/math&gt;, the agent observes &lt;math display=&quot;inline&quot;&gt;(r_t,s_{t+1},e_t)&lt;/math&gt;. The agent uses it to learn two function approximation deep neural networks: A DQN and an AEN. AEN provides an admissible actions set &lt;math display=&quot;inline&quot;&gt;A'&lt;/math&gt; to the DQN, which uses this set to decide how to act and learn. The architecture for both the AEN and DQN is an NLP CNN(100 convolutional filters for AEN and 500 for DQN, with three different 1D kernels of length (1,2,3)), based on(Kim, 2014). The state is represented as a sequence of words, composed of the game descriptor and the player's inventory. These are truncated or zero padded to a length of 50 descriptor + 15 inventory words and each word is embedded into continuous vectors using word2vec in &lt;math display=&quot;inline&quot;&gt;R^{300}&lt;/math&gt;. The features of the last four states are then concatenated together such that the final state representations s are in &lt;math display=&quot;inline&quot;&gt;R^{78000}&lt;/math&gt;. The AEN is trained to minimize the MSE loss, using the elimination signal as a label. The code, the Zork domain, and the implementation of the elimination signal can be found [https://github.com/TomZahavy/CB_AE_DQN here.]<br /> <br /> ==Psuedocode of the Algorithm==<br /> <br /> [[File:lnottol_fig2.png|750px|center]]<br /> <br /> AE-DQN trains two networks: a DQN denoted by Q and an AEN denoted by E. The algorithm creates a linear contextual bandit model from it every L iterations with procedure AENUpdate(). This procedure uses the activations of the last hidden layer of E as features, which are then used to create a contextual linear bandit model.AENUpdate() then solved this model and plugin it into the target AEN. The contextual linear bandit model &lt;math display=&quot;inline&quot;&gt;(E^-,V)&lt;/math&gt; is then used to eliminate actions via the ACT() and Target() functions. ACT() follows an &lt;math display=&quot;inline&quot;&gt;\epsilon&lt;/math&gt;-greedy mechanism on the admissible actions set. For exploitation, it selects the action with highest Q-value by taking an argmax on Q-values among &lt;math display=&quot;inline&quot;&gt;A'&lt;/math&gt;. For exploration, it selects an action uniformly from &lt;math display=&quot;inline&quot;&gt;A'&lt;/math&gt;. The targets() procedure is estimating the value function by taking max over Q-values only among admissible actions, hence, reducing function approximation errors.<br /> <br /> =Experiments=<br /> ==Grid Domain==<br /> The authors start by evaluating our algorithm on a small grid world domain with 9 rooms, where they ca analyze the effect of the action elimination (visualization can be found in the appendix). In this domain, the agent starts at the center of the grid and needs to navigate to its upper-left corner. On every step, the agent suffers a penalty of (−1), with a terminal reward of 0. Prior to the game, the states are randomly divided into K categories. The environment has 4K navigation actions, 4 for each category, each with a probability to move in a random direction. If the chosen action belongs to the same category as the state, the action is performed correctly in probability pTc = 0.75. Otherwise, it will be performed correctly in probability pFc = 0.5. If the action does not fit the state category, the elimination signal equals 1, and if the action and state belong to the same category, then e = 0. The optimal policy will only use the navigation actions from the same type as the state, and all of the other actions are strictly suboptimal. A basic comparison between vanilla Q-learning without action elimination (green) and a tabular version of the action elimination Q-learning (blue) can be found in the figure below. In all of the figures, the results are compared to the case with one category (red), i.e., only 4 basic navigation actions, which forms an upper bound on performance with multiple categories. In Figure (a),(c), the episode length is T = 150, and in Figure (b) it is T = 300, to allow sufficient exploration for the vanilla Q-Learning. It is clear from the simulations that the action elimination dramatically improves the results in large action spaces. Also, note that the gain from action elimination increases with the grid size since the elimination allows the agent to reach the goal earlier.<br /> <br /> <br /> [[File:griddomain.png|1200px|thumb|center|Performance of agents in grid world]]<br /> ==Zork domain==<br /> <br /> The world of Zork presents a rich environment with a large state and action space. <br /> Zork players describe their actions using natural language instructions. For example, &quot;open the mailbox&quot;. Then their actions were processed by a sophisticated natural language parser. Based on the results, the game presents the outcome of the action. The goal of Zork is to collect the Twenty Treasures of Zork and install them in the trophy case. Points that are generated from the game's scoring system are given to the agent as the reward. For example, the player gets the points when solving the puzzles. Placing all treasures in the trophy will get 350 points. The elimination signal is given in two forms, &quot;wrong parse&quot; flag, and text feedback &quot;you cannot take that&quot;. These two signals are grouped together into a single binary signal which then provided to the algorithm. <br /> <br /> [[File:zork_domain.png|1200px|thumb|center|Left:the world of Zork.Right:subdomains of Zork.]]<br /> <br /> Experiments begin with the two subdomains of Zork domains: Egg Quest and the Troll Quest. For these subdomains, an additional reward signal is provided to guide the agent towards solving specific tasks and make the results more visible. A reward of -1 is applied at every time step to encourage the agent to favor short paths. Each trajectory terminates is upon completing the quest or after T steps are taken. The discounted factor for training is &lt;math display=&quot;inline&quot;&gt;\gamma=0.8&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;\gamma=1&lt;/math&gt; during evaluation. Also &lt;math display=&quot;inline&quot;&gt;\beta=0.5, l=0.6&lt;/math&gt; in all experiments. <br /> <br /> ===Egg Quest===<br /> <br /> The goal for this quest is to find and open the jewel-encrusted egg hidden on a tree in the forest. An egg-splorer goes on an adventure to find a mystical ancient relic with his furry companion. You can have a look at the game at [https://scratch.mit.edu/projects/212838126/ EggQuest]<br /> <br /> The agent will get 100 points upon completing this task. For action space, there are 9 fixed actions for navigation, and a second subset which consisting &lt;math display=&quot;inline&quot;&gt;N_{Take}&lt;/math&gt; actions for taking possible objects in the game. &lt;math display=&quot;inline&quot;&gt;N_{Take}=200 (set A_1), N_{Take}=300 (set A_2)&lt;/math&gt; has been tested separately.<br /> AE-DQN (blue) and a vanilla DQN agent (green) has been tested in this quest.<br /> <br /> [[File:AEF_zork_comparison.png|1200px|thumb|center|Performance of agents in the egg quest.]]<br /> <br /> Figure a) corresponds to the set &lt;math display=&quot;inline&quot;&gt;A_1&lt;/math&gt;, with T=100, b) corresponds to the set &lt;math display=&quot;inline&quot;&gt;A_2&lt;/math&gt;, with T=100, and c) corresponds to the set &lt;math display=&quot;inline&quot;&gt;A_2&lt;/math&gt;, with T=200. Both agents have performed well on sets a and c. However, the AE-DQN agent has learned much faster than the DQN on set b, which implies that action elimination is more robust to hyperparameter optimization when the action space is large. One important observation to note is that the three figures have different scales for the cumulative reward. While the AE-DQN outperformed the standard DQN in figure b, both models performed significantly better with the hyperparameter configuration in figure c.<br /> <br /> ===Troll Quest===<br /> <br /> The goal of this quest is to find the troll. To do it the agent needs to find the way to the house, use a lantern to expose the hidden entrance to the underworld. It will get 100 points upon achieving the goal. This quest is a larger problem than Egg Quest. The action set &lt;math display=&quot;inline&quot;&gt;A_1&lt;/math&gt; is 200 take actions and 15 necessary actions, 215 in total.<br /> <br /> [[File:AEF_troll_comparison.png|400px|thumb|center|Results in the Troll Quest.]]<br /> <br /> The red line above is an &quot;optimal elimination&quot; baseline which consists of only 35 actions(15 essential and 20 relevant take actions). We can see that AE-DQN still outperforms DQN and its improvement over DQN is more significant in the Troll Quest than the Egg quest. Also, it achieves compatible performance to the &quot;optimal elimination&quot; baseline.<br /> <br /> ===Open Zork===<br /> <br /> Lastly, the &quot;Open Zork&quot; domain has been tested which only the environment reward has been used. 1M steps have been trained. Each trajectory terminates after T=200 steps. Two action sets have been used:&lt;math display=&quot;inline&quot;&gt;A_3&lt;/math&gt;, the &quot;Minimal Zork&quot; action set, which is the minimal set of actions (131) that is required to solve the game. &lt;math display=&quot;inline&quot;&gt;A_4&lt;/math&gt;, the &quot;Open Zork&quot; action set (1227) which composed of {Verb, Object} tuples for all the verbs and objects in the game.<br /> <br /> [[]]<br /> <br /> [[File:AEF_open_zork_comparison.png|600px|thumb|center|Results in &quot;Open Zork&quot;.]]<br /> <br /> <br /> The above Figure shows the learning curve for both AE-DQN and DQN. We can see that AE-DQN (blue) still outperform the DQN (blue) in terms of speed and cumulative reward.<br /> <br /> =Conclusion=<br /> In this paper, the authors proposed a Deep Reinforcement Learning model for sub-optimal actions while performing Q-learning. Moreover, they showed that by eliminating actions, using linear contextual bandits with theoretical guarantees of convergence, the size of the action space is reduced, exploration is more effective, and learning is improved when tested on Zork, a text-based game.<br /> <br /> For future work the authors aim to investigate more sophisticated architectures and tackle learning shared representations for elimination and control which may boost performance on both tasks.<br /> <br /> They also hope to to investigate other mechanisms for action elimination, such as eliminating actions that result from low Q-values as in Even-Dar, Mannor, and Mansour, 2003.<br /> <br /> The authors aim to generate elimination signals in real-world domains and achieve the purpose of eliminating the signal implicitly.<br /> <br /> =Critique=<br /> The paper is not a significant algorithmic contribution and it merely adds an extra layer of complexity to the very famous DQN algorithm. All the experimental domains considered in the paper are discrete action problems that have so many actions that it could have been easily extended to a continuous action problem. In continuous action space there are several policy gradient based RL algorithms that have provided stronger performances. The authors should have ideally compared their methods to such algorithms like PPO or DRPO.<br /> <br /> Even with the critique above, the paper presents mathematical/theoretical justifications of the methodology. Moreover, since the methodology is built on the standard RL framework, this means that other variant RL algorithms can apply the idea to decrease the complexity and increase the performance. Moreover, the there are some rooms for applying technical variations for the algorithm.<br /> <br /> Also, since we are utilizing the system's response to irrelevant actions, an intuitive approach to eliminate such irrelevant actions is to add a huge negative reward for such actions, which will be much easier than the approach suggested by this paper. However, the in experiments, the author only compares AE-DQN to traditional DQN, not traditional DQN with negative rewards assigned to irrelevant actions.<br /> <br /> After all, the name that the authors have chosen is a good and attractive choice and matches our brain's structure which in so many real-world scenarios detects what not to learn.<br /> <br /> =Reference=<br /> 1. Chu, W.; Li, L.; Reyzin, L.; and Schapire, R. 2011. Contextual bandits with linear payoff functions. In Proceedings of the Fourteenth International Conference on Artiﬁcial Intelligence and Statistics.<br /> <br /> 2. Côté,M.-A.;Kádár,Á.;Yuan,X.;Kybartas,B.;Barnes,T.;Fine,E.;Moore,J.;Hausknecht,M.;Asri, L. E.; Adada, M.; et al. 2018. Textworld: A learning environment for text-based games. arXiv.<br /> <br /> 3. Dulac-Arnold, G.; Evans, R.; van Hasselt, H.; Sunehag, P.; Lillicrap, T.; Hunt, J.; Mann, T.; Weber, T.; Degris, T.; and Coppin, B. 2015. Deep reinforcement learning in large discrete action spaces. arXiv.<br /> <br /> 4. He, J.; Chen, J.; He, X.; Gao, J.; Li, L.; Deng, L.; and Ostendorf, M. 2015. Deep reinforcement learning with an unbounded action space. CoRR abs/1511.04636.<br /> <br /> 5. Kim, Y. 2014. Convolutional neural networks for sentence classiﬁcation. [https://arxiv.org/abs/1408.5882 arXiv preprint].<br /> <br /> 6. VanHasselt,H.,andWiering,M.A. 2009. Usingcontinuousactionspacestosolvediscreteproblems. In Neural Networks, 2009. IJCNN 2009. International Joint Conference on, 1149–1156. IEEE.<br /> <br /> 7. Watkins, C. J., and Dayan, P. 1992. Q-learning. Machine learning 8(3-4):279–292.<br /> <br /> 8. Su, P.-H.; Gasic, M.; Mrksic, N.; Rojas-Barahona, L.; Ultes, S.; Vandyke, D.; Wen, T.-H.; and Young, S. 2016. Continuously learning neural dialogue management. arXiv preprint.<br /> <br /> 9. Wu, Y.; Schuster, M.; Chen, Z.; Le, Q. V.; Norouzi, M.; Macherey, W.; Krikun, M.; Cao, Y.; Gao, Q.; Macherey, K.; et al. 2016. Google’s neural machine translation system: Bridging the gap between human and machine translation. arXiv preprint.<br /> <br /> 10. Yuan, X.; Côté, M.-A.; Sordoni, A.; Laroche, R.; Combes, R. T. d.; Hausknecht, M.; and Trischler, A. 2018. Counting to explore and generalize in text-based games. arXiv preprint arXiv:1806.1152<br /> <br /> 11. Zahavy, T.; Haroush, M.; Merlis, N.; Mankowitz, D. J.; 2018. Learn What Not to Learn: Action Elimination with Deep Reinforcement Learning.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=DON%27T_DECAY_THE_LEARNING_RATE_,_INCREASE_THE_BATCH_SIZE&diff=42486 DON'T DECAY THE LEARNING RATE , INCREASE THE BATCH SIZE 2018-12-17T17:28:42Z <p>Jmmoosa: /* TRAINING IMAGENET IN 30 MINUTES */</p> <hr /> <div>Summary of the ICLR 2018 paper: '''Don't Decay the learning Rate, Increase the Batch Size ''' <br /> <br /> Link: [https://arxiv.org/pdf/1711.00489.pdf]<br /> <br /> Summarized by: Afify, Ahmed [ID: 20700841]<br /> <br /> ==INTUITION==<br /> Nowadays, it is a common practice not to have a singular steady learning rate for the learning phase of neural network models. Instead, we use adaptive learning rates with the standard gradient descent method. The intuition behind this is that when we are far away from the minima, it is beneficial for us to take large steps towards the minima, as it would require a lesser number of steps to converge, but as we approach the minima, our step size should decrease, otherwise we may just keep oscillating around the minima. In practice, this is generally achieved by methods like SGD with momentum, Nesterov momentum, and Adam. However, the core claim of this paper is that the same effect can be achieved by increasing the batch size during the gradient descent process while keeping the learning rate constant throughout. In addition, the paper argues that such an approach also reduces the parameter updates required to reach the minima, thus leading to greater parallelism and shorter training times. The authors present conclusive experimental evidence to prove the empirical benefits of decaying learning rate can be achieved by increasing the batch size instead.<br /> <br /> == INTRODUCTION ==<br /> Stochastic gradient descent (SGD) is the most widely used optimization technique for training deep learning models. The reason for this is that the minima found using this process generalizes well to unseen data (Zhang et al., 2016; Wilson et al., 2017). However, the optimization process is slow and time-consuming as each parameter update corresponds to a small step towards the goal. According to (Goyal et al., 2017; Hoffer et al., 2017; You et al., 2017a), this has motivated researchers to try to speed up this optimization process by taking bigger steps, and hence reduce the number of parameter updates in training a model. This can be achieved by using large batch training, which can be divided across many machines. <br /> <br /> However, increasing the batch size leads to decreasing the test set accuracy (Keskar et al., 2016; Goyal et al., 2017). Smith and Le (2017) believed that SGD has a scale of random fluctuations &lt;math&gt; g = \epsilon (\frac{N}{B}-1) &lt;/math&gt;, where &lt;math&gt; \epsilon &lt;/math&gt; is the learning rate, &lt;math&gt; N &lt;/math&gt; is the number of training samples, and &lt;math&gt; B &lt;/math&gt; is the batch size. They concluded that there is an optimal batch size proportional to the learning rate when &lt;math&gt; B \ll N &lt;/math&gt;, and optimum fluctuation scale &lt;math&gt;g&lt;/math&gt; at constant learning rate which maximizes test set accuracy. This was observed empirically by Goyal et al., 2017 and used to train a ResNet-50 in under an hour with 76.3% validation accuracy on ImageNet dataset.<br /> <br /> In this paper, the authors' main goal is to provide evidence that increasing the batch size is quantitatively equivalent to decreasing the learning rate. They show that this approach achieves almost equivalent model performance on the test set with the same number of training epochs but with a remarkably fewer number of parameter updates. The strategy of increasing the batch size during training is in effect decreasing the scale of random fluctuations. Moreover, an additional reduction in the number of parameter updates can be attained by increasing the learning rate and scaling &lt;math&gt; B \propto \epsilon &lt;/math&gt; or even more reduction by increasing the momentum coefficient, &lt;math&gt; m &lt;/math&gt;, and scaling &lt;math&gt; B \propto \frac{1}{1-m} &lt;/math&gt;. Although the latter decreases the test accuracy. This has been demonstrated by several experiments on the ImageNet and CIFAR-10 datasets using ResNet-50 and Inception-ResNet-V2 architectures respectively. The authors train ResNet-50 on ImageNet to 76.1% validation accuracy in under 30 minutes.<br /> <br /> == STOCHASTIC GRADIENT DESCENT AND CONVEX OPTIMIZATION ==<br /> As mentioned in the previous section, the drawback of SGD when compared to full-batch training is the noise that it introduces that hinders optimization. According to (Robbins &amp; Monro, 1951), there are two equations that govern how to reach the minimum of a convex function: (&lt;math&gt; \epsilon_i &lt;/math&gt; denotes the learning rate at the &lt;math&gt; i^{th} &lt;/math&gt; gradient update)<br /> <br /> &lt;math&gt; \sum_{i=1}^{\infty} \epsilon_i = \infty &lt;/math&gt;. This equation guarantees that we will reach the minimum. <br /> <br /> &lt;math&gt; \sum_{i=1}^{\infty} \epsilon^2_i &lt; \infty &lt;/math&gt;. This equation, which is valid only for a fixed batch size, guarantees that learning rate decays fast enough allowing us to reach the minimum rather than bouncing due to noise.<br /> <br /> These equations indicate that the learning rate must decay during training, and second equation is only available when the batch size is constant. To change the batch size, Smith and Le (2017) proposed to interpret SGD as integrating this stochastic differential equation &lt;math&gt; \frac{dw}{dt} = -\frac{dC}{dw} + \eta(t) &lt;/math&gt;, where &lt;math&gt;C&lt;/math&gt; represents cost function, &lt;math&gt;w&lt;/math&gt; represents the parameters, and &lt;math&gt;\eta&lt;/math&gt; represents the Gaussian random noise. Furthermore, they proved that noise scale &lt;math&gt;g&lt;/math&gt; controls the magnitude of random fluctuations in the training dynamics by this formula: &lt;math&gt; g = \epsilon (\frac{N}{B}-1) &lt;/math&gt;, where &lt;math&gt; \epsilon &lt;/math&gt; is the learning rate, N is the training set size and &lt;math&gt;B&lt;/math&gt; is the batch size. As we usually have &lt;math&gt; B \ll N &lt;/math&gt;, we can define &lt;math&gt; g \approx \epsilon \frac{N}{B} &lt;/math&gt;. This explains why when the learning rate decreases, noise &lt;math&gt;g&lt;/math&gt; decreases, enabling us to converge to the minimum of the cost function. However, increasing the batch size has the same effect and makes &lt;math&gt;g&lt;/math&gt; decays with constant learning rate. In this work, the batch size is increased until &lt;math&gt; B \approx \frac{N}{10} &lt;/math&gt;, then the conventional way of decaying the learning rate is followed.<br /> <br /> == SIMULATED ANNEALING AND THE GENERALIZATION GAP ==<br /> '''Simulated Annealing:''' Decaying learning rates are empirically successful. To understand this, they note that introducing random fluctuations whose scale falls during training is also a well-established technique in non-convex optimization; simulated annealing. The initial noisy optimization phase allows exploring a larger fraction of the parameter space without becoming trapped in local minima. Once a promising region of parameter space is located, the noise is reduced to fine-tune the parameters.<br /> <br /> Simulated Annealing is a famous technique in non-convex optimization. Starting with the noise in the training process helps us to explore a wide range of parameters. Once we are near the optimum value, noise is reduced to fine tune our final parameters. Nowadays, researchers typically use sharp decay schedules like cosine decay or step-function drops. In physical sciences, slowly annealing (or decaying) the temperature (which is the noise scale in this situation) helps to converge to the global minimum, which is sharp. But decaying the temperature in discrete steps can make the system stuck in a local minimum, which leads to higher cost and lower curvature. The authors think that deep learning has the same intuition. Note that this interpretation may explain why conventional learning rate decay schedules like square roots or exponential decay have become less popular in deep learning in recent years. Increasingly, researchers favor sharper decay schedules like cosine decay or step-function drops. To interpret this shift, we note that it is well known in the physical sciences that slowly annealing the temperature (noise scale) helps<br /> the system to converge to the global minimum, which may be sharp. <br /> <br /> '''Generalization Gap:''' Small batch data generalizes better to the test set than large batch data. Smith and Le (2017) found that there is an optimal batch size which corresponds to optimal noise scale &lt;math&gt; g &lt;/math&gt; &lt;math&gt; (g \approx \epsilon \frac{N}{B}) &lt;/math&gt;. They found an optimum batch size &lt;math&gt; B_{opt} \propto \epsilon N &lt;/math&gt; that maximizes test set accuracies. This means that gradient noise is helpful as it makes SGD escape sharp minima which do not generalize well.<br /> <br /> == THE EFFECTIVE LEARNING RATE AND THE ACCUMULATION VARIABLE ==<br /> '''The Effective Learning Rate''' : &lt;math&gt; \epsilon_{eff} = \frac{\epsilon}{1-m} &lt;/math&gt;<br /> <br /> Smith and Le (2017) included momentum &lt;math&gt;m&lt;/math&gt; to the vanilla SGD noise scale equation, &lt;math&gt; g = \frac{\epsilon}{1-m}(\frac{N}{B}-1)\approx \frac{\epsilon N}{B(1-m)} &lt;/math&gt;. They found that by increasing the learning rate and the momentum while proportionally scaling &lt;math&gt; B \propto \frac{\epsilon }{1-m} &lt;/math&gt;, further reduces the number of parameter updates needed during training. However, test accuracy decreases when the momentum coefficient is increased. <br /> <br /> To understand the reasons behind this, we need to analyze momentum update equations below:<br /> <br /> &lt;center&gt;&lt;math&gt;<br /> \Delta A = -(1-m)A + \frac{d\widehat{C}}{dw} <br /> &lt;/math&gt;<br /> <br /> &lt;math&gt;<br /> \Delta w = -A\epsilon<br /> &lt;/math&gt;<br /> &lt;/center&gt;<br /> <br /> We can see that the accumulation variable &lt;math&gt; A &lt;/math&gt;, starting at 0, increases exponentially until it reaches its steady state value during &lt;math&gt; \frac{B}{N(1-m)} &lt;/math&gt; training epochs. If &lt;math&gt; \Delta w &lt;/math&gt; is suppressed, it can reduce the rate of convergence. <br /> <br /> Moreover, at high momentum, we have four challenges:<br /> # Additional epochs are needed to catch up with the accumulation.<br /> # Accumulation needs more time &lt;math&gt; \frac{B}{N(1-m)} &lt;/math&gt; to forget old gradients. <br /> # After this time, however, the accumulation cannot adapt to changes in the loss landscape.<br /> # In the early stage, a large batch size will lead to the instabilities.<br /> <br /> It is thus recommended to keep a reduced learning rate for the first few epochs of training.<br /> <br /> == EXPERIMENTS ==<br /> === SIMULATED ANNEALING IN A WIDE RESNET ===<br /> <br /> '''Dataset:''' CIFAR-10 (50,000 training images)<br /> <br /> '''Network Architecture:''' “16-4” wide ResNet<br /> <br /> '''Training Schedules used as in the below figure:''' . These demonstrate the equivalence between decreasing the learning rate and increasing the batch size.<br /> <br /> - Decaying learning rate: learning rate decays by a factor of 5 at a sequence of “steps”, and the batch size is constant<br /> <br /> - Increasing batch size: learning rate is constant, and the batch size is increased by a factor of 5 at every step.<br /> <br /> - Hybrid: At the beginning, the learning rate is constant and batch size is increased by a factor of 5. Then, the learning rate decays by a factor of 5 at each subsequent step, and the batch size is constant. This is the schedule that will be used if there is a hardware limit affecting a maximum batch size limit.<br /> <br /> If the learning rate itself must decay during training, then these schedules should show different learning curves (as a function of the number of training epochs) and reach different final test set accuracies. Meanwhile, if it is the noise scale which should decay, all three schedules should be indistinguishable.<br /> [[File:Paper_40_Fig_1.png | 800px|center]]<br /> <br /> As shown in the below figure: in the left figure (2a), we can observe that for the training set, the three learning curves are exactly the same while in figure 2b, increasing the batch size has a huge advantage of reducing the number of parameter updates.<br /> This concludes that noise scale is the one that needs to be decayed and not the learning rate itself<br /> [[File:Paper_40_Fig_2.png | 800px|center]] <br /> <br /> To make sure that these results are the same for the test set as well, in figure 3, we can see that the three learning curves are exactly the same for SGD with momentum, and Nesterov momentum. In figure 3b, the test set accuracy when training with Nesterov momentum parameter 0.9 is presented. <br /> [[File:Paper_40_Fig_3.png | 800px|center]]<br /> <br /> To check for other optimizers as well. the below figure shows the same experiment as in figure 3, which is the three learning curves for the test set, but for vanilla SGD and Adam, and showing<br /> [[File:Paper_40_Fig_4.png | 800px|center]]<br /> <br /> In figure 4a, the same experiment is repeated with vanilla SGD, again obtaining three similar curves. Finally, in figure 4b, the authors repeat the experiment with Adam. They also use the default parameter settings of TensorFlow, such that the initial base learning rate here is 0.01, β1 = 0.9 and β2 = 0.999.<br /> <br /> '''Conclusion:''' Decreasing the learning rate and increasing the batch size during training are equivalent<br /> <br /> === INCREASING THE EFFECTIVE LEARNING RATE===<br /> <br /> Here, the focus is on minimizing the number of parameter updates required to train a model. As shown above, the first step is to replace decaying learning rates by increasing batch sizes. Now, the authors show here that we can also increase the effective learning rate &lt;math&gt;\epsilon_{eff} = \epsilon/(1 − m) &lt;/math&gt; at the start of training, while scaling the initial batch size &lt;math&gt;B \propto \epsilon_{eff} &lt;/math&gt; . All experiments are conducted using SGD with momentum. There are 50000 images in the CIFAR-10 training set, and since the scaling rules only hold when &lt;math&gt;B &lt;&lt; N &lt;/math&gt; , we decided to set a maximum batch size &lt;math&gt;B_{max} &lt;/math&gt;= 5120 .<br /> <br /> '''Dataset:''' CIFAR-10 (50,000 training images)<br /> <br /> '''Network Architecture:''' “16-4” wide ResNet<br /> <br /> '''Training Parameters:''' Optimization Algorithm: SGD with momentum / Maximum batch size = 5120<br /> <br /> '''Training Schedules:''' <br /> <br /> The authors consider four training schedules, all of which decay the noise scale by a factor of five in a series of three steps with the same number of epochs.<br /> <br /> Original training schedule: initial learning rate of 0.1 which decays by a factor of 5 at each step, a momentum coefficient of 0.9, and a batch size of 128. Follows the implementation of Zagoruyko &amp; Komodakis (2016).<br /> <br /> Increasing batch size: learning rate of 0.1, momentum coefficient of 0.9, initial batch size of 128 that increases by a factor of 5 at each step. <br /> <br /> Increased initial learning rate: initial learning rate of 0.5, initial batch size of 640 that increase during training.<br /> <br /> Increased momentum coefficient: increased initial learning rate of 0.5, initial batch size of 3200 that increase during training, and an increased momentum coefficient of 0.98.<br /> <br /> The results of all training schedules, which are presented in the below figure, are documented in the following table:<br /> <br /> [[File:Paper_40_Table_1.png | 800px|center]]<br /> <br /> [[File:Paper_40_Fig_5.png | 800px|center]]<br /> <br /> <br /> <br /> '''Conclusion:''' Increasing the effective learning rate and scaling the batch size results in further reduction in the number of parameter updates<br /> <br /> === TRAINING IMAGENET IN 2500 PARAMETER UPDATES===<br /> <br /> '''A) Experiment Goal:''' Control Batch Size<br /> <br /> '''Dataset:''' ImageNet (1.28 million training images)<br /> <br /> The paper modified the setup of Goyal et al. (2017), and used the following configuration:<br /> <br /> '''Network Architecture:''' Inception-ResNet-V2 <br /> <br /> '''Training Parameters:''' <br /> <br /> 90 epochs / noise decayed at epoch 30, 60, and 80 by a factor of 10 / Initial ghost batch size = 32 / Learning rate = 3 / momentum coefficient = 0.9 / Initial batch size = 8192<br /> <br /> Two training schedules were used:<br /> <br /> “Decaying learning rate”, where batch size is fixed and the learning rate is decayed<br /> <br /> “Increasing batch size”, where batch size is increased to 81920 then the learning rate is decayed at two steps.<br /> <br /> [[File:Paper_40_Table_2.png | 800px|center]]<br /> <br /> [[File:Paper_40_Fig_6.png | 800px|center]]<br /> <br /> '''Conclusion:''' Increasing the batch size resulted in reducing the number of parameter updates from 14,000 to 6,000.<br /> <br /> '''B) Experiment Goal:''' Control Batch Size and Momentum Coefficient<br /> <br /> '''Training Parameters:''' Ghost batch size = 64 / noise decayed at epoch 30, 60, and 80 by a factor of 10. <br /> <br /> The below table shows the number of parameter updates and accuracy for different sets of training parameters:<br /> <br /> [[File:Paper_40_Table_3.png | 800px|center]]<br /> <br /> [[File:Paper_40_Fig_7.png | 800px|center]]<br /> <br /> '''Conclusion:''' Increasing the momentum reduces the number of parameter updates but leads to a drop in the test accuracy.<br /> <br /> === TRAINING IMAGENET IN 30 MINUTES===<br /> <br /> '''Dataset:''' ImageNet (already introduced in the previous section)<br /> <br /> '''Network Architecture:''' ResNet-50<br /> <br /> The paper replicated the setup of Goyal et al. (2017) while modifying the number of TPU devices, batch size, learning rate, and then calculating the time to complete 90 epochs, and measuring the accuracy, and performed the following experiments below:<br /> <br /> [[File:Paper_40_Table_4.png | 800px|center]]<br /> <br /> '''Conclusion:''' Model training times can be reduced by increasing the batch size during training.<br /> <br /> == RELATED WORK ==<br /> Main related work mentioned in the paper is as follows:<br /> <br /> - Smith &amp; Le (2017) interpreted Stochastic gradient descent as a stochastic differential equation; the paper built on this idea to include decaying learning rate.<br /> <br /> - Mandt et al. (2017) analyzed how to modify SGD for the task of Bayesian posterior sampling.<br /> <br /> - Keskar et al. (2016) focused on the analysis of noise once the training is started.<br /> <br /> - Moreover, the proportional relationship between batch size and learning rate was first discovered by Goyal et al. (2017) and successfully trained ResNet-50 on ImageNet in one hour after discovering the proportionality relationship between batch size and learning rate.<br /> <br /> - Furthermore, You et al. (2017a) presented Layer-wise Adaptive Rate Scaling (LARS), which is applying different learning rates to train ImageNet in 14 minutes and 74.9% accuracy. <br /> <br /> - Wilson et al. (2017) argued that adaptive optimization methods tend to generalize less well than SGD and SGD with momentum (although<br /> they did not include K-FAC in their study), while the authors' work reduces the gap in convergence speed.<br /> <br /> - Finally, another strategy called Asynchronous-SGD that allowed (Recht et al., 2011; Dean et al., 2012) to use multiple GPUs even with small batch sizes.<br /> <br /> == CONCLUSIONS ==<br /> Increasing the batch size during training has the same benefits of decaying the learning rate in addition to reducing the number of parameter updates, which corresponds to faster training time. Experiments were performed on different image datasets and various optimizers with different training schedules to prove this result. The paper proposed to increase the learning rate and momentum parameter &lt;math&gt;m&lt;/math&gt;, while scaling &lt;math&gt; B \propto \frac{\epsilon}{1-m} &lt;/math&gt;, which achieves fewer parameter updates, but slightly less test set accuracy as mentioned in detail in the experiments’ section. In summary, on ImageNet dataset, Inception-ResNet-V2 achieved 77% validation accuracy in under 2500 parameter updates, and ResNet-50 achieved 76.1% validation set accuracy on TPU in less than 30 minutes. One of the great findings of this paper is that all the methods use the hyper-parameters directly from previous works in the literature, and no additional hyper-parameter tuning was performed.<br /> <br /> == CRITIQUE ==<br /> '''Pros:'''<br /> <br /> - The paper showed empirically that increasing batch size and decaying learning rate are equivalent.<br /> <br /> - Several experiments were performed on different optimizers such as SGD and Adam.<br /> <br /> - Had several comparisons with previous experimental setups.<br /> <br /> - The authors provide quantitative evaluations of their hypothesis by replicating the original training process previously published by other researchers and also implementing an additional training process with an increased batch size. This paper shows the importance of giving enough details not only about the algorithms but also about the hyperparameters, hardware, and other training details that can help other researchers explore other ideas.<br /> <br /> '''Cons:'''<br /> <br /> <br /> - All datasets used are image datasets. Other experiments should have been done on datasets from different domains to ensure generalization. <br /> <br /> - The number of parameter updates was used as a comparison criterion, but wall-clock times could have provided additional measurable judgment although they depend on the hardware used.<br /> <br /> - Special hardware is needed for large batch training, which is not always feasible. As batch-size increases, we generally need more RAM to train the same model. However, if the learning rate is decreased, the RAM use remains constant. As a result, learning rate decay will allow us to train bigger models.<br /> <br /> - In section 5.2 (Increasing the Effective Learning rate), the authors did not test a range of learning rate values and used only (0.1 and 0.5). Additional results from varying the initial learning rate values from 0.1 to 3.2 are provided in the appendix, which indicates that the test accuracy begins to fall for initial learning rates greater than ~0.4. The appended results do not show validation set accuracy curves like in Figure 6, however. It would be beneficial to see if they were similar to the original 0.1 and 0.5 initial learning rate baselines.<br /> <br /> - Although the main idea of the paper is interesting, its results do not seem to be too surprising in comparison with other recent papers in the subject.<br /> <br /> - The paper could benefit from using some other models to demonstrate its claim and generalize its idea by adding some comparisons with other models as well as other recent methods to increase batch size.<br /> <br /> - The paper presents interesting ideas. However, it lacks mathematical and theoretical analysis beyond the idea. Since the experiment is primary on image dataset and it does not provide sufficient theories, the paper itself presents limited applicability to other types. <br /> <br /> - Also, in an experimental setting, only single training runs from one random initialization is used. It would be better to take the best of many runs or to show confidence intervals.<br /> <br /> - It is proposed that we should compare learning rate decay with batch-size increase under the setting that total budget/number of training samples is fixed.<br /> <br /> - While the paper demonstrated the proposed solution can decrease training time, it is not an entirely fair comparison because computations were distributed on a TPU POD. Suppose computing resource remains the same, the purposed method may possibly train slower.<br /> <br /> == REFERENCES ==<br /> # Takuya Akiba, Shuji Suzuki, and Keisuke Fukuda. Extremely large minibatch sgd: Training resnet-50 on imagenet in 15 minutes. arXiv preprint arXiv:1711.04325, 2017.<br /> #Lukas Balles, Javier Romero, and Philipp Hennig. Coupling adaptive batch sizes with learning rates.arXiv preprint arXiv:1612.05086, 2016.<br /> #L´eon Bottou, Frank E Curtis, and Jorge Nocedal. Optimization methods for large-scale machine learning.arXiv preprint arXiv:1606.04838, 2016.<br /> #Richard H Byrd, Gillian M Chin, Jorge Nocedal, and Yuchen Wu. Sample size selection in optimization methods for machine learning. Mathematical programming, 134(1):127–155, 2012.<br /> #Pratik Chaudhari, Anna Choromanska, Stefano Soatto, and Yann LeCun. Entropy-SGD: Biasing gradient descent into wide valleys. arXiv preprint arXiv:1611.01838, 2016.<br /> #Soham De, Abhay Yadav, David Jacobs, and Tom Goldstein. Automated inference with adaptive batches. In Artificial Intelligence and Statistics, pp. 1504–1513, 2017.<br /> #Jeffrey Dean, Greg Corrado, Rajat Monga, Kai Chen, Matthieu Devin, Mark Mao, Andrew Senior, Paul Tucker, Ke Yang, Quoc V Le, et al. Large scale distributed deep networks. In Advances in neural information processing systems, pp. 1223–1231, 2012.<br /> #Michael P Friedlander and Mark Schmidt. Hybrid deterministic-stochastic methods for data fitting.SIAM Journal on Scientific Computing, 34(3):A1380–A1405, 2012.<br /> #Priya Goyal, Piotr Doll´ar, Ross Girshick, Pieter Noordhuis, Lukasz Wesolowski, Aapo Kyrola, Andrew Tulloch, Yangqing Jia, and Kaiming He. Accurate, large minibatch SGD: Training imagenet in 1 hour. arXiv preprint arXiv:1706.02677, 2017.<br /> #Sepp Hochreiter and J¨urgen Schmidhuber. Flat minima. Neural Computation, 9(1):1–42, 1997.<br /> #Elad Hoffer, Itay Hubara, and Daniel Soudry. Train longer, generalize better: closing the generalization gap in large batch training of neural networks. arXiv preprint arXiv:1705.08741, 2017.<br /> #Norman P Jouppi, Cliff Young, Nishant Patil, David Patterson, Gaurav Agrawal, Raminder Bajwa, Sarah Bates, Suresh Bhatia, Nan Boden, Al Borchers, et al. In-datacenter performance analysis of a tensor processing unit. In Proceedings of the 44th Annual International Symposium on Computer Architecture, pp. 1–12. ACM, 2017.<br /> #Nitish Shirish Keskar, Dheevatsa Mudigere, Jorge Nocedal, Mikhail Smelyanskiy, and Ping Tak Peter Tang. On large-batch training for deep learning: Generalization gap and sharp minima. arXiv preprint arXiv:1609.04836, 2016.<br /> #Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.<br /> #Alex Krizhevsky. One weird trick for parallelizing convolutional neural networks. arXiv preprint arXiv:1404.5997, 2014.<br /> #Qianxiao Li, Cheng Tai, and E Weinan. Stochastic modified equations and adaptive stochastic gradient algorithms. arXiv preprint arXiv:1511.06251, 2017.<br /> #Ilya Loshchilov and Frank Hutter. SGDR: stochastic gradient descent with restarts. arXiv preprint arXiv:1608.03983, 2016.<br /> #Stephan Mandt, Matthew D Hoffman, and DavidMBlei. Stochastic gradient descent as approximate bayesian inference. arXiv preprint arXiv:1704.04289, 2017.<br /> #James Martens and Roger Grosse. Optimizing neural networks with kronecker-factored approximate curvature. In International Conference on Machine Learning, pp. 2408–2417, 2015.<br /> #Yurii Nesterov. A method of solving a convex programming problem with convergence rate o (1/k2). In Soviet Mathematics Doklady, volume 27, pp. 372–376, 1983.<br /> #Lutz Prechelt. Early stopping-but when? Neural Networks: Tricks of the trade, pp. 553–553, 1998.<br /> #Benjamin Recht, Christopher Re, Stephen Wright, and Feng Niu. Hogwild: A lock-free approach to parallelizing stochastic gradient descent. In Advances in neural information processing systems, pp. 693–701, 2011.<br /> #Herbert Robbins and Sutton Monro. A stochastic approximation method. The annals of mathematical statistics, pp. 400–407, 1951.<br /> #Samuel L. Smith and Quoc V. Le. A bayesian perspective on generalization and stochastic gradient descent. arXiv preprint arXiv:1710.06451, 2017.<br /> #Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, and Alexander A Alemi. Inception-v4, Inception-ResNet and the impact of residual connections on learning. In AAAI, pp. 4278–4284, 2017.<br /> #Max Welling and Yee W Teh. Bayesian learning via stochastic gradient langevin dynamics. In Proceedings of the 28th International Conference on Machine Learning (ICML-11), pp. 681–688, 2011.<br /> #Ashia C Wilson, Rebecca Roelofs, Mitchell Stern, Nathan Srebro, and Benjamin Recht. The marginal value of adaptive gradient methods in machine learning. arXiv preprint arXiv:1705.08292, 2017.<br /> #Yang You, Igor Gitman, and Boris Ginsburg. Scaling SGD batch size to 32k for imagenet training. arXiv preprint arXiv:1708.03888, 2017a.<br /> #Yang You, Zhao Zhang, C Hsieh, James Demmel, and Kurt Keutzer. Imagenet training in minutes. CoRR, abs/1709.05011, 2017b.<br /> #Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. arXiv preprint arXiv:1605.07146, 2016.<br /> #Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht, and Oriol Vinyals. Understanding deep learning requires rethinking generalization. arXiv preprint arXiv:1611.03530, 2016.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=CapsuleNets&diff=41885 CapsuleNets 2018-11-29T17:32:43Z <p>Jmmoosa: </p> <hr /> <div>The paper &quot;Dynamic Routing Between Capsules&quot; was written by three researchers at Google Brain: Sara Sabour, Nicholas Frosst, and Geoffrey E. Hinton. This paper was published and presented at the 31st Conference on Neural Information Processing Systems (NIPS 2017) in Long Beach, California. The same three researchers recently published a highly related paper &quot;[https://openreview.net/pdf?id=HJWLfGWRb Matrix Capsules with EM Routing]&quot; for ICLR 2018.<br /> <br /> =Motivation=<br /> <br /> Ever since AlexNet eclipsed the performance of competing architectures in the 2012 ImageNet challenge, convolutional neural networks have maintained their dominance in computer vision applications. Despite the recent successes and innovations brought about by convolutional neural networks, some assumptions made in these networks are perhaps unwarranted and deficient. Using a novel neural network architecture, the authors create CapsuleNets, a network that they claim is able to learn image representations in a more robust, human-like manner. With only a 3 layer capsule network, they achieved near state-of-the-art results on MNIST.<br /> ==Adversarial Examples==<br /> <br /> First discussed by Christian Szegedy et. al. in late 2013, adversarial examples have been heavily discussed by the deep learning community as a potential security threat to AI learning. Adversarial examples are defined as inputs that an attacker creates intentionally fool a machine learning model. An example of an adversarial example is shown below: <br /> <br /> [[File:adversarial_img_1.png ‎|center]]<br /> To the human eye, the image appears to be a panda both before and after noise is injected into the image, whereas the trained ConvNet model discerns the noisy image as a Gibbon with almost 100% certainty. The fact that the network is unable to classify the above image as a panda after the epsilon perturbation leads to many potential security risks in AI dependent systems such as self-driving vehicles. Although various methods have been suggested to combat adversarial examples, robust defences are hard to construct due to the inherent difficulties in constructing theoretical models for the adversarial example crafting process. However, beyond the fact that these examples may serve as a security threat, it emphasizes that these convolutional neural networks do not learn image classification/object detection patterns the same way that a human would. Rather than identifying the core features of a panda such as: its eyes, mouth, nose, and the gradient changes in its black/white fur, the convolutional neural network seems to be learning image representations in a completely different manner. Deep learning researchers often attempt to model neural networks after human learning, and it is clear that further steps must be taken to robustify ConvNets against targeted noise perturbations.<br /> <br /> ==Drawbacks of CNNs==<br /> Hinton claims that the key fault with traditional CNNs lies within the pooling function. Although pooling builds translational invariance into the network, it fails to preserve spatial relationships between objects. When we pool, we effectively reduce a kxk kernel of convolved cells into a scalar input. This results in a desired local invariance without inhibiting the network's ability to detect features, but causes valuable spatial information to be lost.<br /> <br /> In the example below, the network is able to detect the similar features (eyes, mouth, nose, etc) within both images, but fails to recognize that one image is a human face, while the other is a Picasso-esque due to the CNN's inability to encode spatial relationships after multiple pooling layers.<br /> <br /> <br /> [[File:Equivariance Face.png ‎|center]]<br /> <br /> Conversely, we hope that a CNN can recognize that both of the following pictures contain a kitten. Unfortunately, when we feed the two images into a ResNet50 architecture, only the first image is correctly classified, while the second image is predicted to be a guinea pig.<br /> <br /> <br /> [[File:kitten.jpeg ‎|center]]<br /> <br /> <br /> [[File:kitten-rotated-180.jpg ‎|center]]<br /> <br /> For a more in depth discussion on the problems with ConvNets, please listen to Geoffrey Hinton's talk &quot;What is wrong with convolutional neural nets?&quot; given at MIT during the Brain &amp; Cognitive Sciences - Fall Colloquium Series (December 4, 2014).<br /> <br /> ==Intuition for Capsules==<br /> Human vision ignores irrelevant details by using a carefully determined sequence of fixation points to ensure that only a tiny fraction of the optic array is ever processed at the highest resolution. Hinton argues that our brains reason visual information by deconstructing it into a hierarchical representation which we then match to familiar patterns and relationships from memory. The key difference between this understanding and the functionality of CNNs is that recognition of an object should not depend on the angle from which it is viewed. <br /> <br /> To enforce rotational and translational equivariance, Capsule Networks store and preserve hierarchical pose relationships between objects. The core idea behind capsule theory is the explicit numerical representations of relative relationships between different objects within an image. Building these relationships into the Capsule Networks model, the network is able to recognize newly seen objects as a rotated view of a previously seen object. For example, the below image shows the Statue of Liberty under five different angles. If a person had only seen the Statue of Liberty from one angle, they would be able to ascertain that all five pictures below contain the same object (just from a different angle).<br /> <br /> [[File:Rotational Invariance.jpeg ‎|center]]<br /> <br /> Building on this idea of hierarchical representation of spatial relationships between key entities within an image, the authors introduce Capsule Networks. Unlike traditional CNNs, Capsule Networks are better equipped to classify correctly under rotational invariance. Furthermore, the authors managed to achieve state of the art results on MNIST using a fraction of the training samples that alternative state of the art networks require.<br /> <br /> <br /> =Background, Notation, and Definitions=<br /> <br /> ==What is a Capsule==<br /> &quot;Each capsule learns to recognize an implicitly defined visual entity over a limited domain of viewing conditions and deformations and it outputs both the probability that the entity is present within its limited domain and a set of “instantiation parameters” that may include the precise pose, lighting and deformation of the visual entity relative to an implicitly defined canonical version of that entity. When the capsule is working properly, the probability of the visual entity being present is locally invariant — it does not change as the entity moves over the manifold of possible appearances within the limited domain covered by the capsule. The instantiation parameters, however, are “equivariant” — as the viewing conditions change and the entity moves over the appearance manifold, the instantiation parameters change by a corresponding amount because they are representing the intrinsic coordinates of the entity on the appearance manifold.&quot;<br /> <br /> In essence, capsules store object properties in a vector form; probability of detection is encoded as the vector's length, while spatial properties are encoded as the individual vector components. Thus, when a feature is present but the image captures it under a different angle, the probability of detection remains unchanged.<br /> <br /> A brief overview/understanding of capsules can be found in other papers from the author. To quote from [https://openreview.net/pdf?id=HJWLfGWRb this paper]:<br /> <br /> &lt;blockquote&gt;<br /> A capsule network consists of several layers of capsules. The set of capsules in layer L is denoted<br /> as &lt;math&gt;\Omega_L&lt;/math&gt;. Each capsule has a 4x4 pose matrix, &lt;math&gt;M&lt;/math&gt;, and an activation probability, &lt;math&gt;a&lt;/math&gt;. These are like the<br /> activities in a standard neural net: they depend on the current input and are not stored. In between<br /> each capsule i in layer L and each capsule j in layer L + 1 is a 4x4 trainable transformation matrix,<br /> &lt;math&gt;W_{ij}&lt;/math&gt; . These &lt;math&gt;W_{ij}&lt;/math&gt;'s (and two learned biases per capsule) are the only stored parameters and they<br /> are learned discriminatively. The pose matrix of capsule i is transformed by &lt;math&gt;W_{ij}&lt;/math&gt; to cast a vote<br /> &lt;math&gt;V_{ij} = M_iW_{ij}&lt;/math&gt; for the pose matrix of capsule j. The poses and activations of all the capsules in layer<br /> L + 1 are calculated by using a non-linear routing procedure which gets as input &lt;math&gt;V_{ij}&lt;/math&gt; and &lt;math&gt;a_i&lt;/math&gt; for all<br /> &lt;math&gt;i \in \Omega_L, j \in \Omega_{L+1}&lt;/math&gt;<br /> &lt;/blockquote&gt;<br /> &lt;math&gt;&lt;/math&gt;<br /> <br /> ==Notation==<br /> <br /> We want the length of the output vector of a capsule to represent the probability that the entity represented by the capsule is present in the current input. The paper performs a non-linear squashing operation to ensure that vector length falls between 0 and 1, with shorter vectors (less likely to exist entities) being shrunk towards 0. <br /> <br /> \begin{align} \mathbf{v}_j &amp;= \frac{||\mathbf{s}_j||^2}{1+ ||\mathbf{s}_j||^2} \frac{\mathbf{s}_j}{||\mathbf{s}_j||} \end{align}<br /> <br /> where &lt;math&gt;\mathbf{v}_j&lt;/math&gt; is the vector output of capsule &lt;math&gt;j&lt;/math&gt; and &lt;math&gt;s_j&lt;/math&gt; is its total input.<br /> <br /> For all but the first layer of capsules, the total input to a capsule &lt;math&gt;s_j&lt;/math&gt; is a weighted sum over all “prediction vectors” &lt;math&gt;\hat{\mathbf{u}}_{j|i}&lt;/math&gt; from the capsules in the layer below and is produced by multiplying the output &lt;math&gt;\mathbf{u}i&lt;/math&gt; of a capsule in the layer below by a weight matrix &lt;math&gt;\mathbf{W}ij&lt;/math&gt;<br /> <br /> \begin{align}<br /> \mathbf{s}_j = \sum_i c_{ij}\hat{\mathbf{u}}_{j|i}, ~\hspace{0.5em} \hat{\mathbf{u}}_{j|i}= \mathbf{W}_{ij}\mathbf{u}_i<br /> \end{align}<br /> where the &lt;math&gt;c_{ij}&lt;/math&gt; are coupling coefficients that are determined by the iterative dynamic routing process.<br /> <br /> The coupling coefficients between capsule &lt;math&gt;i&lt;/math&gt; and all the capsules in the layer above sum to 1 and are determined by a “routing softmax” whose initial logits &lt;math&gt;b_{ij}&lt;/math&gt; are the log prior probabilities that capsule &lt;math&gt;i&lt;/math&gt; should be coupled to capsule &lt;math&gt;j&lt;/math&gt;.<br /> <br /> \begin{align}<br /> c_{ij} = \frac{\exp(b_{ij})}{\sum_k \exp(b_{ik})}<br /> \end{align}<br /> <br /> =Network Training and Dynamic Routing=<br /> <br /> ==Understanding Capsules==<br /> The notation can get somewhat confusing, so I will provide intuition behind the computational steps within a capsule. The following image is taken from naturomic's talk on Capsule Networks.<br /> <br /> [[File:CapsuleNets.jpeg|center|800px]]<br /> <br /> The above image illustrates the key mathematical operations happening within a capsule (and compares them to the structure of a neuron). Although the operations are rather straightforward, it's crucial to note that the capsule computes an affine transformation onto each input vector. The length of the input vectors &lt;math&gt;\mathbf{u}_{i}&lt;/math&gt; represent the probability of entity &lt;math&gt;i&lt;/math&gt; existing in a lower level. This vector is then reoriented with an affine transform using &lt;math&gt;\mathbf{W}_{ij}&lt;/math&gt; matrices that encode spatial relationships between entity &lt;math&gt;\mathbf{u}_{i}&lt;/math&gt; and other lower level features.<br /> <br /> We illustrate the intuition behind vector-to-vector matrix multiplication within capsules using the following example: if vectors &lt;math&gt;\mathbf{u}_{1}&lt;/math&gt;, &lt;math&gt;\mathbf{u}_{2}&lt;/math&gt;, and &lt;math&gt;\mathbf{u}_{3}&lt;/math&gt; represent detection of eyes, nose, and mouth respectively, then after multiplication with trained weight matrices &lt;math&gt;\mathbf{W}_{ij}&lt;/math&gt; (where j denotes existence of a face), we should get a general idea of the general location of the higher level feature (face), similar to the image below.<br /> <br /> [[File:Predictions.jpeg ‎|center]]<br /> <br /> ==Dynamic Routing==<br /> A capsule &lt;math&gt;i&lt;/math&gt; in a lower-level layer needs to decide how to send its output vector to higher-level capsules &lt;math&gt;j&lt;/math&gt;. This decision is made with probability proportional to &lt;math&gt;c_{ij}&lt;/math&gt;. If there are &lt;math&gt;K&lt;/math&gt; capsules in the level that capsule &lt;math&gt;i&lt;/math&gt; routes to, then we know the following properties about &lt;math&gt;c_{ij}&lt;/math&gt;: &lt;math&gt;\sum_{j=1}^M c_{ij} = 1, c_{ij} \geq 0&lt;/math&gt;<br /> <br /> In essence, the &lt;math&gt;\{c_{ij}\}_{j=1}^M&lt;/math&gt; denotes a discrete probability distribution with respect to capsule &lt;math&gt;i&lt;/math&gt;'s output location. Lower level capsules decide which higher level capsules to send vectors into by adjusting the corresponding routing weights &lt;math&gt;\{c_{ij}\}_{j=1}^M&lt;/math&gt;. After a few iterations in training, numerous vectors will have already been sent to all higher level capsules. Based on the similarity between the current vector being routed and all vectors already sent into the higher level capsules, we decide which capsule to send the current vector into.<br /> [[File:Dynamic Routing.png|center|900px]]<br /> <br /> In the image above, we notice that a cluster of points similar to the current vector has already been routed into capsule K, while most points in capsule J are highly dissimilar. It thus makes more sense to route the current observation into capsule K; we adjust the corresponding weight upwards during training.<br /> <br /> These weights are determined through the dynamic routing procedure:<br /> [[File:Routing Algo.png‎|900px]]<br /> <br /> <br /> Although dynamic routing is not the only manner in which we can encode relationships between capsules, the premise of the paper is to demonstrate the capabilities of capsules under a simple implementation. Since the paper's release in 2017, numerous alternative routing implementations have been released including an EM matrix routing algorithm by the same authors (ICLR 2018).<br /> <br /> =Architecture=<br /> The capsule network architecture given by the authors has 11.36 million trainable parameters. The paper itself is not very detailed on exact implementation of each architectural layer, and hence it leaves some degree of ambiguity on coding various aspects of the original network. The capsule network has 6 overall layers, with the first three layers denoting components of the encoder, and the last 3 denoting components of the decoder.<br /> <br /> ==Loss Function==<br /> [[File:Loss Function.png‎|900px]]<br /> <br /> The cost function looks very complicated, but can be broken down into intuitive components. Before diving into the equation, remember that the length of the vector denotes the probability of object existence. The left side of the equation denotes loss when the network classifies an observation correctly; the term becomes zero when the classification is incorrect. To compute loss when the network correctly classifies the label, we subtract the vector norm from a fixed quantity &lt;math&gt;m^+ := 0.9&lt;/math&gt;. On the other hand, when the network classifies a label incorrectly, we penalize the loss based on the network's confidence in the incorrect label; we compute the loss by subtracting &lt;math&gt;m^- := 0.1&lt;/math&gt; from the vector norm.<br /> <br /> A graphical representation of loss function values under varying vector norms is given below.<br /> [[File:Loss function chart.png|900px]]<br /> <br /> ==Encoder Layers==<br /> All experiments within this paper were conducted on the MNIST dataset, and thus the architecture is built to classify the corresponding dataset. For more complex datasets, the experiments were less promising. <br /> <br /> [[File:Architecture.png|center|900px]]<br /> <br /> The encoder layer takes in a 28x28 MNIST image and learns a 16 dimensional representation of instantiation parameters.<br /> <br /> '''Layer 1: Convolution''': <br /> This layer is a standard convolution layer. Using kernels with size 9x9x1, a stride of 1, and a ReLU activation function, we detect the 2D features within the network.<br /> <br /> '''Layer 2: PrimaryCaps''': <br /> We represent the low level features detected during convolution as 32 primary capsules. Each capsule applies eight convolutional kernels with stride 2 to the output of the convolution layer and feeds the corresponding transformed tensors into the DigiCaps layer.<br /> <br /> '''Layer 3: DigiCaps''': <br /> This layer contains 10 digit capsules, one for each digit. As explained in the dynamic routing procedure, each input vector from the PrimaryCaps layer has its own corresponding weight matrix &lt;math&gt;W_{ij}&lt;/math&gt;. Using the routing coefficients &lt;math&gt;c_{ij}&lt;/math&gt; and temporary coefficients &lt;math&gt;b_{ij}&lt;/math&gt;, we train the DigiCaps layer to output a ten 16 dimensional vectors. The length of the &lt;math&gt;i^{th}&lt;/math&gt; vector in this layer corresponds to the probability of detection of digit &lt;math&gt;i&lt;/math&gt;.<br /> <br /> ==Decoder Layers==<br /> The decoder layer aims to train the capsules to extract meaningful features for image detection/classification. During training, it takes the 16 layer instantiation vector of the correct (not predicted) DigiCaps layer, and attempts to recreate the 28x28 MNIST image as best as possible. Setting the loss function as reconstruction error (Euclidean distance between the reconstructed image and original image), we tune the capsules to encode features that are meaningful within the actual image.<br /> <br /> [[File:Decoder.png|center|900px]]<br /> <br /> The layer consists of three fully connected layers, and transforms a 16x1 vector from the encoder layer into a 28x28 image.<br /> <br /> In addition to the digicaps loss function, we add reconstruction error as a form of regularization. We minimize the Euclidean distance between the outputs of the logistic units and the pixel intensities of the original and reconstructed images. We scale down this reconstruction loss by 0.0005 so that it does not dominate the margin loss during training. As illustrated below, reconstructions from the 16D output of the CapsNet are robust while keeping only important details.<br /> <br /> [[File:Reconstruction.png|center|900px]]<br /> <br /> =MNIST Experimental Results=<br /> <br /> ==Accuracy==<br /> The paper tests on the MNIST dataset with 60K training examples, and 10K testing. Wan et al.  achieves 0.21% test error with ensembling and augmenting the data with rotation and scaling. They achieve 0.39% without them. As shown in Table 1, the authors manage to achieve 0.25% test error with only a 3 layer network; the previous state of the art only beat this number with very deep networks. This example shows the importance of routing and reconstruction regularizer, which boosts the performance. On the other hand, while the accuracies are very high, the number of parameters is much smaller compared to the baseline model.<br /> <br /> [[File:Accuracies.png|center|900px]]<br /> <br /> ==What Capsules Represent for MNIST==<br /> The following figure shows the digit representation under capsules. Each row shows the reconstruction when one of the 16 dimensions in the DigitCaps representation is tweaked by intervals of 0.05 in the range [−0.25, 0.25]. By tweaking the values, we notice how the reconstruction changes, and thus get a sense for what each dimension is representing. The authors found that some dimensions represent global properties of the digits, while other represent localized properties. <br /> [[File:CapsuleReps.png|center|900px]]<br /> <br /> One example the authors provide is: different dimensions are used for the length of the ascender of a 6 and the size of the loop. The variations include stroke thickness, skew and width, as well as digit-specific variations. The authors are able to show dimension representations using a decoder network by feeding a perturbed vector.<br /> <br /> ==Robustness of CapsNet==<br /> The authors conclude that DigitCaps capsules learn more robust representations for each digit class than traditional CNNs. The trained CapsNet becomes moderately robust to small affine transformations in the test data.<br /> <br /> To compare the robustness of CapsNet to affine transformations against traditional CNNs, both models (CapsNet and a traditional CNN with MaxPooling and DropOut) were trained on a padded and translated MNIST training set, in which each example is an MNIST digit placed randomly on a black background of 40 × 40 pixels. The networks were then tested on the [http://www.cs.toronto.edu/~tijmen/affNIST/ affNIST] dataset (MNIST digits with random affine transformation). An under-trained CapsNet which achieved 99.23% accuracy on the MNIST test set achieved a corresponding 79% accuracy on the affnist test set. A traditional CNN achieved similar accuracy (99.22%) on the mnist test set, but only 66% on the affnist test set.<br /> <br /> =MultiMNIST &amp; Other Experiments=<br /> <br /> ==MultiMNIST==<br /> To evaluate the performance of the model on highly overlapping digits, the authors generate a 'MultiMNIST' dataset. In MultiMNIST, images are two overlaid MNIST digits of the same set(train or test) but different classes. The results indicate a classification error rate of 5%. Additionally, CapsNet can be used to segment the image into the two digits that compose it. Moreover, the model is able to deal with the overlaps and reconstruct digits correctly since each digit capsule can learn the style from the votes of PrimaryCapsules layer (Figure 5).<br /> <br /> There are some additional steps to generating the MultiMNIST dataset.<br /> <br /> 1. Both images are shifted by up to 4 pixels in each direction resulting in a 36 × 36 image. Bounding boxes of digits in MNIST overlap by approximately 80%, so this is used to make both digits identifiable (since there is no RGB difference learnable by the network to separate the digits)<br /> <br /> 2. The label becomes a vector of two numbers, representing the original digit and the randomly generated (and overlaid) digit.<br /> <br /> <br /> <br /> [[File:CapsuleNets MultiMNIST.PNG|600px|thumb|center|Figure 5: Sample reconstructions of a CapsNet with 3 routing iterations on MultiMNIST test dataset.<br /> The two reconstructed digits are overlayed in green and red as the lower image. The upper image<br /> shows the input image. L:(l1; l2) represents the label for the two digits in the image and R:(r1; r2)<br /> represents the two digits used for reconstruction. The two right most columns show two examples<br /> with wrong classification reconstructed from the label and from the prediction (P). In the (2; 8)<br /> example the model confuses 8 with a 7 and in (4; 9) it confuses 9 with 0. The other columns have<br /> correct classifications and show that the model accounts for all the pixels while being able to assign<br /> one pixel to two digits in extremely difficult scenarios (column 1 − 4). Note that in dataset generation<br /> the pixel values are clipped at 1. The two columns with the (*) mark show reconstructions from a<br /> digit that is neither the label nor the prediction. These columns suggest that the model is not just<br /> finding the best fit for all the digits in the image including the ones that do not exist. Therefore in case<br /> of (5; 0) it cannot reconstruct a 7 because it knows that there is a 5 and 0 that fit best and account for<br /> all the pixels. Also, in the case of (8; 1) the loop of 8 has not triggered 0 because it is already accounted<br /> for by 8. Therefore it will not assign one pixel to two digits if one of them does not have any other<br /> support.]]<br /> <br /> ==Other datasets==<br /> The authors also tested the proposed capsule model on CIFAR10 dataset and achieved an error rate of 10.6%. The model tested was an ensemble of 7 models. Each of the models in the ensemble had the same architecture as the model used for MNIST (apart from 3 additional channels and 64 different types of primary capsules being used). These 7 models were trained on 24x24 patches of the training images for 3 iterations. During experimentation, the authors also found out that adding an additional none-of-the-above category helped improved the overall performance. The error rate achieved is comparable to the error rate achieved by a standard CNN model. According to the authors, one of the reasons for low performance is the fact that background in CIFAR-10 images are too varied for it to be adequately modeled by reasonably sized capsule net.<br /> <br /> The proposed model was also evaluated using a small subset of SVHN dataset. The network trained was much smaller and trained using only 73257 training images. The network still managed to achieve an error rate of 4.3% on the test set.<br /> <br /> =Critique=<br /> Although the network performs incredibly favorably in the author's experiments, it has a long way to go on more complex datasets. On CIFAR 10, the network achieved subpar results, and the experimental results seem to be worse when the problem becomes more complex. This is anticipated, since these networks are still in their early stage; later innovations might come in the upcoming decades/years. It could also be wise to apply the model to other datasets with larger sizes to make the functionality more acceptable. MNIST dataset has simple patterns and even if the model wanted to be presented with only one dataset, it was better not to be MNIST dataset especially in this case that the focus is on human-eye detection and numbers are not that regular in real-life experiences.<br /> <br /> Hinton talks about CapsuleNets revolutionizing areas such as self-driving, but such groundbreaking innovations are far away from CIFAR10, and even further from MNIST. Only time can tell if CapsNets will live up to their hype.<br /> <br /> Capsules inherently segment images and learn a lower dimensional embedding in a new manner, which makes them likely to perform well on segmentation and computer vision tasks once further research is done. <br /> <br /> Additionally, these networks are more interpretable than CNNs, and have strong theoretical reasoning for why they could work. Naturally, it would be hard for a new architecture to beat the heavily researched/modified CNNs.<br /> <br /> * ([https://openreview.net/forum?id=HJWLfGWRb]) it's not fully clear how effective it can be performed / how scalable it is. Evaluation is performed on a small dataset for shape recognition. The approach will need to be tested on larger, more challenging datasets.<br /> <br /> =Future Work=<br /> The same authors [N. F. Geoffrey E Hinton, Sara Sabour] presented another paper &quot;MATRIX CAPSULES WITH EM ROUTING&quot; in ICLR 2018, which achieved better results than the work presented in this paper. They presented a new multi-layered capsule network architecture, implemented an EM routing procedure, and introduced &quot;Coordinate Addition&quot;. This new type reduced number of errors by 45%, and performed better than standard CNN on white box adversarial attacks. Capsule architectures are gaining interest because of their ability to achieve equivariance of parts, and employ a new form of pooling called &quot;routing&quot; (as opposed to max pooling) which groups parts that make similar predictions of the whole to which they belong, rather than relying on spatial co-locality.<br /> Moreover, we may try to change the curvature and sensitivities to various factors by introducing new form of loss function. It may improve the performance of the model for more complicated data set which is one of the model's drawback.<br /> <br /> Moreover, as mentioned in critiques, a good future work for this group would be making the model more robust to the dataset and achieve acceptable performance on datasets with more regularly seen images in real life experiences.<br /> <br /> =References=<br /> #N. F. Geoffrey E Hinton, Sara Sabour. Matrix capsules with em routing. In International Conference on Learning Representations, 2018.<br /> #S. Sabour, N. Frosst, and G. E. Hinton, “Dynamic routing between capsules,” arXiv preprint arXiv:1710.09829v2, 2017<br /> # Hinton, G. E., Krizhevsky, A. and Wang, S. D. (2011), Transforming Auto-encoders <br /> #Geoffrey Hinton's talk: What is wrong with convolutional neural nets? - Talk given at MIT. Brain &amp; Cognitive Sciences - Fall Colloquium Series. [https://www.youtube.com/watch?v=rTawFwUvnLE ]<br /> #Understanding Hinton’s Capsule Networks - Max Pechyonkin's series [https://medium.com/ai%C2%B3-theory-practice-business/understanding-hintons-capsule-networks-part-i-intuition-b4b559d1159b]<br /> #ReferencesMartín Abadi, Ashish Agarwal, Paul Barham, Eugene Brevdo, Zhifeng Chen, Craig Citro, Greg SCorrado, Andy Davis, Jeffrey Dean, Matthieu Devin, et al. Tensorflow: Large-scale machinelearning on heterogeneous distributed systems.arXiv preprint arXiv:1603.04467, 2016.<br /> #Jimmy Ba, Volodymyr Mnih, and Koray Kavukcuoglu. Multiple object recognition with visualattention.arXiv preprint arXiv:1412.7755, 2014.<br /> #Jia-Ren Chang and Yong-Sheng Chen. Batch-normalized maxout network in network.arXiv preprintarXiv:1511.02583, 2015.<br /> #Dan C Cire ̧san, Ueli Meier, Jonathan Masci, Luca M Gambardella, and Jürgen Schmidhuber. High-performance neural networks for visual object classification.arXiv preprint arXiv:1102.0183,2011.<br /> #Ian J Goodfellow, Yaroslav Bulatov, Julian Ibarz, Sacha Arnoud, and Vinay Shet. Multi-digit numberrecognition from street view imagery using deep convolutional neural networks.arXiv preprintarXiv:1312.6082, 2013.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=ShakeDrop_Regularization&diff=41848 ShakeDrop Regularization 2018-11-29T16:46:14Z <p>Jmmoosa: /* Existing Methods */</p> <hr /> <div>=Introduction=<br /> Current state of the art techniques for object classification are deep neural networks based on the residual block, first published by (He et al., 2016). This technique has been the foundation of several improved networks, including Wide ResNet (Zagoruyko &amp; Komodakis, 2016), PyramdNet (Han et al., 2017) and ResNeXt (Xie et al., 2017). They have been further improved by regularization, such as Stochastic Depth (ResDrop) (Huang et al., 2016) and Shake-Shake (Gastaldi, 2017), which can avoid some problem like vanishing gradients. Shake-Shake applied to ResNeXt has achieved one of the lowest error rates on the CIFAR-10 and CIFAR-100 datasets. However, it is only applicable to multi-branch architectures and is not memory efficient since it requires two branches of residual blocks to apply. To address this problem, ShakeDrop regularization that can realize a similar disturbance to Shake-Shake on a single residual block is proposed. Moreover, they use ResDrop to stabilize the learning process. This paper seeks to formulate a general expansion of Shake-Shake that can be applied to any residual block based network.<br /> <br /> =Existing Methods=<br /> <br /> '''Deep Approaches'''<br /> <br /> '''ResNet''', was the first use of residual blocks, a foundational feature in many modern state of the art convolution neural networks. They can be formulated as &lt;math&gt;G(x) = x + F(x)&lt;/math&gt; where &lt;math&gt;x&lt;/math&gt; and &lt;math&gt;G(x)&lt;/math&gt; are the input and output of the residual block, and &lt;math&gt;F(x)&lt;/math&gt; is the output of the residual branch on the residual block. A residual block typically performs a convolution operation and then passes the result plus its input onto the next block.<br /> <br /> Intuition behind Residual blocks:<br /> If the identity mapping is optimal, We can easily push the residuals to zero (F(x) = 0) than to fit an identity mapping (x, input=output) by a stack of non-linear layers. In simple language it is very easy to come up with a solution like F(x) =0 rather than F(x)=x using stack of non-linear cnn layers as function (Think about it). So, this function F(x) is what the authors called Residual function ([https://medium.com/@14prakash/understanding-and-implementing-architectures-of-resnet-and-resnext-for-state-of-the-art-image-cf51669e1624 Reference]).<br /> <br /> <br /> [[File:ResidualBlock.png|580px|centre|thumb|An example of a simple residual block from Deep Residual Learning for Image Recognition by He et al., 2016]]<br /> <br /> ResNet is constructed out of a large number of these residual blocks sequentially stacked. It is interesting to note that having too many layers can cause overfitting, as pointed out by He et al. (2016) with the high error rates for the 1,202-layer ResNet on CIFAR datasets. Another paper (Veit et al., 2016) empirically showed that the cause of the high error rates can be mostly attributed to specific residual blocks whose channels increase greatly.<br /> <br /> '''PyramidNet''' is an important iteration that built on ResNet and WideResNet by gradually increasing channels on each residual block. The residual block is similar to those used in ResNet. It has been used to generate some of the first successful convolution neural networks with very large depth, at 272 layers. Amongst unmodified residual network architectures, it performs the best on the CIFAR datasets.<br /> <br /> [[File:ResidualBlockComparison.png|980px|centre|thumb|A simple illustration of different residual blocks from Deep Pyramidal Residual Networks by Han et al., 2017. The width of a block reflects the number of channels used in that layer.]]<br /> <br /> <br /> '''Non-Deep Approaches'''<br /> <br /> '''Wide ResNet''' modified ResNet by increasing channels in each layer, having a wider and shallower structure. Similarly to PyramidNet, this architecture avoids some of the pitfalls in the original formulation of ResNet.<br /> <br /> '''ResNeXt''' achieved performance beyond that of Wide ResNet with only a small increase in the number of parameters. It can be formulated as &lt;math&gt;G(x) = x + F_1(x)+F_2(x)&lt;/math&gt;. In this case, &lt;math&gt;F_1(x)&lt;/math&gt; and &lt;math&gt;F_2(x)&lt;/math&gt; are the outputs of two paired convolution operations in a single residual block. The number of branches is not limited to 2, and will control the result of this network.<br /> <br /> <br /> [[File:SimplifiedResNeXt.png|600px|centre|thumb|Simplified ResNeXt Convolution Block. Yamada et al., 2018]]<br /> <br /> <br /> '''Regularization Methods'''<br /> <br /> '''Stochastic Depth''' helped address the issue of vanishing gradients in ResNet. It works by randomly dropping residual blocks. On the &lt;math&gt;l^{th}&lt;/math&gt; residual block the Stochastic Depth process is given as &lt;math&gt;G(x)=x+b_lF(x)&lt;/math&gt; where &lt;math&gt;b_l \in \{0,1\}&lt;/math&gt; is a Bernoulli random variable with probability &lt;math&gt;p_l&lt;/math&gt;. Using a constant value for &lt;math&gt;p_l&lt;/math&gt; didn't work well, so instead a linear decay rule &lt;math&gt;p_l = 1 - \frac{l}{L}(1-p_L)&lt;/math&gt; was used. In this equation, &lt;math&gt;L&lt;/math&gt; is the number of layers, and &lt;math&gt;p_L&lt;/math&gt; is the initial parameter. <br /> <br /> '''Shake-Shake''' is a regularization method that specifically improves the ResNeXt architecture. It can be given as &lt;math&gt;G(x)=x+\alpha F_1(x)+(1-\alpha)F_2(x)&lt;/math&gt;, where &lt;math&gt;\alpha \in [0,1]&lt;/math&gt; is a random coefficient. &lt;math&gt;\alpha&lt;/math&gt; is used during the forward pass, and another identically distributed random parameter &lt;math&gt;\beta&lt;/math&gt; is used in the backward pass. This caused one of the two paired convolution operations to be dropped, and further improved ResNeXt.<br /> <br /> [[File:Paper 32.jpg|600px|centre|thumb| Shake-Shake (ResNeXt + Shake-Shake) (Gastaldi, 2017), in which some processing layers omitted for conciseness.]]<br /> <br /> =Proposed Method=<br /> This paper seeks to generalize the method proposed in Shake-Shake to be applied to any residual structure network. Shake-Shake. The initial formulation of 1-branch shake is &lt;math&gt;G(x) = x + \alpha F(x)&lt;/math&gt;. In this case, &lt;math&gt;\alpha&lt;/math&gt; is a coefficient that disturbs the forward pass, but is not necessarily constrained to be [0,1]. Another corresponding coefficient &lt;math&gt;\beta&lt;/math&gt; is used in the backwards pass. Applying this simple adaptation of Shake-Shake on a 110-layer version of PyramidNet with &lt;math&gt;\alpha \in [0,1]&lt;/math&gt; and &lt;math&gt;\beta \in [0,1]&lt;/math&gt; performs abysmally, with an error rate of 77.99%.<br /> <br /> This failure is a result of the setup causing too much perturbation. A trick is needed to promote learning with large perturbations, to preserve the regularization effect. The idea of the authors is to borrow from ResDrop and combine that with Shake-Shake. This works by randomly deciding whether to apply 1-branch shake. This creates in effect two networks, the original network without a regularization component, and a regularized network. When mixing up two networks, we expected the following effects: When the non regularized network is selected, learning is promoted; when the perturbed network is selected, learning is disturbed. Achieving good performance requires a balance between the two. <br /> <br /> '''ShakeDrop''' is given as <br /> <br /> &lt;div align=&quot;center&quot;&gt;<br /> &lt;math&gt;G(x) = x + (b_l + \alpha - b_l \alpha)F(x)&lt;/math&gt;,<br /> &lt;/div&gt;<br /> <br /> where &lt;math&gt;b_l&lt;/math&gt; is a Bernoulli random variable following the linear decay rule used in Stochastic Depth. An alternative presentation is <br /> <br /> &lt;div align=&quot;center&quot;&gt;<br /> &lt;math&gt;<br /> G(x) = \begin{cases}<br /> x + F(x) ~~ \text{if } b_l = 1 \\<br /> x + \alpha F(x) ~~ \text{otherwise}<br /> \end{cases}<br /> &lt;/math&gt;<br /> &lt;/div&gt;<br /> <br /> If &lt;math&gt;b_l = 1&lt;/math&gt; then ShakeDrop is equivalent to the original network, otherwise it is the network + 1-branch Shake. The authors also found that the linear decay rule of ResDrop works well, compared with the uniform rule. Regardless of the value of &lt;math&gt;\beta&lt;/math&gt; on the backwards pass, network weights will be updated.<br /> <br /> =Experiments=<br /> <br /> '''Parameter Search'''<br /> <br /> The authors experiments began with a hyperparameter search utilizing ShakeDrop on pyramidal networks. The PyramidNet used was made up of a total of 110 layers which included a convolutional layer and a final fully connected layer. It had 54 additive pyramidal residual blocks and the final residual block had 286 channels. The results of this search are presented below. <br /> <br /> [[File:ShakeDropHyperParameterSearch.png|600px|centre|thumb|Average Top-1 errors (%) of “PyramidNet + ShakeDrop” with several ranges of parameters of 4 runs at the final (300th) epoch on CIFAR-100 dataset in the “Batch” level. In some settings, it is equivalent to PyramidNet and PyramidDrop. Borrowed from ShakeDrop Regularization by Yamada et al., 2018.]]<br /> <br /> The setting that are used throughout the rest of the experiments are then &lt;math&gt;\alpha \in [-1,1]&lt;/math&gt; and &lt;math&gt;\beta \in [0,1]&lt;/math&gt;. Cases H and F outperform PyramidNet, suggesting that the strong perturbations imposed by ShakeDrop are functioning as intended. However, fully applying the perturbations in the backwards pass appears to destabilize the network, resulting in performance that is worse than standard PyramidNet.<br /> <br /> [[File:ParameterUpdateShakeDrop.png|400px|centre]]<br /> <br /> Following this initial parameter decision, the authors tested 4 different strategies for parameter update among &quot;Batch&quot; (same coefficients for all images in minibatch for each residual block), &quot;Image&quot; (same scaling coefficients for each image for each residual block), &quot;Channel&quot; (same scaling coefficients for each element for each residual block), and &quot;Pixel&quot; (same scaling coefficients for each element for each residual block). While Pixel was the best in terms of error rate, it is not very memory efficient, so Image was selected as it had the second best performance without the memory drawback.<br /> <br /> '''Comparison with Regularization Methods'''<br /> <br /> For these experiments, there are a few modifications that were made to assist with training. For ResNeXt, the EraseRelu formulation has each residual block ends in batch normalization. The Wide ResNet also is compared between vanilla with batch normalization and without. Batch normalization keeps the outputs of residual blocks in a certain range, as otherwise &lt;math&gt;\alpha&lt;/math&gt; and &lt;math&gt;\beta&lt;/math&gt; could cause perturbations that are too large, causing divergent learning. There is also a comparison of ResDrop/ShakeDrop Type A (where the regularization unit is inserted before the add unit for a residual branch) and after (where the regularization unit is inserted after the add unit for a residual branch). <br /> <br /> These experiments are performed on the CIFAR-100 dataset.<br /> <br /> [[File:ShakeDropArchitectureComparison1.png|800px|centre|thumb|]]<br /> <br /> [[File:ShakeDropArchitectureComparison2.png|800px|centre|thumb|]]<br /> <br /> [[File:ShakeDropArchitectureComparison3.png|800px|centre|thumb|]]<br /> <br /> For a final round of testing, the training setup was modified to incorporate other techniques used in state of the art methods. For most of the tests, the learning rate for the 300 epoch version started at 0.1 and decayed by a factor of 0.1 1/2 &amp; 3/4 of the way through training. The alternative was cosine annealing, based on the presentation by Loshchilov and Hutter in their paper SGDR: Stochastic Gradient Descent with Warm Restarts. This is indicated in the Cos column, with a check indicating cosine annealing. <br /> <br /> [[File:CosineAnnealing.png|400px|centre|thumb|]]<br /> <br /> The Reg column indicates the regularization method used, either none, ResDrop (RD), Shake-Shake (SS), or ShakeDrop (SD). Fianlly, the Fil Column determines the type of data augmentation used, either none, cutout (CO) (DeVries &amp; Taylor, 2017b), or Random Erasing (RE) (Zhong et al., 2017). <br /> <br /> [[File:ShakeDropComparison.png|800px|centre|thumb|Top-1 Errors (%) at final epoch on CIFAR-10/100 datasets]]<br /> <br /> '''State-of-the-Art Comparisons'''<br /> <br /> A direct comparison with state of the art methods is favorable for this new method. <br /> <br /> # Fair comparison of ResNeXt + Shake-Shake with PyramidNet + ShakeDrop gives an improvement of 0.19% on CIFAR-10 and 1.86% on CIFAR-100. Under these conditions, the final error rate is then 2.67% for CIFAR-10 and 13.99% for CIFAR-100.<br /> # Fair comparison of ResNeXt + Shake-Shake + Cutout with PyramidNet + ShakeDrop + Random Erasing gives an improvement of 0.25% on CIFAR-10 and 3.01% on CIFAR 100. Under these conditions, the final error rate is then 2.31% for CIFAR-10 and 12.19% for CIFAR-100.<br /> # Comparison with the state-of-the-arts, PyramidNet + ShakeDrop gives an improvement of 0.25% on CIFAR-10 than ResNeXt + Shake-Shake + Cutout, PyramidNet + ShakeDrop gives an improvement of 2.85% on CIFAR-100 than Coupled Ensemble.<br /> <br /> =Conclusion=<br /> <br /> This paper proposed a new stochastic regularization method, ShakeDrop, which outperforms previous state of the art methods while maintaining similar memory efficiency. It demonstrates that heavily perturbing a network can help to overcome issues with overfitting. It is also an effective way to regularize residual networks for image classification. The method was tested by CIFAR-10/100 and Tiny ImageNet datasets and showed great performance.<br /> <br /> =Critique=<br /> <br /> The novelty of this paper is low as pointed out by the reviewers. The proposed ShakeDrop regularization is essentially a combination of the PyramidDrop and Shake-Shake regularization. The most surprising part is that the forward weight can be negative thus inverting the output of a convolution. The mathematical justification for ShakeDrop regularization is limited, relying on intuition and empirical evidence instead.<br /> As pointed out from the above, the method basically relies heavily on the intuition. This means that the performance of the algorithm can vary a lot depending on the characteristics of data sets that users are performing, with some exaggeration. However, the performance is still impressive since it performs better than known algorithms.<br /> <br /> =References=<br /> [Yamada et al., 2018] Yamada Y, Iwamura M, Kise K. ShakeDrop regularization. arXiv preprint arXiv:1802.02375. 2018 Feb 7.<br /> <br /> [He et al., 2016] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proc. CVPR, 2016.<br /> <br /> [Zagoruyko &amp; Komodakis, 2016] Sergey Zagoruyko and Nikos Komodakis. Wide residual networks. In Proc. BMVC, 2016.<br /> <br /> [Han et al., 2017] Dongyoon Han, Jiwhan Kim, and Junmo Kim. Deep pyramidal residual networks. In Proc. CVPR, 2017a.<br /> <br /> [Xie et al., 2017] Saining Xie, Ross Girshick, Piotr Dollar, Zhuowen Tu, and Kaiming He. Aggregated residual transformations for deep neural networks. In Proc. CVPR, 2017.<br /> <br /> [Huang et al., 2016] Gao Huang, Yu Sun, Zhuang Liu, Daniel Sedra, and Kilian Weinberger. Deep networks with stochastic depth. arXiv preprint arXiv:1603.09382v3, 2016.<br /> <br /> [Gastaldi, 2017] Xavier Gastaldi. Shake-shake regularization. arXiv preprint arXiv:1705.07485v2, 2017.<br /> <br /> [Loshilov &amp; Hutter, 2016] Ilya Loshchilov and Frank Hutter. Sgdr: Stochastic gradient descent with warm restarts. arXiv preprint arXiv:1608.03983, 2016.<br /> <br /> [DeVries &amp; Taylor, 2017b] Terrance DeVries and Graham W. Taylor. Improved regularization of convolutional neural networks with cutout. arXiv preprint arXiv:1708.04552, 2017b.<br /> <br /> [Zhong et al., 2017] Zhun Zhong, Liang Zheng, Guoliang Kang, Shaozi Li, and Yi Yang. Random erasing data augmentation. arXiv preprint arXiv:1708.04896, 2017.<br /> <br /> [Dutt et al., 2017] Anuvabh Dutt, Denis Pellerin, and Georges Qunot. Coupled ensembles of neural networks. arXiv preprint 1709.06053v1, 2017.<br /> <br /> [Veit et al., 2016] Andreas Veit, Michael J Wilber, and Serge Belongie. Residual networks behave like ensembles of relatively shallow networks. Advances in Neural Information Processing Systems 29, 2016.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=stat946F18/Autoregressive_Convolutional_Neural_Networks_for_Asynchronous_Time_Series&diff=41846 stat946F18/Autoregressive Convolutional Neural Networks for Asynchronous Time Series 2018-11-29T16:44:44Z <p>Jmmoosa: /* Experiments */</p> <hr /> <div>This page is a summary of the paper &quot;[http://proceedings.mlr.press/v80/binkowski18a/binkowski18a.pdf Autoregressive Convolutional Neural Networks for Asynchronous Time Series]&quot; by Mikołaj Binkowski, Gautier Marti, Philippe Donnat. It was published at ICML in 2018. The code for this paper is provided [https://github.com/mbinkowski/nntimeseries here].<br /> <br /> =Introduction=<br /> In this paper, the authors propose a deep convolutional network architecture called Significance-Offset Convolutional Neural Network for regression of multivariate asynchronous time series. The model is inspired by standard autoregressive (AR) models and gating systems used in recurrent neural networks. The model is evaluated on various time series data including:<br /> # Hedge fund proprietary dataset of over 2 million quotes for a credit derivative index, <br /> # An artificially generated noisy auto-regressive series, <br /> # A UCI household electricity consumption dataset. <br /> <br /> This paper focuses on time series that have multivariate and noisy signals, especially financial data. Financial time series is challenging to predict due to their low signal-to-noise ratio and heavy-tailed distributions. For example, the same signal (e.g. price of a stock) is obtained from different sources (e.g. financial news, an investment bank, financial analyst etc.) asynchronously. Each source may have a different bias or noise. ([[Media: Junyi1.png|Figure 1]]) The investment bank with more clients can update their information more precisely than the investment bank with fewer clients, which means the significance of each past observations may depend on other factors that change in time. Therefore, the traditional econometric models such as AR, VAR (Vector Autoregressive Model), VARMA (Vector Autoregressive Moving Average Model)  might not be sufficient. However, their relatively good performance could allow us to combine such linear econometric models with deep neural networks that can learn highly nonlinear relationships. This model is inspired by the gating mechanism which is successful in RNNs and Highway Networks.<br /> <br /> The time series forecasting problem can be expressed as a conditional probability distribution below,<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;p(X_{t+d}|X_t,X_{t-1},...) = f(X_t,X_{t-1},...)&lt;/math&gt;&lt;/div&gt;<br /> Thus, we focus on modeling the predictors of future values of time series given their past values. <br /> <br /> The reasons that financial time series are particularly challenging:<br /> * Low signal-to-noise ratio and heavy-tailed distributions.<br /> * Being observed different sources (e.g. financial news, analysts, portfolio managers in hedge funds, market-makers in investment banks) in asynchronous moments of time. Each of these sources may have a different bias and noise with respect to the original signal that needs to be recovered.<br /> * Data sources are usually strongly correlated and lead-lag relationships are possible (e.g. a market-maker with more clients can update its view more frequently and precisely than one with fewer clients). <br /> * The significance of each of the available past observations might be dependent on some other factors that can change in time. Hence, the traditional econometric models such as AR, VAR, VARMA might not be sufficient.<br /> <br /> The predictability of financial dataset still remains an open problem and is discussed in various publications .<br /> <br /> [[File:Junyi1.png | 500px|thumb|center|Figure 1: Quotes from four different market participants (sources) for the same credit default swaps (CDS) throughout one day. Each trader displays from time to time the prices for which he offers to buy (bid) and sell (ask) the underlying CDS. The filled area marks the difference between the best sell and buy offers (spread) at each time.]]<br /> <br /> The paper also provides empirical evidence that their model which combines linear models with deep learning models could perform better than just DL models like CNN, LSTMs and Phased LSTMs.<br /> <br /> =Related Work=<br /> ===Time series forecasting===<br /> From recent proceedings in main machine learning venues i.e. ICML, NIPS, AISTATS, UAI, we can notice that time series are often forecast using Gaussian processes[3,4], especially for irregularly sampled time series. Though still largely independent, combined models have started to appear, for example, the Gaussian Copula Process Volatility model. For this paper, the authors use coupling AR models and neural networks to achieve such combined models.<br /> <br /> Although deep neural networks have been applied into many fields and produced satisfactory results, there still is little literature on deep learning for time series forecasting. More recently, the papers include Sirignano (2016) that used 4-layer perceptrons in modeling price change distributions in Limit Order Books, and Borovykh et al. (2017) who applied more recent WaveNet architecture to several short univariate and bivariate time-series (including financial ones). Heaton et al. (2016) claimed to use autoencoders with a single hidden layer to compress multivariate financial data. Neil et al. (2016) presented augmentation of LSTM architecture suitable for asynchronous series, which stimulates learning dependencies of different frequencies through time gate. <br /> <br /> In this paper, the authors examine the capabilities of several architectures (CNN, residual network, multi-layer LSTM, and phase LSTM) on AR-like artificial asynchronous and noisy time series, household electricity consumption dataset, and on real financial data from the credit default swap market with some inefficiencies.<br /> <br /> ====AR Model====<br /> <br /> An autoregressive (AR) model describes the next value in a time-series as a combination of previous values, scaling factors, a bias, and noise [https://onlinecourses.science.psu.edu/stat501/node/358/ (source)]. For a p-th order (relating the current state to the p last states), the equation of the model is:<br /> <br /> &lt;math&gt; X_t = c + \sum_{i=1}^p \varphi_i X_{t-i}+ \varepsilon_t \,&lt;/math&gt; [https://en.wikipedia.org/wiki/Autoregressive_model#Definition (equation source)]<br /> <br /> With parameters/coefficients &lt;math&gt;\varphi_i&lt;/math&gt;, constant &lt;math&gt;c&lt;/math&gt;, and noise &lt;math&gt;\varepsilon_t&lt;/math&gt; This can be extended to vector form to create the VAR model mentioned in the paper.<br /> <br /> ===Gating and weighting mechanisms===<br /> Gating mechanisms for neural networks has ability to overcome the problem of vanishing gradient, and can be expressed as &lt;math display=&quot;inline&quot;&gt;f(x)=c(x) \otimes \sigma(x)&lt;/math&gt;, where &lt;math&gt;f&lt;/math&gt; is the output function, &lt;math&gt;c&lt;/math&gt; is a &quot;candidate output&quot; (a nonlinear function of &lt;math&gt;x&lt;/math&gt;), &lt;math&gt;\otimes&lt;/math&gt; is an element-wise matrix product, and &lt;math&gt;\sigma : \mathbb{R} \rightarrow [0,1] &lt;/math&gt; is a sigmoid nonlinearity that controls the amount of output passed to the next layer. Different composition of functions of the same type as described above have proven to be an essential ingredient in popular recurrent architecture such as LSTM and GRU.<br /> <br /> The main purpose of the proposed gating system is to weight the outputs of the intermediate layers within neural networks, and is most closely related to softmax gating used in MuFuRu(Multi-Function Recurrent Unit), i.e.<br /> &lt;math display=&quot;inline&quot;&gt; f(x) = \sum_{l=1}^L p^l(x) \otimes f^l(x)\text{,}\ p(x)=\text{softmax}(\widehat{p}(x)), &lt;/math&gt;, where &lt;math&gt;(f^l)_{l=1}^L &lt;/math&gt;are candidate outputs (composition operators in MuFuRu), &lt;math&gt;(\widehat{p}^l)_{l=1}^L &lt;/math&gt;are linear functions of inputs. <br /> <br /> This idea is also successfully used in attention networks such as image captioning and machine translation. In this paper, the proposed method is similar as the separate inputs (time series steps in this case) are weighted in accordance with learned functions of these inputs. The difference is that the functions are being modeled using multi-layer CNNs. Another difference is that the proposed method is not using recurrent layers, which enables the network to remember parts of the sentence/image already translated/described.<br /> <br /> =Motivation=<br /> There are mainly five motivations that are stated in the paper by the authors:<br /> #The forecasting problem in this paper has been done almost independently by econometrics and machine learning communities. Unlike in machine learning, research in econometrics is more likely to explain variables rather than improving out-of-sample prediction power. These models tend to 'over-fit' on financial time series, their parameters are unstable and have poor performance on out-of-sample prediction.<br /> #It is difficult for the learning algorithms to deal with time series data where the observations have been made irregularly. Although Gaussian processes provide a useful theoretical framework that is able to handle asynchronous data, they are not suitable for financial datasets, which often follow heavy-tailed distribution .<br /> #Predictions of autoregressive time series may involve highly nonlinear functions if sampled irregularly. For AR time series with higher order and have more past observations, the expectation of it &lt;math display=&quot;inline&quot;&gt;\mathbb{E}[X(t)|{X(t-m), m=1,...,M}]&lt;/math&gt; may involve more complicated functions that in general may not allow closed-form expression.<br /> #In practice, the dimensions of multivariate time series are often observed separately and asynchronously, such series at fixed frequency may lead to lose information or enlarge the dataset, which is shown in Figure 2(a). Therefore, the core of the proposed architecture SOCNN represents separate dimensions as a single one with dimension and duration indicators as additional features(Figure 2(b)).<br /> #Given a series of pairs of consecutive input values and corresponding durations, &lt;math display=&quot;inline&quot;&gt; x_n = (X(t_n),t_n-t_{n-1}) &lt;/math&gt;. One may expect that LSTM may memorize the input values in each step and weight them at the output according to the duration, but this approach may lead to an imbalance between the needs for memory and for linearity. The weights that are assigned to the memorized observations potentially require several layers of nonlinearity to be computed properly, while past observations might just need to be memorized as they are.<br /> <br /> [[File:Junyi2.png | 550px|thumb|center|Figure 2: (a) Fixed sampling frequency and its drawbacks; keep- ing all available information leads to much more datapoints. (b) Proposed data representation for the asynchronous series. Consecutive observations are stored together as a single value series, regardless of which series they belong to; this information, however, is stored in indicator features, alongside durations between observations.]]<br /> <br /> =Model Architecture=<br /> Suppose there exists a multivariate time series &lt;math display=&quot;inline&quot;&gt;(x_n)_{n=0}^{\infty} \subset \mathbb{R}^d &lt;/math&gt;, we want to predict the conditional future values of a subset of elements of &lt;math&gt;x_n&lt;/math&gt;<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;y_n = \mathbb{E} [x_n^I | \{x_{n-m}, m=1,2,...\}], &lt;/math&gt;&lt;/div&gt;<br /> where &lt;math&gt; I=\{i_1,i_2,...i_{d_I}\} \subset \{1,2,...,d\} &lt;/math&gt; is a subset of features of &lt;math&gt;x_n&lt;/math&gt;.<br /> <br /> Let &lt;math&gt; \textbf{x}_n^{-M} = (x_{n-m})_{m=1}^M &lt;/math&gt;. <br /> <br /> The estimator of &lt;math&gt;y_n&lt;/math&gt; can be expressed as:<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;\hat{y}_n = \sum_{m=1}^M [F(\textbf{x}_n^{-M}) \otimes \sigma(S(\textbf{x}_n^{-M}))].,_m ,&lt;/math&gt;&lt;/div&gt;<br /> The estimate is the summation of the columns of the matrix in bracket. Here<br /> #&lt;math&gt;F,S : \mathbb{R}^{d \times M} \rightarrow \mathbb{R}^{d_I \times M}&lt;/math&gt; are neural networks. <br /> #* &lt;math&gt;S&lt;/math&gt; is a fully convolutional network which is composed of convolutional layers only. <br /> #* &lt;math display=&quot;inline&quot;&gt;F(\textbf{x}_n^{-M}) = W \otimes [\text{off}(x_{n-m}) + x_{n-m}^I)]_{m=1}^M &lt;/math&gt; <br /> #** &lt;math&gt; W \in \mathbb{R}^{d_I \times M}&lt;/math&gt; <br /> #** &lt;math&gt; \text{off}: \mathbb{R}^d \rightarrow \mathbb{R}^{d_I} &lt;/math&gt; is a multilayer perceptron.<br /> <br /> #&lt;math&gt;\sigma&lt;/math&gt; is a normalized activation function independent at each row, i.e. &lt;math display=&quot;inline&quot;&gt; \sigma ((a_1^T, ..., a_{d_I}^T)^T)=(\sigma(a_1)^T,..., \sigma(a_{d_I})^T)^T &lt;/math&gt;<br /> #* for any &lt;math&gt;a_{i} \in \mathbb{R}^{M}&lt;/math&gt;<br /> #* and &lt;math&gt;\sigma &lt;/math&gt; is defined such that &lt;math&gt;\sigma(a)^{T} \mathbf{1}_{M}=1&lt;/math&gt; for any &lt;math&gt;a \in \mathbb{R}^M&lt;/math&gt;.<br /> # &lt;math&gt;\otimes&lt;/math&gt; is element-wise matrix multiplication (also known as Hadamard matrix multiplication).<br /> #&lt;math&gt;A.,_m&lt;/math&gt; denotes the m-th column of a matrix A.<br /> <br /> Since &lt;math&gt;\sum_{m=1}^M W.,_m=W\cdot(1,1,...,1)^T&lt;/math&gt; and &lt;math&gt;\sum_{m=1}^M S.,_m=S\cdot(1,1,...,1)^T&lt;/math&gt;, we can express &lt;math&gt;\hat{y}_n&lt;/math&gt; as:<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;\hat{y}_n = \sum_{m=1}^M W.,_m \otimes (off(x_{n-m}) + x_{n-m}^I) \otimes \sigma(S.,_m(\textbf{x}_n^{-M}))&lt;/math&gt;&lt;/div&gt;<br /> This is the proposed network, Significance-Offset Convolutional Neural Network, &lt;math&gt;\text{off}&lt;/math&gt; and &lt;math&gt;S&lt;/math&gt; in the equation are corresponding to Offset and Significance in the name respectively.<br /> Figure 3 shows the scheme of network.<br /> <br /> [[File:Junyi3.png | 600px|thumb|center|Figure 3: A scheme of the proposed SOCNN architecture. The network preserves the time-dimension up to the top layer, while the number of features per timestep (filters) in the hidden layers is custom. The last convolutional layer, however, has the number of filters equal to dimension of the output. The Weighting frame shows how outputs from offset and significance networks are combined in accordance with Eq. of &lt;math&gt;\hat{y}_n&lt;/math&gt;.]]<br /> <br /> The form of &lt;math&gt;\hat{y}_n&lt;/math&gt; ensures the separation of the temporal dependence (obtained in weights &lt;math&gt;W_m&lt;/math&gt;). &lt;math&gt;S&lt;/math&gt;, which represents the local significance of observations, is determined by its filters which capture local dependencies and are independent of the relative position in time, and the predictors &lt;math&gt;\text{off}(x_{n-m})&lt;/math&gt; are completely independent of position in time. An adjusted single regressor for the target variable is provided by each past observation through the offset network. Since in asynchronous sampling procedure, consecutive values of x come from different signals and might be heterogeneous, therefore adjustment of offset network is important. In addition, significance network provides data-dependent weight for each regressor and sums them up in an autoregressive manner.<br /> <br /> ===Relation to asynchronous data===<br /> One common problem of time series is that durations are varying between consecutive observations, the paper states two ways to solve this problem<br /> #Data preprocessing: aligning the observations at some fixed frequency e.g. duplicating and interpolating observations as shown in Figure 2(a). However, as mentioned in the figure, this approach will tend to loss of information and enlarge the size of the dataset and model complexity.<br /> #Add additional features: Treating the duration or time of the observations as additional features, it is the core of SOCNN, which is shown in Figure 2(b).<br /> <br /> ===Loss function===<br /> The L2 error is a natural loss function for the estimators of expected value: &lt;math&gt;L^2(y,y')=||y-y'||^2&lt;/math&gt;<br /> <br /> The output of the offset network is series of separate predictors of changes between corresponding observations &lt;math&gt;x_{n-m}^I&lt;/math&gt; and the target value&lt;math&gt;y_n&lt;/math&gt;, this is the reason why we use auxiliary loss function, which equals to mean squared error of such intermediate predictions:<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;L^{aux}(\textbf{x}_n^{-M}, y_n)=\frac{1}{M} \sum_{m=1}^M ||off(x_{n-m}) + x_{n-m}^I -y_n||^2 &lt;/math&gt;&lt;/div&gt;<br /> The total loss for the sample &lt;math&gt; \textbf{x}_n^{-M},y_n) &lt;/math&gt; is then given by:<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;L^{tot}(\textbf{x}_n^{-M}, y_n)=L^2(\widehat{y}_n, y_n)+\alpha L^{aux}(\textbf{x}_n^{-M}, y_n)&lt;/math&gt;&lt;/div&gt;<br /> where &lt;math&gt;\widehat{y}_n&lt;/math&gt; was mentioned before, &lt;math&gt;\alpha \geq 0&lt;/math&gt; is a constant.<br /> <br /> =Experiments=<br /> The paper evaluated SOCNN architecture on three datasets: artificially generated datasets, [https://archive.ics.uci.edu/ml/datasets/Individual+household+electric+power+consumption household electric power consumption dataset], and the financial dataset of bid/ask quotes provided by several market participants active in the credit derivatives market. Comparing its performance with simple CNN, single and multiplayer LSTM and 25-layer ResNet. Apart from the evaluation of the SOCNN architecture the paper also discusses the impact of network components such as auxiliary<br /> loss and the depth of the offset sub-network. The code and datasets are available [https://github.com/mbinkowski/nntimeseries here]<br /> <br /> ==Datasets==<br /> Artificial data: They generated 4 artificial series, &lt;math&gt; X_{K \times N}&lt;/math&gt;, where &lt;math&gt;K \in \{16,64\} &lt;/math&gt;. Therefore there is a synchronous and an asynchronous series for each K value.<br /> <br /> Electricity data: This UCI dataset contains 7 different features excluding date and time. The features include global active power, global reactive power, voltage, global intensity, sub-metering 1, sub-metering 2 and sub-metering 3, recorded every minute for 47 months. The data has been altered so that one observation contains only one value of 7 features, while durations between consecutive observations are ranged from 1 to 7 minutes. The goal is to predict all 7 features for the next time step.<br /> <br /> Non-anonymous quotes: The dataset contains 2.1 million quotes from 28 different sources from different market participants such as analysts, banks etc. Each quote is characterized by 31 features: the offered price, 28 indicators of the quoting source, the direction indicator (the quote refers to either a buy or a sell offer) and duration from the previous quote. For each source and direction, we want to predict the next quoted price from this given source and direction considering the last 60 quotes.<br /> <br /> ==Training details==<br /> They applied grid search on some hyperparameters in order to get the significance of its components. The hyperparameters include the offset sub-network's depth and the auxiliary weight &lt;math&gt;\alpha&lt;/math&gt;. For offset sub-network's depth, they use 1, 10,1 for artificial, electricity and quotes dataset respectively; and they compared the values of &lt;math&gt;\alpha&lt;/math&gt; in {0,0.1,0.01}.<br /> <br /> They chose LeakyReLU as activation function for all networks:<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;\sigma^{LeakyReLU}(x) = x&lt;/math&gt; if &lt;math&gt;x\geq 0&lt;/math&gt;, and &lt;math&gt;0.1x&lt;/math&gt; otherwise &lt;/div&gt;<br /> They use the same number of layers, same stride and similar kernel size structure in CNN. In each trained CNN, they applied max pooling with the pool size of 2 every 2 convolutional layers.<br /> <br /> Table 1 presents the configuration of network hyperparameters used in comparison<br /> <br /> [[File:Junyi4.png | 520px|center|]]<br /> <br /> ===Network Training===<br /> The training and validation data were sampled randomly from the first 80% of timesteps in each series, with ratio of 3 to 1. The remaining 20% of data was used as a test set.<br /> <br /> All models were trained using Adam optimizer because the authors found that its rate of convergence was much faster than standard Stochastic Gradient Descent in early tests.<br /> <br /> They used a batch size of 128 for artificial and electricity data, and 256 for quotes dataset, and applied batch normalization between each convolution and the following activation. <br /> <br /> At the beginning of each epoch, the training samples were randomly sampled. To prevent overfitting, they applied dropout and early stopping.<br /> <br /> Weights were initialized using the normalized uniform procedure proposed by Glorot &amp; Bengio (2010).<br /> <br /> The authors carried out the experiments on Tensorflow and Keras and used different GPU to optimize the model for different datasets.<br /> <br /> ==Results==<br /> Table 2 shows all results performed from all datasets.<br /> [[File:Junyi5.png | 800px|center|]]<br /> We can see that SOCNN outperforms in all asynchronous artificial, electricity and quotes datasets. For synchronous data, LSTM might be slightly better, but SOCNN almost has the same results with LSTM. Phased LSTM and ResNet have performed really bad on artificial asynchronous dataset and quotes dataset respectively. Notice that having more than one layer of offset network would have negative impact on results. Also, the higher weights of auxiliary loss(&lt;math&gt;\alpha&lt;/math&gt;considerably improved the test error on asynchronous dataset, see Table 3. However, for other datasets, its impact was negligible.<br /> [[File:Junyi6.png | 480px|center|]]<br /> In general, SOCNN has significantly lower variance of the test and validation errors, especially in the early stage of the training process and for quotes dataset. This effect can be seen in the learning curves for Asynchronous 64 artificial dataset presented in Figure 5.<br /> [[File:Junyi7.png | 500px|thumb|center|Figure 5: Learning curves with different auxiliary weights for SOCNN model trained on Asynchronous 64 dataset. The solid lines indicate the test error while the dashed lines indicate the training error.]]<br /> <br /> Finally, we want to test the robustness of the proposed model SOCNN, adding noise terms to asynchronous 16 dataset and check how these networks perform. The result is shown in Figure 6.<br /> [[File:Junyi8.png | 600px|thumb|center|Figure 6: Experiment comparing robustness of the considered networks for Asynchronous 16 dataset. The plots show how the error would change if an additional noise term was added to the input series. The dotted curves show the total significance and average absolute offset (not to scale) outputs for the noisy observations. Interestingly, the significance of the noisy observations increases with the magnitude of noise; i.e. noisy observations are far from being discarded by SOCNN.]]<br /> From Figure 6, the purple line and green line seems staying at the same position in training and testing process. SOCNN and single-layer LSTM are most robust compared to other networks, and least prone to overfitting.<br /> <br /> =Conclusion and Discussion=<br /> In this paper, the authors have proposed a new architecture called Significance-Offset Convolutional Neural Network, which combines AR-like weighting mechanism and convolutional neural network. This new architecture is designed for high-noise asynchronous time series and achieves outperformance in forecasting several asynchronous time series compared to popular convolutional and recurrent networks. <br /> <br /> The SOCNN can be extended further by adding intermediate weighting layers of the same type in the network structure. Another possible extension but needs further empirical studies is that we consider not just &lt;math&gt;1 \times 1&lt;/math&gt; convolutional kernels on the offset sub-network. Also, this new architecture might be tested on other real-life datasets with relevant characteristics in the future, especially on econometric datasets and more generally for time series (stochastic processes) regression.<br /> <br /> =Critiques=<br /> #The paper is most likely an application paper, and the proposed new architecture shows improved performance over baselines in the asynchronous time series.<br /> #The quote data cannot be reached, only two datasets available.<br /> #The 'Significance' network was described as critical to the model in paper, but they did not show how the performance of SOCNN with respect to the significance network.<br /> #The transform of the original data to asynchronous data is not clear.<br /> #The experiments on the main application are not reproducible because the data is proprietary.<br /> #The way that train and test data were split is unclear. This could be important in the case of the financial data set.<br /> #Although the auxiliary loss function was mentioned as an important part, the advantages of it was not too clear in the paper. Maybe it is better that the paper describes a little more about its effectiveness.<br /> #It was not mentioned clearly in the paper whether the model training was done on a rolling basis for time series forecasting.<br /> #The noise term used in section 5's model robustness analysis uses evenly distributed noise (see Appendix B). While the analysis is a good start, analysis with different noise distributions would make the findings more generalizable.<br /> #The paper uses financial/economic data as one of its testing data set. Instead of comparing neural network models such as CNN which is known to work badly on time series data, it would be much better if the author compared to well-known econometric time series models such as GARCH and VAR.<br /> <br /> =References=<br />  Hamilton, J. D. Time series analysis, volume 2. Princeton university press Princeton, 1994. <br /> <br />  Fama, E. F. Efficient capital markets: A review of theory and empirical work. The journal of Finance, 25(2):383–417, 1970.<br /> <br />  Petelin, D., Sˇindela ́ˇr, J., Pˇrikryl, J., and Kocijan, J. Financial modeling using gaussian process models. In Intelligent Data Acquisition and Advanced Computing Systems (IDAACS), 2011 IEEE 6th International Conference on, volume 2, pp. 672–677. IEEE, 2011.<br /> <br />  Tobar, F., Bui, T. D., and Turner, R. E. Learning stationary time series using gaussian processes with nonparametric kernels. In Advances in Neural Information Processing Systems, pp. 3501–3509, 2015.<br /> <br />  Hwang, Y., Tong, A., and Choi, J. Automatic construction of nonparametric relational regression models for multiple time series. In Proceedings of the 33rd International Conference on Machine Learning, 2016.<br /> <br />  Wilson, A. and Ghahramani, Z. Copula processes. In Advances in Neural Information Processing Systems, pp. 2460–2468, 2010.<br /> <br />  Sirignano, J. Extended abstract: Neural networks for limit order books, February 2016.<br /> <br />  Borovykh, A., Bohte, S., and Oosterlee, C. W. Condi- tional time series forecasting with convolutional neural networks, March 2017.<br /> <br />  Heaton, J. B., Polson, N. G., and Witte, J. H. Deep learn- ing in finance, February 2016.<br /> <br />  Neil, D., Pfeiffer, M., and Liu, S.-C. Phased lstm: Acceler- ating recurrent network training for long or event-based sequences. In Advances In Neural Information Process- ing Systems, pp. 3882–3890, 2016.<br /> <br />  Chung, J., Gulcehre, C., Cho, K., and Bengio, Y. Em- pirical evaluation of gated recurrent neural networks on sequence modeling, December 2014.<br /> <br />  Weissenborn, D. and Rockta ̈schel, T. MuFuRU: The Multi-Function recurrent unit, June 2016.<br /> <br />  Cho, K., Courville, A., and Bengio, Y. Describing multi- media content using attention-based Encoder–Decoder networks. IEEE Transactions on Multimedia, 17(11): 1875–1886, July 2015. ISSN 1520-9210.<br /> <br />  Glorot, X. and Bengio, Y. Understanding the dif- ficulty of training deep feedforward neural net- works. In In Proceedings of the International Con- ference on Artificial Intelligence and Statistics (AIS- TATSaˆ10). Society for Artificial Intelligence and Statistics, 2010.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=stat946F18/Autoregressive_Convolutional_Neural_Networks_for_Asynchronous_Time_Series&diff=41839 stat946F18/Autoregressive Convolutional Neural Networks for Asynchronous Time Series 2018-11-29T16:37:01Z <p>Jmmoosa: /* Results */</p> <hr /> <div>This page is a summary of the paper &quot;[http://proceedings.mlr.press/v80/binkowski18a/binkowski18a.pdf Autoregressive Convolutional Neural Networks for Asynchronous Time Series]&quot; by Mikołaj Binkowski, Gautier Marti, Philippe Donnat. It was published at ICML in 2018. The code for this paper is provided [https://github.com/mbinkowski/nntimeseries here].<br /> <br /> =Introduction=<br /> In this paper, the authors propose a deep convolutional network architecture called Significance-Offset Convolutional Neural Network for regression of multivariate asynchronous time series. The model is inspired by standard autoregressive (AR) models and gating systems used in recurrent neural networks. The model is evaluated on various time series data including:<br /> # Hedge fund proprietary dataset of over 2 million quotes for a credit derivative index, <br /> # An artificially generated noisy auto-regressive series, <br /> # A UCI household electricity consumption dataset. <br /> <br /> This paper focuses on time series that have multivariate and noisy signals, especially financial data. Financial time series is challenging to predict due to their low signal-to-noise ratio and heavy-tailed distributions. For example, the same signal (e.g. price of a stock) is obtained from different sources (e.g. financial news, an investment bank, financial analyst etc.) asynchronously. Each source may have a different bias or noise. (Figure 1) The investment bank with more clients can update their information more precisely than the investment bank with fewer clients, which means the significance of each past observations may depend on other factors that change in time. Therefore, the traditional econometric models such as AR, VAR (Vector Autoregressive Model), VARMA (Vector Autoregressive Moving Average Model)  might not be sufficient. However, their relatively good performance could allow us to combine such linear econometric models with deep neural networks that can learn highly nonlinear relationships. This model is inspired by the gating mechanism which is successful in RNNs and Highway Networks.<br /> <br /> The time series forecasting problem can be expressed as a conditional probability distribution below,<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;p(X_{t+d}|X_t,X_{t-1},...) = f(X_t,X_{t-1},...)&lt;/math&gt;&lt;/div&gt;<br /> Thus, we focus on modeling the predictors of future values of time series given their past values. <br /> <br /> The reasons that financial time series are particularly challenging:<br /> * Low signal-to-noise ratio and heavy-tailed distributions.<br /> * Being observed different sources (e.g. financial news, analysts, portfolio managers in hedge funds, market-makers in investment banks) in asynchronous moments of time. Each of these sources may have a different bias and noise with respect to the original signal that needs to be recovered.<br /> * Data sources are usually strongly correlated and lead-lag relationships are possible (e.g. a market-maker with more clients can update its view more frequently and precisely than one with fewer clients). <br /> * The significance of each of the available past observations might be dependent on some other factors that can change in time. Hence, the traditional econometric models such as AR, VAR, VARMA might not be sufficient.<br /> <br /> The predictability of financial dataset still remains an open problem and is discussed in various publications .<br /> <br /> [[File:Junyi1.png | 500px|thumb|center|Figure 1: Quotes from four different market participants (sources) for the same credit default swaps (CDS) throughout one day. Each trader displays from time to time the prices for which he offers to buy (bid) and sell (ask) the underlying CDS. The filled area marks the difference between the best sell and buy offers (spread) at each time.]]<br /> <br /> The paper also provides empirical evidence that their model which combines linear models with deep learning models could perform better than just DL models like CNN, LSTMs and Phased LSTMs.<br /> <br /> =Related Work=<br /> ===Time series forecasting===<br /> From recent proceedings in main machine learning venues i.e. ICML, NIPS, AISTATS, UAI, we can notice that time series are often forecast using Gaussian processes[3,4], especially for irregularly sampled time series. Though still largely independent, combined models have started to appear, for example, the Gaussian Copula Process Volatility model. For this paper, the authors use coupling AR models and neural networks to achieve such combined models.<br /> <br /> Although deep neural networks have been applied into many fields and produced satisfactory results, there still is little literature on deep learning for time series forecasting. More recently, the papers include Sirignano (2016) that used 4-layer perceptrons in modeling price change distributions in Limit Order Books, and Borovykh et al. (2017) who applied more recent WaveNet architecture to several short univariate and bivariate time-series (including financial ones). Heaton et al. (2016) claimed to use autoencoders with a single hidden layer to compress multivariate financial data. Neil et al. (2016) presented augmentation of LSTM architecture suitable for asynchronous series, which stimulates learning dependencies of different frequencies through time gate. <br /> <br /> In this paper, the authors examine the capabilities of several architectures (CNN, residual network, multi-layer LSTM, and phase LSTM) on AR-like artificial asynchronous and noisy time series, household electricity consumption dataset, and on real financial data from the credit default swap market with some inefficiencies.<br /> <br /> ====AR Model====<br /> <br /> An autoregressive (AR) model describes the next value in a time-series as a combination of previous values, scaling factors, a bias, and noise [https://onlinecourses.science.psu.edu/stat501/node/358/ (source)]. For a p-th order (relating the current state to the p last states), the equation of the model is:<br /> <br /> &lt;math&gt; X_t = c + \sum_{i=1}^p \varphi_i X_{t-i}+ \varepsilon_t \,&lt;/math&gt; [https://en.wikipedia.org/wiki/Autoregressive_model#Definition (equation source)]<br /> <br /> With parameters/coefficients &lt;math&gt;\varphi_i&lt;/math&gt;, constant &lt;math&gt;c&lt;/math&gt;, and noise &lt;math&gt;\varepsilon_t&lt;/math&gt; This can be extended to vector form to create the VAR model mentioned in the paper.<br /> <br /> ===Gating and weighting mechanisms===<br /> Gating mechanisms for neural networks has ability to overcome the problem of vanishing gradient, and can be expressed as &lt;math display=&quot;inline&quot;&gt;f(x)=c(x) \otimes \sigma(x)&lt;/math&gt;, where &lt;math&gt;f&lt;/math&gt; is the output function, &lt;math&gt;c&lt;/math&gt; is a &quot;candidate output&quot; (a nonlinear function of &lt;math&gt;x&lt;/math&gt;), &lt;math&gt;\otimes&lt;/math&gt; is an element-wise matrix product, and &lt;math&gt;\sigma : \mathbb{R} \rightarrow [0,1] &lt;/math&gt; is a sigmoid nonlinearity that controls the amount of output passed to the next layer. Different composition of functions of the same type as described above have proven to be an essential ingredient in popular recurrent architecture such as LSTM and GRU.<br /> <br /> The main purpose of the proposed gating system is to weight the outputs of the intermediate layers within neural networks, and is most closely related to softmax gating used in MuFuRu(Multi-Function Recurrent Unit), i.e.<br /> &lt;math display=&quot;inline&quot;&gt; f(x) = \sum_{l=1}^L p^l(x) \otimes f^l(x)\text{,}\ p(x)=\text{softmax}(\widehat{p}(x)), &lt;/math&gt;, where &lt;math&gt;(f^l)_{l=1}^L &lt;/math&gt;are candidate outputs (composition operators in MuFuRu), &lt;math&gt;(\widehat{p}^l)_{l=1}^L &lt;/math&gt;are linear functions of inputs. <br /> <br /> This idea is also successfully used in attention networks such as image captioning and machine translation. In this paper, the proposed method is similar as the separate inputs (time series steps in this case) are weighted in accordance with learned functions of these inputs. The difference is that the functions are being modeled using multi-layer CNNs. Another difference is that the proposed method is not using recurrent layers, which enables the network to remember parts of the sentence/image already translated/described.<br /> <br /> =Motivation=<br /> There are mainly five motivations that are stated in the paper by the authors:<br /> #The forecasting problem in this paper has been done almost independently by econometrics and machine learning communities. Unlike in machine learning, research in econometrics is more likely to explain variables rather than improving out-of-sample prediction power. These models tend to 'over-fit' on financial time series, their parameters are unstable and have poor performance on out-of-sample prediction.<br /> #It is difficult for the learning algorithms to deal with time series data where the observations have been made irregularly. Although Gaussian processes provide a useful theoretical framework that is able to handle asynchronous data, they are not suitable for financial datasets, which often follow heavy-tailed distribution .<br /> #Predictions of autoregressive time series may involve highly nonlinear functions if sampled irregularly. For AR time series with higher order and have more past observations, the expectation of it &lt;math display=&quot;inline&quot;&gt;\mathbb{E}[X(t)|{X(t-m), m=1,...,M}]&lt;/math&gt; may involve more complicated functions that in general may not allow closed-form expression.<br /> #In practice, the dimensions of multivariate time series are often observed separately and asynchronously, such series at fixed frequency may lead to lose information or enlarge the dataset, which is shown in Figure 2(a). Therefore, the core of the proposed architecture SOCNN represents separate dimensions as a single one with dimension and duration indicators as additional features(Figure 2(b)).<br /> #Given a series of pairs of consecutive input values and corresponding durations, &lt;math display=&quot;inline&quot;&gt; x_n = (X(t_n),t_n-t_{n-1}) &lt;/math&gt;. One may expect that LSTM may memorize the input values in each step and weight them at the output according to the duration, but this approach may lead to an imbalance between the needs for memory and for linearity. The weights that are assigned to the memorized observations potentially require several layers of nonlinearity to be computed properly, while past observations might just need to be memorized as they are.<br /> <br /> [[File:Junyi2.png | 550px|thumb|center|Figure 2: (a) Fixed sampling frequency and its drawbacks; keep- ing all available information leads to much more datapoints. (b) Proposed data representation for the asynchronous series. Consecutive observations are stored together as a single value series, regardless of which series they belong to; this information, however, is stored in indicator features, alongside durations between observations.]]<br /> <br /> =Model Architecture=<br /> Suppose there exists a multivariate time series &lt;math display=&quot;inline&quot;&gt;(x_n)_{n=0}^{\infty} \subset \mathbb{R}^d &lt;/math&gt;, we want to predict the conditional future values of a subset of elements of &lt;math&gt;x_n&lt;/math&gt;<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;y_n = \mathbb{E} [x_n^I | \{x_{n-m}, m=1,2,...\}], &lt;/math&gt;&lt;/div&gt;<br /> where &lt;math&gt; I=\{i_1,i_2,...i_{d_I}\} \subset \{1,2,...,d\} &lt;/math&gt; is a subset of features of &lt;math&gt;x_n&lt;/math&gt;.<br /> <br /> Let &lt;math&gt; \textbf{x}_n^{-M} = (x_{n-m})_{m=1}^M &lt;/math&gt;. <br /> <br /> The estimator of &lt;math&gt;y_n&lt;/math&gt; can be expressed as:<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;\hat{y}_n = \sum_{m=1}^M [F(\textbf{x}_n^{-M}) \otimes \sigma(S(\textbf{x}_n^{-M}))].,_m ,&lt;/math&gt;&lt;/div&gt;<br /> The estimate is the summation of the columns of the matrix in bracket. Here<br /> #&lt;math&gt;F,S : \mathbb{R}^{d \times M} \rightarrow \mathbb{R}^{d_I \times M}&lt;/math&gt; are neural networks. <br /> #* &lt;math&gt;S&lt;/math&gt; is a fully convolutional network which is composed of convolutional layers only. <br /> #* &lt;math display=&quot;inline&quot;&gt;F(\textbf{x}_n^{-M}) = W \otimes [\text{off}(x_{n-m}) + x_{n-m}^I)]_{m=1}^M &lt;/math&gt; <br /> #** &lt;math&gt; W \in \mathbb{R}^{d_I \times M}&lt;/math&gt; <br /> #** &lt;math&gt; \text{off}: \mathbb{R}^d \rightarrow \mathbb{R}^{d_I} &lt;/math&gt; is a multilayer perceptron.<br /> <br /> #&lt;math&gt;\sigma&lt;/math&gt; is a normalized activation function independent at each row, i.e. &lt;math display=&quot;inline&quot;&gt; \sigma ((a_1^T, ..., a_{d_I}^T)^T)=(\sigma(a_1)^T,..., \sigma(a_{d_I})^T)^T &lt;/math&gt;<br /> #* for any &lt;math&gt;a_{i} \in \mathbb{R}^{M}&lt;/math&gt;<br /> #* and &lt;math&gt;\sigma &lt;/math&gt; is defined such that &lt;math&gt;\sigma(a)^{T} \mathbf{1}_{M}=1&lt;/math&gt; for any &lt;math&gt;a \in \mathbb{R}^M&lt;/math&gt;.<br /> # &lt;math&gt;\otimes&lt;/math&gt; is element-wise matrix multiplication (also known as Hadamard matrix multiplication).<br /> #&lt;math&gt;A.,_m&lt;/math&gt; denotes the m-th column of a matrix A.<br /> <br /> Since &lt;math&gt;\sum_{m=1}^M W.,_m=W\cdot(1,1,...,1)^T&lt;/math&gt; and &lt;math&gt;\sum_{m=1}^M S.,_m=S\cdot(1,1,...,1)^T&lt;/math&gt;, we can express &lt;math&gt;\hat{y}_n&lt;/math&gt; as:<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;\hat{y}_n = \sum_{m=1}^M W.,_m \otimes (off(x_{n-m}) + x_{n-m}^I) \otimes \sigma(S.,_m(\textbf{x}_n^{-M}))&lt;/math&gt;&lt;/div&gt;<br /> This is the proposed network, Significance-Offset Convolutional Neural Network, &lt;math&gt;\text{off}&lt;/math&gt; and &lt;math&gt;S&lt;/math&gt; in the equation are corresponding to Offset and Significance in the name respectively.<br /> Figure 3 shows the scheme of network.<br /> <br /> [[File:Junyi3.png | 600px|thumb|center|Figure 3: A scheme of the proposed SOCNN architecture. The network preserves the time-dimension up to the top layer, while the number of features per timestep (filters) in the hidden layers is custom. The last convolutional layer, however, has the number of filters equal to dimension of the output. The Weighting frame shows how outputs from offset and significance networks are combined in accordance with Eq. of &lt;math&gt;\hat{y}_n&lt;/math&gt;.]]<br /> <br /> The form of &lt;math&gt;\hat{y}_n&lt;/math&gt; ensures the separation of the temporal dependence (obtained in weights &lt;math&gt;W_m&lt;/math&gt;). &lt;math&gt;S&lt;/math&gt;, which represents the local significance of observations, is determined by its filters which capture local dependencies and are independent of the relative position in time, and the predictors &lt;math&gt;\text{off}(x_{n-m})&lt;/math&gt; are completely independent of position in time. An adjusted single regressor for the target variable is provided by each past observation through the offset network. Since in asynchronous sampling procedure, consecutive values of x come from different signals and might be heterogeneous, therefore adjustment of offset network is important. In addition, significance network provides data-dependent weight for each regressor and sums them up in an autoregressive manner.<br /> <br /> ===Relation to asynchronous data===<br /> One common problem of time series is that durations are varying between consecutive observations, the paper states two ways to solve this problem<br /> #Data preprocessing: aligning the observations at some fixed frequency e.g. duplicating and interpolating observations as shown in Figure 2(a). However, as mentioned in the figure, this approach will tend to loss of information and enlarge the size of the dataset and model complexity.<br /> #Add additional features: Treating the duration or time of the observations as additional features, it is the core of SOCNN, which is shown in Figure 2(b).<br /> <br /> ===Loss function===<br /> The L2 error is a natural loss function for the estimators of expected value: &lt;math&gt;L^2(y,y')=||y-y'||^2&lt;/math&gt;<br /> <br /> The output of the offset network is series of separate predictors of changes between corresponding observations &lt;math&gt;x_{n-m}^I&lt;/math&gt; and the target value&lt;math&gt;y_n&lt;/math&gt;, this is the reason why we use auxiliary loss function, which equals to mean squared error of such intermediate predictions:<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;L^{aux}(\textbf{x}_n^{-M}, y_n)=\frac{1}{M} \sum_{m=1}^M ||off(x_{n-m}) + x_{n-m}^I -y_n||^2 &lt;/math&gt;&lt;/div&gt;<br /> The total loss for the sample &lt;math&gt; \textbf{x}_n^{-M},y_n) &lt;/math&gt; is then given by:<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;L^{tot}(\textbf{x}_n^{-M}, y_n)=L^2(\widehat{y}_n, y_n)+\alpha L^{aux}(\textbf{x}_n^{-M}, y_n)&lt;/math&gt;&lt;/div&gt;<br /> where &lt;math&gt;\widehat{y}_n&lt;/math&gt; was mentioned before, &lt;math&gt;\alpha \geq 0&lt;/math&gt; is a constant.<br /> <br /> =Experiments=<br /> The paper evaluated SOCNN architecture on three datasets: artificially generated datasets, [https://archive.ics.uci.edu/ml/datasets/Individual+household+electric+power+consumption household electric power consumption dataset], and the financial dataset of bid/ask quotes sent by several market participants active in the credit derivatives market. Comparing its performance with simple CNN, single and multiplayer LSTM and 25-layer ResNet. Apart from the evaluation of the SOCNN architecture the paper also discusses the impact of network components such as auxiliary<br /> loss and the depth of the offset sub-network. The code and datasets are available [https://github.com/mbinkowski/nntimeseries here]<br /> <br /> ==Datasets==<br /> Artificial data: They generated 4 artificial series, &lt;math&gt; X_{K \times N}&lt;/math&gt;, where &lt;math&gt;K \in \{16,64\} &lt;/math&gt;. Therefore there is a synchronous and an asynchronous series for each K value.<br /> <br /> Electricity data: This UCI dataset contains 7 different features excluding date and time. The features include global active power, global reactive power, voltage, global intensity, sub-metering 1, sub-metering 2 and sub-metering 3, recorded every minute for 47 months. The data has been altered so that one observation contains only one value of 7 features, while durations between consecutive observations are ranged from 1 to 7 minutes. The goal is to predict all 7 features for the next time step.<br /> <br /> Non-anonymous quotes: The dataset contains 2.1 million quotes from 28 different sources from different market participants such as analysts, banks etc. Each quote is characterized by 31 features: the offered price, 28 indicators of the quoting source, the direction indicator (the quote refers to either a buy or a sell offer) and duration from the previous quote. For each source and direction, we want to predict the next quoted price from this given source and direction considering the last 60 quotes.<br /> <br /> ==Training details==<br /> They applied grid search on some hyperparameters in order to get the significance of its components. The hyperparameters include the offset sub-network's depth and the auxiliary weight &lt;math&gt;\alpha&lt;/math&gt;. For offset sub-network's depth, they use 1, 10,1 for artificial, electricity and quotes dataset respectively; and they compared the values of &lt;math&gt;\alpha&lt;/math&gt; in {0,0.1,0.01}.<br /> <br /> They chose LeakyReLU as activation function for all networks:<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;\sigma^{LeakyReLU}(x) = x&lt;/math&gt; if &lt;math&gt;x\geq 0&lt;/math&gt;, and &lt;math&gt;0.1x&lt;/math&gt; otherwise &lt;/div&gt;<br /> They use the same number of layers, same stride and similar kernel size structure in CNN. In each trained CNN, they applied max pooling with the pool size of 2 every 2 convolutional layers.<br /> <br /> Table 1 presents the configuration of network hyperparameters used in comparison<br /> <br /> [[File:Junyi4.png | 520px|center|]]<br /> <br /> ===Network Training===<br /> The training and validation data were sampled randomly from the first 80% of timesteps in each series, with ratio of 3 to 1. The remaining 20% of data was used as a test set.<br /> <br /> All models were trained using Adam optimizer because the authors found that its rate of convergence was much faster than standard Stochastic Gradient Descent in early tests.<br /> <br /> They used a batch size of 128 for artificial and electricity data, and 256 for quotes dataset, and applied batch normalization between each convolution and the following activation. <br /> <br /> At the beginning of each epoch, the training samples were randomly sampled. To prevent overfitting, they applied dropout and early stopping.<br /> <br /> Weights were initialized using the normalized uniform procedure proposed by Glorot &amp; Bengio (2010).<br /> <br /> The authors carried out the experiments on Tensorflow and Keras and used different GPU to optimize the model for different datasets.<br /> <br /> ==Results==<br /> Table 2 shows all results performed from all datasets.<br /> [[File:Junyi5.png | 800px|center|]]<br /> We can see that SOCNN outperforms in all asynchronous artificial, electricity and quotes datasets. For synchronous data, LSTM might be slightly better, but SOCNN almost has the same results with LSTM. Phased LSTM and ResNet have performed really bad on artificial asynchronous dataset and quotes dataset respectively. Notice that having more than one layer of offset network would have negative impact on results. Also, the higher weights of auxiliary loss(&lt;math&gt;\alpha&lt;/math&gt;considerably improved the test error on asynchronous dataset, see Table 3. However, for other datasets, its impact was negligible.<br /> [[File:Junyi6.png | 480px|center|]]<br /> In general, SOCNN has significantly lower variance of the test and validation errors, especially in the early stage of the training process and for quotes dataset. This effect can be seen in the learning curves for Asynchronous 64 artificial dataset presented in Figure 5.<br /> [[File:Junyi7.png | 500px|thumb|center|Figure 5: Learning curves with different auxiliary weights for SOCNN model trained on Asynchronous 64 dataset. The solid lines indicate the test error while the dashed lines indicate the training error.]]<br /> <br /> Finally, we want to test the robustness of the proposed model SOCNN, adding noise terms to asynchronous 16 dataset and check how these networks perform. The result is shown in Figure 6.<br /> [[File:Junyi8.png | 600px|thumb|center|Figure 6: Experiment comparing robustness of the considered networks for Asynchronous 16 dataset. The plots show how the error would change if an additional noise term was added to the input series. The dotted curves show the total significance and average absolute offset (not to scale) outputs for the noisy observations. Interestingly, the significance of the noisy observations increases with the magnitude of noise; i.e. noisy observations are far from being discarded by SOCNN.]]<br /> From Figure 6, the purple line and green line seems staying at the same position in training and testing process. SOCNN and single-layer LSTM are most robust compared to other networks, and least prone to overfitting.<br /> <br /> =Conclusion and Discussion=<br /> In this paper, the authors have proposed a new architecture called Significance-Offset Convolutional Neural Network, which combines AR-like weighting mechanism and convolutional neural network. This new architecture is designed for high-noise asynchronous time series and achieves outperformance in forecasting several asynchronous time series compared to popular convolutional and recurrent networks. <br /> <br /> The SOCNN can be extended further by adding intermediate weighting layers of the same type in the network structure. Another possible extension but needs further empirical studies is that we consider not just &lt;math&gt;1 \times 1&lt;/math&gt; convolutional kernels on the offset sub-network. Also, this new architecture might be tested on other real-life datasets with relevant characteristics in the future, especially on econometric datasets and more generally for time series (stochastic processes) regression.<br /> <br /> =Critiques=<br /> #The paper is most likely an application paper, and the proposed new architecture shows improved performance over baselines in the asynchronous time series.<br /> #The quote data cannot be reached, only two datasets available.<br /> #The 'Significance' network was described as critical to the model in paper, but they did not show how the performance of SOCNN with respect to the significance network.<br /> #The transform of the original data to asynchronous data is not clear.<br /> #The experiments on the main application are not reproducible because the data is proprietary.<br /> #The way that train and test data were split is unclear. This could be important in the case of the financial data set.<br /> #Although the auxiliary loss function was mentioned as an important part, the advantages of it was not too clear in the paper. Maybe it is better that the paper describes a little more about its effectiveness.<br /> #It was not mentioned clearly in the paper whether the model training was done on a rolling basis for time series forecasting.<br /> #The noise term used in section 5's model robustness analysis uses evenly distributed noise (see Appendix B). While the analysis is a good start, analysis with different noise distributions would make the findings more generalizable.<br /> #The paper uses financial/economic data as one of its testing data set. Instead of comparing neural network models such as CNN which is known to work badly on time series data, it would be much better if the author compared to well-known econometric time series models such as GARCH and VAR.<br /> <br /> =References=<br />  Hamilton, J. D. Time series analysis, volume 2. Princeton university press Princeton, 1994. <br /> <br />  Fama, E. F. Efficient capital markets: A review of theory and empirical work. The journal of Finance, 25(2):383–417, 1970.<br /> <br />  Petelin, D., Sˇindela ́ˇr, J., Pˇrikryl, J., and Kocijan, J. Financial modeling using gaussian process models. In Intelligent Data Acquisition and Advanced Computing Systems (IDAACS), 2011 IEEE 6th International Conference on, volume 2, pp. 672–677. IEEE, 2011.<br /> <br />  Tobar, F., Bui, T. D., and Turner, R. E. Learning stationary time series using gaussian processes with nonparametric kernels. In Advances in Neural Information Processing Systems, pp. 3501–3509, 2015.<br /> <br />  Hwang, Y., Tong, A., and Choi, J. Automatic construction of nonparametric relational regression models for multiple time series. In Proceedings of the 33rd International Conference on Machine Learning, 2016.<br /> <br />  Wilson, A. and Ghahramani, Z. Copula processes. In Advances in Neural Information Processing Systems, pp. 2460–2468, 2010.<br /> <br />  Sirignano, J. Extended abstract: Neural networks for limit order books, February 2016.<br /> <br />  Borovykh, A., Bohte, S., and Oosterlee, C. W. Condi- tional time series forecasting with convolutional neural networks, March 2017.<br /> <br />  Heaton, J. B., Polson, N. G., and Witte, J. H. Deep learn- ing in finance, February 2016.<br /> <br />  Neil, D., Pfeiffer, M., and Liu, S.-C. Phased lstm: Acceler- ating recurrent network training for long or event-based sequences. In Advances In Neural Information Process- ing Systems, pp. 3882–3890, 2016.<br /> <br />  Chung, J., Gulcehre, C., Cho, K., and Bengio, Y. Em- pirical evaluation of gated recurrent neural networks on sequence modeling, December 2014.<br /> <br />  Weissenborn, D. and Rockta ̈schel, T. MuFuRU: The Multi-Function recurrent unit, June 2016.<br /> <br />  Cho, K., Courville, A., and Bengio, Y. Describing multi- media content using attention-based Encoder–Decoder networks. IEEE Transactions on Multimedia, 17(11): 1875–1886, July 2015. ISSN 1520-9210.<br /> <br />  Glorot, X. and Bengio, Y. Understanding the dif- ficulty of training deep feedforward neural net- works. In In Proceedings of the International Con- ference on Artificial Intelligence and Statistics (AIS- TATSaˆ10). Society for Artificial Intelligence and Statistics, 2010.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=stat946F18/Autoregressive_Convolutional_Neural_Networks_for_Asynchronous_Time_Series&diff=41838 stat946F18/Autoregressive Convolutional Neural Networks for Asynchronous Time Series 2018-11-29T16:36:18Z <p>Jmmoosa: /* Training details */</p> <hr /> <div>This page is a summary of the paper &quot;[http://proceedings.mlr.press/v80/binkowski18a/binkowski18a.pdf Autoregressive Convolutional Neural Networks for Asynchronous Time Series]&quot; by Mikołaj Binkowski, Gautier Marti, Philippe Donnat. It was published at ICML in 2018. The code for this paper is provided [https://github.com/mbinkowski/nntimeseries here].<br /> <br /> =Introduction=<br /> In this paper, the authors propose a deep convolutional network architecture called Significance-Offset Convolutional Neural Network for regression of multivariate asynchronous time series. The model is inspired by standard autoregressive (AR) models and gating systems used in recurrent neural networks. The model is evaluated on various time series data including:<br /> # Hedge fund proprietary dataset of over 2 million quotes for a credit derivative index, <br /> # An artificially generated noisy auto-regressive series, <br /> # A UCI household electricity consumption dataset. <br /> <br /> This paper focuses on time series that have multivariate and noisy signals, especially financial data. Financial time series is challenging to predict due to their low signal-to-noise ratio and heavy-tailed distributions. For example, the same signal (e.g. price of a stock) is obtained from different sources (e.g. financial news, an investment bank, financial analyst etc.) asynchronously. Each source may have a different bias or noise. (Figure 1) The investment bank with more clients can update their information more precisely than the investment bank with fewer clients, which means the significance of each past observations may depend on other factors that change in time. Therefore, the traditional econometric models such as AR, VAR (Vector Autoregressive Model), VARMA (Vector Autoregressive Moving Average Model)  might not be sufficient. However, their relatively good performance could allow us to combine such linear econometric models with deep neural networks that can learn highly nonlinear relationships. This model is inspired by the gating mechanism which is successful in RNNs and Highway Networks.<br /> <br /> The time series forecasting problem can be expressed as a conditional probability distribution below,<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;p(X_{t+d}|X_t,X_{t-1},...) = f(X_t,X_{t-1},...)&lt;/math&gt;&lt;/div&gt;<br /> Thus, we focus on modeling the predictors of future values of time series given their past values. <br /> <br /> The reasons that financial time series are particularly challenging:<br /> * Low signal-to-noise ratio and heavy-tailed distributions.<br /> * Being observed different sources (e.g. financial news, analysts, portfolio managers in hedge funds, market-makers in investment banks) in asynchronous moments of time. Each of these sources may have a different bias and noise with respect to the original signal that needs to be recovered.<br /> * Data sources are usually strongly correlated and lead-lag relationships are possible (e.g. a market-maker with more clients can update its view more frequently and precisely than one with fewer clients). <br /> * The significance of each of the available past observations might be dependent on some other factors that can change in time. Hence, the traditional econometric models such as AR, VAR, VARMA might not be sufficient.<br /> <br /> The predictability of financial dataset still remains an open problem and is discussed in various publications .<br /> <br /> [[File:Junyi1.png | 500px|thumb|center|Figure 1: Quotes from four different market participants (sources) for the same credit default swaps (CDS) throughout one day. Each trader displays from time to time the prices for which he offers to buy (bid) and sell (ask) the underlying CDS. The filled area marks the difference between the best sell and buy offers (spread) at each time.]]<br /> <br /> The paper also provides empirical evidence that their model which combines linear models with deep learning models could perform better than just DL models like CNN, LSTMs and Phased LSTMs.<br /> <br /> =Related Work=<br /> ===Time series forecasting===<br /> From recent proceedings in main machine learning venues i.e. ICML, NIPS, AISTATS, UAI, we can notice that time series are often forecast using Gaussian processes[3,4], especially for irregularly sampled time series. Though still largely independent, combined models have started to appear, for example, the Gaussian Copula Process Volatility model. For this paper, the authors use coupling AR models and neural networks to achieve such combined models.<br /> <br /> Although deep neural networks have been applied into many fields and produced satisfactory results, there still is little literature on deep learning for time series forecasting. More recently, the papers include Sirignano (2016) that used 4-layer perceptrons in modeling price change distributions in Limit Order Books, and Borovykh et al. (2017) who applied more recent WaveNet architecture to several short univariate and bivariate time-series (including financial ones). Heaton et al. (2016) claimed to use autoencoders with a single hidden layer to compress multivariate financial data. Neil et al. (2016) presented augmentation of LSTM architecture suitable for asynchronous series, which stimulates learning dependencies of different frequencies through time gate. <br /> <br /> In this paper, the authors examine the capabilities of several architectures (CNN, residual network, multi-layer LSTM, and phase LSTM) on AR-like artificial asynchronous and noisy time series, household electricity consumption dataset, and on real financial data from the credit default swap market with some inefficiencies.<br /> <br /> ====AR Model====<br /> <br /> An autoregressive (AR) model describes the next value in a time-series as a combination of previous values, scaling factors, a bias, and noise [https://onlinecourses.science.psu.edu/stat501/node/358/ (source)]. For a p-th order (relating the current state to the p last states), the equation of the model is:<br /> <br /> &lt;math&gt; X_t = c + \sum_{i=1}^p \varphi_i X_{t-i}+ \varepsilon_t \,&lt;/math&gt; [https://en.wikipedia.org/wiki/Autoregressive_model#Definition (equation source)]<br /> <br /> With parameters/coefficients &lt;math&gt;\varphi_i&lt;/math&gt;, constant &lt;math&gt;c&lt;/math&gt;, and noise &lt;math&gt;\varepsilon_t&lt;/math&gt; This can be extended to vector form to create the VAR model mentioned in the paper.<br /> <br /> ===Gating and weighting mechanisms===<br /> Gating mechanisms for neural networks has ability to overcome the problem of vanishing gradient, and can be expressed as &lt;math display=&quot;inline&quot;&gt;f(x)=c(x) \otimes \sigma(x)&lt;/math&gt;, where &lt;math&gt;f&lt;/math&gt; is the output function, &lt;math&gt;c&lt;/math&gt; is a &quot;candidate output&quot; (a nonlinear function of &lt;math&gt;x&lt;/math&gt;), &lt;math&gt;\otimes&lt;/math&gt; is an element-wise matrix product, and &lt;math&gt;\sigma : \mathbb{R} \rightarrow [0,1] &lt;/math&gt; is a sigmoid nonlinearity that controls the amount of output passed to the next layer. Different composition of functions of the same type as described above have proven to be an essential ingredient in popular recurrent architecture such as LSTM and GRU.<br /> <br /> The main purpose of the proposed gating system is to weight the outputs of the intermediate layers within neural networks, and is most closely related to softmax gating used in MuFuRu(Multi-Function Recurrent Unit), i.e.<br /> &lt;math display=&quot;inline&quot;&gt; f(x) = \sum_{l=1}^L p^l(x) \otimes f^l(x)\text{,}\ p(x)=\text{softmax}(\widehat{p}(x)), &lt;/math&gt;, where &lt;math&gt;(f^l)_{l=1}^L &lt;/math&gt;are candidate outputs (composition operators in MuFuRu), &lt;math&gt;(\widehat{p}^l)_{l=1}^L &lt;/math&gt;are linear functions of inputs. <br /> <br /> This idea is also successfully used in attention networks such as image captioning and machine translation. In this paper, the proposed method is similar as the separate inputs (time series steps in this case) are weighted in accordance with learned functions of these inputs. The difference is that the functions are being modeled using multi-layer CNNs. Another difference is that the proposed method is not using recurrent layers, which enables the network to remember parts of the sentence/image already translated/described.<br /> <br /> =Motivation=<br /> There are mainly five motivations that are stated in the paper by the authors:<br /> #The forecasting problem in this paper has been done almost independently by econometrics and machine learning communities. Unlike in machine learning, research in econometrics is more likely to explain variables rather than improving out-of-sample prediction power. These models tend to 'over-fit' on financial time series, their parameters are unstable and have poor performance on out-of-sample prediction.<br /> #It is difficult for the learning algorithms to deal with time series data where the observations have been made irregularly. Although Gaussian processes provide a useful theoretical framework that is able to handle asynchronous data, they are not suitable for financial datasets, which often follow heavy-tailed distribution .<br /> #Predictions of autoregressive time series may involve highly nonlinear functions if sampled irregularly. For AR time series with higher order and have more past observations, the expectation of it &lt;math display=&quot;inline&quot;&gt;\mathbb{E}[X(t)|{X(t-m), m=1,...,M}]&lt;/math&gt; may involve more complicated functions that in general may not allow closed-form expression.<br /> #In practice, the dimensions of multivariate time series are often observed separately and asynchronously, such series at fixed frequency may lead to lose information or enlarge the dataset, which is shown in Figure 2(a). Therefore, the core of the proposed architecture SOCNN represents separate dimensions as a single one with dimension and duration indicators as additional features(Figure 2(b)).<br /> #Given a series of pairs of consecutive input values and corresponding durations, &lt;math display=&quot;inline&quot;&gt; x_n = (X(t_n),t_n-t_{n-1}) &lt;/math&gt;. One may expect that LSTM may memorize the input values in each step and weight them at the output according to the duration, but this approach may lead to an imbalance between the needs for memory and for linearity. The weights that are assigned to the memorized observations potentially require several layers of nonlinearity to be computed properly, while past observations might just need to be memorized as they are.<br /> <br /> [[File:Junyi2.png | 550px|thumb|center|Figure 2: (a) Fixed sampling frequency and its drawbacks; keep- ing all available information leads to much more datapoints. (b) Proposed data representation for the asynchronous series. Consecutive observations are stored together as a single value series, regardless of which series they belong to; this information, however, is stored in indicator features, alongside durations between observations.]]<br /> <br /> =Model Architecture=<br /> Suppose there exists a multivariate time series &lt;math display=&quot;inline&quot;&gt;(x_n)_{n=0}^{\infty} \subset \mathbb{R}^d &lt;/math&gt;, we want to predict the conditional future values of a subset of elements of &lt;math&gt;x_n&lt;/math&gt;<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;y_n = \mathbb{E} [x_n^I | \{x_{n-m}, m=1,2,...\}], &lt;/math&gt;&lt;/div&gt;<br /> where &lt;math&gt; I=\{i_1,i_2,...i_{d_I}\} \subset \{1,2,...,d\} &lt;/math&gt; is a subset of features of &lt;math&gt;x_n&lt;/math&gt;.<br /> <br /> Let &lt;math&gt; \textbf{x}_n^{-M} = (x_{n-m})_{m=1}^M &lt;/math&gt;. <br /> <br /> The estimator of &lt;math&gt;y_n&lt;/math&gt; can be expressed as:<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;\hat{y}_n = \sum_{m=1}^M [F(\textbf{x}_n^{-M}) \otimes \sigma(S(\textbf{x}_n^{-M}))].,_m ,&lt;/math&gt;&lt;/div&gt;<br /> The estimate is the summation of the columns of the matrix in bracket. Here<br /> #&lt;math&gt;F,S : \mathbb{R}^{d \times M} \rightarrow \mathbb{R}^{d_I \times M}&lt;/math&gt; are neural networks. <br /> #* &lt;math&gt;S&lt;/math&gt; is a fully convolutional network which is composed of convolutional layers only. <br /> #* &lt;math display=&quot;inline&quot;&gt;F(\textbf{x}_n^{-M}) = W \otimes [\text{off}(x_{n-m}) + x_{n-m}^I)]_{m=1}^M &lt;/math&gt; <br /> #** &lt;math&gt; W \in \mathbb{R}^{d_I \times M}&lt;/math&gt; <br /> #** &lt;math&gt; \text{off}: \mathbb{R}^d \rightarrow \mathbb{R}^{d_I} &lt;/math&gt; is a multilayer perceptron.<br /> <br /> #&lt;math&gt;\sigma&lt;/math&gt; is a normalized activation function independent at each row, i.e. &lt;math display=&quot;inline&quot;&gt; \sigma ((a_1^T, ..., a_{d_I}^T)^T)=(\sigma(a_1)^T,..., \sigma(a_{d_I})^T)^T &lt;/math&gt;<br /> #* for any &lt;math&gt;a_{i} \in \mathbb{R}^{M}&lt;/math&gt;<br /> #* and &lt;math&gt;\sigma &lt;/math&gt; is defined such that &lt;math&gt;\sigma(a)^{T} \mathbf{1}_{M}=1&lt;/math&gt; for any &lt;math&gt;a \in \mathbb{R}^M&lt;/math&gt;.<br /> # &lt;math&gt;\otimes&lt;/math&gt; is element-wise matrix multiplication (also known as Hadamard matrix multiplication).<br /> #&lt;math&gt;A.,_m&lt;/math&gt; denotes the m-th column of a matrix A.<br /> <br /> Since &lt;math&gt;\sum_{m=1}^M W.,_m=W\cdot(1,1,...,1)^T&lt;/math&gt; and &lt;math&gt;\sum_{m=1}^M S.,_m=S\cdot(1,1,...,1)^T&lt;/math&gt;, we can express &lt;math&gt;\hat{y}_n&lt;/math&gt; as:<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;\hat{y}_n = \sum_{m=1}^M W.,_m \otimes (off(x_{n-m}) + x_{n-m}^I) \otimes \sigma(S.,_m(\textbf{x}_n^{-M}))&lt;/math&gt;&lt;/div&gt;<br /> This is the proposed network, Significance-Offset Convolutional Neural Network, &lt;math&gt;\text{off}&lt;/math&gt; and &lt;math&gt;S&lt;/math&gt; in the equation are corresponding to Offset and Significance in the name respectively.<br /> Figure 3 shows the scheme of network.<br /> <br /> [[File:Junyi3.png | 600px|thumb|center|Figure 3: A scheme of the proposed SOCNN architecture. The network preserves the time-dimension up to the top layer, while the number of features per timestep (filters) in the hidden layers is custom. The last convolutional layer, however, has the number of filters equal to dimension of the output. The Weighting frame shows how outputs from offset and significance networks are combined in accordance with Eq. of &lt;math&gt;\hat{y}_n&lt;/math&gt;.]]<br /> <br /> The form of &lt;math&gt;\hat{y}_n&lt;/math&gt; ensures the separation of the temporal dependence (obtained in weights &lt;math&gt;W_m&lt;/math&gt;). &lt;math&gt;S&lt;/math&gt;, which represents the local significance of observations, is determined by its filters which capture local dependencies and are independent of the relative position in time, and the predictors &lt;math&gt;\text{off}(x_{n-m})&lt;/math&gt; are completely independent of position in time. An adjusted single regressor for the target variable is provided by each past observation through the offset network. Since in asynchronous sampling procedure, consecutive values of x come from different signals and might be heterogeneous, therefore adjustment of offset network is important. In addition, significance network provides data-dependent weight for each regressor and sums them up in an autoregressive manner.<br /> <br /> ===Relation to asynchronous data===<br /> One common problem of time series is that durations are varying between consecutive observations, the paper states two ways to solve this problem<br /> #Data preprocessing: aligning the observations at some fixed frequency e.g. duplicating and interpolating observations as shown in Figure 2(a). However, as mentioned in the figure, this approach will tend to loss of information and enlarge the size of the dataset and model complexity.<br /> #Add additional features: Treating the duration or time of the observations as additional features, it is the core of SOCNN, which is shown in Figure 2(b).<br /> <br /> ===Loss function===<br /> The L2 error is a natural loss function for the estimators of expected value: &lt;math&gt;L^2(y,y')=||y-y'||^2&lt;/math&gt;<br /> <br /> The output of the offset network is series of separate predictors of changes between corresponding observations &lt;math&gt;x_{n-m}^I&lt;/math&gt; and the target value&lt;math&gt;y_n&lt;/math&gt;, this is the reason why we use auxiliary loss function, which equals to mean squared error of such intermediate predictions:<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;L^{aux}(\textbf{x}_n^{-M}, y_n)=\frac{1}{M} \sum_{m=1}^M ||off(x_{n-m}) + x_{n-m}^I -y_n||^2 &lt;/math&gt;&lt;/div&gt;<br /> The total loss for the sample &lt;math&gt; \textbf{x}_n^{-M},y_n) &lt;/math&gt; is then given by:<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;L^{tot}(\textbf{x}_n^{-M}, y_n)=L^2(\widehat{y}_n, y_n)+\alpha L^{aux}(\textbf{x}_n^{-M}, y_n)&lt;/math&gt;&lt;/div&gt;<br /> where &lt;math&gt;\widehat{y}_n&lt;/math&gt; was mentioned before, &lt;math&gt;\alpha \geq 0&lt;/math&gt; is a constant.<br /> <br /> =Experiments=<br /> The paper evaluated SOCNN architecture on three datasets: artificially generated datasets, [https://archive.ics.uci.edu/ml/datasets/Individual+household+electric+power+consumption household electric power consumption dataset], and the financial dataset of bid/ask quotes sent by several market participants active in the credit derivatives market. Comparing its performance with simple CNN, single and multiplayer LSTM and 25-layer ResNet. Apart from the evaluation of the SOCNN architecture the paper also discusses the impact of network components such as auxiliary<br /> loss and the depth of the offset sub-network. The code and datasets are available [https://github.com/mbinkowski/nntimeseries here]<br /> <br /> ==Datasets==<br /> Artificial data: They generated 4 artificial series, &lt;math&gt; X_{K \times N}&lt;/math&gt;, where &lt;math&gt;K \in \{16,64\} &lt;/math&gt;. Therefore there is a synchronous and an asynchronous series for each K value.<br /> <br /> Electricity data: This UCI dataset contains 7 different features excluding date and time. The features include global active power, global reactive power, voltage, global intensity, sub-metering 1, sub-metering 2 and sub-metering 3, recorded every minute for 47 months. The data has been altered so that one observation contains only one value of 7 features, while durations between consecutive observations are ranged from 1 to 7 minutes. The goal is to predict all 7 features for the next time step.<br /> <br /> Non-anonymous quotes: The dataset contains 2.1 million quotes from 28 different sources from different market participants such as analysts, banks etc. Each quote is characterized by 31 features: the offered price, 28 indicators of the quoting source, the direction indicator (the quote refers to either a buy or a sell offer) and duration from the previous quote. For each source and direction, we want to predict the next quoted price from this given source and direction considering the last 60 quotes.<br /> <br /> ==Training details==<br /> They applied grid search on some hyperparameters in order to get the significance of its components. The hyperparameters include the offset sub-network's depth and the auxiliary weight &lt;math&gt;\alpha&lt;/math&gt;. For offset sub-network's depth, they use 1, 10,1 for artificial, electricity and quotes dataset respectively; and they compared the values of &lt;math&gt;\alpha&lt;/math&gt; in {0,0.1,0.01}.<br /> <br /> They chose LeakyReLU as activation function for all networks:<br /> &lt;div style=&quot;text-align: center;&quot;&gt;&lt;math&gt;\sigma^{LeakyReLU}(x) = x&lt;/math&gt; if &lt;math&gt;x\geq 0&lt;/math&gt;, and &lt;math&gt;0.1x&lt;/math&gt; otherwise &lt;/div&gt;<br /> They use the same number of layers, same stride and similar kernel size structure in CNN. In each trained CNN, they applied max pooling with the pool size of 2 every 2 convolutional layers.<br /> <br /> Table 1 presents the configuration of network hyperparameters used in comparison<br /> <br /> [[File:Junyi4.png | 520px|center|]]<br /> <br /> ===Network Training===<br /> The training and validation data were sampled randomly from the first 80% of timesteps in each series, with ratio of 3 to 1. The remaining 20% of data was used as a test set.<br /> <br /> All models were trained using Adam optimizer because the authors found that its rate of convergence was much faster than standard Stochastic Gradient Descent in early tests.<br /> <br /> They used a batch size of 128 for artificial and electricity data, and 256 for quotes dataset, and applied batch normalization between each convolution and the following activation. <br /> <br /> At the beginning of each epoch, the training samples were randomly sampled. To prevent overfitting, they applied dropout and early stopping.<br /> <br /> Weights were initialized using the normalized uniform procedure proposed by Glorot &amp; Bengio (2010).<br /> <br /> The authors carried out the experiments on Tensorflow and Keras and used different GPU to optimize the model for different datasets.<br /> <br /> ==Results==<br /> Table 2 shows all results performed from all datasets.<br /> [[File:Junyi5.png | 600px|center|]]<br /> We can see that SOCNN outperforms in all asynchronous artificial, electricity and quotes datasets. For synchronous data, LSTM might be slightly better, but SOCNN almost has the same results with LSTM. Phased LSTM and ResNet have performed really bad on artificial asynchronous dataset and quotes dataset respectively. Notice that having more than one layer of offset network would have negative impact on results. Also, the higher weights of auxiliary loss(&lt;math&gt;\alpha&lt;/math&gt;considerably improved the test error on asynchronous dataset, see Table 3. However, for other datasets, its impact was negligible.<br /> [[File:Junyi6.png | 400px|center|]]<br /> In general, SOCNN has significantly lower variance of the test and validation errors, especially in the early stage of the training process and for quotes dataset. This effect can be seen in the learning curves for Asynchronous 64 artificial dataset presented in Figure 5.<br /> [[File:Junyi7.png | 500px|thumb|center|Figure 5: Learning curves with different auxiliary weights for SOCNN model trained on Asynchronous 64 dataset. The solid lines indicate the test error while the dashed lines indicate the training error.]]<br /> <br /> Finally, we want to test the robustness of the proposed model SOCNN, adding noise terms to asynchronous 16 dataset and check how these networks perform. The result is shown in Figure 6.<br /> [[File:Junyi8.png | 600px|thumb|center|Figure 6: Experiment comparing robustness of the considered networks for Asynchronous 16 dataset. The plots show how the error would change if an additional noise term was added to the input series. The dotted curves show the total significance and average absolute offset (not to scale) outputs for the noisy observations. Interestingly, the significance of the noisy observations increases with the magnitude of noise; i.e. noisy observations are far from being discarded by SOCNN.]]<br /> From Figure 6, the purple line and green line seems staying at the same position in training and testing process. SOCNN and single-layer LSTM are most robust compared to other networks, and least prone to overfitting.<br /> <br /> =Conclusion and Discussion=<br /> In this paper, the authors have proposed a new architecture called Significance-Offset Convolutional Neural Network, which combines AR-like weighting mechanism and convolutional neural network. This new architecture is designed for high-noise asynchronous time series and achieves outperformance in forecasting several asynchronous time series compared to popular convolutional and recurrent networks. <br /> <br /> The SOCNN can be extended further by adding intermediate weighting layers of the same type in the network structure. Another possible extension but needs further empirical studies is that we consider not just &lt;math&gt;1 \times 1&lt;/math&gt; convolutional kernels on the offset sub-network. Also, this new architecture might be tested on other real-life datasets with relevant characteristics in the future, especially on econometric datasets and more generally for time series (stochastic processes) regression.<br /> <br /> =Critiques=<br /> #The paper is most likely an application paper, and the proposed new architecture shows improved performance over baselines in the asynchronous time series.<br /> #The quote data cannot be reached, only two datasets available.<br /> #The 'Significance' network was described as critical to the model in paper, but they did not show how the performance of SOCNN with respect to the significance network.<br /> #The transform of the original data to asynchronous data is not clear.<br /> #The experiments on the main application are not reproducible because the data is proprietary.<br /> #The way that train and test data were split is unclear. This could be important in the case of the financial data set.<br /> #Although the auxiliary loss function was mentioned as an important part, the advantages of it was not too clear in the paper. Maybe it is better that the paper describes a little more about its effectiveness.<br /> #It was not mentioned clearly in the paper whether the model training was done on a rolling basis for time series forecasting.<br /> #The noise term used in section 5's model robustness analysis uses evenly distributed noise (see Appendix B). While the analysis is a good start, analysis with different noise distributions would make the findings more generalizable.<br /> #The paper uses financial/economic data as one of its testing data set. Instead of comparing neural network models such as CNN which is known to work badly on time series data, it would be much better if the author compared to well-known econometric time series models such as GARCH and VAR.<br /> <br /> =References=<br />  Hamilton, J. D. Time series analysis, volume 2. Princeton university press Princeton, 1994. <br /> <br />  Fama, E. F. Efficient capital markets: A review of theory and empirical work. The journal of Finance, 25(2):383–417, 1970.<br /> <br />  Petelin, D., Sˇindela ́ˇr, J., Pˇrikryl, J., and Kocijan, J. Financial modeling using gaussian process models. In Intelligent Data Acquisition and Advanced Computing Systems (IDAACS), 2011 IEEE 6th International Conference on, volume 2, pp. 672–677. IEEE, 2011.<br /> <br />  Tobar, F., Bui, T. D., and Turner, R. E. Learning stationary time series using gaussian processes with nonparametric kernels. In Advances in Neural Information Processing Systems, pp. 3501–3509, 2015.<br /> <br />  Hwang, Y., Tong, A., and Choi, J. Automatic construction of nonparametric relational regression models for multiple time series. In Proceedings of the 33rd International Conference on Machine Learning, 2016.<br /> <br />  Wilson, A. and Ghahramani, Z. Copula processes. In Advances in Neural Information Processing Systems, pp. 2460–2468, 2010.<br /> <br />  Sirignano, J. Extended abstract: Neural networks for limit order books, February 2016.<br /> <br />  Borovykh, A., Bohte, S., and Oosterlee, C. W. Condi- tional time series forecasting with convolutional neural networks, March 2017.<br /> <br />  Heaton, J. B., Polson, N. G., and Witte, J. H. Deep learn- ing in finance, February 2016.<br /> <br />  Neil, D., Pfeiffer, M., and Liu, S.-C. Phased lstm: Acceler- ating recurrent network training for long or event-based sequences. In Advances In Neural Information Process- ing Systems, pp. 3882–3890, 2016.<br /> <br />  Chung, J., Gulcehre, C., Cho, K., and Bengio, Y. Em- pirical evaluation of gated recurrent neural networks on sequence modeling, December 2014.<br /> <br />  Weissenborn, D. and Rockta ̈schel, T. MuFuRU: The Multi-Function recurrent unit, June 2016.<br /> <br />  Cho, K., Courville, A., and Bengio, Y. Describing multi- media content using attention-based Encoder–Decoder networks. IEEE Transactions on Multimedia, 17(11): 1875–1886, July 2015. ISSN 1520-9210.<br /> <br />  Glorot, X. and Bengio, Y. Understanding the dif- ficulty of training deep feedforward neural net- works. In In Proceedings of the International Con- ference on Artificial Intelligence and Statistics (AIS- TATSaˆ10). Society for Artificial Intelligence and Statistics, 2010.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=policy_optimization_with_demonstrations&diff=41622 policy optimization with demonstrations 2018-11-27T17:41:31Z <p>Jmmoosa: /* Discussion on Existing LfD Methods */</p> <hr /> <div>= Introduction =<br /> <br /> The reinforcement learning (RL) method has made significant progress in a variety of applications, but the exploration problems regarding how to gain more experience from novel policies to improve long-term performance are still challenges, especially in environments where reward signals are sparse and rare. There are currently two ways to solve such exploration problems in RL: <br /> <br /> 1) Guide the agent to explore states that have never been seen. <br /> <br /> 2) Guide the agent to imitate a demonstration trajectory sampled from an expert policy to learn. <br /> <br /> When guiding the agent to imitate the expert behavior for learning, there are also two methods: putting the demonstration directly into the replay memory    or using the demonstration trajectory to pre-train the policy in a supervised manner . However, neither of these methods takes full advantage of the demonstration data. They instead treat the demonstration data identically to self-generated data, requiring a tremendous number of difficult to collect examples to learn effectively. To address this problem, a novel policy optimization method from demonstration (POfD) is proposed, which takes full advantage of the demonstration and there is no need to ensure that the expert policy is the optimal policy. To summarize, the authors bring forth this idea through the following techniques:<br /> <br /> 1) A demonstration guided exploration term measuring the divergence between current and the expert policy is added to the policy optimization objective, increasing the similarity to expert-like exploration.<br /> <br /> 2) They say that for better learning from demonstrations and getting an optimization friendly lower bound, the proposed objective could be defined on an occupancy measure as in .<br /> <br /> 3) Finally, they show that the optimization can move towards optimizing the derived lower bound and the generative adversarial training.<br /> <br /> The authors also evaluate the performance of POfD on Mujoco  in sparse-reward environments. The experiments results show that the performance of POfD is greatly improved compared with some strong baselines and even to the policy gradient method in dense-reward environments.<br /> <br /> ==Intuition==<br /> The agent should imitate the demonstrated behavior when rewards are sparse and then explore new states on its own after acquiring sufficient skills, which is a dynamic intrinsic reward mechanism that can be reshaped in terms of the native rewards in RL. At present the state of the art exploration in Reinforcement learning is simply epsilon greedy which just makes random moves for a small percentage of times to explore unexplored moves. This is very naive and is one of the main reasons for the high sample complexity in RL. On the other hand, if there is an expert demonstrator who can guide exploration, the agent can make more guided and accurate exploratory moves.<br /> <br /> =Related Work =<br /> There are some related works in overcoming exploration difficulties by learning from demonstration  and imitation learning in RL.<br /> <br /> For learning from demonstration (LfD),<br /> # Most LfD methods adopt value-based RL algorithms, such as DQfD (Deep Q-learning from Demonstrations)  which are applied into the discrete action spaces and DDPGfD (Deep Deterministic Policy Gradient from Demonstrations)  which extends this idea to the continuous spaces. But both of them under-utilize the demonstration data.<br /> # There are some methods based on policy iteration  , which shapes the value function by using demonstration data. But they get the bad performance when demonstration data is imperfect.<br /> # A hybrid framework  that learns the policy in which the probability of taking demonstrated actions is maximized is proposed, which considers less demonstration data.<br /> # A reward reshaping mechanism  that encourages taking actions close to the demonstrated ones is proposed. It is similar to the method in this paper, but there exists some differences as it is defined as a potential function based on multi-variate Gaussian to model the distribution of state-actions.<br /> All of the above methods require a lot of perfect demonstrations to get satisfactory performance, which is different from POfD in this paper.<br /> <br /> For imitation learning, <br /> # Inverse Reinforce Learning  problems are solved by alternating between fitting the reward function and selecting the policy  . But it cannot be extended to big-scale problems.<br /> # Generative Adversarial Imitation Learning (GAIL)  uses a discriminator to distinguish whether a state-action pair is from the expert or the learned policy and it can be applied into the high-dimensional continuous control problems.<br /> <br /> Both of the above methods are effective for imitation learning, but cannot leverage the valuable feedback given by the environments and usually suffer from bad performance when the expert data is imperfect. That is different from POfD in this paper.<br /> <br /> There is also another idea in which an agent learns using hybrid imitation learning and reinforcement learning reward[23, 24]. However, unlike this paper, they did not provide some theoretical support for their method and only explained some intuitive explanations.<br /> <br /> =Background=<br /> <br /> ==Preliminaries==<br /> Markov Decision Process (MDP)  is defined by a tuple &lt;math&gt;⟨\mathcal{S}, \mathcal{A}, \mathcal{P}, r, \gamma⟩ &lt;/math&gt;, where &lt;math&gt;\mathcal{S}&lt;/math&gt; is the state space, &lt;math&gt;\mathcal{A} &lt;/math&gt; is the action space, &lt;math&gt;\mathcal{P}(s'|s,a)&lt;/math&gt; is the transition distribution of taking action &lt;math&gt; a &lt;/math&gt; at state &lt;math&gt;s &lt;/math&gt;, &lt;math&gt; r(s,a) &lt;/math&gt;is the reward function, and &lt;math&gt; \gamma &lt;/math&gt; is the discount factor between 0 and 1. Policy &lt;math&gt; \pi(a|s) &lt;/math&gt; is a mapping from state to action probabilities, the performance of &lt;math&gt; \pi &lt;/math&gt; is usually evaluated by its expected discounted reward &lt;math&gt; \eta(\pi) &lt;/math&gt;: <br /> $\eta(\pi)=\mathbb{E}_{\pi}[r(s,a)]=\mathbb{E}_{(s_0,a_0,s_1,...)}[\sum_{t=0}^\infty\gamma^{t}r(s_t,a_t)]$<br /> The value function is &lt;math&gt; V_{\pi}(s) =\mathbb{E}_{\pi}[r(·,·)|s_0=s] &lt;/math&gt;, the action value function is &lt;math&gt; Q_{\pi}(s,a) =\mathbb{E}_{\pi}[r(·,·)|s_0=s,a_0=a] &lt;/math&gt;, and the advantage function that reflects the expected additional reward after taking action a at state s is &lt;math&gt; A_{\pi}(s,a)=Q_{\pi}(s,a)-V_{\pi}(s)&lt;/math&gt;.<br /> Then the authors define Occupancy measure, which is used to estimate the probability that state &lt;math&gt;s&lt;/math&gt; and state action pairs &lt;math&gt;(s,a)&lt;/math&gt; when executing a certain policy.<br /> [[File:def1.png|500px|center]]<br /> Then the performance of &lt;math&gt; \pi &lt;/math&gt; can be rewritten to: <br /> [[File:equ2.png|500px|center]]<br /> At the same time, the authors propose a lemma: <br /> [[File:lemma1.png|500px|center]]<br /> <br /> ==Problem Definition==<br /> Generally, RL tasks and environments do not provide a comprehensive reward and instead rely on sparse feedback indicating whether the goal is reached.<br /> <br /> In this paper, the authors aim to develop a method that can boost exploration by leveraging effectively the demonstrations &lt;math&gt;D^E &lt;/math&gt;from the expert policy &lt;math&gt; \pi_E &lt;/math&gt; and maximize &lt;math&gt; \eta(\pi) &lt;/math&gt; in the sparse-reward environment. The authors define the demonstrations &lt;math&gt;D^E=\{\tau_1,\tau_2,...,\tau_N\} &lt;/math&gt;, where the i-th trajectory &lt;math&gt;\tau_i=\{(s_0^i,a_0^i),(s_1^i,a_1^i),...,(s_T^i,a_T^i)\} &lt;/math&gt; is generated from the unknown expert policy &lt;math&gt;\pi_E &lt;/math&gt;. In addition, there is an assumption on the quality of the expert policy:<br /> [[File:asp1.png|500px|center]]<br /> <br /> <br /> Throughout the paper, they use &lt;math&gt;\pi_E &lt;/math&gt; to denote the expert policy that gives the relatively good &lt;math&gt;\eta_\pi &lt;/math&gt;, and use &lt;math&gt;\hat{\mathbb{E}}_D &lt;/math&gt;to denote empirical expectation estimated from the demonstrated trajectories &lt;math&gt;D^E &lt;/math&gt;. We have the following reasonable and necessary assumption on the quality of the expert policy &lt;math&gt;\pi_E &lt;/math&gt;.<br /> <br /> <br /> Moreover, it is not necessary to ensure that the expert policy is advantageous over all the policies. This is because that POfD will learn a better policy than expert policy by exploring on its own in later learning stages.<br /> <br /> =Method=<br /> <br /> ==Policy Optimization with Demonstration (POfD)==<br /> <br /> [[File:ff1.png|thumb|500px|center |Figure 1: Demonstrations (the blue curve) enables POfD to explore in the high-reward regions (red arrows). On the other hand random explorations (olive green dashed curves) occur in sparse-reward environments.]]<br /> <br /> This method optimizes the policy by forcing the policy to explore in the nearby region of the expert policy that is specified by several demonstrated trajectories &lt;math&gt;D^E &lt;/math&gt; (as shown in Fig.1) in order to avoid causing slow convergence or failure when the environment feedback is sparse. In addition, the authors encourage the policy π to explore by &quot;following&quot; the demonstrations &lt;math&gt;D^E &lt;/math&gt;. Thus, a new learning objective is given:<br /> $\mathcal{L}(\pi_{\theta})=-\eta(\pi_{\theta})+\lambda_{1}D_{JS}(\pi_{\theta},\pi_{E})$<br /> where &lt;math&gt;D_{JS}(\pi_{\theta},\pi_{E})&lt;/math&gt; is Jensen-Shannon divergence between current policy &lt;math&gt;\pi_{\theta}&lt;/math&gt; and the expert policy &lt;math&gt;\pi_{E}&lt;/math&gt; , &lt;math&gt;\lambda_1&lt;/math&gt; is a trading-off parameter, and &lt;math&gt;\theta&lt;/math&gt; is policy parameter. According to Lemma 1, the authors use &lt;math&gt;D_{JS}(\rho_{\theta},\rho_{E})&lt;/math&gt; to instead of &lt;math&gt;D_{JS}(\pi_{\theta},\pi_{E})&lt;/math&gt;, because it is easier to optimize through adversarial training on demonstrations. The learning objective is: <br /> $\mathcal{L}(\pi_{\theta})=-\eta(\pi_{\theta})+\lambda_{1}D_{JS}(\rho_{\theta},\rho_{E})$<br /> <br /> ==Benefits of Exploration with Demonstrations==<br /> The authors introduce the benefits of POfD. Firstly, we consider the expression of expected return in policy gradient methods .<br /> $\eta(\pi)=\eta(\pi_{old})+\mathbb{E}_{\tau\sim\pi}[\sum_{t=0}^\infty\gamma^{t}A_{\pi_{old}}(s,a)]$<br /> &lt;math&gt;\eta(\pi)&lt;/math&gt;is the advantage over the policy &lt;math&gt;\pi_{old}&lt;/math&gt; in the previous iteration, so the expression can be rewritten by<br /> $\eta(\pi)=\eta(\pi_{old})+\sum_{s}\rho_{\pi}(s)\sum_{a}\pi(a|s)A_{\pi_{old}}(s,a)$<br /> The local approximation to &lt;math&gt;\eta(\pi)&lt;/math&gt; up to first order is usually as the surrogate learning objective to be optimized by policy gradient methods due to the difficulties brought by complex dependency of &lt;math&gt;\rho_{\pi}(s)&lt;/math&gt; over &lt;math&gt; \pi &lt;/math&gt;:<br /> $J_{\pi_{old}}(\pi)=\eta(\pi_{old})+\sum_{s}\rho_{\pi_{old}}(s)\sum_{a}\pi(a|s)A_{\pi_{old}}(s,a)$<br /> The policy gradient methods improve &lt;math&gt;\eta(\pi)&lt;/math&gt; monotonically by optimizing the above &lt;math&gt;J_{\pi_{old}}(\pi)&lt;/math&gt; with a sufficiently small update step from &lt;math&gt;\pi_{old}&lt;/math&gt; to &lt;math&gt;\pi&lt;/math&gt; such that &lt;math&gt;D_{KL}^{max}(\pi, \pi_{old})&lt;/math&gt; is bounded   . POfD imposes an additional regularization &lt;math&gt;D_{JS}(\pi_{\theta}, \pi_{E})&lt;/math&gt; between &lt;math&gt;\pi_\theta&lt;/math&gt; and &lt;math&gt;\pi_{E}&lt;/math&gt; in order to encourage explorations around regions demonstrated by the expert policy. Theorem 1 shows such benefits,<br /> [[File:them1.png|500px|center]]<br /> <br /> In fact, POfD brings another factor, &lt;math&gt;D_{J S}^{max}(\pi_{i}, \pi_{E})&lt;/math&gt;, that would fully use the advantage &lt;math&gt;{\hat \delta}&lt;/math&gt;and add improvements with a margin over pure policy gradient methods.<br /> <br /> ==Optimization==<br /> <br /> For POfD, the authors choose to optimize the lower bound of the Jensen-Shannon divergence instead of directly optimizing the difficult Jensen-Shannon divergence. This optimization method is compatible with any policy gradient methods. Theorem 2 gives the lower bound of &lt;math&gt;D_{JS}(\rho_{\theta}, \rho_{E})&lt;/math&gt;：<br /> [[File:them2.png|450px|center]]<br /> Thus, the occupancy measure matching objective can be written as:<br /> [[File:eqnlm.png|450px|center]]<br /> where &lt;math&gt; D(s,a)=\frac{1}{1+e^{-U(s,a)}}: \mathcal{S}\times \mathcal{A} \rightarrow (0,1)&lt;/math&gt; is an arbitrary mapping function followed by a sigmoid activation function used for scaling, and its supremum ranging is like a discriminator for distinguishing whether the state-action pair is a current policy or an expert policy.<br /> To avoid overfitting, the authors add causal entropy &lt;math&gt;−H (\pi_{\theta}) &lt;/math&gt; as the regularization term. Thus, the learning objective is: <br /> $\min_{\theta}\mathcal{L}=-\eta(\pi_{\theta})-\lambda_{2}H(\pi_{\theta})+\lambda_{1} \sup_{{D\in(0,1)}^{S\times A}} \mathbb{E}_{\pi_{\theta}}[\log(D(s,a))]+\mathbb{E}_{\pi_{E}}[\log(1-D(s,a))]$<br /> At this point, the problem closely resembles the minimax problem related to the Generative Adversarial Networks (GANs) . The difference is that the discriminative model D of GANs is well-trained but the expert policy of POfD is not optimal. Then suppose D is parameterized by w. If it is from an expert policy, &lt;math&gt;D_w&lt;/math&gt;is toward 1, otherwise it is toward 0. Thus, the minimax learning objective is:<br /> $\min_{\theta}\max_{w}\mathcal{L}=-\eta(\pi_{\theta})-\lambda_{2}H (\pi_{\theta})+\lambda_{1}( \mathbb{E}_{\pi_{\theta}}[\log(D_{w}(s,a))]+\mathbb{E}_{\pi_{E}}[\log(1-D_{w}(s,a))])$<br /> The minimax learning objective can be rewritten by substituting the expression of &lt;math&gt; \eta(\pi) &lt;/math&gt;:<br /> $\min_{\theta}\max_{w}-\mathbb{E}_{\pi_{\theta}}[r'(s,a)]-\lambda_{2}H (\pi_{\theta})+\lambda_{1}\mathbb{E}_{\pi_{E}}[\log(1-D_{w}(s,a))]$<br /> where &lt;math&gt; r'(s,a)=r(a,b)-\lambda_{1}\log(D_{w}(s,a))&lt;/math&gt; is the reshaped reward function.<br /> The above objective can be optimized efficiently by alternately updating policy parameters θ and discriminator parameters w, then the gradient is given by:<br /> $\mathbb{E}_{\pi}[\nabla_{w}\log(D_{w}(s,a))]+\mathbb{E}_{\pi_{E}}[\nabla_{w}\log(1-D_{w}(s,a))]$<br /> Then, fixing the discriminator &lt;math&gt;D_w&lt;/math&gt;, the reshaped policy gradient is:<br /> $\nabla_{\theta}\mathbb{E}_{\pi_{\theta}}[r'(s,a)]=\mathbb{E}_{\pi_{\theta}}[\nabla_{\theta}\log\pi_{\theta}(a|s)Q'(s,a)]$<br /> where &lt;math&gt;Q'(\bar{s},\bar{a})=\mathbb{E}_{\pi_{\theta}}[r'(s,a)|s_0=\bar{s},a_0=\bar{a}]&lt;/math&gt;.<br /> <br /> At the end, Algorithm 1 gives the detailed process.<br /> [[File:pofd.png|450px|center]]<br /> <br /> =Discussion on Existing LfD Methods=<br /> <br /> To connect with the proposed POfD method, interpretation of the existing methods DQfD and DDPGfD through occupancy measure matching is provided. Both of the existing methods leverage demonstrations to aid exploration in RL.<br /> <br /> ==DQFD==<br /> DQFD  puts the demonstrations into a replay memory D and keeps them throughout the Q-learning process. The objective for DQFD is:<br /> $J_{DQfD}={\hat{\mathbb{E}}}_{D}[(R_t(n)-Q_w(s_t,a_t))^2]+\alpha{\hat{\mathbb{E}}}_{D^E}[(R_t(n)-Q_w(s_t,a_t))^2]$<br /> The second term can be rewritten as &lt;math&gt; {\hat{\mathbb{E}}}_{D^E}[(R_t(n)-Q_w(s_t,a_t))^2]={\hat{\mathbb{E}}}_{D^E}[(\hat{\rho}_E(s,a)-\rho_{\pi}(s,a))^{2}r^2(s,a)]&lt;/math&gt;, which can be regarded as a regularization forcing current policy's occupancy measure to match the expert's empirical occupancy measure, weighted by the potential reward.<br /> <br /> ==DDPGfD==<br /> DDPGfD  also puts the demonstrations into a replay memory D, but it is based on an actor-critic framework . The objective for DDPGfD is the same as DQFD. Its policy gradient is:<br /> $\nabla_{\theta}J_{DDPGfD}\approx \mathbb{E}_{s,a}[\nabla_{a}Q_w(s,a)\nabla_{\theta}\pi_{\theta}(s)], a=\pi_{\theta}(s)$<br /> From this equation, policy is updated relying on learned Q-network &lt;math&gt;Q_w &lt;/math&gt;rather than the demonstrations &lt;math&gt;D^{E} &lt;/math&gt;. DDPGfD shares the same objective function for &lt;math&gt;Q_w &lt;/math&gt; as DQfD, thus they have the same way of leveraging demonstrations, that is the demonstrations in DQfD and DDPGfD induce an occupancy measure matching regularization.<br /> <br /> =Experiments=<br /> <br /> ==Goal==<br /> The authors aim at investigating 1) whether POfD can aid exploration by leveraging a few demonstrations, even though the demonstrations are imperfect. 2) whether POfD can succeed and achieve high empirical return, especially in environments where reward signals are sparse and rare. <br /> <br /> ==Settings==<br /> The authors conduct the experiments on 8 physical control tasks, ranging from low-dimensional spaces to high-dimensional spaces and naturally sparse environments based on OpenAI Gym  and Mujoco (Multi-Joint dynamics with Contact)  (Gym is a toolkit for developing and comparing reinforcement learning algorithms. It supports teaching agents everything from walking to playing games like Pong or Pinball. MuJoCo is a physics engine aiming to facilitate research and development in robotics, biomechanics, graphics and animation, and other areas where fast and accurate simulation is needed. In order to get familiar with OpenAI Gym and Mujoco environment, you can watch these videos, respectively: [http://www.mujoco.org/image/home/mujocodemo.mp4 Mujoco], [https://gym.openai.com/v2018-02-21/videos/SpaceInvaders-v0-4184afb3-1223-4ac6-b52b-8e863cbe24a5/original.mp4 OpenAI Gym]). Due to the uniqueness of the environments, the authors introduce 4 ways to sparsify their built-in dense rewards. TYPE1: a reward of +1 is given when the agent reaches the terminal state, and otherwisel 0. TYPE2: a reward of +1 is given when the agent survives for a while. TYPE3: a reward of +1 is given for every time the agent moves forward over a specific number of units in Mujoco environments. TYPE4: specially designed for InvertedDoublePendulum, a reward +1 is given when the second pole stays above a specific height of 0.89. The details are shown in Table 1. Moreover, only one single imperfect trajectory is used as the demonstrations in this paper. The authors collect the demonstrations by training an agent insufficiently by running TRPO (Trust Region Policy Optimization) in the corresponding dense environment. <br /> [[File:pofdt1.png|900px|center]]<br /> <br /> ==Baselines==<br /> The authors compare POfD against 5 strong baselines:<br /> * training the policy with TRPO  in dense environments, which is called expert <br /> * training the policy with TRPO  in sparse environments<br /> * applying GAIL  to learn the policy from demonstrations<br /> * DQfD <br /> * DDPGfD <br /> <br /> ==Results==<br /> Firstly, the authors test the performance of POfD in sparse control environments with discrete actions. From Table 1, POfD achieves performance comparable with the policy learned under dense environments. From Figure 2, only POfD successes to explore sufficiently and achieves great performance in both sparse environments. TRPO  and DQFD  fail to explore and GAIL  converges to the imperfect demonstration in MountainCar .<br /> <br /> [[File:pofdf2.png|500px|center]]<br /> <br /> Then, the authors test the performance of POfD under spares environments with continuous actions space. From Figure 3, POfD achieves expert-level performance in terms of accumulated rewards and surpasses other strong baselines training the policy with TRPO. By watching the learning process of different methods, we can see that TRPO consistently fails to explore the environments when the feedback is sparse, except for HalfCheetah. This may be because there is no terminal state in HalfCheetah, thus a random agent can perform reasonably well as long as the time horizon is sufficiently long. This is shown in Figure3 where the improvement of TRPO begins to show after 400 iterations. DDPGfD and GAIL have common drawback: during training process, they both converge to the imperfect demonstration data. For HalfCheetah, GAIL fails to converge and DDPGfD converges to an even worse point. This situation is expected because the policy and value networks tend to over-fit when having few data, so the training process of GAIL and DDPGfD is severely biased by the imperfect data. Finally, our proposed method can effectively explore the environment with the help of demonstration-based intrinsic reward reshaping, and succeeds consistently across different tasks both in terms of learning stability and convergence speed.<br /> [[File:pofdf3.png|900px|center]]<br /> <br /> The authors also implement a locomotion task &lt;math&gt;Humanoid&lt;/math&gt;, which teaches a human-like robot to walk. The state space of dimension is 376, which is very hard to render. As a result, POfD still outperformed all three baselike methods, as they failed to learn policies in such a sparse reward environment.<br /> <br /> The reacher environment is a task that the target is to control a robot arm to touch an object. the location of the object is random for each instantiation. The environment reward is sparse: every time the arm reaches the ball and holds for a while (e.g., 5 time steps), it receives a reward of +1; otherwise it gets zero reward. The authors select 15 random trajectories as demonstration data, and the performance of POfD is much better than the expert, while all other baseline methods failed.<br /> <br /> =Conclusion=<br /> In this paper, a method, POfD, is proposed that can acquire knowledge from a limited amount of imperfect demonstration data to aid exploration in environments with sparse feedback. It is compatible with any policy gradient methods. POfD induces implicit dynamic reward shaping and brings provable benefits for policy improvement. Moreover, the experiments results have shown the validity and effectivness of POfD in encouraging the agent to explore around the nearby region of the expert policy and learn better policies. The key contribution is that POfD helps the agent work with few and imperfect demonstrations in an environment with sparse rewards.<br /> <br /> =Critique=<br /> # A novel demonstration-based policy optimization method is proposed. In the process of policy optimization, POfD reshapes the reward function. This new reward function can guide the agent to imitate the expert behaviour when the reward is sparse and explore on its own when the reward value can be obtained, which can take full advantage of the demonstration data and there is no need to ensure that the expert policy is the optimal policy.<br /> # POfD can be combined with any policy gradient methods. Its performance surpasses five strong baselines and can be comparable to the agents trained in the dense-reward environment.<br /> # The paper is structured and the flow of ideas is easy to follow. For related work, the authors clearly explain similarities and differences among these related works.<br /> # This paper's scalability is demonstrated. The experiments environments are ranging from low-dimensional spaces to high-dimensional spaces and from discrete action spaces to continuous actions spaces. For future work, can it be realized in the real world?<br /> # There is a doubt that whether it is a correct method to use the trajectory that was insufficiently learned in dense-reward environment as the imperfect demonstration.<br /> # In this paper, the performance only is judged by the cumulative reward, can other evaluation terms be considered? For example, the convergence rate.<br /> # The performance of this algorithm hinges on the assumption that expert demonstrations are near optimal in the action space. As seen in figure 3, there appears to be an upper bound to performance near (or just above) the expert accuracy -- this may be an indication of a performance ceiling. In games where near-optimal policies can differ greatly (e.g.; offensive or defensive strategies in chess), the success of the model will depend on the selection of expert demonstrations that are closest to a truly optimal policy (i.e.; just because a policy is the current expert, it does not mean it resembles the true optimal policy).<br /> <br /> =References=<br />  Nair, A., McGrew, B., Andrychowicz, M., Zaremba, W., and Abbeel, P. Overcoming exploration in reinforcement learning with demonstrations. arXiv preprint arXiv:1709.10089, 2017.<br /> <br />  Hester, T., Vecerik, M., Pietquin, O., Lanctot, M., Schaul, T., Piot, B., Sendonaris, A., Dulac-Arnold, G., Osband, I., Agapiou, J., et al. Learning from demonstrations for real world reinforcement learning. arXiv preprint arXiv:1704.03732, 2017.<br /> <br />  Večerík, M., Hester, T., Scholz, J., Wang, F., Pietquin, O., Piot, B., Heess, N., Rotho ̈rl, T., Lampe, T., and Riedmiller, M. Leveraging demonstrations for deep reinforcement learning on robotics problems with sparse rewards. arXiv preprint arXiv:1707.08817, 2017.<br /> <br />  Silver, D., Huang, A., Maddison, C. J., Guez, A., Sifre, L., Van Den Driessche, G., Schrittwieser, J., Antonoglou, I., Panneershelvam, V., Lanctot, M., et al. Mastering the game of go with deep neural networks and tree search. nature, 529(7587):484–489, 2016.<br /> <br />  Todorov, E., Erez, T., and Tassa, Y. Mujoco: A physics engine for model-based control. In Intelligent Robots and Systems (IROS), 2012 IEEE/RSJ International Con- ference on, pp. 5026–5033. IEEE, 2012.<br /> <br />  Schaal, S. Learning from demonstration. In Advances in neural information processing systems, pp. 1040–1046, 1997.<br /> <br />  Kim, B., Farahmand, A.-m., Pineau, J., and Precup, D. Learning from limited demonstrations. In Advances in Neural Information Processing Systems, pp. 2859–2867, 2013.<br /> <br />  Piot, B., Geist, M., and Pietquin, O. Boosted bellman resid- ual minimization handling expert demonstrations. In Joint European Conference on Machine Learning and Knowl- edge Discovery in Databases, pp. 549–564. Springer, 2014.<br /> <br />  Aravind S. Lakshminarayanan, Sherjil Ozair, Y. B. Rein- forcement learning with few expert demonstrations. In NIPS workshop, 2016.<br /> <br />  Brys, T., Harutyunyan, A., Suay, H. B., Chernova, S., Tay- lor, M. E., and Nowe ́, A. Reinforcement learning from demonstration through shaping. In IJCAI, pp. 3352–3358, 2015.<br /> <br />  Ng, A. Y., Russell, S. J., et al. Algorithms for inverse reinforcement learning. In Icml, pp. 663–670, 2000.<br /> <br />  Syed, U. and Schapire, R. E. A game-theoretic approach to apprenticeship learning. In Advances in neural informa- tion processing systems, pp. 1449–1456, 2008.<br /> <br />  Syed, U., Bowling, M., and Schapire, R. E. Apprenticeship learning using linear programming. In Proceedings of the 25th international conference on Machine learning, pp. 1032–1039. ACM, 2008.<br /> <br />  Ho, J. and Ermon, S. Generative adversarial imitation learn- ing. In Advances in Neural Information Processing Sys- tems, pp. 4565–4573, 2016.<br /> <br />  Sutton, R. S. and Barto, A. G. Reinforcement learning: An introduction, volume 1. MIT press Cambridge, 1998.<br /> <br />  Kakade, S. M. A natural policy gradient. In Advances in neural information processing systems, pp. 1531–1538, 2002.<br /> <br />  Schulman, J., Levine, S., Abbeel, P., Jordan, M., and Moritz, P. Trust region policy optimization. In Proceedings of the 32nd International Conference on Machine Learning (ICML-15), pp. 1889–1897, 2015.<br /> <br />  Schulman, J., Wolski, F., Dhariwal, P., Radford, A., and Klimov, O. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.<br /> <br />  Goodfellow, I., Pouget-Abadie, J., Mirza, M., Xu, B., Warde-Farley, D., Ozair, S., Courville, A., and Bengio, Y. Generative adversarial nets. In Advances in neural information processing systems, pp. 2672–2680, 2014.<br /> <br />  Brockman, G., Cheung, V., Pettersson, L., Schneider, J., Schulman, J., Tang, J., and Zaremba, W. Openai gym, 2016.<br /> <br />  Lillicrap, T. P., Hunt, J. J., Pritzel, A., Heess, N., Erez, T., Tassa, Y., Silver, D., and Wierstra, D. Continuous control with deep reinforcement learning. arXiv preprint arXiv:1509.02971, 2015.<br /> <br />  Moore, A. W. Efficient memory-based learning for robot control. 1990.<br /> <br />  Zhu, Y., Wang, Z., Merel, J., Rusu, A., Erez, T., Cabi, S., Tunyasuvunakool, S., Kramar, J., Hadsell, R., de Freitas, N., et al. Reinforcement and imitation learning for diverse visuomotor skills. arXiv preprint arXiv:1802.09564, 2018.<br /> <br />  Li, Y., Song, J., and Ermon, S. Infogail: Interpretable imitation learning from visual demonstrations. In Advances in Neural Information Processing Systems, pp. 3815–3825, 2017.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=policy_optimization_with_demonstrations&diff=41617 policy optimization with demonstrations 2018-11-27T17:37:31Z <p>Jmmoosa: /* Policy Optimization with Demonstration (POfD) */</p> <hr /> <div>= Introduction =<br /> <br /> The reinforcement learning (RL) method has made significant progress in a variety of applications, but the exploration problems regarding how to gain more experience from novel policies to improve long-term performance are still challenges, especially in environments where reward signals are sparse and rare. There are currently two ways to solve such exploration problems in RL: <br /> <br /> 1) Guide the agent to explore states that have never been seen. <br /> <br /> 2) Guide the agent to imitate a demonstration trajectory sampled from an expert policy to learn. <br /> <br /> When guiding the agent to imitate the expert behavior for learning, there are also two methods: putting the demonstration directly into the replay memory    or using the demonstration trajectory to pre-train the policy in a supervised manner . However, neither of these methods takes full advantage of the demonstration data. They instead treat the demonstration data identically to self-generated data, requiring a tremendous number of difficult to collect examples to learn effectively. To address this problem, a novel policy optimization method from demonstration (POfD) is proposed, which takes full advantage of the demonstration and there is no need to ensure that the expert policy is the optimal policy. To summarize, the authors bring forth this idea through the following techniques:<br /> <br /> 1) A demonstration guided exploration term measuring the divergence between current and the expert policy is added to the policy optimization objective, increasing the similarity to expert-like exploration.<br /> <br /> 2) They say that for better learning from demonstrations and getting an optimization friendly lower bound, the proposed objective could be defined on an occupancy measure as in .<br /> <br /> 3) Finally, they show that the optimization can move towards optimizing the derived lower bound and the generative adversarial training.<br /> <br /> The authors also evaluate the performance of POfD on Mujoco  in sparse-reward environments. The experiments results show that the performance of POfD is greatly improved compared with some strong baselines and even to the policy gradient method in dense-reward environments.<br /> <br /> ==Intuition==<br /> The agent should imitate the demonstrated behavior when rewards are sparse and then explore new states on its own after acquiring sufficient skills, which is a dynamic intrinsic reward mechanism that can be reshaped in terms of the native rewards in RL. At present the state of the art exploration in Reinforcement learning is simply epsilon greedy which just makes random moves for a small percentage of times to explore unexplored moves. This is very naive and is one of the main reasons for the high sample complexity in RL. On the other hand, if there is an expert demonstrator who can guide exploration, the agent can make more guided and accurate exploratory moves.<br /> <br /> =Related Work =<br /> There are some related works in overcoming exploration difficulties by learning from demonstration  and imitation learning in RL.<br /> <br /> For learning from demonstration (LfD),<br /> # Most LfD methods adopt value-based RL algorithms, such as DQfD (Deep Q-learning from Demonstrations)  which are applied into the discrete action spaces and DDPGfD (Deep Deterministic Policy Gradient from Demonstrations)  which extends this idea to the continuous spaces. But both of them under-utilize the demonstration data.<br /> # There are some methods based on policy iteration  , which shapes the value function by using demonstration data. But they get the bad performance when demonstration data is imperfect.<br /> # A hybrid framework  that learns the policy in which the probability of taking demonstrated actions is maximized is proposed, which considers less demonstration data.<br /> # A reward reshaping mechanism  that encourages taking actions close to the demonstrated ones is proposed. It is similar to the method in this paper, but there exists some differences as it is defined as a potential function based on multi-variate Gaussian to model the distribution of state-actions.<br /> All of the above methods require a lot of perfect demonstrations to get satisfactory performance, which is different from POfD in this paper.<br /> <br /> For imitation learning, <br /> # Inverse Reinforce Learning  problems are solved by alternating between fitting the reward function and selecting the policy  . But it cannot be extended to big-scale problems.<br /> # Generative Adversarial Imitation Learning (GAIL)  uses a discriminator to distinguish whether a state-action pair is from the expert or the learned policy and it can be applied into the high-dimensional continuous control problems.<br /> <br /> Both of the above methods are effective for imitation learning, but cannot leverage the valuable feedback given by the environments and usually suffer from bad performance when the expert data is imperfect. That is different from POfD in this paper.<br /> <br /> There is also another idea in which an agent learns using hybrid imitation learning and reinforcement learning reward[23, 24]. However, unlike this paper, they did not provide some theoretical support for their method and only explained some intuitive explanations.<br /> <br /> =Background=<br /> <br /> ==Preliminaries==<br /> Markov Decision Process (MDP)  is defined by a tuple &lt;math&gt;⟨\mathcal{S}, \mathcal{A}, \mathcal{P}, r, \gamma⟩ &lt;/math&gt;, where &lt;math&gt;\mathcal{S}&lt;/math&gt; is the state space, &lt;math&gt;\mathcal{A} &lt;/math&gt; is the action space, &lt;math&gt;\mathcal{P}(s'|s,a)&lt;/math&gt; is the transition distribution of taking action &lt;math&gt; a &lt;/math&gt; at state &lt;math&gt;s &lt;/math&gt;, &lt;math&gt; r(s,a) &lt;/math&gt;is the reward function, and &lt;math&gt; \gamma &lt;/math&gt; is the discount factor between 0 and 1. Policy &lt;math&gt; \pi(a|s) &lt;/math&gt; is a mapping from state to action probabilities, the performance of &lt;math&gt; \pi &lt;/math&gt; is usually evaluated by its expected discounted reward &lt;math&gt; \eta(\pi) &lt;/math&gt;: <br /> $\eta(\pi)=\mathbb{E}_{\pi}[r(s,a)]=\mathbb{E}_{(s_0,a_0,s_1,...)}[\sum_{t=0}^\infty\gamma^{t}r(s_t,a_t)]$<br /> The value function is &lt;math&gt; V_{\pi}(s) =\mathbb{E}_{\pi}[r(·,·)|s_0=s] &lt;/math&gt;, the action value function is &lt;math&gt; Q_{\pi}(s,a) =\mathbb{E}_{\pi}[r(·,·)|s_0=s,a_0=a] &lt;/math&gt;, and the advantage function that reflects the expected additional reward after taking action a at state s is &lt;math&gt; A_{\pi}(s,a)=Q_{\pi}(s,a)-V_{\pi}(s)&lt;/math&gt;.<br /> Then the authors define Occupancy measure, which is used to estimate the probability that state &lt;math&gt;s&lt;/math&gt; and state action pairs &lt;math&gt;(s,a)&lt;/math&gt; when executing a certain policy.<br /> [[File:def1.png|500px|center]]<br /> Then the performance of &lt;math&gt; \pi &lt;/math&gt; can be rewritten to: <br /> [[File:equ2.png|500px|center]]<br /> At the same time, the authors propose a lemma: <br /> [[File:lemma1.png|500px|center]]<br /> <br /> ==Problem Definition==<br /> Generally, RL tasks and environments do not provide a comprehensive reward and instead rely on sparse feedback indicating whether the goal is reached.<br /> <br /> In this paper, the authors aim to develop a method that can boost exploration by leveraging effectively the demonstrations &lt;math&gt;D^E &lt;/math&gt;from the expert policy &lt;math&gt; \pi_E &lt;/math&gt; and maximize &lt;math&gt; \eta(\pi) &lt;/math&gt; in the sparse-reward environment. The authors define the demonstrations &lt;math&gt;D^E=\{\tau_1,\tau_2,...,\tau_N\} &lt;/math&gt;, where the i-th trajectory &lt;math&gt;\tau_i=\{(s_0^i,a_0^i),(s_1^i,a_1^i),...,(s_T^i,a_T^i)\} &lt;/math&gt; is generated from the unknown expert policy &lt;math&gt;\pi_E &lt;/math&gt;. In addition, there is an assumption on the quality of the expert policy:<br /> [[File:asp1.png|500px|center]]<br /> <br /> <br /> Throughout the paper, they use &lt;math&gt;\pi_E &lt;/math&gt; to denote the expert policy that gives the relatively good &lt;math&gt;\eta_\pi &lt;/math&gt;, and use &lt;math&gt;\hat{\mathbb{E}}_D &lt;/math&gt;to denote empirical expectation estimated from the demonstrated trajectories &lt;math&gt;D^E &lt;/math&gt;. We have the following reasonable and necessary assumption on the quality of the expert policy &lt;math&gt;\pi_E &lt;/math&gt;.<br /> <br /> <br /> Moreover, it is not necessary to ensure that the expert policy is advantageous over all the policies. This is because that POfD will learn a better policy than expert policy by exploring on its own in later learning stages.<br /> <br /> =Method=<br /> <br /> ==Policy Optimization with Demonstration (POfD)==<br /> <br /> [[File:ff1.png|thumb|500px|center |Figure 1: Demonstrations (the blue curve) enables POfD to explore in the high-reward regions (red arrows). On the other hand random explorations (olive green dashed curves) occur in sparse-reward environments.]]<br /> <br /> This method optimizes the policy by forcing the policy to explore in the nearby region of the expert policy that is specified by several demonstrated trajectories &lt;math&gt;D^E &lt;/math&gt; (as shown in Fig.1) in order to avoid causing slow convergence or failure when the environment feedback is sparse. In addition, the authors encourage the policy π to explore by &quot;following&quot; the demonstrations &lt;math&gt;D^E &lt;/math&gt;. Thus, a new learning objective is given:<br /> $\mathcal{L}(\pi_{\theta})=-\eta(\pi_{\theta})+\lambda_{1}D_{JS}(\pi_{\theta},\pi_{E})$<br /> where &lt;math&gt;D_{JS}(\pi_{\theta},\pi_{E})&lt;/math&gt; is Jensen-Shannon divergence between current policy &lt;math&gt;\pi_{\theta}&lt;/math&gt; and the expert policy &lt;math&gt;\pi_{E}&lt;/math&gt; , &lt;math&gt;\lambda_1&lt;/math&gt; is a trading-off parameter, and &lt;math&gt;\theta&lt;/math&gt; is policy parameter. According to Lemma 1, the authors use &lt;math&gt;D_{JS}(\rho_{\theta},\rho_{E})&lt;/math&gt; to instead of &lt;math&gt;D_{JS}(\pi_{\theta},\pi_{E})&lt;/math&gt;, because it is easier to optimize through adversarial training on demonstrations. The learning objective is: <br /> $\mathcal{L}(\pi_{\theta})=-\eta(\pi_{\theta})+\lambda_{1}D_{JS}(\rho_{\theta},\rho_{E})$<br /> <br /> ==Benefits of Exploration with Demonstrations==<br /> The authors introduce the benefits of POfD. Firstly, we consider the expression of expected return in policy gradient methods .<br /> $\eta(\pi)=\eta(\pi_{old})+\mathbb{E}_{\tau\sim\pi}[\sum_{t=0}^\infty\gamma^{t}A_{\pi_{old}}(s,a)]$<br /> &lt;math&gt;\eta(\pi)&lt;/math&gt;is the advantage over the policy &lt;math&gt;\pi_{old}&lt;/math&gt; in the previous iteration, so the expression can be rewritten by<br /> $\eta(\pi)=\eta(\pi_{old})+\sum_{s}\rho_{\pi}(s)\sum_{a}\pi(a|s)A_{\pi_{old}}(s,a)$<br /> The local approximation to &lt;math&gt;\eta(\pi)&lt;/math&gt; up to first order is usually as the surrogate learning objective to be optimized by policy gradient methods due to the difficulties brought by complex dependency of &lt;math&gt;\rho_{\pi}(s)&lt;/math&gt; over &lt;math&gt; \pi &lt;/math&gt;:<br /> $J_{\pi_{old}}(\pi)=\eta(\pi_{old})+\sum_{s}\rho_{\pi_{old}}(s)\sum_{a}\pi(a|s)A_{\pi_{old}}(s,a)$<br /> The policy gradient methods improve &lt;math&gt;\eta(\pi)&lt;/math&gt; monotonically by optimizing the above &lt;math&gt;J_{\pi_{old}}(\pi)&lt;/math&gt; with a sufficiently small update step from &lt;math&gt;\pi_{old}&lt;/math&gt; to &lt;math&gt;\pi&lt;/math&gt; such that &lt;math&gt;D_{KL}^{max}(\pi, \pi_{old})&lt;/math&gt; is bounded   . POfD imposes an additional regularization &lt;math&gt;D_{JS}(\pi_{\theta}, \pi_{E})&lt;/math&gt; between &lt;math&gt;\pi_\theta&lt;/math&gt; and &lt;math&gt;\pi_{E}&lt;/math&gt; in order to encourage explorations around regions demonstrated by the expert policy. Theorem 1 shows such benefits,<br /> [[File:them1.png|500px|center]]<br /> <br /> In fact, POfD brings another factor, &lt;math&gt;D_{J S}^{max}(\pi_{i}, \pi_{E})&lt;/math&gt;, that would fully use the advantage &lt;math&gt;{\hat \delta}&lt;/math&gt;and add improvements with a margin over pure policy gradient methods.<br /> <br /> ==Optimization==<br /> <br /> For POfD, the authors choose to optimize the lower bound of the Jensen-Shannon divergence instead of directly optimizing the difficult Jensen-Shannon divergence. This optimization method is compatible with any policy gradient methods. Theorem 2 gives the lower bound of &lt;math&gt;D_{JS}(\rho_{\theta}, \rho_{E})&lt;/math&gt;：<br /> [[File:them2.png|450px|center]]<br /> Thus, the occupancy measure matching objective can be written as:<br /> [[File:eqnlm.png|450px|center]]<br /> where &lt;math&gt; D(s,a)=\frac{1}{1+e^{-U(s,a)}}: \mathcal{S}\times \mathcal{A} \rightarrow (0,1)&lt;/math&gt; is an arbitrary mapping function followed by a sigmoid activation function used for scaling, and its supremum ranging is like a discriminator for distinguishing whether the state-action pair is a current policy or an expert policy.<br /> To avoid overfitting, the authors add causal entropy &lt;math&gt;−H (\pi_{\theta}) &lt;/math&gt; as the regularization term. Thus, the learning objective is: <br /> $\min_{\theta}\mathcal{L}=-\eta(\pi_{\theta})-\lambda_{2}H(\pi_{\theta})+\lambda_{1} \sup_{{D\in(0,1)}^{S\times A}} \mathbb{E}_{\pi_{\theta}}[\log(D(s,a))]+\mathbb{E}_{\pi_{E}}[\log(1-D(s,a))]$<br /> At this point, the problem closely resembles the minimax problem related to the Generative Adversarial Networks (GANs) . The difference is that the discriminative model D of GANs is well-trained but the expert policy of POfD is not optimal. Then suppose D is parameterized by w. If it is from an expert policy, &lt;math&gt;D_w&lt;/math&gt;is toward 1, otherwise it is toward 0. Thus, the minimax learning objective is:<br /> $\min_{\theta}\max_{w}\mathcal{L}=-\eta(\pi_{\theta})-\lambda_{2}H (\pi_{\theta})+\lambda_{1}( \mathbb{E}_{\pi_{\theta}}[\log(D_{w}(s,a))]+\mathbb{E}_{\pi_{E}}[\log(1-D_{w}(s,a))])$<br /> The minimax learning objective can be rewritten by substituting the expression of &lt;math&gt; \eta(\pi) &lt;/math&gt;:<br /> $\min_{\theta}\max_{w}-\mathbb{E}_{\pi_{\theta}}[r'(s,a)]-\lambda_{2}H (\pi_{\theta})+\lambda_{1}\mathbb{E}_{\pi_{E}}[\log(1-D_{w}(s,a))]$<br /> where &lt;math&gt; r'(s,a)=r(a,b)-\lambda_{1}\log(D_{w}(s,a))&lt;/math&gt; is the reshaped reward function.<br /> The above objective can be optimized efficiently by alternately updating policy parameters θ and discriminator parameters w, then the gradient is given by:<br /> $\mathbb{E}_{\pi}[\nabla_{w}\log(D_{w}(s,a))]+\mathbb{E}_{\pi_{E}}[\nabla_{w}\log(1-D_{w}(s,a))]$<br /> Then, fixing the discriminator &lt;math&gt;D_w&lt;/math&gt;, the reshaped policy gradient is:<br /> $\nabla_{\theta}\mathbb{E}_{\pi_{\theta}}[r'(s,a)]=\mathbb{E}_{\pi_{\theta}}[\nabla_{\theta}\log\pi_{\theta}(a|s)Q'(s,a)]$<br /> where &lt;math&gt;Q'(\bar{s},\bar{a})=\mathbb{E}_{\pi_{\theta}}[r'(s,a)|s_0=\bar{s},a_0=\bar{a}]&lt;/math&gt;.<br /> <br /> At the end, Algorithm 1 gives the detailed process.<br /> [[File:pofd.png|450px|center]]<br /> <br /> =Discussion on Existing LfD Methods=<br /> <br /> ==DQFD==<br /> DQFD  puts the demonstrations into a replay memory D and keeps them throughout the Q-learning process. The objective for DQFD is:<br /> $J_{DQfD}={\hat{\mathbb{E}}}_{D}[(R_t(n)-Q_w(s_t,a_t))^2]+\alpha{\hat{\mathbb{E}}}_{D^E}[(R_t(n)-Q_w(s_t,a_t))^2]$<br /> The second term can be rewritten as &lt;math&gt; {\hat{\mathbb{E}}}_{D^E}[(R_t(n)-Q_w(s_t,a_t))^2]={\hat{\mathbb{E}}}_{D^E}[(\hat{\rho}_E(s,a)-\rho_{\pi}(s,a))^{2}r^2(s,a)]&lt;/math&gt;, which can be regarded as a regularization forcing current policy's occupancy measure to match the expert's empirical occupancy measure, weighted by the potential reward.<br /> <br /> ==DDPGfD==<br /> DDPGfD  also puts the demonstrations into a replay memory D, but it is based on an actor-critic framework . The objective for DDPGfD is the same as DQFD. Its policy gradient is:<br /> $\nabla_{\theta}J_{DDPGfD}\approx \mathbb{E}_{s,a}[\nabla_{a}Q_w(s,a)\nabla_{\theta}\pi_{\theta}(s)], a=\pi_{\theta}(s)$<br /> From this equation, policy is updated relying on learned Q-network &lt;math&gt;Q_w &lt;/math&gt;rather than the demonstrations &lt;math&gt;D^{E} &lt;/math&gt;. DDPGfD shares the same objective function for &lt;math&gt;Q_w &lt;/math&gt; as DQfD, thus they have the same way of leveraging demonstrations, that is the demonstrations in DQfD and DDPGfD induce an occupancy measure matching regularization.<br /> <br /> =Experiments=<br /> <br /> ==Goal==<br /> The authors aim at investigating 1) whether POfD can aid exploration by leveraging a few demonstrations, even though the demonstrations are imperfect. 2) whether POfD can succeed and achieve high empirical return, especially in environments where reward signals are sparse and rare. <br /> <br /> ==Settings==<br /> The authors conduct the experiments on 8 physical control tasks, ranging from low-dimensional spaces to high-dimensional spaces and naturally sparse environments based on OpenAI Gym  and Mujoco (Multi-Joint dynamics with Contact)  (Gym is a toolkit for developing and comparing reinforcement learning algorithms. It supports teaching agents everything from walking to playing games like Pong or Pinball. MuJoCo is a physics engine aiming to facilitate research and development in robotics, biomechanics, graphics and animation, and other areas where fast and accurate simulation is needed. In order to get familiar with OpenAI Gym and Mujoco environment, you can watch these videos, respectively: [http://www.mujoco.org/image/home/mujocodemo.mp4 Mujoco], [https://gym.openai.com/v2018-02-21/videos/SpaceInvaders-v0-4184afb3-1223-4ac6-b52b-8e863cbe24a5/original.mp4 OpenAI Gym]). Due to the uniqueness of the environments, the authors introduce 4 ways to sparsify their built-in dense rewards. TYPE1: a reward of +1 is given when the agent reaches the terminal state, and otherwisel 0. TYPE2: a reward of +1 is given when the agent survives for a while. TYPE3: a reward of +1 is given for every time the agent moves forward over a specific number of units in Mujoco environments. TYPE4: specially designed for InvertedDoublePendulum, a reward +1 is given when the second pole stays above a specific height of 0.89. The details are shown in Table 1. Moreover, only one single imperfect trajectory is used as the demonstrations in this paper. The authors collect the demonstrations by training an agent insufficiently by running TRPO (Trust Region Policy Optimization) in the corresponding dense environment. <br /> [[File:pofdt1.png|900px|center]]<br /> <br /> ==Baselines==<br /> The authors compare POfD against 5 strong baselines:<br /> * training the policy with TRPO  in dense environments, which is called expert <br /> * training the policy with TRPO  in sparse environments<br /> * applying GAIL  to learn the policy from demonstrations<br /> * DQfD <br /> * DDPGfD <br /> <br /> ==Results==<br /> Firstly, the authors test the performance of POfD in sparse control environments with discrete actions. From Table 1, POfD achieves performance comparable with the policy learned under dense environments. From Figure 2, only POfD successes to explore sufficiently and achieves great performance in both sparse environments. TRPO  and DQFD  fail to explore and GAIL  converges to the imperfect demonstration in MountainCar .<br /> <br /> [[File:pofdf2.png|500px|center]]<br /> <br /> Then, the authors test the performance of POfD under spares environments with continuous actions space. From Figure 3, POfD achieves expert-level performance in terms of accumulated rewards and surpasses other strong baselines training the policy with TRPO. By watching the learning process of different methods, we can see that TRPO consistently fails to explore the environments when the feedback is sparse, except for HalfCheetah. This may be because there is no terminal state in HalfCheetah, thus a random agent can perform reasonably well as long as the time horizon is sufficiently long. This is shown in Figure3 where the improvement of TRPO begins to show after 400 iterations. DDPGfD and GAIL have common drawback: during training process, they both converge to the imperfect demonstration data. For HalfCheetah, GAIL fails to converge and DDPGfD converges to an even worse point. This situation is expected because the policy and value networks tend to over-fit when having few data, so the training process of GAIL and DDPGfD is severely biased by the imperfect data. Finally, our proposed method can effectively explore the environment with the help of demonstration-based intrinsic reward reshaping, and succeeds consistently across different tasks both in terms of learning stability and convergence speed.<br /> [[File:pofdf3.png|900px|center]]<br /> <br /> The authors also implement a locomotion task &lt;math&gt;Humanoid&lt;/math&gt;, which teaches a human-like robot to walk. The state space of dimension is 376, which is very hard to render. As a result, POfD still outperformed all three baselike methods, as they failed to learn policies in such a sparse reward environment.<br /> <br /> The reacher environment is a task that the target is to control a robot arm to touch an object. the location of the object is random for each instantiation. The environment reward is sparse: every time the arm reaches the ball and holds for a while (e.g., 5 time steps), it receives a reward of +1; otherwise it gets zero reward. The authors select 15 random trajectories as demonstration data, and the performance of POfD is much better than the expert, while all other baseline methods failed.<br /> <br /> =Conclusion=<br /> In this paper, a method, POfD, is proposed that can acquire knowledge from a limited amount of imperfect demonstration data to aid exploration in environments with sparse feedback. It is compatible with any policy gradient methods. POfD induces implicit dynamic reward shaping and brings provable benefits for policy improvement. Moreover, the experiments results have shown the validity and effectivness of POfD in encouraging the agent to explore around the nearby region of the expert policy and learn better policies. The key contribution is that POfD helps the agent work with few and imperfect demonstrations in an environment with sparse rewards.<br /> <br /> =Critique=<br /> # A novel demonstration-based policy optimization method is proposed. In the process of policy optimization, POfD reshapes the reward function. This new reward function can guide the agent to imitate the expert behaviour when the reward is sparse and explore on its own when the reward value can be obtained, which can take full advantage of the demonstration data and there is no need to ensure that the expert policy is the optimal policy.<br /> # POfD can be combined with any policy gradient methods. Its performance surpasses five strong baselines and can be comparable to the agents trained in the dense-reward environment.<br /> # The paper is structured and the flow of ideas is easy to follow. For related work, the authors clearly explain similarities and differences among these related works.<br /> # This paper's scalability is demonstrated. The experiments environments are ranging from low-dimensional spaces to high-dimensional spaces and from discrete action spaces to continuous actions spaces. For future work, can it be realized in the real world?<br /> # There is a doubt that whether it is a correct method to use the trajectory that was insufficiently learned in dense-reward environment as the imperfect demonstration.<br /> # In this paper, the performance only is judged by the cumulative reward, can other evaluation terms be considered? For example, the convergence rate.<br /> # The performance of this algorithm hinges on the assumption that expert demonstrations are near optimal in the action space. As seen in figure 3, there appears to be an upper bound to performance near (or just above) the expert accuracy -- this may be an indication of a performance ceiling. In games where near-optimal policies can differ greatly (e.g.; offensive or defensive strategies in chess), the success of the model will depend on the selection of expert demonstrations that are closest to a truly optimal policy (i.e.; just because a policy is the current expert, it does not mean it resembles the true optimal policy).<br /> <br /> =References=<br />  Nair, A., McGrew, B., Andrychowicz, M., Zaremba, W., and Abbeel, P. Overcoming exploration in reinforcement learning with demonstrations. arXiv preprint arXiv:1709.10089, 2017.<br /> <br />  Hester, T., Vecerik, M., Pietquin, O., Lanctot, M., Schaul, T., Piot, B., Sendonaris, A., Dulac-Arnold, G., Osband, I., Agapiou, J., et al. Learning from demonstrations for real world reinforcement learning. arXiv preprint arXiv:1704.03732, 2017.<br /> <br />  Večerík, M., Hester, T., Scholz, J., Wang, F., Pietquin, O., Piot, B., Heess, N., Rotho ̈rl, T., Lampe, T., and Riedmiller, M. Leveraging demonstrations for deep reinforcement learning on robotics problems with sparse rewards. arXiv preprint arXiv:1707.08817, 2017.<br /> <br />  Silver, D., Huang, A., Maddison, C. J., Guez, A., Sifre, L., Van Den Driessche, G., Schrittwieser, J., Antonoglou, I., Panneershelvam, V., Lanctot, M., et al. Mastering the game of go with deep neural networks and tree search. nature, 529(7587):484–489, 2016.<br /> <br />  Todorov, E., Erez, T., and Tassa, Y. Mujoco: A physics engine for model-based control. In Intelligent Robots and Systems (IROS), 2012 IEEE/RSJ International Con- ference on, pp. 5026–5033. IEEE, 2012.<br /> <br />  Schaal, S. Learning from demonstration. In Advances in neural information processing systems, pp. 1040–1046, 1997.<br /> <br />  Kim, B., Farahmand, A.-m., Pineau, J., and Precup, D. Learning from limited demonstrations. In Advances in Neural Information Processing Systems, pp. 2859–2867, 2013.<br /> <br />  Piot, B., Geist, M., and Pietquin, O. Boosted bellman resid- ual minimization handling expert demonstrations. In Joint European Conference on Machine Learning and Knowl- edge Discovery in Databases, pp. 549–564. Springer, 2014.<br /> <br />  Aravind S. Lakshminarayanan, Sherjil Ozair, Y. B. Rein- forcement learning with few expert demonstrations. In NIPS workshop, 2016.<br /> <br />  Brys, T., Harutyunyan, A., Suay, H. B., Chernova, S., Tay- lor, M. E., and Nowe ́, A. Reinforcement learning from demonstration through shaping. In IJCAI, pp. 3352–3358, 2015.<br /> <br />  Ng, A. Y., Russell, S. J., et al. Algorithms for inverse reinforcement learning. In Icml, pp. 663–670, 2000.<br /> <br />  Syed, U. and Schapire, R. E. A game-theoretic approach to apprenticeship learning. In Advances in neural informa- tion processing systems, pp. 1449–1456, 2008.<br /> <br />  Syed, U., Bowling, M., and Schapire, R. E. Apprenticeship learning using linear programming. In Proceedings of the 25th international conference on Machine learning, pp. 1032–1039. ACM, 2008.<br /> <br />  Ho, J. and Ermon, S. Generative adversarial imitation learn- ing. In Advances in Neural Information Processing Sys- tems, pp. 4565–4573, 2016.<br /> <br />  Sutton, R. S. and Barto, A. G. Reinforcement learning: An introduction, volume 1. MIT press Cambridge, 1998.<br /> <br />  Kakade, S. M. A natural policy gradient. In Advances in neural information processing systems, pp. 1531–1538, 2002.<br /> <br />  Schulman, J., Levine, S., Abbeel, P., Jordan, M., and Moritz, P. Trust region policy optimization. In Proceedings of the 32nd International Conference on Machine Learning (ICML-15), pp. 1889–1897, 2015.<br /> <br />  Schulman, J., Wolski, F., Dhariwal, P., Radford, A., and Klimov, O. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.<br /> <br />  Goodfellow, I., Pouget-Abadie, J., Mirza, M., Xu, B., Warde-Farley, D., Ozair, S., Courville, A., and Bengio, Y. Generative adversarial nets. In Advances in neural information processing systems, pp. 2672–2680, 2014.<br /> <br />  Brockman, G., Cheung, V., Pettersson, L., Schneider, J., Schulman, J., Tang, J., and Zaremba, W. Openai gym, 2016.<br /> <br />  Lillicrap, T. P., Hunt, J. J., Pritzel, A., Heess, N., Erez, T., Tassa, Y., Silver, D., and Wierstra, D. Continuous control with deep reinforcement learning. arXiv preprint arXiv:1509.02971, 2015.<br /> <br />  Moore, A. W. Efficient memory-based learning for robot control. 1990.<br /> <br />  Zhu, Y., Wang, Z., Merel, J., Rusu, A., Erez, T., Cabi, S., Tunyasuvunakool, S., Kramar, J., Hadsell, R., de Freitas, N., et al. Reinforcement and imitation learning for diverse visuomotor skills. arXiv preprint arXiv:1802.09564, 2018.<br /> <br />  Li, Y., Song, J., and Ermon, S. Infogail: Interpretable imitation learning from visual demonstrations. In Advances in Neural Information Processing Systems, pp. 3815–3825, 2017.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=policy_optimization_with_demonstrations&diff=41616 policy optimization with demonstrations 2018-11-27T17:33:24Z <p>Jmmoosa: /* Policy Optimization with Demonstration (POfD) */</p> <hr /> <div>= Introduction =<br /> <br /> The reinforcement learning (RL) method has made significant progress in a variety of applications, but the exploration problems regarding how to gain more experience from novel policies to improve long-term performance are still challenges, especially in environments where reward signals are sparse and rare. There are currently two ways to solve such exploration problems in RL: <br /> <br /> 1) Guide the agent to explore states that have never been seen. <br /> <br /> 2) Guide the agent to imitate a demonstration trajectory sampled from an expert policy to learn. <br /> <br /> When guiding the agent to imitate the expert behavior for learning, there are also two methods: putting the demonstration directly into the replay memory    or using the demonstration trajectory to pre-train the policy in a supervised manner . However, neither of these methods takes full advantage of the demonstration data. They instead treat the demonstration data identically to self-generated data, requiring a tremendous number of difficult to collect examples to learn effectively. To address this problem, a novel policy optimization method from demonstration (POfD) is proposed, which takes full advantage of the demonstration and there is no need to ensure that the expert policy is the optimal policy. To summarize, the authors bring forth this idea through the following techniques:<br /> <br /> 1) A demonstration guided exploration term measuring the divergence between current and the expert policy is added to the policy optimization objective, increasing the similarity to expert-like exploration.<br /> <br /> 2) They say that for better learning from demonstrations and getting an optimization friendly lower bound, the proposed objective could be defined on an occupancy measure as in .<br /> <br /> 3) Finally, they show that the optimization can move towards optimizing the derived lower bound and the generative adversarial training.<br /> <br /> The authors also evaluate the performance of POfD on Mujoco  in sparse-reward environments. The experiments results show that the performance of POfD is greatly improved compared with some strong baselines and even to the policy gradient method in dense-reward environments.<br /> <br /> ==Intuition==<br /> The agent should imitate the demonstrated behavior when rewards are sparse and then explore new states on its own after acquiring sufficient skills, which is a dynamic intrinsic reward mechanism that can be reshaped in terms of the native rewards in RL. At present the state of the art exploration in Reinforcement learning is simply epsilon greedy which just makes random moves for a small percentage of times to explore unexplored moves. This is very naive and is one of the main reasons for the high sample complexity in RL. On the other hand, if there is an expert demonstrator who can guide exploration, the agent can make more guided and accurate exploratory moves.<br /> <br /> =Related Work =<br /> There are some related works in overcoming exploration difficulties by learning from demonstration  and imitation learning in RL.<br /> <br /> For learning from demonstration (LfD),<br /> # Most LfD methods adopt value-based RL algorithms, such as DQfD (Deep Q-learning from Demonstrations)  which are applied into the discrete action spaces and DDPGfD (Deep Deterministic Policy Gradient from Demonstrations)  which extends this idea to the continuous spaces. But both of them under-utilize the demonstration data.<br /> # There are some methods based on policy iteration  , which shapes the value function by using demonstration data. But they get the bad performance when demonstration data is imperfect.<br /> # A hybrid framework  that learns the policy in which the probability of taking demonstrated actions is maximized is proposed, which considers less demonstration data.<br /> # A reward reshaping mechanism  that encourages taking actions close to the demonstrated ones is proposed. It is similar to the method in this paper, but there exists some differences as it is defined as a potential function based on multi-variate Gaussian to model the distribution of state-actions.<br /> All of the above methods require a lot of perfect demonstrations to get satisfactory performance, which is different from POfD in this paper.<br /> <br /> For imitation learning, <br /> # Inverse Reinforce Learning  problems are solved by alternating between fitting the reward function and selecting the policy  . But it cannot be extended to big-scale problems.<br /> # Generative Adversarial Imitation Learning (GAIL)  uses a discriminator to distinguish whether a state-action pair is from the expert or the learned policy and it can be applied into the high-dimensional continuous control problems.<br /> <br /> Both of the above methods are effective for imitation learning, but cannot leverage the valuable feedback given by the environments and usually suffer from bad performance when the expert data is imperfect. That is different from POfD in this paper.<br /> <br /> There is also another idea in which an agent learns using hybrid imitation learning and reinforcement learning reward[23, 24]. However, unlike this paper, they did not provide some theoretical support for their method and only explained some intuitive explanations.<br /> <br /> =Background=<br /> <br /> ==Preliminaries==<br /> Markov Decision Process (MDP)  is defined by a tuple &lt;math&gt;⟨\mathcal{S}, \mathcal{A}, \mathcal{P}, r, \gamma⟩ &lt;/math&gt;, where &lt;math&gt;\mathcal{S}&lt;/math&gt; is the state space, &lt;math&gt;\mathcal{A} &lt;/math&gt; is the action space, &lt;math&gt;\mathcal{P}(s'|s,a)&lt;/math&gt; is the transition distribution of taking action &lt;math&gt; a &lt;/math&gt; at state &lt;math&gt;s &lt;/math&gt;, &lt;math&gt; r(s,a) &lt;/math&gt;is the reward function, and &lt;math&gt; \gamma &lt;/math&gt; is the discount factor between 0 and 1. Policy &lt;math&gt; \pi(a|s) &lt;/math&gt; is a mapping from state to action probabilities, the performance of &lt;math&gt; \pi &lt;/math&gt; is usually evaluated by its expected discounted reward &lt;math&gt; \eta(\pi) &lt;/math&gt;: <br /> $\eta(\pi)=\mathbb{E}_{\pi}[r(s,a)]=\mathbb{E}_{(s_0,a_0,s_1,...)}[\sum_{t=0}^\infty\gamma^{t}r(s_t,a_t)]$<br /> The value function is &lt;math&gt; V_{\pi}(s) =\mathbb{E}_{\pi}[r(·,·)|s_0=s] &lt;/math&gt;, the action value function is &lt;math&gt; Q_{\pi}(s,a) =\mathbb{E}_{\pi}[r(·,·)|s_0=s,a_0=a] &lt;/math&gt;, and the advantage function that reflects the expected additional reward after taking action a at state s is &lt;math&gt; A_{\pi}(s,a)=Q_{\pi}(s,a)-V_{\pi}(s)&lt;/math&gt;.<br /> Then the authors define Occupancy measure, which is used to estimate the probability that state &lt;math&gt;s&lt;/math&gt; and state action pairs &lt;math&gt;(s,a)&lt;/math&gt; when executing a certain policy.<br /> [[File:def1.png|500px|center]]<br /> Then the performance of &lt;math&gt; \pi &lt;/math&gt; can be rewritten to: <br /> [[File:equ2.png|500px|center]]<br /> At the same time, the authors propose a lemma: <br /> [[File:lemma1.png|500px|center]]<br /> <br /> ==Problem Definition==<br /> Generally, RL tasks and environments do not provide a comprehensive reward and instead rely on sparse feedback indicating whether the goal is reached.<br /> <br /> In this paper, the authors aim to develop a method that can boost exploration by leveraging effectively the demonstrations &lt;math&gt;D^E &lt;/math&gt;from the expert policy &lt;math&gt; \pi_E &lt;/math&gt; and maximize &lt;math&gt; \eta(\pi) &lt;/math&gt; in the sparse-reward environment. The authors define the demonstrations &lt;math&gt;D^E=\{\tau_1,\tau_2,...,\tau_N\} &lt;/math&gt;, where the i-th trajectory &lt;math&gt;\tau_i=\{(s_0^i,a_0^i),(s_1^i,a_1^i),...,(s_T^i,a_T^i)\} &lt;/math&gt; is generated from the unknown expert policy &lt;math&gt;\pi_E &lt;/math&gt;. In addition, there is an assumption on the quality of the expert policy:<br /> [[File:asp1.png|500px|center]]<br /> <br /> <br /> Throughout the paper, they use &lt;math&gt;\pi_E &lt;/math&gt; to denote the expert policy that gives the relatively good &lt;math&gt;\eta_\pi &lt;/math&gt;, and use &lt;math&gt;\hat{\mathbb{E}}_D &lt;/math&gt;to denote empirical expectation estimated from the demonstrated trajectories &lt;math&gt;D^E &lt;/math&gt;. We have the following reasonable and necessary assumption on the quality of the expert policy &lt;math&gt;\pi_E &lt;/math&gt;.<br /> <br /> <br /> Moreover, it is not necessary to ensure that the expert policy is advantageous over all the policies. This is because that POfD will learn a better policy than expert policy by exploring on its own in later learning stages.<br /> <br /> =Method=<br /> <br /> ==Policy Optimization with Demonstration (POfD)==<br /> <br /> Demonstrations (the blue curve) enables POfD to explore in the high-reward regions (red arrows). On the other hand random explorations (olive green dashed curves) occur in sparse-reward environments.<br /> <br /> [[File:ff1.png|500px|center]]<br /> This method optimizes the policy by forcing the policy to explore in the nearby region of the expert policy that is specified by several demonstrated trajectories &lt;math&gt;D^E &lt;/math&gt; (as shown in Fig.1) in order to avoid causing slow convergence or failure when the environment feedback is sparse. In addition, the authors encourage the policy π to explore by &quot;following&quot; the demonstrations &lt;math&gt;D^E &lt;/math&gt;. Thus, a new learning objective is given:<br /> $\mathcal{L}(\pi_{\theta})=-\eta(\pi_{\theta})+\lambda_{1}D_{JS}(\pi_{\theta},\pi_{E})$<br /> where &lt;math&gt;D_{JS}(\pi_{\theta},\pi_{E})&lt;/math&gt; is Jensen-Shannon divergence between current policy &lt;math&gt;\pi_{\theta}&lt;/math&gt; and the expert policy &lt;math&gt;\pi_{E}&lt;/math&gt; , &lt;math&gt;\lambda_1&lt;/math&gt; is a trading-off parameter, and &lt;math&gt;\theta&lt;/math&gt; is policy parameter. According to Lemma 1, the authors use &lt;math&gt;D_{JS}(\rho_{\theta},\rho_{E})&lt;/math&gt; to instead of &lt;math&gt;D_{JS}(\pi_{\theta},\pi_{E})&lt;/math&gt;, because it is easier to optimize through adversarial training on demonstrations. The learning objective is: <br /> $\mathcal{L}(\pi_{\theta})=-\eta(\pi_{\theta})+\lambda_{1}D_{JS}(\rho_{\theta},\rho_{E})$<br /> <br /> ==Benefits of Exploration with Demonstrations==<br /> The authors introduce the benefits of POfD. Firstly, we consider the expression of expected return in policy gradient methods .<br /> $\eta(\pi)=\eta(\pi_{old})+\mathbb{E}_{\tau\sim\pi}[\sum_{t=0}^\infty\gamma^{t}A_{\pi_{old}}(s,a)]$<br /> &lt;math&gt;\eta(\pi)&lt;/math&gt;is the advantage over the policy &lt;math&gt;\pi_{old}&lt;/math&gt; in the previous iteration, so the expression can be rewritten by<br /> $\eta(\pi)=\eta(\pi_{old})+\sum_{s}\rho_{\pi}(s)\sum_{a}\pi(a|s)A_{\pi_{old}}(s,a)$<br /> The local approximation to &lt;math&gt;\eta(\pi)&lt;/math&gt; up to first order is usually as the surrogate learning objective to be optimized by policy gradient methods due to the difficulties brought by complex dependency of &lt;math&gt;\rho_{\pi}(s)&lt;/math&gt; over &lt;math&gt; \pi &lt;/math&gt;:<br /> $J_{\pi_{old}}(\pi)=\eta(\pi_{old})+\sum_{s}\rho_{\pi_{old}}(s)\sum_{a}\pi(a|s)A_{\pi_{old}}(s,a)$<br /> The policy gradient methods improve &lt;math&gt;\eta(\pi)&lt;/math&gt; monotonically by optimizing the above &lt;math&gt;J_{\pi_{old}}(\pi)&lt;/math&gt; with a sufficiently small update step from &lt;math&gt;\pi_{old}&lt;/math&gt; to &lt;math&gt;\pi&lt;/math&gt; such that &lt;math&gt;D_{KL}^{max}(\pi, \pi_{old})&lt;/math&gt; is bounded   . POfD imposes an additional regularization &lt;math&gt;D_{JS}(\pi_{\theta}, \pi_{E})&lt;/math&gt; between &lt;math&gt;\pi_\theta&lt;/math&gt; and &lt;math&gt;\pi_{E}&lt;/math&gt; in order to encourage explorations around regions demonstrated by the expert policy. Theorem 1 shows such benefits,<br /> [[File:them1.png|500px|center]]<br /> <br /> In fact, POfD brings another factor, &lt;math&gt;D_{J S}^{max}(\pi_{i}, \pi_{E})&lt;/math&gt;, that would fully use the advantage &lt;math&gt;{\hat \delta}&lt;/math&gt;and add improvements with a margin over pure policy gradient methods.<br /> <br /> ==Optimization==<br /> <br /> For POfD, the authors choose to optimize the lower bound of the Jensen-Shannon divergence instead of directly optimizing the difficult Jensen-Shannon divergence. This optimization method is compatible with any policy gradient methods. Theorem 2 gives the lower bound of &lt;math&gt;D_{JS}(\rho_{\theta}, \rho_{E})&lt;/math&gt;：<br /> [[File:them2.png|450px|center]]<br /> Thus, the occupancy measure matching objective can be written as:<br /> [[File:eqnlm.png|450px|center]]<br /> where &lt;math&gt; D(s,a)=\frac{1}{1+e^{-U(s,a)}}: \mathcal{S}\times \mathcal{A} \rightarrow (0,1)&lt;/math&gt; is an arbitrary mapping function followed by a sigmoid activation function used for scaling, and its supremum ranging is like a discriminator for distinguishing whether the state-action pair is a current policy or an expert policy.<br /> To avoid overfitting, the authors add causal entropy &lt;math&gt;−H (\pi_{\theta}) &lt;/math&gt; as the regularization term. Thus, the learning objective is: <br /> $\min_{\theta}\mathcal{L}=-\eta(\pi_{\theta})-\lambda_{2}H(\pi_{\theta})+\lambda_{1} \sup_{{D\in(0,1)}^{S\times A}} \mathbb{E}_{\pi_{\theta}}[\log(D(s,a))]+\mathbb{E}_{\pi_{E}}[\log(1-D(s,a))]$<br /> At this point, the problem closely resembles the minimax problem related to the Generative Adversarial Networks (GANs) . The difference is that the discriminative model D of GANs is well-trained but the expert policy of POfD is not optimal. Then suppose D is parameterized by w. If it is from an expert policy, &lt;math&gt;D_w&lt;/math&gt;is toward 1, otherwise it is toward 0. Thus, the minimax learning objective is:<br /> $\min_{\theta}\max_{w}\mathcal{L}=-\eta(\pi_{\theta})-\lambda_{2}H (\pi_{\theta})+\lambda_{1}( \mathbb{E}_{\pi_{\theta}}[\log(D_{w}(s,a))]+\mathbb{E}_{\pi_{E}}[\log(1-D_{w}(s,a))])$<br /> The minimax learning objective can be rewritten by substituting the expression of &lt;math&gt; \eta(\pi) &lt;/math&gt;:<br /> $\min_{\theta}\max_{w}-\mathbb{E}_{\pi_{\theta}}[r'(s,a)]-\lambda_{2}H (\pi_{\theta})+\lambda_{1}\mathbb{E}_{\pi_{E}}[\log(1-D_{w}(s,a))]$<br /> where &lt;math&gt; r'(s,a)=r(a,b)-\lambda_{1}\log(D_{w}(s,a))&lt;/math&gt; is the reshaped reward function.<br /> The above objective can be optimized efficiently by alternately updating policy parameters θ and discriminator parameters w, then the gradient is given by:<br /> $\mathbb{E}_{\pi}[\nabla_{w}\log(D_{w}(s,a))]+\mathbb{E}_{\pi_{E}}[\nabla_{w}\log(1-D_{w}(s,a))]$<br /> Then, fixing the discriminator &lt;math&gt;D_w&lt;/math&gt;, the reshaped policy gradient is:<br /> $\nabla_{\theta}\mathbb{E}_{\pi_{\theta}}[r'(s,a)]=\mathbb{E}_{\pi_{\theta}}[\nabla_{\theta}\log\pi_{\theta}(a|s)Q'(s,a)]$<br /> where &lt;math&gt;Q'(\bar{s},\bar{a})=\mathbb{E}_{\pi_{\theta}}[r'(s,a)|s_0=\bar{s},a_0=\bar{a}]&lt;/math&gt;.<br /> <br /> At the end, Algorithm 1 gives the detailed process.<br /> [[File:pofd.png|450px|center]]<br /> <br /> =Discussion on Existing LfD Methods=<br /> <br /> ==DQFD==<br /> DQFD  puts the demonstrations into a replay memory D and keeps them throughout the Q-learning process. The objective for DQFD is:<br /> $J_{DQfD}={\hat{\mathbb{E}}}_{D}[(R_t(n)-Q_w(s_t,a_t))^2]+\alpha{\hat{\mathbb{E}}}_{D^E}[(R_t(n)-Q_w(s_t,a_t))^2]$<br /> The second term can be rewritten as &lt;math&gt; {\hat{\mathbb{E}}}_{D^E}[(R_t(n)-Q_w(s_t,a_t))^2]={\hat{\mathbb{E}}}_{D^E}[(\hat{\rho}_E(s,a)-\rho_{\pi}(s,a))^{2}r^2(s,a)]&lt;/math&gt;, which can be regarded as a regularization forcing current policy's occupancy measure to match the expert's empirical occupancy measure, weighted by the potential reward.<br /> <br /> ==DDPGfD==<br /> DDPGfD  also puts the demonstrations into a replay memory D, but it is based on an actor-critic framework . The objective for DDPGfD is the same as DQFD. Its policy gradient is:<br /> $\nabla_{\theta}J_{DDPGfD}\approx \mathbb{E}_{s,a}[\nabla_{a}Q_w(s,a)\nabla_{\theta}\pi_{\theta}(s)], a=\pi_{\theta}(s)$<br /> From this equation, policy is updated relying on learned Q-network &lt;math&gt;Q_w &lt;/math&gt;rather than the demonstrations &lt;math&gt;D^{E} &lt;/math&gt;. DDPGfD shares the same objective function for &lt;math&gt;Q_w &lt;/math&gt; as DQfD, thus they have the same way of leveraging demonstrations, that is the demonstrations in DQfD and DDPGfD induce an occupancy measure matching regularization.<br /> <br /> =Experiments=<br /> <br /> ==Goal==<br /> The authors aim at investigating 1) whether POfD can aid exploration by leveraging a few demonstrations, even though the demonstrations are imperfect. 2) whether POfD can succeed and achieve high empirical return, especially in environments where reward signals are sparse and rare. <br /> <br /> ==Settings==<br /> The authors conduct the experiments on 8 physical control tasks, ranging from low-dimensional spaces to high-dimensional spaces and naturally sparse environments based on OpenAI Gym  and Mujoco (Multi-Joint dynamics with Contact)  (Gym is a toolkit for developing and comparing reinforcement learning algorithms. It supports teaching agents everything from walking to playing games like Pong or Pinball. MuJoCo is a physics engine aiming to facilitate research and development in robotics, biomechanics, graphics and animation, and other areas where fast and accurate simulation is needed. In order to get familiar with OpenAI Gym and Mujoco environment, you can watch these videos, respectively: [http://www.mujoco.org/image/home/mujocodemo.mp4 Mujoco], [https://gym.openai.com/v2018-02-21/videos/SpaceInvaders-v0-4184afb3-1223-4ac6-b52b-8e863cbe24a5/original.mp4 OpenAI Gym]). Due to the uniqueness of the environments, the authors introduce 4 ways to sparsify their built-in dense rewards. TYPE1: a reward of +1 is given when the agent reaches the terminal state, and otherwisel 0. TYPE2: a reward of +1 is given when the agent survives for a while. TYPE3: a reward of +1 is given for every time the agent moves forward over a specific number of units in Mujoco environments. TYPE4: specially designed for InvertedDoublePendulum, a reward +1 is given when the second pole stays above a specific height of 0.89. The details are shown in Table 1. Moreover, only one single imperfect trajectory is used as the demonstrations in this paper. The authors collect the demonstrations by training an agent insufficiently by running TRPO (Trust Region Policy Optimization) in the corresponding dense environment. <br /> [[File:pofdt1.png|900px|center]]<br /> <br /> ==Baselines==<br /> The authors compare POfD against 5 strong baselines:<br /> * training the policy with TRPO  in dense environments, which is called expert <br /> * training the policy with TRPO  in sparse environments<br /> * applying GAIL  to learn the policy from demonstrations<br /> * DQfD <br /> * DDPGfD <br /> <br /> ==Results==<br /> Firstly, the authors test the performance of POfD in sparse control environments with discrete actions. From Table 1, POfD achieves performance comparable with the policy learned under dense environments. From Figure 2, only POfD successes to explore sufficiently and achieves great performance in both sparse environments. TRPO  and DQFD  fail to explore and GAIL  converges to the imperfect demonstration in MountainCar .<br /> <br /> [[File:pofdf2.png|500px|center]]<br /> <br /> Then, the authors test the performance of POfD under spares environments with continuous actions space. From Figure 3, POfD achieves expert-level performance in terms of accumulated rewards and surpasses other strong baselines training the policy with TRPO. By watching the learning process of different methods, we can see that TRPO consistently fails to explore the environments when the feedback is sparse, except for HalfCheetah. This may be because there is no terminal state in HalfCheetah, thus a random agent can perform reasonably well as long as the time horizon is sufficiently long. This is shown in Figure3 where the improvement of TRPO begins to show after 400 iterations. DDPGfD and GAIL have common drawback: during training process, they both converge to the imperfect demonstration data. For HalfCheetah, GAIL fails to converge and DDPGfD converges to an even worse point. This situation is expected because the policy and value networks tend to over-fit when having few data, so the training process of GAIL and DDPGfD is severely biased by the imperfect data. Finally, our proposed method can effectively explore the environment with the help of demonstration-based intrinsic reward reshaping, and succeeds consistently across different tasks both in terms of learning stability and convergence speed.<br /> [[File:pofdf3.png|900px|center]]<br /> <br /> The authors also implement a locomotion task &lt;math&gt;Humanoid&lt;/math&gt;, which teaches a human-like robot to walk. The state space of dimension is 376, which is very hard to render. As a result, POfD still outperformed all three baselike methods, as they failed to learn policies in such a sparse reward environment.<br /> <br /> The reacher environment is a task that the target is to control a robot arm to touch an object. the location of the object is random for each instantiation. The environment reward is sparse: every time the arm reaches the ball and holds for a while (e.g., 5 time steps), it receives a reward of +1; otherwise it gets zero reward. The authors select 15 random trajectories as demonstration data, and the performance of POfD is much better than the expert, while all other baseline methods failed.<br /> <br /> =Conclusion=<br /> In this paper, a method, POfD, is proposed that can acquire knowledge from a limited amount of imperfect demonstration data to aid exploration in environments with sparse feedback. It is compatible with any policy gradient methods. POfD induces implicit dynamic reward shaping and brings provable benefits for policy improvement. Moreover, the experiments results have shown the validity and effectivness of POfD in encouraging the agent to explore around the nearby region of the expert policy and learn better policies. The key contribution is that POfD helps the agent work with few and imperfect demonstrations in an environment with sparse rewards.<br /> <br /> =Critique=<br /> # A novel demonstration-based policy optimization method is proposed. In the process of policy optimization, POfD reshapes the reward function. This new reward function can guide the agent to imitate the expert behaviour when the reward is sparse and explore on its own when the reward value can be obtained, which can take full advantage of the demonstration data and there is no need to ensure that the expert policy is the optimal policy.<br /> # POfD can be combined with any policy gradient methods. Its performance surpasses five strong baselines and can be comparable to the agents trained in the dense-reward environment.<br /> # The paper is structured and the flow of ideas is easy to follow. For related work, the authors clearly explain similarities and differences among these related works.<br /> # This paper's scalability is demonstrated. The experiments environments are ranging from low-dimensional spaces to high-dimensional spaces and from discrete action spaces to continuous actions spaces. For future work, can it be realized in the real world?<br /> # There is a doubt that whether it is a correct method to use the trajectory that was insufficiently learned in dense-reward environment as the imperfect demonstration.<br /> # In this paper, the performance only is judged by the cumulative reward, can other evaluation terms be considered? For example, the convergence rate.<br /> # The performance of this algorithm hinges on the assumption that expert demonstrations are near optimal in the action space. As seen in figure 3, there appears to be an upper bound to performance near (or just above) the expert accuracy -- this may be an indication of a performance ceiling. In games where near-optimal policies can differ greatly (e.g.; offensive or defensive strategies in chess), the success of the model will depend on the selection of expert demonstrations that are closest to a truly optimal policy (i.e.; just because a policy is the current expert, it does not mean it resembles the true optimal policy).<br /> <br /> =References=<br />  Nair, A., McGrew, B., Andrychowicz, M., Zaremba, W., and Abbeel, P. Overcoming exploration in reinforcement learning with demonstrations. arXiv preprint arXiv:1709.10089, 2017.<br /> <br />  Hester, T., Vecerik, M., Pietquin, O., Lanctot, M., Schaul, T., Piot, B., Sendonaris, A., Dulac-Arnold, G., Osband, I., Agapiou, J., et al. Learning from demonstrations for real world reinforcement learning. arXiv preprint arXiv:1704.03732, 2017.<br /> <br />  Večerík, M., Hester, T., Scholz, J., Wang, F., Pietquin, O., Piot, B., Heess, N., Rotho ̈rl, T., Lampe, T., and Riedmiller, M. Leveraging demonstrations for deep reinforcement learning on robotics problems with sparse rewards. arXiv preprint arXiv:1707.08817, 2017.<br /> <br />  Silver, D., Huang, A., Maddison, C. J., Guez, A., Sifre, L., Van Den Driessche, G., Schrittwieser, J., Antonoglou, I., Panneershelvam, V., Lanctot, M., et al. Mastering the game of go with deep neural networks and tree search. nature, 529(7587):484–489, 2016.<br /> <br />  Todorov, E., Erez, T., and Tassa, Y. Mujoco: A physics engine for model-based control. In Intelligent Robots and Systems (IROS), 2012 IEEE/RSJ International Con- ference on, pp. 5026–5033. IEEE, 2012.<br /> <br />  Schaal, S. Learning from demonstration. In Advances in neural information processing systems, pp. 1040–1046, 1997.<br /> <br />  Kim, B., Farahmand, A.-m., Pineau, J., and Precup, D. Learning from limited demonstrations. In Advances in Neural Information Processing Systems, pp. 2859–2867, 2013.<br /> <br />  Piot, B., Geist, M., and Pietquin, O. Boosted bellman resid- ual minimization handling expert demonstrations. In Joint European Conference on Machine Learning and Knowl- edge Discovery in Databases, pp. 549–564. Springer, 2014.<br /> <br />  Aravind S. Lakshminarayanan, Sherjil Ozair, Y. B. Rein- forcement learning with few expert demonstrations. In NIPS workshop, 2016.<br /> <br />  Brys, T., Harutyunyan, A., Suay, H. B., Chernova, S., Tay- lor, M. E., and Nowe ́, A. Reinforcement learning from demonstration through shaping. In IJCAI, pp. 3352–3358, 2015.<br /> <br />  Ng, A. Y., Russell, S. J., et al. Algorithms for inverse reinforcement learning. In Icml, pp. 663–670, 2000.<br /> <br />  Syed, U. and Schapire, R. E. A game-theoretic approach to apprenticeship learning. In Advances in neural informa- tion processing systems, pp. 1449–1456, 2008.<br /> <br />  Syed, U., Bowling, M., and Schapire, R. E. Apprenticeship learning using linear programming. In Proceedings of the 25th international conference on Machine learning, pp. 1032–1039. ACM, 2008.<br /> <br />  Ho, J. and Ermon, S. Generative adversarial imitation learn- ing. In Advances in Neural Information Processing Sys- tems, pp. 4565–4573, 2016.<br /> <br />  Sutton, R. S. and Barto, A. G. Reinforcement learning: An introduction, volume 1. MIT press Cambridge, 1998.<br /> <br />  Kakade, S. M. A natural policy gradient. In Advances in neural information processing systems, pp. 1531–1538, 2002.<br /> <br />  Schulman, J., Levine, S., Abbeel, P., Jordan, M., and Moritz, P. Trust region policy optimization. In Proceedings of the 32nd International Conference on Machine Learning (ICML-15), pp. 1889–1897, 2015.<br /> <br />  Schulman, J., Wolski, F., Dhariwal, P., Radford, A., and Klimov, O. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.<br /> <br />  Goodfellow, I., Pouget-Abadie, J., Mirza, M., Xu, B., Warde-Farley, D., Ozair, S., Courville, A., and Bengio, Y. Generative adversarial nets. In Advances in neural information processing systems, pp. 2672–2680, 2014.<br /> <br />  Brockman, G., Cheung, V., Pettersson, L., Schneider, J., Schulman, J., Tang, J., and Zaremba, W. Openai gym, 2016.<br /> <br />  Lillicrap, T. P., Hunt, J. J., Pritzel, A., Heess, N., Erez, T., Tassa, Y., Silver, D., and Wierstra, D. Continuous control with deep reinforcement learning. arXiv preprint arXiv:1509.02971, 2015.<br /> <br />  Moore, A. W. Efficient memory-based learning for robot control. 1990.<br /> <br />  Zhu, Y., Wang, Z., Merel, J., Rusu, A., Erez, T., Cabi, S., Tunyasuvunakool, S., Kramar, J., Hadsell, R., de Freitas, N., et al. Reinforcement and imitation learning for diverse visuomotor skills. arXiv preprint arXiv:1802.09564, 2018.<br /> <br />  Li, Y., Song, J., and Ermon, S. Infogail: Interpretable imitation learning from visual demonstrations. In Advances in Neural Information Processing Systems, pp. 3815–3825, 2017.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=Visual_Reinforcement_Learning_with_Imagined_Goals&diff=41612 Visual Reinforcement Learning with Imagined Goals 2018-11-27T17:27:45Z <p>Jmmoosa: /* Experiments */</p> <hr /> <div>Video and details of this work are available [https://sites.google.com/site/visualrlwithimaginedgoals/ here]<br /> <br /> =Introduction and Motivation=<br /> <br /> Humans are able to accomplish many tasks without any explicit or supervised training, simply by exploring their environment. We are able to set our own goals and learn from our experiences, and thus able to accomplish specific tasks without ever having been trained explicitly for them. It would be ideal if an autonomous agent can also set its own goals and learn from its environment.<br /> <br /> In the paper “Visual Reinforcement Learning with Imagined Goals”, the authors are able to devise such an unsupervised reinforcement learning system. They introduce a system that sets abstract (self-generated) goals and autonomously learns to achieve those goals. They then show that the system can use these autonomously learned skills to perform a variety of user-specified goals, such as pushing objects, grasping objects, and opening doors, without any additional learning. Lastly, they demonstrate that their method is efficient enough to work in the real world on a Sawyer robot. The robot learns to set and achieve goals with only images as the input to the system.<br /> <br /> The algorithm proposed by the authors is summarized below. A Variational Auto Encoder (VAE) on the (left) learns a latent representation of images gathered during training time (center). These latent variables are used to train a policy on imagined goals (center), which can then be used for accomplishing user-specified goals (right).<br /> <br /> [[File: WF_Sec_11Nov25_01.png |center| 800px]]<br /> <br /> =Related Work =<br /> <br /> Many previous works on vision-based deep reinforcement learning for robotics studied a variety of behaviours such as grasping , pushing , navigation , and other manipulation tasks . However, their assumptions on the models limit their suitability for training general-purpose robots. Some previous works such as Levine et al.  proposed time-varying models which require episodic setups. There are also other works such as Pinto et al.  that proposed an approach using goal images, but it requires instrumented training simulations. Lillicrap et al.  uses fully model-free training (Model-based RL uses experience to construct an internal model of the transitions and<br /> immediate outcomes in the environment. Appropriate actions are then chosen by searching or planning in this world model. Model-free RL, on the other hand, uses experience to learn directly one or both of two simpler quantities (state/action values or policies) which can achieve the same optimal behavior but without estimation or use of a world model. Given a policy, a state has a value, defined in terms of the future utility that is expected to accrue starting from that state [https://www.princeton.edu/~yael/Publications/DayanNiv2008.pdf Reinforcement learning: The Good, The Bad and The Ugly].), but does not learn goal-conditioned skills. There are currently no examples that use model-free reinforcement learning for learning policies to train on real-world robotic systems without having ground-truth information.<br /> <br /> In this paper, the authors utilize a goal-conditioned value function to tackle more general tasks through goal relabelling, which improves sample efficiency. Goal relabelling is to retroactively relabel samples in the replay buffer with goals sampled from the latent representation. The paper uses sample random goals from learned latent space to use as replay goals for off-policy Q-learning rather than restricting to states seen along the sampled trajectory as was done in the earlier works. Specifically, they use a model-free Q-learning method that operates on raw state observations and actions. This approach allows for a single transition tuple to be converted into potentially infinite valid training examples. <br /> <br /> Unsupervised learning has been used in a number of prior works to acquire better representations of reinforcement learning. In these methods, the learned representation is used as a substitute for the state for the policy. However, these methods require additional information, such as access to the ground truth reward function based on the true state during training time , expert trajectories , human demonstrations , or pre-trained object-detection features . In contrast, the authors learn to generate goals and use the learned representation to get a reward function for those goals without any of these extra sources of supervision.<br /> <br /> =Goal-Conditioned Reinforcement Learning=<br /> <br /> The ultimate goal in reinforcement learning is to learn a policy &lt;math&gt;\pi&lt;/math&gt;, that when given a state &lt;math&gt;s_t&lt;/math&gt; and goal &lt;math&gt;g&lt;/math&gt; (desired state), can dictate the optimal action &lt;math&gt;a_t&lt;/math&gt;. The optimal action &lt;math&gt;a_t&lt;/math&gt; is defined as an action which maximizes the expected return denoted by &lt;math&gt;R_t&lt;/math&gt; and defined as &lt;math&gt;R_t = \mathbb{E}[\sum_{i = t}^T\gamma^{(i-t)}r_i]&lt;/math&gt;, where &lt;math&gt;r_i = r(s_i, a_i, s_{i+1})&lt;/math&gt; is the reward for performing action &lt;math&gt;a_i&lt;/math&gt; when the current state is &lt;math&gt;s_i&lt;/math&gt; and the goal state is &lt;math&gt;s_{i+1}&lt;/math&gt; and &lt;math&gt;\gamma&lt;/math&gt; is a discount factor which determines the relative importance given to rewards at different times. <br /> <br /> In this paper, goals are not explicitly defined during training. If a goal is not explicitly defined, the agent must be able to generate a set of synthetic goals automatically. Suppose we let an autonomous agent explore an environment with a random policy. After executing each action, start and stop state observations are collected and stored. All state observations are images. For training, the agent can randomly select starting states and goals images from the set of state observations.<br /> <br /> Now given a set of all possible states, a goal, and an initial state, a reinforcement learning framework can be used to find the optimal policy such that a chosen value function is maximized. However, to implement such a framework, a reward function needs to be defined. One choice for the reward is the negative distance between the current state and the goal state, so that maximizing the reward corresponds to minimizing the distance to the goal state.<br /> <br /> [[File:human-giving-goal.png|center|thumb|400px|The task: Make the world look like this image. ]]<br /> <br /> In reinforcement learning, a goal-conditioned Q-function can be used to find a single policy to maximize rewards and therefore reach goal states. A goal-conditioned Q-function &lt;math&gt;Q(s,a,g)&lt;/math&gt; tells us how good an action &lt;math&gt;a&lt;/math&gt; is, given the current state &lt;math&gt;s&lt;/math&gt; and goal &lt;math&gt;g&lt;/math&gt;. For example, a Q-function tells us, “How good is it to move my hand up (action &lt;math&gt;a&lt;/math&gt;), if I’m holding a plate (state &lt;math&gt;s&lt;/math&gt;) and want to put the plate on the table (goal &lt;math&gt;g&lt;/math&gt;)?” Once this Q-function is trained, a goal-conditioned policy can be obtained by performing the following optimization<br /> <br /> &lt;div align=&quot;center&quot;&gt;<br /> &lt;math&gt;\pi(s,g) = max_a Q(s,a,g)&lt;/math&gt;<br /> &lt;/div&gt;<br /> <br /> which effectively says, “choose the best action according to this Q-function.” By using this procedure, one can obtain a policy that maximizes the sum of rewards, i.e. reaches various goals.<br /> <br /> The reason why Q-learning is popular is that it can be trained in an off-policy manner. Therefore, the only things a Q-function needs are samples of state, action, next state, goal, and reward &lt;math&gt;(s,a,s′,g,r)&lt;/math&gt;. This data can be collected by any policy and can be reused across multiples tasks. So a preliminary goal-conditioned Q-learning algorithm looks like this:<br /> <br /> [[File:ql.png|center|600px]]<br /> <br /> From the tuple &lt;math&gt;(s,a,s',g,r)&lt;/math&gt;, an approximate Q-function paramaterized by &lt;math&gt;w&lt;/math&gt; can be trained by minimizing the Bellman error:<br /> <br /> &lt;div align=&quot;center&quot;&gt;<br /> &lt;math&gt;\mathcal{E}(w) = \frac{1}{2} || Q_w(s,a,g) -(r + \gamma \max_{a'} Q_{\overline{w}}(s',a',g)) ||^2 &lt;/math&gt;<br /> &lt;/div&gt;<br /> <br /> where &lt;math&gt;\overline{w}&lt;/math&gt; is treated as some constant.<br /> <br /> The main drawback in this training procedure is collecting data. In theory, one could learn to solve various tasks without even interacting with the world if more data are available. Unfortunately, it is difficult to learn an accurate model of the world, so sampling is usually performed to get state-action-next-state data, (s,a,s′). However, if the reward function &lt;math&gt;r(s,g)&lt;/math&gt; can be accessed, one can retroactively relabel goals and recompute rewards. This way, more data can be artificially generated given a single &lt;math&gt;(s,a,s′)&lt;/math&gt; tuple. As a result, the training procedure can be modified like so:<br /> <br /> [[File:qlr.png|center|600px]]<br /> <br /> This goal resampling makes it possible to simultaneously learn how to reach multiple goals at once without needing more data from the environment. Thus, this simple modification can result in substantially faster learning. However, the method described above makes two major assumptions: (1) you have access to a reward function and (2) you have access to a goal sampling distribution &lt;math&gt;p(g)&lt;/math&gt;. When moving to vision-based tasks where goals are images, both of these assumptions introduce practical concerns.<br /> <br /> For one, a fundamental problem with this reward function is that it assumes that the distance between raw images will yield semantically useful information. But images are noisy and a large amount of information in an image may not be related to the object we analyze. Thus, the distance between two images may not correlate with their semantic distance.<br /> <br /> Second, because the goals are images, a goal image distribution &lt;math&gt;p(g)&lt;/math&gt; is needed so that one can sample goal images. Manually designing a distribution over goal images is a non-trivial task and image generation is still an active field of research. It would be ideal if the agent can autonomously imagine its own goals and learn how to reach them.<br /> <br /> =Variational Autoencoder=<br /> An autoencoder is a type of machine learning model that can learn to extract a robust, space-efficient feature vector from an image. This generative model converts high-dimensional observations &lt;math&gt;x&lt;/math&gt;, like images, into low-dimensional latent variables &lt;math&gt;z&lt;/math&gt;, and vice versa. The model is trained so that the latent variables capture the underlying factors of variation in an image. A current image &lt;math&gt;x&lt;/math&gt; and goal image &lt;math&gt;x_g&lt;/math&gt; can be converted into latent variables &lt;math&gt;z&lt;/math&gt; and &lt;math&gt;z_g&lt;/math&gt;, respectively. These latent variables can then be used to represent the state and goal for the reinforcement learning algorithm. Learning Q functions and policies on top of this low-dimensional latent space rather than directly on images results in faster learning.<br /> <br /> [[File:robot-interpreting-scene.png|center|thumb|600px|The agent encodes the current image (&lt;math&gt;x&lt;/math&gt;) and goal image (&lt;math&gt;x_g&lt;/math&gt;) into a latent space and use distances in that latent space for reward. ]]<br /> <br /> Using the latent variable representations for the images and goals also solves the problem of computing rewards. Instead of using pixel-wise error as our reward, the distance in the latent space is used as the reward to train the agent to reach a goal. The paper shows that this corresponds to rewarding reaching states that maximize the probability of the latent goal &lt;math&gt;z_g&lt;/math&gt;.<br /> <br /> This generative model is also important because it allows an agent to easily generate goals in the latent space. In particular, the authors design the generative model so that latent variables are sampled from the VAE prior. This sampling mechanism is used for two reasons: First, it provides a mechanism for an agent to set its own goals. The agent simply samples a value for the latent variable from the generative model, and tries to reach that latent goal. Second, this resampling mechanism is also used to relabel goals as mentioned above. Since the VAE prior is trained by real images, meaningful latent goals can be sampled from the latent variable prior. This will help the agent set its own goals and practice towards them if no goal is provided at test time.<br /> <br /> [[File:robot-imagining-goals.png|center|thumb|600px|Even without a human providing a goal, our agent can still generate its own goals, both for exploration and for goal relabeling. ]]<br /> <br /> The authors summarize the purpose of the latent variable representation of images as follows: (1) captures the underlying factors of a scene, (2) provides meaningful distances to optimize, and (3) provides an efficient goal sampling mechanism which can be used by the agent to generate its own goals. The overall method is called reinforcement learning with imagined goals (RIG) by the authors.<br /> The process involves starts with collecting data through a simple exploration policy. Possible alternative explorations could be employed here including off-the-shelf exploration bonuses or unsupervised reinforcement learning methods. Then, a VAE latent variable model is trained on state observations and fine-tuned during training. The latent variable model is used for multiple purposes: sampling a latent goal &lt;math&gt;z_g&lt;/math&gt; from the model and conditioning the policy on this goal. All states and goals are embedded using the model’s encoder and then used to train the goal-conditioned value function. The authors then resample goals from the prior and compute rewards in the latent space.<br /> <br /> =Algorithm=<br /> [[File:algorithm1.png|center|thumb|600px|]]<br /> <br /> Algorithm 1 is called reinforcement learning with imagined goals (RIG). The data is first collected via a simple exploration policy. The proposed model allows for alternate exploration policies to be used which include off-the-shelf exploration bonuses or unsupervised reinforcement learning methods. Then, the authors train a VAE latent variable model on state observations and finetune it over the course of training. VAE latent space modeling is used to allow the conditioning of policy on the goal which is sampled from the latent model. The VAE model is also used to encode all the goals and the states. When the goal-conditioned value function is trained, the authors resample prior goals and compute rewards in the latent space using the equation &lt;math display=&quot;inline&quot;&gt; r(s, g) = - || z - z_g ||_A \propto \sqrt{log(e_{\Phi}(z_g | s))} &lt;/math&gt;<br /> <br /> =Experiments=<br /> <br /> The authors evaluated their method against some prior algorithms and ablated versions of their approach on a suite of simulated and real-world tasks: Visual Reacher, Visual Pusher, and Visual Multi-Object Pusher. They compared their model with the following prior works: L&amp;R, DSAE, HER, and Oracle. It is concluded that their approach substantially outperforms the previous methods and is close to the state-based &quot;oracle&quot; method in terms of efficiency and performance.<br /> <br /> The figure below shows the performance of different algorithms on this task. This involved a simulated environment with a Sawyer arm. The authors' algorithm was given only visual input, and the available controls were end-effector velocity. The plots show the distance to the goal state as a function of simulation steps. The oracle, as a baseline, was given true object location information, as opposed to visual pixel information.<br /> <br /> [[File:WF_Sec_11Nov_25_02.png|1000px]]<br /> <br /> <br /> They then investigated the effectiveness of distances in the VAE latent space for the Visual Pusher task. They observed that latent distance significantly outperforms the log probability and pixel mean-squared error. The resampling strategies are also varied while fixing other components of the algorithm to study the effect of relabeling strategy. In this experiment, the RIG, which is an equal mixture of the VAE and Future sampling strategies, performs best. Subsequently, learning with variable numbers of objects was studied by evaluating on a task where the environment, based on the Visual Multi-Object Pusher, randomly contains zero, one, or two objects during testing. The results show that their model can tackle this task successfully.<br /> <br /> Finally, the authors tested the RIG in a real-world robot for its ability to reach user-specified positions and push objects to desired locations, as indicated by a goal image. The robot is trained with access only to 84x84 RGB images and without access to joint angles or object positions. The robot first learns by settings its own goals in the latent space and autonomously practices reaching different positions without human involvement. After a reasonable amount of time of training, the robot is given a goal image. Because the robot has practiced reaching so many goals, it is able to reach this goal without additional training:<br /> <br /> [[File:reaching.JPG|center|thumb|600px|(Left) The robot setup is pictured. (Right) Test rollouts of the learned policy.]]<br /> <br /> The method for reaching only needs 10,000 samples and an hour of real-world interactions.<br /> <br /> They also used RIG to train a policy to push objects to target locations:<br /> <br /> [[File:pushing.JPG|center|thumb|600px|The robot pushing setup is<br /> pictured, with frames from test rollouts of the learned policy.]]<br /> <br /> The pushing task is more complicated and the method requires about 25,000 samples. Since the authors do not have the true position during training, so they used test episode returns as the VAE latent distance reward. As learning proceeds, RIG makes steady progress at optimizing the latent distance.<br /> <br /> =Conclusion &amp; Future Work=<br /> <br /> In this paper, a new RL algorithm is proposed to efficiently solve goal-conditioned, vision-based tasks without any ground truth state information or reward functions. The author suggests that one could instead use other representations, such as language and demonstrations, to specify goals. Also, while the paper provides a mechanism to sample goals for autonomous exploration, one can combine the proposed method with existing work by choosing these goals in a more principled way, i.e. a procedure that is not only goal-oriented, but also information seeking or uncertainty aware, to perform even better exploration. Furthermore, combining the idea of this paper with methods from multitask learning and meta-learning is a promising path to create general-purpose agents that can continuously and efficiently acquire skill. Lastly, there are a variety of robot tasks whose state representation would be difficult to capture with sensors, such as manipulating deformable objects or handling scenes with variable number of objects. It is interesting to see whether the RIG can be scaled up to solve these tasks. A new paper  was published last week that built on the framework of goal conditioned Reinforcement Learning to extract state representations based on the actions required to reach them, which is abbreviated ARC for actionable representation for control.<br /> <br /> =Critique=<br /> 1. This paper is novel because it uses visual data and trains in an unsupervised fashion. The algorithm has no access to a ground truth state or to a pre-defined reward function. It can perform well in a real-world environment with no explicit programming.<br /> <br /> 2. From the videos, one major concern is that the output of robotic arm's position is not stable during training and test time. It is likely that the encoder reduces the image features too much so that the images in the latent space are too blury to be used goal images. It would be better if this can be investigated in future. It would be better, if a method is investigated with multiple data sources, and the agent is trained to choose the source which has more complete information. <br /> <br /> 3. The algorithm seems to perform better when there is only one object in the images. For example, in Visual Multi-Object Pusher experiment, the relative positions of two pucks do not correspond well with the relative positions of two pucks in goal images. The same situation is also observed in Variable-object experiment. We may guess that the more information contained in an image, the less likely the robot will perform well. This limits the applicability of the current algorithm to solving real-world problems.<br /> <br /> 4. The instability mentioned in #2 is even more apparent in the multi-object scenario, and appears to result from the model attempting to optimize on the position of both objects at the same time. Reducing the problem to a sequence of single-object targets may reduce the amount of time the robots spends moving between the multiple objects in the scene (which it currently does quite frequently).<br /> <br /> =References=<br /> 1. Lerrel Pinto, Marcin Andrychowicz, Peter Welinder, Wojciech Zaremba, and Pieter Abbeel. Asymmetric<br /> Actor Critic for Image-Based Robot Learning. arXiv preprint arXiv:1710.06542, 2017.<br /> <br /> 2. Pulkit Agrawal, Ashvin Nair, Pieter Abbeel, Jitendra Malik, and Sergey Levine. Learning to Poke by<br /> Poking: Experiential Learning of Intuitive Physics. In Advances in Neural Information Processing Systems<br /> (NIPS), 2016.<br /> <br /> 3. Deepak Pathak, Parsa Mahmoudieh, Guanghao Luo, Pulkit Agrawal, Dian Chen, Yide Shentu, Evan<br /> Shelhamer, Jitendra Malik, Alexei A Efros, and Trevor Darrell. Zero-Shot Visual Imitation. In International<br /> Conference on Learning Representations (ICLR), 2018.<br /> <br /> 4. Timothy P Lillicrap, Jonathan J Hunt, Alexander Pritzel, Nicolas Heess, Tom Erez, Yuval Tassa, David<br /> Silver, and Daan Wierstra. Continuous control with deep reinforcement learning. In International<br /> Conference on Learning Representations (ICLR), 2016.<br /> <br /> 5. Irina Higgins, Arka Pal, Andrei A Rusu, Loic Matthey, Christopher P Burgess, Alexander Pritzel, Matthew<br /> Botvinick, Charles Blundell, and Alexander Lerchner. Darla: Improving zero-shot transfer in reinforcement<br /> learning. International Conference on Machine Learning (ICML), 2017.<br /> <br /> 6. Aravind Srinivas, Allan Jabri, Pieter Abbeel, Sergey Levine, and Chelsea Finn. Universal Planning<br /> Networks. In International Conference on Machine Learning (ICML), 2018.<br /> <br /> 7. Pierre Sermanet, Corey Lynch, Yevgen Chebotar, Jasmine Hsu, Eric Jang, Stefan Schaal, and Sergey<br /> Levine. Time-contrastive networks: Self-supervised learning from video. arXiv preprint arXiv:1704.06888,<br /> 2017.<br /> <br /> 8. Alex Lee, Sergey Levine, and Pieter Abbeel. Learning Visual Servoing with Deep Features and Fitted<br /> Q-Iteration. In International Conference on Learning Representations (ICLR), 2017.<br /> <br /> 9. Online source: https://bair.berkeley.edu/blog/2018/09/06/rig/<br /> <br /> 10. https://arxiv.org/pdf/1811.07819.pdf<br /> <br /> 11. Sergey Levine, Chelsea Finn, Trevor Darrell, and Pieter Abbeel. End-to-End Training of Deep Visuomotor Policies. Journal of Machine Learning Research (JMLR), 17(1):1334–1373, 2016. ISSN 15337928.<br /> <br /> 12. Lerrel Pinto, Marcin Andrychowicz, Peter Welinder, Wojciech Zaremba, and Pieter Abbeel. Asymmetric Actor Critic for Image-Based Robot Learning. arXiv preprint arXiv:1710.06542, 2017.<br /> <br /> 13. Timothy P Lillicrap, Jonathan J Hunt, Alexander Pritzel, Nicolas Heess, Tom Erez, Yuval Tassa, David Silver, and Daan Wierstra. Continuous control with deep reinforcement learning. In International Conference on Learning Representations (ICLR), 2016.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=Visual_Reinforcement_Learning_with_Imagined_Goals&diff=41600 Visual Reinforcement Learning with Imagined Goals 2018-11-27T17:17:37Z <p>Jmmoosa: /* Conclusion &amp; Future Work */</p> <hr /> <div>Video and details of this work are available [https://sites.google.com/site/visualrlwithimaginedgoals/ here]<br /> <br /> =Introduction and Motivation=<br /> <br /> Humans are able to accomplish many tasks without any explicit or supervised training, simply by exploring their environment. We are able to set our own goals and learn from our experiences, and thus able to accomplish specific tasks without ever having been trained explicitly for them. It would be ideal if an autonomous agent can also set its own goals and learn from its environment.<br /> <br /> In the paper “Visual Reinforcement Learning with Imagined Goals”, the authors are able to devise such an unsupervised reinforcement learning system. They introduce a system that sets abstract (self-generated) goals and autonomously learns to achieve those goals. They then show that the system can use these autonomously learned skills to perform a variety of user-specified goals, such as pushing objects, grasping objects, and opening doors, without any additional learning. Lastly, they demonstrate that their method is efficient enough to work in the real world on a Sawyer robot. The robot learns to set and achieve goals with only images as the input to the system.<br /> <br /> The algorithm proposed by the authors is summarized below. A Variational Auto Encoder (VAE) on the (left) learns a latent representation of images gathered during training time (center). These latent variables are used to train a policy on imagined goals (center), which can then be used for accomplishing user-specified goals (right).<br /> <br /> [[File: WF_Sec_11Nov25_01.png |center| 800px]]<br /> <br /> =Related Work =<br /> <br /> Many previous works on vision-based deep reinforcement learning for robotics studied a variety of behaviours such as grasping , pushing , navigation , and other manipulation tasks . However, their assumptions on the models limit their suitability for training general-purpose robots. Some previous works such as Levine et al.  proposed time-varying models which require episodic setups. There are also other works such as Pinto et al.  that proposed an approach using goal images, but it requires instrumented training simulations. Lillicrap et al.  uses fully model-free training (Model-based RL uses experience to construct an internal model of the transitions and<br /> immediate outcomes in the environment. Appropriate actions are then chosen by searching or planning in this world model. Model-free RL, on the other hand, uses experience to learn directly one or both of two simpler quantities (state/action values or policies) which can achieve the same optimal behavior but without estimation or use of a world model. Given a policy, a state has a value, defined in terms of the future utility that is expected to accrue starting from that state [https://www.princeton.edu/~yael/Publications/DayanNiv2008.pdf Reinforcement learning: The Good, The Bad and The Ugly].), but does not learn goal-conditioned skills. There are currently no examples that use model-free reinforcement learning for learning policies to train on real-world robotic systems without having ground-truth information.<br /> <br /> In this paper, the authors utilize a goal-conditioned value function to tackle more general tasks through goal relabelling, which improves sample efficiency. Goal relabelling is to retroactively relabel samples in the replay buffer with goals sampled from the latent representation. The paper uses sample random goals from learned latent space to use as replay goals for off-policy Q-learning rather than restricting to states seen along the sampled trajectory as was done in the earlier works. Specifically, they use a model-free Q-learning method that operates on raw state observations and actions. This approach allows for a single transition tuple to be converted into potentially infinite valid training examples. <br /> <br /> Unsupervised learning has been used in a number of prior works to acquire better representations of reinforcement learning. In these methods, the learned representation is used as a substitute for the state for the policy. However, these methods require additional information, such as access to the ground truth reward function based on the true state during training time , expert trajectories , human demonstrations , or pre-trained object-detection features . In contrast, the authors learn to generate goals and use the learned representation to get a reward function for those goals without any of these extra sources of supervision.<br /> <br /> =Goal-Conditioned Reinforcement Learning=<br /> <br /> The ultimate goal in reinforcement learning is to learn a policy &lt;math&gt;\pi&lt;/math&gt;, that when given a state &lt;math&gt;s_t&lt;/math&gt; and goal &lt;math&gt;g&lt;/math&gt; (desired state), can dictate the optimal action &lt;math&gt;a_t&lt;/math&gt;. The optimal action &lt;math&gt;a_t&lt;/math&gt; is defined as an action which maximizes the expected return denoted by &lt;math&gt;R_t&lt;/math&gt; and defined as &lt;math&gt;R_t = \mathbb{E}[\sum_{i = t}^T\gamma^{(i-t)}r_i]&lt;/math&gt;, where &lt;math&gt;r_i = r(s_i, a_i, s_{i+1})&lt;/math&gt; is the reward for performing action &lt;math&gt;a_i&lt;/math&gt; when the current state is &lt;math&gt;s_i&lt;/math&gt; and the goal state is &lt;math&gt;s_{i+1}&lt;/math&gt; and &lt;math&gt;\gamma&lt;/math&gt; is a discount factor which determines the relative importance given to rewards at different times. <br /> <br /> In this paper, goals are not explicitly defined during training. If a goal is not explicitly defined, the agent must be able to generate a set of synthetic goals automatically. Suppose we let an autonomous agent explore an environment with a random policy. After executing each action, start and stop state observations are collected and stored. All state observations are images. For training, the agent can randomly select starting states and goals images from the set of state observations.<br /> <br /> Now given a set of all possible states, a goal, and an initial state, a reinforcement learning framework can be used to find the optimal policy such that a chosen value function is maximized. However, to implement such a framework, a reward function needs to be defined. One choice for the reward is the negative distance between the current state and the goal state, so that maximizing the reward corresponds to minimizing the distance to the goal state.<br /> <br /> [[File:human-giving-goal.png|center|thumb|400px|The task: Make the world look like this image. ]]<br /> <br /> In reinforcement learning, a goal-conditioned Q-function can be used to find a single policy to maximize rewards and therefore reach goal states. A goal-conditioned Q-function &lt;math&gt;Q(s,a,g)&lt;/math&gt; tells us how good an action &lt;math&gt;a&lt;/math&gt; is, given the current state &lt;math&gt;s&lt;/math&gt; and goal &lt;math&gt;g&lt;/math&gt;. For example, a Q-function tells us, “How good is it to move my hand up (action &lt;math&gt;a&lt;/math&gt;), if I’m holding a plate (state &lt;math&gt;s&lt;/math&gt;) and want to put the plate on the table (goal &lt;math&gt;g&lt;/math&gt;)?” Once this Q-function is trained, a goal-conditioned policy can be obtained by performing the following optimization<br /> <br /> &lt;div align=&quot;center&quot;&gt;<br /> &lt;math&gt;\pi(s,g) = max_a Q(s,a,g)&lt;/math&gt;<br /> &lt;/div&gt;<br /> <br /> which effectively says, “choose the best action according to this Q-function.” By using this procedure, one can obtain a policy that maximizes the sum of rewards, i.e. reaches various goals.<br /> <br /> The reason why Q-learning is popular is that it can be trained in an off-policy manner. Therefore, the only things a Q-function needs are samples of state, action, next state, goal, and reward &lt;math&gt;(s,a,s′,g,r)&lt;/math&gt;. This data can be collected by any policy and can be reused across multiples tasks. So a preliminary goal-conditioned Q-learning algorithm looks like this:<br /> <br /> [[File:ql.png|center|600px]]<br /> <br /> From the tuple &lt;math&gt;(s,a,s',g,r)&lt;/math&gt;, an approximate Q-function paramaterized by &lt;math&gt;w&lt;/math&gt; can be trained by minimizing the Bellman error:<br /> <br /> &lt;div align=&quot;center&quot;&gt;<br /> &lt;math&gt;\mathcal{E}(w) = \frac{1}{2} || Q_w(s,a,g) -(r + \gamma \max_{a'} Q_{\overline{w}}(s',a',g)) ||^2 &lt;/math&gt;<br /> &lt;/div&gt;<br /> <br /> where &lt;math&gt;\overline{w}&lt;/math&gt; is treated as some constant.<br /> <br /> The main drawback in this training procedure is collecting data. In theory, one could learn to solve various tasks without even interacting with the world if more data are available. Unfortunately, it is difficult to learn an accurate model of the world, so sampling is usually performed to get state-action-next-state data, (s,a,s′). However, if the reward function &lt;math&gt;r(s,g)&lt;/math&gt; can be accessed, one can retroactively relabel goals and recompute rewards. This way, more data can be artificially generated given a single &lt;math&gt;(s,a,s′)&lt;/math&gt; tuple. As a result, the training procedure can be modified like so:<br /> <br /> [[File:qlr.png|center|600px]]<br /> <br /> This goal resampling makes it possible to simultaneously learn how to reach multiple goals at once without needing more data from the environment. Thus, this simple modification can result in substantially faster learning. However, the method described above makes two major assumptions: (1) you have access to a reward function and (2) you have access to a goal sampling distribution &lt;math&gt;p(g)&lt;/math&gt;. When moving to vision-based tasks where goals are images, both of these assumptions introduce practical concerns.<br /> <br /> For one, a fundamental problem with this reward function is that it assumes that the distance between raw images will yield semantically useful information. But images are noisy and a large amount of information in an image may not be related to the object we analyze. Thus, the distance between two images may not correlate with their semantic distance.<br /> <br /> Second, because the goals are images, a goal image distribution &lt;math&gt;p(g)&lt;/math&gt; is needed so that one can sample goal images. Manually designing a distribution over goal images is a non-trivial task and image generation is still an active field of research. It would be ideal if the agent can autonomously imagine its own goals and learn how to reach them.<br /> <br /> =Variational Autoencoder=<br /> An autoencoder is a type of machine learning model that can learn to extract a robust, space-efficient feature vector from an image. This generative model converts high-dimensional observations &lt;math&gt;x&lt;/math&gt;, like images, into low-dimensional latent variables &lt;math&gt;z&lt;/math&gt;, and vice versa. The model is trained so that the latent variables capture the underlying factors of variation in an image. A current image &lt;math&gt;x&lt;/math&gt; and goal image &lt;math&gt;x_g&lt;/math&gt; can be converted into latent variables &lt;math&gt;z&lt;/math&gt; and &lt;math&gt;z_g&lt;/math&gt;, respectively. These latent variables can then be used to represent the state and goal for the reinforcement learning algorithm. Learning Q functions and policies on top of this low-dimensional latent space rather than directly on images results in faster learning.<br /> <br /> [[File:robot-interpreting-scene.png|center|thumb|600px|The agent encodes the current image (&lt;math&gt;x&lt;/math&gt;) and goal image (&lt;math&gt;x_g&lt;/math&gt;) into a latent space and use distances in that latent space for reward. ]]<br /> <br /> Using the latent variable representations for the images and goals also solves the problem of computing rewards. Instead of using pixel-wise error as our reward, the distance in the latent space is used as the reward to train the agent to reach a goal. The paper shows that this corresponds to rewarding reaching states that maximize the probability of the latent goal &lt;math&gt;z_g&lt;/math&gt;.<br /> <br /> This generative model is also important because it allows an agent to easily generate goals in the latent space. In particular, the authors design the generative model so that latent variables are sampled from the VAE prior. This sampling mechanism is used for two reasons: First, it provides a mechanism for an agent to set its own goals. The agent simply samples a value for the latent variable from the generative model, and tries to reach that latent goal. Second, this resampling mechanism is also used to relabel goals as mentioned above. Since the VAE prior is trained by real images, meaningful latent goals can be sampled from the latent variable prior. This will help the agent set its own goals and practice towards them if no goal is provided at test time.<br /> <br /> [[File:robot-imagining-goals.png|center|thumb|600px|Even without a human providing a goal, our agent can still generate its own goals, both for exploration and for goal relabeling. ]]<br /> <br /> The authors summarize the purpose of the latent variable representation of images as follows: (1) captures the underlying factors of a scene, (2) provides meaningful distances to optimize, and (3) provides an efficient goal sampling mechanism which can be used by the agent to generate its own goals. The overall method is called reinforcement learning with imagined goals (RIG) by the authors.<br /> The process involves starts with collecting data through a simple exploration policy. Possible alternative explorations could be employed here including off-the-shelf exploration bonuses or unsupervised reinforcement learning methods. Then, a VAE latent variable model is trained on state observations and fine-tuned during training. The latent variable model is used for multiple purposes: sampling a latent goal &lt;math&gt;z_g&lt;/math&gt; from the model and conditioning the policy on this goal. All states and goals are embedded using the model’s encoder and then used to train the goal-conditioned value function. The authors then resample goals from the prior and compute rewards in the latent space.<br /> <br /> =Algorithm=<br /> [[File:algorithm1.png|center|thumb|600px|]]<br /> <br /> Algorithm 1 is called reinforcement learning with imagined goals (RIG). The data is first collected via a simple exploration policy. The proposed model allows for alternate exploration policies to be used which include off-the-shelf exploration bonuses or unsupervised reinforcement learning methods. Then, the authors train a VAE latent variable model on state observations and finetune it over the course of training. VAE latent space modeling is used to allow the conditioning of policy on the goal which is sampled from the latent model. The VAE model is also used to encode all the goals and the states. When the goal-conditioned value function is trained, the authors resample prior goals and compute rewards in the latent space using the equation &lt;math display=&quot;inline&quot;&gt; r(s, g) = - || z - z_g ||_A \propto \sqrt{log(e_{\Phi}(z_g | s))} &lt;/math&gt;<br /> <br /> =Experiments=<br /> <br /> The authors evaluated their method against some prior algorithms and ablated versions of their approach on a suite of simulated and real-world tasks: Visual Reacher, Visual Pusher, and Visual Multi-Object Pusher. They compared their model with the following prior works: L&amp;R, DSAE, HER, and Oracle. It is concluded that their approach substantially outperforms the previous methods and is close to the state-based &quot;oracle&quot; method in terms of efficiency and performance.<br /> <br /> The figure below shows the performance of different algorithms on this task. This involved a simulated environment with a Sawyer arm. The authors' algorithm was given only visual input, and the available controls were end-effector velocity. The plots show the distance to the goal state as a function of simulation steps. The oracle, as a baseline, was given true object location information, as opposed to visual pixel information.<br /> <br /> [[File:WF_Sec_11Nov_25_02.png|1000px]]<br /> <br /> <br /> They then investigated the effectiveness of distances in the VAE latent space for the Visual Pusher task. They observed that latent distance significantly outperforms the log probability and pixel mean-squared error. The resampling strategies are also varied while fixing other components of the algorithm to study the effect of relabeling strategy. In this experiment, the RIG, which is an equal mixture of the VAE and Future sampling strategies, performs best. Subsequently, learning with variable numbers of objects was studied by evaluating on a task where the environment, based on the Visual Multi-Object Pusher, randomly contains zero, one, or two objects during testing. The results show that their model can tackle this task successfully.<br /> <br /> Finally, the authors tested the RIG in a real-world robot for its ability to reach user-specified positions and push objects to desired locations, as indicated by a goal image. The robot is trained with access only to 84x84 RGB images and without access to joint angles or object positions. The robot first learns by settings its own goals in the latent space and autonomously practices reaching different positions without human involvement. After a reasonable amount of time of training, the robot is given a goal image. Because the robot has practiced reaching so many goals, it is able to reach this goal without additional training:<br /> <br /> [[File:reaching.JPG|center|thumb|600px|(Left) The robot setup is pictured. (Right) Test rollouts of the learned policy.]]<br /> <br /> The method for reaching only needs 10,000 samples and an hour of real-world interactions.<br /> <br /> They also used RIG to train a policy to push objects to target locations:<br /> <br /> [[File:pushing.JPG|center|thumb|600px|The robot pushing setup is<br /> pictured, with frames from test rollouts of the learned policy.]]<br /> <br /> The pushing task is more complicated and the method requires about 25,000 samples. Since the authors do not have the true position during training, so they used test episode returns as the VAE latent distance reward.<br /> <br /> =Conclusion &amp; Future Work=<br /> <br /> In this paper, a new RL algorithm is proposed to efficiently solve goal-conditioned, vision-based tasks without any ground truth state information or reward functions. The author suggests that one could instead use other representations, such as language and demonstrations, to specify goals. Also, while the paper provides a mechanism to sample goals for autonomous exploration, one can combine the proposed method with existing work by choosing these goals in a more principled way, i.e. a procedure that is not only goal-oriented, but also information seeking or uncertainty aware, to perform even better exploration. Furthermore, combining the idea of this paper with methods from multitask learning and meta-learning is a promising path to create general-purpose agents that can continuously and efficiently acquire skill. Lastly, there are a variety of robot tasks whose state representation would be difficult to capture with sensors, such as manipulating deformable objects or handling scenes with variable number of objects. It is interesting to see whether the RIG can be scaled up to solve these tasks. A new paper  was published last week that built on the framework of goal conditioned Reinforcement Learning to extract state representations based on the actions required to reach them, which is abbreviated ARC for actionable representation for control.<br /> <br /> =Critique=<br /> 1. This paper is novel because it uses visual data and trains in an unsupervised fashion. The algorithm has no access to a ground truth state or to a pre-defined reward function. It can perform well in a real-world environment with no explicit programming.<br /> <br /> 2. From the videos, one major concern is that the output of robotic arm's position is not stable during training and test time. It is likely that the encoder reduces the image features too much so that the images in the latent space are too blury to be used goal images. It would be better if this can be investigated in future. It would be better, if a method is investigated with multiple data sources, and the agent is trained to choose the source which has more complete information. <br /> <br /> 3. The algorithm seems to perform better when there is only one object in the images. For example, in Visual Multi-Object Pusher experiment, the relative positions of two pucks do not correspond well with the relative positions of two pucks in goal images. The same situation is also observed in Variable-object experiment. We may guess that the more information contained in an image, the less likely the robot will perform well. This limits the applicability of the current algorithm to solving real-world problems.<br /> <br /> 4. The instability mentioned in #2 is even more apparent in the multi-object scenario, and appears to result from the model attempting to optimize on the position of both objects at the same time. Reducing the problem to a sequence of single-object targets may reduce the amount of time the robots spends moving between the multiple objects in the scene (which it currently does quite frequently).<br /> <br /> =References=<br /> 1. Lerrel Pinto, Marcin Andrychowicz, Peter Welinder, Wojciech Zaremba, and Pieter Abbeel. Asymmetric<br /> Actor Critic for Image-Based Robot Learning. arXiv preprint arXiv:1710.06542, 2017.<br /> <br /> 2. Pulkit Agrawal, Ashvin Nair, Pieter Abbeel, Jitendra Malik, and Sergey Levine. Learning to Poke by<br /> Poking: Experiential Learning of Intuitive Physics. In Advances in Neural Information Processing Systems<br /> (NIPS), 2016.<br /> <br /> 3. Deepak Pathak, Parsa Mahmoudieh, Guanghao Luo, Pulkit Agrawal, Dian Chen, Yide Shentu, Evan<br /> Shelhamer, Jitendra Malik, Alexei A Efros, and Trevor Darrell. Zero-Shot Visual Imitation. In International<br /> Conference on Learning Representations (ICLR), 2018.<br /> <br /> 4. Timothy P Lillicrap, Jonathan J Hunt, Alexander Pritzel, Nicolas Heess, Tom Erez, Yuval Tassa, David<br /> Silver, and Daan Wierstra. Continuous control with deep reinforcement learning. In International<br /> Conference on Learning Representations (ICLR), 2016.<br /> <br /> 5. Irina Higgins, Arka Pal, Andrei A Rusu, Loic Matthey, Christopher P Burgess, Alexander Pritzel, Matthew<br /> Botvinick, Charles Blundell, and Alexander Lerchner. Darla: Improving zero-shot transfer in reinforcement<br /> learning. International Conference on Machine Learning (ICML), 2017.<br /> <br /> 6. Aravind Srinivas, Allan Jabri, Pieter Abbeel, Sergey Levine, and Chelsea Finn. Universal Planning<br /> Networks. In International Conference on Machine Learning (ICML), 2018.<br /> <br /> 7. Pierre Sermanet, Corey Lynch, Yevgen Chebotar, Jasmine Hsu, Eric Jang, Stefan Schaal, and Sergey<br /> Levine. Time-contrastive networks: Self-supervised learning from video. arXiv preprint arXiv:1704.06888,<br /> 2017.<br /> <br /> 8. Alex Lee, Sergey Levine, and Pieter Abbeel. Learning Visual Servoing with Deep Features and Fitted<br /> Q-Iteration. In International Conference on Learning Representations (ICLR), 2017.<br /> <br /> 9. Online source: https://bair.berkeley.edu/blog/2018/09/06/rig/<br /> <br /> 10. https://arxiv.org/pdf/1811.07819.pdf<br /> <br /> 11. Sergey Levine, Chelsea Finn, Trevor Darrell, and Pieter Abbeel. End-to-End Training of Deep Visuomotor Policies. Journal of Machine Learning Research (JMLR), 17(1):1334–1373, 2016. ISSN 15337928.<br /> <br /> 12. Lerrel Pinto, Marcin Andrychowicz, Peter Welinder, Wojciech Zaremba, and Pieter Abbeel. Asymmetric Actor Critic for Image-Based Robot Learning. arXiv preprint arXiv:1710.06542, 2017.<br /> <br /> 13. Timothy P Lillicrap, Jonathan J Hunt, Alexander Pritzel, Nicolas Heess, Tom Erez, Yuval Tassa, David Silver, and Daan Wierstra. Continuous control with deep reinforcement learning. In International Conference on Learning Representations (ICLR), 2016.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=Unsupervised_Neural_Machine_Translation&diff=41594 Unsupervised Neural Machine Translation 2018-11-27T16:54:50Z <p>Jmmoosa: /* Methodology */</p> <hr /> <div>This paper was published in ICLR 2018, authored by Mikel Artetxe, Gorka Labaka, Eneko Agirre, and Kyunghyun Cho. Open source implementation of this paper is available [https://github.com/artetxem/undreamt here]<br /> <br /> = Introduction =<br /> The paper presents an unsupervised Neural Machine Translation (NMT) method that uses monolingual corpora (single language texts) only. This contrasts with the usual supervised NMT approach which relies on parallel corpora (aligned text) from the source and target languages being available for training. This problem is important because parallel pairing for a majority of languages, e.g. for German-Russian, do not exist.<br /> <br /> Other authors have recently tried to address this problem using semi-supervised approaches (small set of parallel corpora). However, these methods still require a strong cross-lingual signal. The proposed method eliminates the need for cross-lingual information all together and relies solely on monolingual data. The proposed method builds upon the work done recently on unsupervised cross-lingual embeddings by Artetxe et al., 2017 and Zhang et al., 2017.<br /> <br /> The general approach of the methodology is to:<br /> <br /> # Use monolingual corpora in the source and target languages to learn single language word embeddings for both languages separately.<br /> # Align the 2 sets of word embeddings into a single cross lingual (language independent) embedding.<br /> Then iteratively perform:<br /> # Train an encoder-decoder model to reconstruct noisy versions of sentences in both source and target languages separately. The model uses a single encoder and different decoders for each language. The encoder uses cross lingual word embedding.<br /> # Tune the decoder in each language by back-translating between the source and target language.<br /> <br /> = Background =<br /> <br /> ===Word Embedding Alignment===<br /> <br /> The paper uses word2vec [Mikolov, 2013] to convert each monolingual corpora to vector embeddings. They improve the continuous Skip-gram model for learning high-quality distributed vector representations that capture a large number of precise syntactic and semantic word relationships. These embeddings have been shown to contain the contextual and syntactic features independent of language, and so, in theory, there could exist a linear map that maps the embeddings from language L1 to language L2. <br /> <br /> Figure 1 shows an example of aligning the word embeddings in English and French.<br /> <br /> [[File:Figure1_lwali.png|frame|400px|center|Figure 1: the word embeddings in English and French (a &amp; b), and (c) shows the aligned word embeddings after some linear transformation.[Gouws,2016]]]<br /> <br /> Most cross-lingual word embedding methods use bilingual signals in the form of parallel corpora. Usually, the embedding mapping methods train the embeddings in different languages using monolingual corpora, then use a linear transformation to map them into a shared space based on a bilingual dictionary.<br /> <br /> The paper uses the methodology proposed by [Artetxe, 2017] to do cross-lingual embedding aligning in an unsupervised manner and without parallel data. Without going into the details, the general approach of this paper is starting from a seed dictionary of numeral pairings (e.g. 1-1, 2-2, etc.), to iteratively learn the mapping between 2 language embeddings, while concurrently improving the dictionary with the learned mapping at each iteration. This is in contrast to earlier work which used dictionaries of a few thousand words.<br /> <br /> ===Other related work and inspirations===<br /> ====Statistical Decipherment for Machine Translation====<br /> There has been significant work in statistical deciphering techniques (decipherment is the discovery of the meaning of texts written in ancient or obscure languages or scripts) to develop a machine translation model from monolingual data (Ravi &amp; Knight, 2011; Dou &amp; Knight, 2012). These techniques treat the source language as ciphertext (encrypted or encoded information because it contains a form of the original plaintext that is unreadable by a human or computer without the proper cipher for decoding) and model the generation process of the ciphertext as a two-stage process, which includes the generation of the original English sequence and the probabilistic replacement of the words in it. This approach takes advantage of the incorporation of syntactic knowledge of the languages. The use of word embeddings has also shown improvements in statistical decipherment.<br /> <br /> ====Low-Resource Neural Machine Translation====<br /> There are also proposals that use techniques other than direct parallel corpora to do NMT. Some use a third intermediate language that is well connected to the source and target languages independently. For example, if we want to translate German into Russian, we can use English as an intermediate language (German-English and then English-Russian) since there are plenty of resources to connect English and other languages. Johnson et al. (2017) show that a multilingual extension of a standard NMT architecture performs reasonably well for language pairs when no parallel data for the source and target data was used during training. Firat et al. (2016) and Chen et al. (2017) showed that the use of advanced models like teacher-student framework can be used to improve over the baseline of translating using a third intermediate language.<br /> <br /> Other works use monolingual data in combination with scarce parallel corpora. A simple but effective technique is back-translation [Sennrich et al, 2016]. First, a synthetic parallel corpus in the target language is created. Translated sentence and back translated to the source language and compared with the original sentence.<br /> <br /> The most important contribution to the problem of training an NMT model with monolingual data was from [He, 2016], which trains two agents to translate in opposite directions (e.g. French → English and English → French) and teach each other through reinforcement learning. However, this approach still required a large parallel corpus for a warm start (about 1.2 million sentences), while this paper does not use parallel data.<br /> <br /> = Methodology =<br /> <br /> The corpora data is first preprocessed in a standard way to tokenize and case the words. The authors also experimented with an alternate way of tokenizing words by using Byte-Pair Encoding (BPE) [Sennrich, 2016] (Byte pair encoding or digram coding is a simple form of data compression in which the most common pair of consecutive bytes of data is replaced with a byte that does not occur within that data). BPE has been shown to improve embeddings of rare-words. The vocabulary was limited to the most frequent 50,000 tokens (BPE tokens or words).<br /> <br /> The tokens were then converted to word embeddings using word2vec with 300 dimensions and then aligned between languages using the method proposed by [Artetxe, 2017]. The alignment method proposed by [Artetxe, 2017] is also used as a baseline to evaluate this model as discussed later in Results.<br /> <br /> The translation model uses a standard encoder-decoder model with attention. The encoder is a 2-layer bidirectional RNN, and the decoder is a 2 layer RNN. All RNNs use GRU cells with 600 hidden units. The encoder is shared by the source and target language, while the decoder is different for each language.<br /> <br /> Although the architecture uses standard models, the proposed system differs from the standard NMT through 3 aspects:<br /> <br /> #Dual structure: NMT usually are built for one direction translations English&lt;math&gt;\rightarrow&lt;/math&gt;French or French&lt;math&gt;\rightarrow&lt;/math&gt;English, whereas the proposed model trains both directions at the same time translating English&lt;math&gt;\leftrightarrow&lt;/math&gt;French.<br /> #Shared encoder: one encoder is shared for both source and target languages in order to produce a representation in the latent space independent of language, and each decoder learns to transform the representation back to its corresponding language. <br /> #Fixed embeddings in the encoder: Most NMT systems initialize the embeddings and update them during training, whereas the proposed system trains the embeddings in the beginning and keeps these fixed throughout training, so the encoder receives language-independent representations of the words. This approach ensures that the encoder only learns how to compose the language independent representations to build representations of the larger phrases. This requires existing unsupervised methods to create embeddings using monolingual corpora as discussed in the background. In the proposed method, even though the embeddings used are cross-lingual, the vocabulary used for each language is different. This way if the same word occurs in two different languages and has a different meaning in the respective languages then each word would get a different vector in the respective languages despite being in the same vector space. <br /> <br /> [[File:Figure2_lwali.png|600px|center]]<br /> <br /> The translation model iteratively improves the encoder and decoder by performing 2 tasks: Denoising, and Back-translation.<br /> <br /> ===Denoising===<br /> Random noise is added to the input sentences in order to allow the model to learn some structure of languages. Without noise, the model would simply learn to copy the input word by word. Noise also allows the shared encoder to compose the embeddings of both languages in a language-independent fashion, and then be decoded by the language dependent decoder.<br /> <br /> Denoising works by reconstructing a noisy version of a sentence back into the original sentence in the same language. In mathematical form, if &lt;math&gt;x&lt;/math&gt; is a sentence in language L1:<br /> <br /> # Construct &lt;math&gt;C(x)&lt;/math&gt;, noisy version of &lt;math&gt;x&lt;/math&gt;. In the proposed model, &lt;math&gt;C(x)&lt;/math&gt; is constructed by randomly swapping contiguous words. If the length of the input sequence &lt;math&gt;x&lt;/math&gt; is &lt;math&gt;N&lt;/math&gt;, then a total of &lt;math&gt;\frac{N}{2}&lt;/math&gt; such swaps are made.<br /> # Input &lt;math&gt;C(x)&lt;/math&gt; into the current iteration of the shared encoder and use decoder for L1 to get reconstructed &lt;math&gt;\hat{x}&lt;/math&gt;.<br /> <br /> The training objective is to minimize the cross entropy loss between &lt;math&gt;{x}&lt;/math&gt; and &lt;math&gt;\hat{x}&lt;/math&gt;.<br /> <br /> In other words, the whole system is optimized to take an input sentence in a given language, encode it using the shared encoder, and reconstruct the original sentence using the decoder of that language.<br /> <br /> The proposed noise function is to perform &lt;math&gt;N/2&lt;/math&gt; random swaps of words that are contiguous, where &lt;math&gt;N&lt;/math&gt; is the number of words in the sentence. This noise model also helps reduce the reliance of the model on the order of words in a sentence which may be different in the source and target languages. The system will also need to correctly learn the internal structure of a language to decode the sentence into the correct order.<br /> <br /> ===Back-Translation===<br /> <br /> With only denoising, the system doesn't have a goal to improve the actual translation. Back-translation works by using the decoder of the target language to create a translation, then encoding this translation and decoding again using the source decoder to reconstruct the original sentence. In mathematical form, if &lt;math&gt;C(x)&lt;/math&gt; is a noisy version of sentence &lt;math&gt;x&lt;/math&gt; in language L1:<br /> <br /> # Input &lt;math&gt;C(x)&lt;/math&gt; into the current iteration of shared encoder and the decoder in L2 to construct translation &lt;math&gt;y&lt;/math&gt; in L2,<br /> # Construct &lt;math&gt;C(y)&lt;/math&gt;, noisy version of translation &lt;math&gt;y&lt;/math&gt;,<br /> # Input &lt;math&gt;C(y)&lt;/math&gt; into the current iteration of shared encoder and the decoder in L1 to reconstruct &lt;math&gt;\hat{x}&lt;/math&gt; in L1.<br /> <br /> The training objective is to minimize the cross entropy loss between &lt;math&gt;{x}&lt;/math&gt; and &lt;math&gt;\hat{x}&lt;/math&gt;.<br /> <br /> This approach alleviates issues that would have resulted from the training procedure only dealing with a single language at a time. The corpus of a language is converted to a synthetic translation, and trained to predict the original sentence from this translation. <br /> <br /> Contrary to standard back-translation that uses an independent model to back-translate the entire corpus at once, the system uses mini-batches and the dual architecture to generate pseudo-translations and then train the model with the translation, improving the model iteratively as the training progresses.<br /> <br /> ===Training===<br /> <br /> Training is done by alternating these 2 objectives from mini-batch to mini-batch. Each iteration would perform one mini-batch of denoising for L1, another one for L2, one mini-batch of back-translation from L1 to L2, and another one from L2 to L1. The procedure is repeated until convergence. <br /> During decoding, greedy decoding was used at training time for back-translation, but actual inference at test time was done using beam-search with a beam size of 12.<br /> <br /> Optimizer choice and other hyperparameters can be found in the paper.<br /> <br /> =Experiments and Results=<br /> <br /> The model was evaluated using the Bilingual Evaluation Understudy (BLEU) Score, which is typically used to evaluate the quality of the translation, using a reference (ground-truth) translation.<br /> <br /> The paper trained translation model under 3 different settings to compare the performance (Table 1). All training and testing data used was from a standard NMT dataset, WMT'14.<br /> <br /> [[File:Table1_lwali.png|600px|center]]<br /> <br /> The results exhibit that for the proposed system to work properly, backtranslation is necessary. The denoising technique alone is below the baseline while big improvements appear when introducing backtranslation.<br /> <br /> ===Unsupervised===<br /> <br /> The model only has access to monolingual corpora, using the News Crawl corpus with articles from 2007 to 2013. The baseline for unsupervised is the method proposed by [Artetxe, 2017], which was the unsupervised word vector alignment method discussed in the Background section.<br /> <br /> The paper adds each component piece-wise when doing an evaluation to test the impact each piece has on the final score. As shown in Table 1, Unsupervised results compared to the baseline of word-by-word results are strong, with improvement between 40% to 140%. Results also show that back-translation is essential. Denoising doesn't show a big improvement however it is required for back-translation, because otherwise, back-translation would translate nonsensical sentences. The addition of backtranslation, however, does show large improvement on all tested cases.<br /> <br /> For the BPE experiment, results show it helps in some language pairs but detract in some other language pairs. This is because while BPE helped to translate some rare words, it increased the error rates in other words. It also did not perform well when translating named entities which occur infrequently.<br /> <br /> ===Semi-supervised===<br /> <br /> Since there is often some small parallel data but not enough to train a Neural Machine Translation system, the authors test a semi-supervised setting with the same monolingual data from the unsupervised settings together with either 10,000 or 100,000 random sentence pairs from the News Commentary parallel corpus. The supervision is included to improve the model during the back-translation stage to directly predict sentences that are in the parallel corpus.<br /> <br /> Table 1 shows that the model can greatly benefit from the addition of a small parallel corpus to the monolingual corpora. It is surprising that semi-supervised in row 6 outperforms supervised in row 7, one possible explanation is that both the semi-supervised training set and the test set belong to the news domain, whereas the supervised training set is all domains of corpora.<br /> <br /> ===Supervised===<br /> <br /> This setting provides an upper bound to the unsupervised proposed system. The data used was the combination of all parallel corpora provided at WMT 2014, which includes Europarl, Common Crawl and News Commentary for both language pairs plus the UN and the Gigaword corpus for French- English. Moreover, the authors use the same subsets of News Commentary alone to run the separate experiments in order to compare with the semi-supervised scenario.<br /> <br /> The Comparable NMT was trained using the same proposed model except it does not use monolingual corpora, and consequently, it was trained without denoising and back-translation. The proposed model under a supervised setting does much worse than the state of the NMT in row 10, which suggests that adding the additional constraints to enable unsupervised learning also limits the potential performance. To improve these results, the authors also suggest using larger models, longer training times, and incorporating several well-known NMT techniques.<br /> <br /> ===Qualitative Analysis===<br /> <br /> [[File:Table2_lwali.png|600px|center]]<br /> <br /> Table 2 shows 4 examples of French to English translations, which shows that the high-quality translations are produced by the proposed system, and this system adequately models non-trivial translation relations. Example 1 and 2 show that the model is able to not only go beyond a literal word-by-word substitution but also model structural differences in the languages (ex.e, it correctly translates &quot;l’aeroport international de Los Angeles&quot; as &quot;Los Angeles International Airport&quot;, and it is capable of producing high-quality translations of long and more complex sentences. However, in Example 3 and 4, the system failed to translate the months and numbers correctly and having difficulty with comprehending odd sentence structures, which means that the proposed system has limitations. Specially, the authors points that the proposed model has difficulties to preserve some concrete details from source sentences. Results also show, the proposed model's translation quality often lags behind that of a standard supervised NMT system and also there are also some cases where there are both fluency and adequacy problems that severely hinders understanding the original message from the proposed translation, suggesting that there is still room for improvement and possible future work.<br /> <br /> =Conclusions and Future Work=<br /> <br /> The paper presented an unsupervised model to perform translations with monolingual corpora by using an attention-based encoder-decoder system and training using denoise and back-translation.<br /> <br /> Although experimental results show that the proposed model is effective as an unsupervised approach, there is significant room for improvement when using the model in a supervised way, suggesting the model is limited by the architectural modifications. Some ideas for future improvement include:<br /> *Instead of using fixed cross-lingual word embeddings at the beginning which forces the encoder to learn a common representation for both languages, progressively update the weight of the embeddings as training progresses.<br /> *Decouple the shared encoder into 2 independent encoders at some point during training<br /> *Progressively reduce the noise level<br /> *Incorporate character level information into the model, which might help address some of the adequacy issues observed in our manual analysis<br /> *Use other noise/denoising techniques, and analyze their effect in relation to the typological divergences of different language pairs.<br /> <br /> = Critique =<br /> <br /> While the idea is interesting and the results are impressive for an unsupervised approach, much of the model had actually already been proposed by other papers that are referenced. The paper doesn't add a lot of new ideas but only builds on existing techniques and combines them in a different way to achieve good experimental results. The paper is not a significant algorithmic contribution. <br /> <br /> As pointed out, in order to critically analyze the effect of the algorithm, we need to formulate the algorithm in terms of mathematics.<br /> <br /> The results showed that the proposed system performed far worse than the state of the art when used in a supervised setting, which is concerning and shows that the techniques used creates a limitation and a ceiling for performance.<br /> <br /> Additionally, there was no rigorous hyperparameter exploration/optimization for the model. As a result, it is difficult to conclude whether the performance limit observed in the constrained supervised model is the absolute limit, or whether this could be overcome in both supervised/unsupervised models with the right constraints to achieve more competitive results. <br /> <br /> The best results shown are between two very closely related languages(English and French), and does much worse for English - German, even though English and German are also closely related (but less so than English and French) which suggests that the model may not be successful at translating between distant language pairs. More testing would be interesting to see.<br /> <br /> The results comparison could have shown how the semi-supervised version of the model scores compared to other semi-supervised approaches as touched on in the other works section.<br /> <br /> Their qualitative analysis just checks whether their proposed unsupervised NMT generates a sensible translation. It is limited and it needs further detailed analysis regarding the characteristics and properties of translation which is generated by unsupervised NMT.<br /> <br /> * (As pointed out by an anonymous reviewer [https://openreview.net/forum?id=Sy2ogebAW])Future work is vague: “we would like to detect and mitigate the specific causes…” “We also think that a better handling of rare words…” That’s great, but how will you do these things? Do you have specific reasons to think this, or ideas on how to approach them? Otherwise, this is just hand-waving.<br /> <br /> = References =<br /> #'''[Mikolov, 2013]''' Tomas Mikolov, Ilya Sutskever, Kai Chen, Greg S Corrado, and Jeff Dean. &quot;Distributed representations of words and phrases and their compositionality.&quot;<br /> #'''[Artetxe, 2017]''' Mikel Artetxe, Gorka Labaka, Eneko Agirre, &quot;Learning bilingual word embeddings with (almost) no bilingual data&quot;.<br /> #'''[Gouws,2016]''' Stephan Gouws, Yoshua Bengio, Greg Corrado, &quot;BilBOWA: Fast Bilingual Distributed Representations without Word Alignments.&quot;<br /> #'''[He, 2016]''' Di He, Yingce Xia, Tao Qin, Liwei Wang, Nenghai Yu, Tieyan Liu, and Wei-Ying Ma. &quot;Dual learning for machine translation.&quot;<br /> #'''[Sennrich,2016]''' Rico Sennrich and Barry Haddow and Alexandra Birch, &quot;Neural Machine Translation of Rare Words with Subword Units.&quot;<br /> #'''[Ravi &amp; Knight, 2011]''' Sujith Ravi and Kevin Knight, &quot;Deciphering foreign language.&quot;<br /> #'''[Dou &amp; Knight, 2012]''' Qing Dou and Kevin Knight, &quot;Large scale decipherment for out-of-domain machine translation.&quot;<br /> #'''[Johnson et al. 2017]''' Melvin Johnson,et al, &quot;Google’s multilingual neural machine translation system: Enabling zero-shot translation.&quot;<br /> #'''[Zhang et al. 2017]''' Meng Zhang, Yang Liu, Huanbo Luan, and Maosong Sun. &quot;Adversarial training for unsupervised bilingual lexicon induction&quot;</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=Visual_Reinforcement_Learning_with_Imagined_Goals&diff=41591 Visual Reinforcement Learning with Imagined Goals 2018-11-27T16:41:08Z <p>Jmmoosa: /* Related Work */</p> <hr /> <div>Video and details of this work are available [https://sites.google.com/site/visualrlwithimaginedgoals/ here]<br /> <br /> =Introduction and Motivation=<br /> <br /> Humans are able to accomplish many tasks without any explicit or supervised training, simply by exploring their environment. We are able to set our own goals and learn from our experiences, and thus able to accomplish specific tasks without ever having been trained explicitly for them. It would be ideal if an autonomous agent can also set its own goals and learn from its environment.<br /> <br /> In the paper “Visual Reinforcement Learning with Imagined Goals”, the authors are able to devise such an unsupervised reinforcement learning system. They introduce a system that sets abstract (self-generated) goals and autonomously learns to achieve those goals. They then show that the system can use these autonomously learned skills to perform a variety of user-specified goals, such as pushing objects, grasping objects, and opening doors, without any additional learning. Lastly, they demonstrate that their method is efficient enough to work in the real world on a Sawyer robot. The robot learns to set and achieve goals with only images as the input to the system.<br /> <br /> The algorithm proposed by the authors is summarized below. A Variational Auto Encoder (VAE) on the (left) learns a latent representation of images gathered during training time (center). These latent variables are used to train a policy on imagined goals (center), which can then be used for accomplishing user-specified goals (right).<br /> <br /> [[File: WF_Sec_11Nov25_01.png |center| 800px]]<br /> <br /> =Related Work =<br /> <br /> Many previous works on vision-based deep reinforcement learning for robotics studied a variety of behaviours such as grasping , pushing , navigation , and other manipulation tasks . However, their assumptions on the models limit their suitability for training general-purpose robots. Some previous works such as Levine et al.  proposed time-varying models which require episodic setups. There are also other works such as Pinto et al.  that proposed an approach using goal images, but it requires instrumented training simulations. Lillicrap et al.  uses fully model-free training (Model-based RL uses experience to construct an internal model of the transitions and<br /> immediate outcomes in the environment. Appropriate actions are then chosen by searching or planning in this world model. Model-free RL, on the other hand, uses experience to learn directly one or both of two simpler quantities (state/action values or policies) which can achieve the same optimal behavior but without estimation or use of a world model. Given a policy, a state has a value, defined in terms of the future utility that is expected to accrue starting from that state [https://www.princeton.edu/~yael/Publications/DayanNiv2008.pdf Reinforcement learning: The Good, The Bad and The Ugly].), but does not learn goal-conditioned skills. There are currently no examples that use model-free reinforcement learning for learning policies to train on real-world robotic systems without having ground-truth information.<br /> <br /> In this paper, the authors utilize a goal-conditioned value function to tackle more general tasks through goal relabelling, which improves sample efficiency. Goal relabelling is to retroactively relabel samples in the replay buffer with goals sampled from the latent representation. The paper uses sample random goals from learned latent space to use as replay goals for off-policy Q-learning rather than restricting to states seen along the sampled trajectory as was done in the earlier works. Specifically, they use a model-free Q-learning method that operates on raw state observations and actions. This approach allows for a single transition tuple to be converted into potentially infinite valid training examples. <br /> <br /> Unsupervised learning has been used in a number of prior works to acquire better representations of reinforcement learning. In these methods, the learned representation is used as a substitute for the state for the policy. However, these methods require additional information, such as access to the ground truth reward function based on the true state during training time , expert trajectories , human demonstrations , or pre-trained object-detection features . In contrast, the authors learn to generate goals and use the learned representation to get a reward function for those goals without any of these extra sources of supervision.<br /> <br /> =Goal-Conditioned Reinforcement Learning=<br /> <br /> The ultimate goal in reinforcement learning is to learn a policy &lt;math&gt;\pi&lt;/math&gt;, that when given a state &lt;math&gt;s_t&lt;/math&gt; and goal &lt;math&gt;g&lt;/math&gt; (desired state), can dictate the optimal action &lt;math&gt;a_t&lt;/math&gt;. The optimal action &lt;math&gt;a_t&lt;/math&gt; is defined as an action which maximizes the expected return denoted by &lt;math&gt;R_t&lt;/math&gt; and defined as &lt;math&gt;R_t = \mathbb{E}[\sum_{i = t}^T\gamma^{(i-t)}r_i]&lt;/math&gt;, where &lt;math&gt;r_i = r(s_i, a_i, s_{i+1})&lt;/math&gt; is the reward for performing action &lt;math&gt;a_i&lt;/math&gt; when the current state is &lt;math&gt;s_i&lt;/math&gt; and the goal state is &lt;math&gt;s_{i+1}&lt;/math&gt; and &lt;math&gt;\gamma&lt;/math&gt; is a discount factor which determines the relative importance given to rewards at different times. <br /> <br /> In this paper, goals are not explicitly defined during training. If a goal is not explicitly defined, the agent must be able to generate a set of synthetic goals automatically. Suppose we let an autonomous agent explore an environment with a random policy. After executing each action, start and stop state observations are collected and stored. All state observations are images. For training, the agent can randomly select starting states and goals images from the set of state observations.<br /> <br /> Now given a set of all possible states, a goal, and an initial state, a reinforcement learning framework can be used to find the optimal policy such that a chosen value function is maximized. However, to implement such a framework, a reward function needs to be defined. One choice for the reward is the negative distance between the current state and the goal state, so that maximizing the reward corresponds to minimizing the distance to the goal state.<br /> <br /> [[File:human-giving-goal.png|center|thumb|400px|The task: Make the world look like this image. ]]<br /> <br /> In reinforcement learning, a goal-conditioned Q-function can be used to find a single policy to maximize rewards and therefore reach goal states. A goal-conditioned Q-function &lt;math&gt;Q(s,a,g)&lt;/math&gt; tells us how good an action &lt;math&gt;a&lt;/math&gt; is, given the current state &lt;math&gt;s&lt;/math&gt; and goal &lt;math&gt;g&lt;/math&gt;. For example, a Q-function tells us, “How good is it to move my hand up (action &lt;math&gt;a&lt;/math&gt;), if I’m holding a plate (state &lt;math&gt;s&lt;/math&gt;) and want to put the plate on the table (goal &lt;math&gt;g&lt;/math&gt;)?” Once this Q-function is trained, a goal-conditioned policy can be obtained by performing the following optimization<br /> <br /> &lt;div align=&quot;center&quot;&gt;<br /> &lt;math&gt;\pi(s,g) = max_a Q(s,a,g)&lt;/math&gt;<br /> &lt;/div&gt;<br /> <br /> which effectively says, “choose the best action according to this Q-function.” By using this procedure, one can obtain a policy that maximizes the sum of rewards, i.e. reaches various goals.<br /> <br /> The reason why Q-learning is popular is that it can be trained in an off-policy manner. Therefore, the only things a Q-function needs are samples of state, action, next state, goal, and reward &lt;math&gt;(s,a,s′,g,r)&lt;/math&gt;. This data can be collected by any policy and can be reused across multiples tasks. So a preliminary goal-conditioned Q-learning algorithm looks like this:<br /> <br /> [[File:ql.png|center|600px]]<br /> <br /> From the tuple &lt;math&gt;(s,a,s',g,r)&lt;/math&gt;, an approximate Q-function paramaterized by &lt;math&gt;w&lt;/math&gt; can be trained by minimizing the Bellman error:<br /> <br /> &lt;div align=&quot;center&quot;&gt;<br /> &lt;math&gt;\mathcal{E}(w) = \frac{1}{2} || Q_w(s,a,g) -(r + \gamma \max_{a'} Q_{\overline{w}}(s',a',g)) ||^2 &lt;/math&gt;<br /> &lt;/div&gt;<br /> <br /> where &lt;math&gt;\overline{w}&lt;/math&gt; is treated as some constant.<br /> <br /> The main drawback in this training procedure is collecting data. In theory, one could learn to solve various tasks without even interacting with the world if more data are available. Unfortunately, it is difficult to learn an accurate model of the world, so sampling is usually performed to get state-action-next-state data, (s,a,s′). However, if the reward function &lt;math&gt;r(s,g)&lt;/math&gt; can be accessed, one can retroactively relabel goals and recompute rewards. This way, more data can be artificially generated given a single &lt;math&gt;(s,a,s′)&lt;/math&gt; tuple. As a result, the training procedure can be modified like so:<br /> <br /> [[File:qlr.png|center|600px]]<br /> <br /> This goal resampling makes it possible to simultaneously learn how to reach multiple goals at once without needing more data from the environment. Thus, this simple modification can result in substantially faster learning. However, the method described above makes two major assumptions: (1) you have access to a reward function and (2) you have access to a goal sampling distribution &lt;math&gt;p(g)&lt;/math&gt;. When moving to vision-based tasks where goals are images, both of these assumptions introduce practical concerns.<br /> <br /> For one, a fundamental problem with this reward function is that it assumes that the distance between raw images will yield semantically useful information. But images are noisy and a large amount of information in an image may not be related to the object we analyze. Thus, the distance between two images may not correlate with their semantic distance.<br /> <br /> Second, because the goals are images, a goal image distribution &lt;math&gt;p(g)&lt;/math&gt; is needed so that one can sample goal images. Manually designing a distribution over goal images is a non-trivial task and image generation is still an active field of research. It would be ideal if the agent can autonomously imagine its own goals and learn how to reach them.<br /> <br /> =Variational Autoencoder=<br /> An autoencoder is a type of machine learning model that can learn to extract a robust, space-efficient feature vector from an image. This generative model converts high-dimensional observations &lt;math&gt;x&lt;/math&gt;, like images, into low-dimensional latent variables &lt;math&gt;z&lt;/math&gt;, and vice versa. The model is trained so that the latent variables capture the underlying factors of variation in an image. A current image &lt;math&gt;x&lt;/math&gt; and goal image &lt;math&gt;x_g&lt;/math&gt; can be converted into latent variables &lt;math&gt;z&lt;/math&gt; and &lt;math&gt;z_g&lt;/math&gt;, respectively. These latent variables can then be used to represent the state and goal for the reinforcement learning algorithm. Learning Q functions and policies on top of this low-dimensional latent space rather than directly on images results in faster learning.<br /> <br /> [[File:robot-interpreting-scene.png|center|thumb|600px|The agent encodes the current image (&lt;math&gt;x&lt;/math&gt;) and goal image (&lt;math&gt;x_g&lt;/math&gt;) into a latent space and use distances in that latent space for reward. ]]<br /> <br /> Using the latent variable representations for the images and goals also solves the problem of computing rewards. Instead of using pixel-wise error as our reward, the distance in the latent space is used as the reward to train the agent to reach a goal. The paper shows that this corresponds to rewarding reaching states that maximize the probability of the latent goal &lt;math&gt;z_g&lt;/math&gt;.<br /> <br /> This generative model is also important because it allows an agent to easily generate goals in the latent space. In particular, the authors design the generative model so that latent variables are sampled from the VAE prior. This sampling mechanism is used for two reasons: First, it provides a mechanism for an agent to set its own goals. The agent simply samples a value for the latent variable from the generative model, and tries to reach that latent goal. Second, this resampling mechanism is also used to relabel goals as mentioned above. Since the VAE prior is trained by real images, meaningful latent goals can be sampled from the latent variable prior. This will help the agent set its own goals and practice towards them if no goal is provided at test time.<br /> <br /> [[File:robot-imagining-goals.png|center|thumb|600px|Even without a human providing a goal, our agent can still generate its own goals, both for exploration and for goal relabeling. ]]<br /> <br /> The authors summarize the purpose of the latent variable representation of images as follows: (1) captures the underlying factors of a scene, (2) provides meaningful distances to optimize, and (3) provides an efficient goal sampling mechanism which can be used by the agent to generate its own goals. The overall method is called reinforcement learning with imagined goals (RIG) by the authors.<br /> The process involves starts with collecting data through a simple exploration policy. Possible alternative explorations could be employed here including off-the-shelf exploration bonuses or unsupervised reinforcement learning methods. Then, a VAE latent variable model is trained on state observations and fine-tuned during training. The latent variable model is used for multiple purposes: sampling a latent goal &lt;math&gt;z_g&lt;/math&gt; from the model and conditioning the policy on this goal. All states and goals are embedded using the model’s encoder and then used to train the goal-conditioned value function. The authors then resample goals from the prior and compute rewards in the latent space.<br /> <br /> =Algorithm=<br /> [[File:algorithm1.png|center|thumb|600px|]]<br /> <br /> Algorithm 1 is called reinforcement learning with imagined goals (RIG). The data is first collected via a simple exploration policy. The proposed model allows for alternate exploration policies to be used which include off-the-shelf exploration bonuses or unsupervised reinforcement learning methods. Then, the authors train a VAE latent variable model on state observations and finetune it over the course of training. VAE latent space modeling is used to allow the conditioning of policy on the goal which is sampled from the latent model. The VAE model is also used to encode all the goals and the states. When the goal-conditioned value function is trained, the authors resample prior goals and compute rewards in the latent space using the equation &lt;math display=&quot;inline&quot;&gt; r(s, g) = - || z - z_g ||_A \propto \sqrt{log(e_{\Phi}(z_g | s))} &lt;/math&gt;<br /> <br /> =Experiments=<br /> <br /> The authors evaluated their method against some prior algorithms and ablated versions of their approach on a suite of simulated and real-world tasks: Visual Reacher, Visual Pusher, and Visual Multi-Object Pusher. They compared their model with the following prior works: L&amp;R, DSAE, HER, and Oracle. It is concluded that their approach substantially outperforms the previous methods and is close to the state-based &quot;oracle&quot; method in terms of efficiency and performance.<br /> <br /> The figure below shows the performance of different algorithms on this task. This involved a simulated environment with a Sawyer arm. The authors' algorithm was given only visual input, and the available controls were end-effector velocity. The plots show the distance to the goal state as a function of simulation steps. The oracle, as a baseline, was given true object location information, as opposed to visual pixel information.<br /> <br /> [[File:WF_Sec_11Nov_25_02.png|1000px]]<br /> <br /> <br /> They then investigated the effectiveness of distances in the VAE latent space for the Visual Pusher task. They observed that latent distance significantly outperforms the log probability and pixel mean-squared error. The resampling strategies are also varied while fixing other components of the algorithm to study the effect of relabeling strategy. In this experiment, the RIG, which is an equal mixture of the VAE and Future sampling strategies, performs best. Subsequently, learning with variable numbers of objects was studied by evaluating on a task where the environment, based on the Visual Multi-Object Pusher, randomly contains zero, one, or two objects during testing. The results show that their model can tackle this task successfully.<br /> <br /> Finally, the authors tested the RIG in a real-world robot for its ability to reach user-specified positions and push objects to desired locations, as indicated by a goal image. The robot is trained with access only to 84x84 RGB images and without access to joint angles or object positions. The robot first learns by settings its own goals in the latent space and autonomously practices reaching different positions without human involvement. After a reasonable amount of time of training, the robot is given a goal image. Because the robot has practiced reaching so many goals, it is able to reach this goal without additional training:<br /> <br /> [[File:reaching.JPG|center|thumb|600px|(Left) The robot setup is pictured. (Right) Test rollouts of the learned policy.]]<br /> <br /> The method for reaching only needs 10,000 samples and an hour of real-world interactions.<br /> <br /> They also used RIG to train a policy to push objects to target locations:<br /> <br /> [[File:pushing.JPG|center|thumb|600px|The robot pushing setup is<br /> pictured, with frames from test rollouts of the learned policy.]]<br /> <br /> The pushing task is more complicated and the method requires about 25,000 samples. Since the authors do not have the true position during training, so they used test episode returns as the VAE latent distance reward.<br /> <br /> =Conclusion &amp; Future Work=<br /> <br /> In this paper, a new RL algorithm is proposed to efficiently solve goal-conditioned, vision-based tasks without any ground truth state information or reward functions. The author suggests that one could instead use other representations, such as language and demonstrations, to specify goals. Also, while the paper provides a mechanism to sample goals for autonomous exploration, one can combine the proposed method with existing work by choosing these goals in a more principled way, i.e. a procedure that is not only goal-oriented, but also information seeking or uncertainty aware, to perform even better exploration. Furthermore, combining the idea of this paper with methods from multitask learning and meta-learning is a promising path to create general-purpose agents that can continuously and efficiently acquire skill. Lastly, there are a variety of robot tasks whose state representation would be difficult to capture with sensors, such as manipulating deformable objects or handling scenes with variable number of objects. It is interesting to see whether the RIG can be scaled up to solve these tasks.  A new paper was published last week that built on the framework of goal conditioned Reinforcement Learning to extract state representations based on the actions required to reach them, which is abbreviated ARC for actionable representation for control.<br /> <br /> =Critique=<br /> 1. This paper is novel because it uses visual data and trains in an unsupervised fashion. The algorithm has no access to a ground truth state or to a pre-defined reward function. It can perform well in a real-world environment with no explicit programming.<br /> <br /> 2. From the videos, one major concern is that the output of robotic arm's position is not stable during training and test time. It is likely that the encoder reduces the image features too much so that the images in the latent space are too blury to be used goal images. It would be better if this can be investigated in future. It would be better, if a method is investigated with multiple data sources, and the agent is trained to choose the source which has more complete information. <br /> <br /> 3. The algorithm seems to perform better when there is only one object in the images. For example, in Visual Multi-Object Pusher experiment, the relative positions of two pucks do not correspond well with the relative positions of two pucks in goal images. The same situation is also observed in Variable-object experiment. We may guess that the more information contained in an image, the less likely the robot will perform well. This limits the applicability of the current algorithm to solving real-world problems.<br /> <br /> 4. The instability mentioned in #2 is even more apparent in the multi-object scenario, and appears to result from the model attempting to optimize on the position of both objects at the same time. Reducing the problem to a sequence of single-object targets may reduce the amount of time the robots spends moving between the multiple objects in the scene (which it currently does quite frequently).<br /> <br /> =References=<br /> 1. Lerrel Pinto, Marcin Andrychowicz, Peter Welinder, Wojciech Zaremba, and Pieter Abbeel. Asymmetric<br /> Actor Critic for Image-Based Robot Learning. arXiv preprint arXiv:1710.06542, 2017.<br /> <br /> 2. Pulkit Agrawal, Ashvin Nair, Pieter Abbeel, Jitendra Malik, and Sergey Levine. Learning to Poke by<br /> Poking: Experiential Learning of Intuitive Physics. In Advances in Neural Information Processing Systems<br /> (NIPS), 2016.<br /> <br /> 3. Deepak Pathak, Parsa Mahmoudieh, Guanghao Luo, Pulkit Agrawal, Dian Chen, Yide Shentu, Evan<br /> Shelhamer, Jitendra Malik, Alexei A Efros, and Trevor Darrell. Zero-Shot Visual Imitation. In International<br /> Conference on Learning Representations (ICLR), 2018.<br /> <br /> 4. Timothy P Lillicrap, Jonathan J Hunt, Alexander Pritzel, Nicolas Heess, Tom Erez, Yuval Tassa, David<br /> Silver, and Daan Wierstra. Continuous control with deep reinforcement learning. In International<br /> Conference on Learning Representations (ICLR), 2016.<br /> <br /> 5. Irina Higgins, Arka Pal, Andrei A Rusu, Loic Matthey, Christopher P Burgess, Alexander Pritzel, Matthew<br /> Botvinick, Charles Blundell, and Alexander Lerchner. Darla: Improving zero-shot transfer in reinforcement<br /> learning. International Conference on Machine Learning (ICML), 2017.<br /> <br /> 6. Aravind Srinivas, Allan Jabri, Pieter Abbeel, Sergey Levine, and Chelsea Finn. Universal Planning<br /> Networks. In International Conference on Machine Learning (ICML), 2018.<br /> <br /> 7. Pierre Sermanet, Corey Lynch, Yevgen Chebotar, Jasmine Hsu, Eric Jang, Stefan Schaal, and Sergey<br /> Levine. Time-contrastive networks: Self-supervised learning from video. arXiv preprint arXiv:1704.06888,<br /> 2017.<br /> <br /> 8. Alex Lee, Sergey Levine, and Pieter Abbeel. Learning Visual Servoing with Deep Features and Fitted<br /> Q-Iteration. In International Conference on Learning Representations (ICLR), 2017.<br /> <br /> 9. Online source: https://bair.berkeley.edu/blog/2018/09/06/rig/<br /> <br /> 10. https://arxiv.org/pdf/1811.07819.pdf<br /> <br /> 11. Sergey Levine, Chelsea Finn, Trevor Darrell, and Pieter Abbeel. End-to-End Training of Deep Visuomotor Policies. Journal of Machine Learning Research (JMLR), 17(1):1334–1373, 2016. ISSN 15337928.<br /> <br /> 12. Lerrel Pinto, Marcin Andrychowicz, Peter Welinder, Wojciech Zaremba, and Pieter Abbeel. Asymmetric Actor Critic for Image-Based Robot Learning. arXiv preprint arXiv:1710.06542, 2017.<br /> <br /> 13. Timothy P Lillicrap, Jonathan J Hunt, Alexander Pritzel, Nicolas Heess, Tom Erez, Yuval Tassa, David Silver, and Daan Wierstra. Continuous control with deep reinforcement learning. In International Conference on Learning Representations (ICLR), 2016.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=Unsupervised_Neural_Machine_Translation&diff=41590 Unsupervised Neural Machine Translation 2018-11-27T16:27:36Z <p>Jmmoosa: /* Experiments and Results */</p> <hr /> <div>This paper was published in ICLR 2018, authored by Mikel Artetxe, Gorka Labaka, Eneko Agirre, and Kyunghyun Cho. Open source implementation of this paper is available [https://github.com/artetxem/undreamt here]<br /> <br /> = Introduction =<br /> The paper presents an unsupervised Neural Machine Translation (NMT) method that uses monolingual corpora (single language texts) only. This contrasts with the usual supervised NMT approach which relies on parallel corpora (aligned text) from the source and target languages being available for training. This problem is important because parallel pairing for a majority of languages, e.g. for German-Russian, do not exist.<br /> <br /> Other authors have recently tried to address this problem using semi-supervised approaches (small set of parallel corpora). However, these methods still require a strong cross-lingual signal. The proposed method eliminates the need for cross-lingual information all together and relies solely on monolingual data. The proposed method builds upon the work done recently on unsupervised cross-lingual embeddings by Artetxe et al., 2017 and Zhang et al., 2017.<br /> <br /> The general approach of the methodology is to:<br /> <br /> # Use monolingual corpora in the source and target languages to learn single language word embeddings for both languages separately.<br /> # Align the 2 sets of word embeddings into a single cross lingual (language independent) embedding.<br /> Then iteratively perform:<br /> # Train an encoder-decoder model to reconstruct noisy versions of sentences in both source and target languages separately. The model uses a single encoder and different decoders for each language. The encoder uses cross lingual word embedding.<br /> # Tune the decoder in each language by back-translating between the source and target language.<br /> <br /> = Background =<br /> <br /> ===Word Embedding Alignment===<br /> <br /> The paper uses word2vec [Mikolov, 2013] to convert each monolingual corpora to vector embeddings. They improve the continuous Skip-gram model for learning high-quality distributed vector representations that capture a large number of precise syntactic and semantic word relationships. These embeddings have been shown to contain the contextual and syntactic features independent of language, and so, in theory, there could exist a linear map that maps the embeddings from language L1 to language L2. <br /> <br /> Figure 1 shows an example of aligning the word embeddings in English and French.<br /> <br /> [[File:Figure1_lwali.png|frame|400px|center|Figure 1: the word embeddings in English and French (a &amp; b), and (c) shows the aligned word embeddings after some linear transformation.[Gouws,2016]]]<br /> <br /> Most cross-lingual word embedding methods use bilingual signals in the form of parallel corpora. Usually, the embedding mapping methods train the embeddings in different languages using monolingual corpora, then use a linear transformation to map them into a shared space based on a bilingual dictionary.<br /> <br /> The paper uses the methodology proposed by [Artetxe, 2017] to do cross-lingual embedding aligning in an unsupervised manner and without parallel data. Without going into the details, the general approach of this paper is starting from a seed dictionary of numeral pairings (e.g. 1-1, 2-2, etc.), to iteratively learn the mapping between 2 language embeddings, while concurrently improving the dictionary with the learned mapping at each iteration. This is in contrast to earlier work which used dictionaries of a few thousand words.<br /> <br /> ===Other related work and inspirations===<br /> ====Statistical Decipherment for Machine Translation====<br /> There has been significant work in statistical deciphering techniques (decipherment is the discovery of the meaning of texts written in ancient or obscure languages or scripts) to develop a machine translation model from monolingual data (Ravi &amp; Knight, 2011; Dou &amp; Knight, 2012). These techniques treat the source language as ciphertext (encrypted or encoded information because it contains a form of the original plaintext that is unreadable by a human or computer without the proper cipher for decoding) and model the generation process of the ciphertext as a two-stage process, which includes the generation of the original English sequence and the probabilistic replacement of the words in it. This approach takes advantage of the incorporation of syntactic knowledge of the languages. The use of word embeddings has also shown improvements in statistical decipherment.<br /> <br /> ====Low-Resource Neural Machine Translation====<br /> There are also proposals that use techniques other than direct parallel corpora to do NMT. Some use a third intermediate language that is well connected to the source and target languages independently. For example, if we want to translate German into Russian, we can use English as an intermediate language (German-English and then English-Russian) since there are plenty of resources to connect English and other languages. Johnson et al. (2017) show that a multilingual extension of a standard NMT architecture performs reasonably well for language pairs when no parallel data for the source and target data was used during training. Firat et al. (2016) and Chen et al. (2017) showed that the use of advanced models like teacher-student framework can be used to improve over the baseline of translating using a third intermediate language.<br /> <br /> Other works use monolingual data in combination with scarce parallel corpora. A simple but effective technique is back-translation [Sennrich et al, 2016]. First, a synthetic parallel corpus in the target language is created. Translated sentence and back translated to the source language and compared with the original sentence.<br /> <br /> The most important contribution to the problem of training an NMT model with monolingual data was from [He, 2016], which trains two agents to translate in opposite directions (e.g. French → English and English → French) and teach each other through reinforcement learning. However, this approach still required a large parallel corpus for a warm start (about 1.2 million sentences), while this paper does not use parallel data.<br /> <br /> = Methodology =<br /> <br /> The corpora data is first preprocessed in a standard way to tokenize and case the words. The authors also experimented with an alternate way of tokenizing words by using Byte-Pair Encoding (BPE) [Sennrich, 2016](Byte pair encoding or digram coding is a simple form of data compression in which the most common pair of consecutive bytes of data is replaced with a byte that does not occur within that data). BPE has been shown to improve embeddings of rare-words. The vocabulary was limited to the most frequent 50,000 tokens (BPE tokens or words).<br /> <br /> The tokens were then converted to word embeddings using word2vec with 300 dimensions and then aligned between languages using the method proposed by [Artetxe, 2017]. The alignment method proposed by [Artetxe, 2017] is also used as a baseline to evaluate this model as discussed later in Results.<br /> <br /> The translation model uses a standard encoder-decoder model with attention. The encoder is a 2-layer bidirectional RNN, and the decoder is a 2 layer RNN. All RNNs use GRU cells with 600 hidden units. The encoder is shared by the source and target language, while the decoder is different for each language.<br /> <br /> Although the architecture uses standard models, the proposed system differs from the standard NMT through 3 aspects:<br /> <br /> #Dual structure: NMT usually are built for one direction translations English&lt;math&gt;\rightarrow&lt;/math&gt;French or French&lt;math&gt;\rightarrow&lt;/math&gt;English, whereas the proposed model trains both directions at the same time translating English&lt;math&gt;\leftrightarrow&lt;/math&gt;French.<br /> #Shared encoder: one encoder is shared for both source and target languages in order to produce a representation in the latent space independent of language, and each decoder learns to transform the representation back to its corresponding language. <br /> #Fixed embeddings in the encoder: Most NMT systems initialize the embeddings and update them during training, whereas the proposed system trains the embeddings in the beginning and keeps these fixed throughout training, so the encoder receives language-independent representations of the words. This approach ensures that the encoder only learns how to compose the language independent representations to build representations of the larger phrases. This requires existing unsupervised methods to create embeddings using monolingual corpora as discussed in the background. In the proposed method, even though the embeddings used are cross-lingual, the vocabulary used for each language is different. This way if the same word occurs in two different languages and has a different meaning in the respective languages then each word would get a different vector in the respective languages despite being in the same vector space. <br /> <br /> [[File:Figure2_lwali.png|600px|center]]<br /> <br /> The translation model iteratively improves the encoder and decoder by performing 2 tasks: Denoising, and Back-translation.<br /> <br /> ===Denoising===<br /> Random noise is added to the input sentences in order to allow the model to learn some structure of languages. Without noise, the model would simply learn to copy the input word by word. Noise also allows the shared encoder to compose the embeddings of both languages in a language-independent fashion, and then be decoded by the language dependent decoder.<br /> <br /> Denoising works by reconstructing a noisy version of a sentence back into the original sentence in the same language. In mathematical form, if &lt;math&gt;x&lt;/math&gt; is a sentence in language L1:<br /> <br /> # Construct &lt;math&gt;C(x)&lt;/math&gt;, noisy version of &lt;math&gt;x&lt;/math&gt;. In the proposed model, &lt;math&gt;C(x)&lt;/math&gt; is constructed by randomly swapping contiguous words. If the length of the input sequence &lt;math&gt;x&lt;/math&gt; is &lt;math&gt;N&lt;/math&gt;, then a total of &lt;math&gt;\frac{N}{2}&lt;/math&gt; such swaps are made.<br /> # Input &lt;math&gt;C(x)&lt;/math&gt; into the current iteration of the shared encoder and use decoder for L1 to get reconstructed &lt;math&gt;\hat{x}&lt;/math&gt;.<br /> <br /> The training objective is to minimize the cross entropy loss between &lt;math&gt;{x}&lt;/math&gt; and &lt;math&gt;\hat{x}&lt;/math&gt;.<br /> <br /> In other words, the whole system is optimized to take an input sentence in a given language, encode it using the shared encoder, and reconstruct the original sentence using the decoder of that language.<br /> <br /> The proposed noise function is to perform &lt;math&gt;N/2&lt;/math&gt; random swaps of words that are contiguous, where &lt;math&gt;N&lt;/math&gt; is the number of words in the sentence. This noise model also helps reduce the reliance of the model on the order of words in a sentence which may be different in the source and target languages. The system will also need to correctly learn the internal structure of a language to decode the sentence into the correct order.<br /> <br /> ===Back-Translation===<br /> <br /> With only denoising, the system doesn't have a goal to improve the actual translation. Back-translation works by using the decoder of the target language to create a translation, then encoding this translation and decoding again using the source decoder to reconstruct the original sentence. In mathematical form, if &lt;math&gt;C(x)&lt;/math&gt; is a noisy version of sentence &lt;math&gt;x&lt;/math&gt; in language L1:<br /> <br /> # Input &lt;math&gt;C(x)&lt;/math&gt; into the current iteration of shared encoder and the decoder in L2 to construct translation &lt;math&gt;y&lt;/math&gt; in L2,<br /> # Construct &lt;math&gt;C(y)&lt;/math&gt;, noisy version of translation &lt;math&gt;y&lt;/math&gt;,<br /> # Input &lt;math&gt;C(y)&lt;/math&gt; into the current iteration of shared encoder and the decoder in L1 to reconstruct &lt;math&gt;\hat{x}&lt;/math&gt; in L1.<br /> <br /> The training objective is to minimize the cross entropy loss between &lt;math&gt;{x}&lt;/math&gt; and &lt;math&gt;\hat{x}&lt;/math&gt;.<br /> <br /> This approach alleviates issues that would have resulted from the training procedure only dealing with a single language at a time. The corpus of a language is converted to a synthetic translation, and trained to predict the original sentence from this translation. <br /> <br /> Contrary to standard back-translation that uses an independent model to back-translate the entire corpus at once, the system uses mini-batches and the dual architecture to generate pseudo-translations and then train the model with the translation, improving the model iteratively as the training progresses.<br /> <br /> ===Training===<br /> <br /> Training is done by alternating these 2 objectives from mini-batch to mini-batch. Each iteration would perform one mini-batch of denoising for L1, another one for L2, one mini-batch of back-translation from L1 to L2, and another one from L2 to L1. The procedure is repeated until convergence. <br /> During decoding, greedy decoding was used at training time for back-translation, but actual inference at test time was done using beam-search with a beam size of 12.<br /> <br /> Optimizer choice and other hyperparameters can be found in the paper.<br /> <br /> =Experiments and Results=<br /> <br /> The model was evaluated using the Bilingual Evaluation Understudy (BLEU) Score, which is typically used to evaluate the quality of the translation, using a reference (ground-truth) translation.<br /> <br /> The paper trained translation model under 3 different settings to compare the performance (Table 1). All training and testing data used was from a standard NMT dataset, WMT'14.<br /> <br /> [[File:Table1_lwali.png|600px|center]]<br /> <br /> The results exhibit that for the proposed system to work properly, backtranslation is necessary. The denoising technique alone is below the baseline while big improvements appear when introducing backtranslation.<br /> <br /> ===Unsupervised===<br /> <br /> The model only has access to monolingual corpora, using the News Crawl corpus with articles from 2007 to 2013. The baseline for unsupervised is the method proposed by [Artetxe, 2017], which was the unsupervised word vector alignment method discussed in the Background section.<br /> <br /> The paper adds each component piece-wise when doing an evaluation to test the impact each piece has on the final score. As shown in Table 1, Unsupervised results compared to the baseline of word-by-word results are strong, with improvement between 40% to 140%. Results also show that back-translation is essential. Denoising doesn't show a big improvement however it is required for back-translation, because otherwise, back-translation would translate nonsensical sentences. The addition of backtranslation, however, does show large improvement on all tested cases.<br /> <br /> For the BPE experiment, results show it helps in some language pairs but detract in some other language pairs. This is because while BPE helped to translate some rare words, it increased the error rates in other words. It also did not perform well when translating named entities which occur infrequently.<br /> <br /> ===Semi-supervised===<br /> <br /> Since there is often some small parallel data but not enough to train a Neural Machine Translation system, the authors test a semi-supervised setting with the same monolingual data from the unsupervised settings together with either 10,000 or 100,000 random sentence pairs from the News Commentary parallel corpus. The supervision is included to improve the model during the back-translation stage to directly predict sentences that are in the parallel corpus.<br /> <br /> Table 1 shows that the model can greatly benefit from the addition of a small parallel corpus to the monolingual corpora. It is surprising that semi-supervised in row 6 outperforms supervised in row 7, one possible explanation is that both the semi-supervised training set and the test set belong to the news domain, whereas the supervised training set is all domains of corpora.<br /> <br /> ===Supervised===<br /> <br /> This setting provides an upper bound to the unsupervised proposed system. The data used was the combination of all parallel corpora provided at WMT 2014, which includes Europarl, Common Crawl and News Commentary for both language pairs plus the UN and the Gigaword corpus for French- English. Moreover, the authors use the same subsets of News Commentary alone to run the separate experiments in order to compare with the semi-supervised scenario.<br /> <br /> The Comparable NMT was trained using the same proposed model except it does not use monolingual corpora, and consequently, it was trained without denoising and back-translation. The proposed model under a supervised setting does much worse than the state of the NMT in row 10, which suggests that adding the additional constraints to enable unsupervised learning also limits the potential performance. To improve these results, the authors also suggest using larger models, longer training times, and incorporating several well-known NMT techniques.<br /> <br /> ===Qualitative Analysis===<br /> <br /> [[File:Table2_lwali.png|600px|center]]<br /> <br /> Table 2 shows 4 examples of French to English translations, which shows that the high-quality translations are produced by the proposed system, and this system adequately models non-trivial translation relations. Example 1 and 2 show that the model is able to not only go beyond a literal word-by-word substitution but also model structural differences in the languages (ex.e, it correctly translates &quot;l’aeroport international de Los Angeles&quot; as &quot;Los Angeles International Airport&quot;, and it is capable of producing high-quality translations of long and more complex sentences. However, in Example 3 and 4, the system failed to translate the months and numbers correctly and having difficulty with comprehending odd sentence structures, which means that the proposed system has limitations. Specially, the authors points that the proposed model has difficulties to preserve some concrete details from source sentences. Results also show, the proposed model's translation quality often lags behind that of a standard supervised NMT system and also there are also some cases where there are both fluency and adequacy problems that severely hinders understanding the original message from the proposed translation, suggesting that there is still room for improvement and possible future work.<br /> <br /> =Conclusions and Future Work=<br /> <br /> The paper presented an unsupervised model to perform translations with monolingual corpora by using an attention-based encoder-decoder system and training using denoise and back-translation.<br /> <br /> Although experimental results show that the proposed model is effective as an unsupervised approach, there is significant room for improvement when using the model in a supervised way, suggesting the model is limited by the architectural modifications. Some ideas for future improvement include:<br /> *Instead of using fixed cross-lingual word embeddings at the beginning which forces the encoder to learn a common representation for both languages, progressively update the weight of the embeddings as training progresses.<br /> *Decouple the shared encoder into 2 independent encoders at some point during training<br /> *Progressively reduce the noise level<br /> *Incorporate character level information into the model, which might help address some of the adequacy issues observed in our manual analysis<br /> *Use other noise/denoising techniques, and analyze their effect in relation to the typological divergences of different language pairs.<br /> <br /> = Critique =<br /> <br /> While the idea is interesting and the results are impressive for an unsupervised approach, much of the model had actually already been proposed by other papers that are referenced. The paper doesn't add a lot of new ideas but only builds on existing techniques and combines them in a different way to achieve good experimental results. The paper is not a significant algorithmic contribution. <br /> <br /> As pointed out, in order to critically analyze the effect of the algorithm, we need to formulate the algorithm in terms of mathematics.<br /> <br /> The results showed that the proposed system performed far worse than the state of the art when used in a supervised setting, which is concerning and shows that the techniques used creates a limitation and a ceiling for performance.<br /> <br /> Additionally, there was no rigorous hyperparameter exploration/optimization for the model. As a result, it is difficult to conclude whether the performance limit observed in the constrained supervised model is the absolute limit, or whether this could be overcome in both supervised/unsupervised models with the right constraints to achieve more competitive results. <br /> <br /> The best results shown are between two very closely related languages(English and French), and does much worse for English - German, even though English and German are also closely related (but less so than English and French) which suggests that the model may not be successful at translating between distant language pairs. More testing would be interesting to see.<br /> <br /> The results comparison could have shown how the semi-supervised version of the model scores compared to other semi-supervised approaches as touched on in the other works section.<br /> <br /> Their qualitative analysis just checks whether their proposed unsupervised NMT generates a sensible translation. It is limited and it needs further detailed analysis regarding the characteristics and properties of translation which is generated by unsupervised NMT.<br /> <br /> * (As pointed out by an anonymous reviewer [https://openreview.net/forum?id=Sy2ogebAW])Future work is vague: “we would like to detect and mitigate the specific causes…” “We also think that a better handling of rare words…” That’s great, but how will you do these things? Do you have specific reasons to think this, or ideas on how to approach them? Otherwise, this is just hand-waving.<br /> <br /> = References =<br /> #'''[Mikolov, 2013]''' Tomas Mikolov, Ilya Sutskever, Kai Chen, Greg S Corrado, and Jeff Dean. &quot;Distributed representations of words and phrases and their compositionality.&quot;<br /> #'''[Artetxe, 2017]''' Mikel Artetxe, Gorka Labaka, Eneko Agirre, &quot;Learning bilingual word embeddings with (almost) no bilingual data&quot;.<br /> #'''[Gouws,2016]''' Stephan Gouws, Yoshua Bengio, Greg Corrado, &quot;BilBOWA: Fast Bilingual Distributed Representations without Word Alignments.&quot;<br /> #'''[He, 2016]''' Di He, Yingce Xia, Tao Qin, Liwei Wang, Nenghai Yu, Tieyan Liu, and Wei-Ying Ma. &quot;Dual learning for machine translation.&quot;<br /> #'''[Sennrich,2016]''' Rico Sennrich and Barry Haddow and Alexandra Birch, &quot;Neural Machine Translation of Rare Words with Subword Units.&quot;<br /> #'''[Ravi &amp; Knight, 2011]''' Sujith Ravi and Kevin Knight, &quot;Deciphering foreign language.&quot;<br /> #'''[Dou &amp; Knight, 2012]''' Qing Dou and Kevin Knight, &quot;Large scale decipherment for out-of-domain machine translation.&quot;<br /> #'''[Johnson et al. 2017]''' Melvin Johnson,et al, &quot;Google’s multilingual neural machine translation system: Enabling zero-shot translation.&quot;<br /> #'''[Zhang et al. 2017]''' Meng Zhang, Yang Liu, Huanbo Luan, and Maosong Sun. &quot;Adversarial training for unsupervised bilingual lexicon induction&quot;</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=Unsupervised_Neural_Machine_Translation&diff=41158 Unsupervised Neural Machine Translation 2018-11-23T15:23:20Z <p>Jmmoosa: /* Critique */</p> <hr /> <div>This paper was published in ICLR 2018, authored by Mikel Artetxe, Gorka Labaka, Eneko Agirre, and Kyunghyun Cho.<br /> <br /> = Introduction =<br /> The paper presents an unsupervised Neural Machine Translation(NMT) method to machine translation using only monolingual corpora without any alignment between sentences or documents. Monolingual corpora are text corpora that are made up of one language only. This contrasts with the usual Supervised NMT approach that uses parallel corpora, where two corpora are the direct translation of each other and the translations are aligned by words or sentences. This problem is important as NMT often requires large parallel corpora to achieve good results, however, in reality, there are a number of languages that lack parallel pairing, e.g. for German-Russian.<br /> <br /> Other authors have recently tried to address this problem as well as semi-supervised approaches but these methods still require a strong cross-lingual signal. The proposed method eliminates the need for a cross-lingual information, relying solely on monolingual data.<br /> <br /> The general approach of the methodology is to:<br /> <br /> # Use monolingual corpora in the source and target languages to learn source and target word embeddings.<br /> # Align the 2 sets of word embeddings in the same latent space.<br /> Then iteratively perform:<br /> # Train an encoder-decoder to reconstruct noisy versions of sentence embeddings for both source and target language, where the encoder is shared and the decoder is different in each language.<br /> # Tune the decoder in each language by back-translating between the source and target language.<br /> <br /> = Background =<br /> <br /> ===Word Embedding Alignment===<br /> <br /> The paper uses word2vec [Mikolov, 2013] to convert each monolingual corpora to vector embeddings. These embeddings have been shown to contain the contextual and syntactic features independent of language, and so, in theory, there could exist a linear map that maps the embeddings from language L1 to language L2. <br /> <br /> Figure 1 shows an example of aligning the word embeddings in English and French.<br /> <br /> [[File:Figure1_lwali.png|frame|400px|center|Figure 1: the word embeddings in English and French (a &amp; b), and (c) shows the aligned word embeddings after some linear transformation.[Gouws,2016]]]<br /> <br /> Most cross-lingual word embedding methods use bilingual signals in the form of parallel corpora. Usually, the embedding mapping methods train the embeddings in different languages using monolingual corpora, then use a linear transformation to map them into a shared space based on a bilingual dictionary.<br /> <br /> The paper uses the methodology proposed by [Artetxe, 2017] to do cross-lingual embedding aligning in an unsupervised manner and without parallel data. Without going into the details, the general approach of this paper is starting from a seed dictionary of numeral pairings (e.g. 1-1, 2-2, etc.), to iteratively learn the mapping between 2 language embeddings, while concurrently improving the dictionary with the learned mapping at each iteration. <br /> <br /> ===Other related work and inspirations===<br /> ====STATISTICAL DECIPHERMENT FOR MACHINE TRANSLATION====<br /> There has been significant work in statistical deciphering technique to induce a machine translation model from monolingual data, which similar to the noisy-channel model used by SMT(Ravi &amp; Knight, 2011; Dou &amp; Knight, 2012). These techniques treat the source language as ciphertext and models the distribution of the ciphertext. This approach is able to take advantage of the incorporation of syntactic knowledge of the languages. It shows that word embeddings implementation improves statistical decipherment in machine translation.<br /> <br /> ====LOW-RESOURCE NEURAL MACHINE TRANSLATION====<br /> There are also proposals that use techniques other than direct parallel corpora to do neural machine translation(NMT). Some use a third intermediate language that is well connected to 2 other languages that otherwise have little direct resources. For example, we want to translate German into Russian, but little direct-source for these two languages, we can use English as an intermediate language(German-English and English-Russian) since there are plenty of resources to connect English and other languages. Johnson et al. (2017) show that a multilingual extension of a standard NMT architecture performs reasonably well even for language pairs which have no direct data was given.<br /> <br /> Other works use monolingual data in combination with scarce parallel corpora. Creating a synthetic parallel corpus by backtranslating a monolingual corpus in the target language is one of simple but effective approach.<br /> <br /> The most important contribution to the problem of training an NMT model with monolingual data was from [He, 2016], which trains two agents to translate in opposite directions (e.g. French → English and English → French) and teach each other through reinforcement learning. However, this approach still required a large parallel corpus for a warm start, while our paper does not use parallel data.<br /> <br /> = Methodology =<br /> <br /> The corpora data is first processed in a standard way to tokenize and case the words. The authors also experiment with an additional way of translation using Byte-Pair Encoding(BPE) [Sennrich, 2016], where the translation is done by sub-words instead of words. BPE is often used to improve rare-word translations. To test the effectiveness of BPE, they limited the vocabulary to the most frequent 50,000 BPE tokens.<br /> <br /> The words or BPEs are then converted to word embeddings using word2vec with 300 dimensions and then aligned between languages using the method proposed by [Artetxe, 2017]. The alignment method proposed by [Artetxe, 2017] is also used as a baseline to evaluate this model as discussed later in Results.<br /> <br /> The translation model uses a standard encoder-decoder model with attention. The encoder is a 2-layer bidirectional RNN, and the decoder is a 2 layer RNN. All RNNs use GRU cells with 600 hidden units. The encoder is shared by the source and target language, while the decoder is different by language.<br /> <br /> Although the architecture uses standard models, the proposed system differs from the standard NMT through 3 aspects:<br /> <br /> #Dual structure: NMT usually are built for one direction translations English&lt;math&gt;\rightarrow&lt;/math&gt;French or French&lt;math&gt;\rightarrow&lt;/math&gt;English, whereas the proposed model trains both directions at the same time translating English&lt;math&gt;\leftrightarrow&lt;/math&gt;French.<br /> #Shared encoder: one encoder is shared for both source and target languages in order to produce a representation in the latent space independent of language, and each decoder learns to transform the representation back to its corresponding language. <br /> #Fixed embeddings in the encoder: Most NMT systems initialize the embeddings and update them during training, whereas the proposed system trains the embeddings in the beginning and keeps these fixed throughout training, so the encoder receives language-independent representations of the words. This requires existing unsupervised methods to create embeddings using monolingual corpora as discussed in the background.<br /> <br /> [[File:Figure2_lwali.png|600px|center]]<br /> <br /> The translation model iteratively improves the encoder and decoder by performing 2 tasks: Denoising, and Back-translation.<br /> <br /> ===Denoising===<br /> <br /> Random noise is added to the input sentences in order to allow the model to learn some structure of languages. Without noise, the model would simply learn to copy the input word by word. Noise also allows the shared encoder to compose the embeddings of both<br /> languages in a language-independent fashion, and then be decoded by the language dependent decoder.<br /> <br /> Denoising works to reconstruct a noisy version of the same language back to the original sentence. In mathematical form, if &lt;math&gt;x&lt;/math&gt; is a sentence in language L1:<br /> <br /> # Construct &lt;math&gt;C(x)&lt;/math&gt;, noisy version of &lt;math&gt;x&lt;/math&gt;,<br /> # Input &lt;math&gt;C(x)&lt;/math&gt; into the current iteration of the shared encoder and use decoder for L1 to get reconstructed &lt;math&gt;\hat{x}&lt;/math&gt;.<br /> <br /> The training objective is to minimize the cross entropy loss between &lt;math&gt;{x}&lt;/math&gt; and &lt;math&gt;\hat{x}&lt;/math&gt;.<br /> <br /> In other words, the whole system is optimized to take an input sentence in a given language, encode it using the shared encoder, and reconstruct the original sentence using the decoder of that language.<br /> <br /> The proposed noise function is to perform &lt;math&gt;N/2&lt;/math&gt; random swaps of words that are near each other, where &lt;math&gt;N&lt;/math&gt; is the number of words in the sentence.<br /> <br /> ===Back-Translation===<br /> <br /> With only denoising, the system doesn't have a goal to improve the actual translation. Back-translation works by using the decoder of the target language to create a translation, then encoding this translation and decoding again using the source decoder to reconstruct a the original sentence. In mathematical form, if &lt;math&gt;C(x)&lt;/math&gt; is a noisy version of sentence &lt;math&gt;x&lt;/math&gt; in language L1:<br /> <br /> # Input &lt;math&gt;C(x)&lt;/math&gt; into the current iteration of shared encoder and the decoder in L2 to construct translation &lt;math&gt;y&lt;/math&gt; in L1,<br /> # Construct &lt;math&gt;C(y)&lt;/math&gt;, noisy version of translation &lt;math&gt;y&lt;/math&gt;,<br /> # Input &lt;math&gt;C(y)&lt;/math&gt; into the current iteration of shared encoder and the decoder in L1 to reconstruct &lt;math&gt;\hat{x}&lt;/math&gt; in L1.<br /> <br /> The training objective is to minimize the cross entropy loss between &lt;math&gt;{x}&lt;/math&gt; and &lt;math&gt;\hat{x}&lt;/math&gt;.<br /> <br /> Contrary to standard back-translation that uses an independent model to back-translate the entire corpus at one time, the system uses mini-batches and the dual architecture to generate pseudo-translations and then train the model with the translation, improving the model iteratively as the training progresses.<br /> <br /> ===Training===<br /> <br /> Training is done by alternating these 2 objectives from mini-batch to mini-batch. Each iteration would perform one mini-batch of denoising for L1, another one for L2, one mini-batch of back-translation from L1 to L2, and another one from L2 to L1. The procedure is repeated until convergence. <br /> During decoding, greedy decoding was used at training time for back-translation, but actual inference at test time was done using beam-search with a beam size of 12.<br /> <br /> Optimizer choice and other hyperparameters can be found in the paper.<br /> <br /> =Experiments and Results=<br /> <br /> The model is evaluated using the Bilingual Evaluation Understudy(BLEU) Score, which is typically used to evaluate the quality of the translation, using a reference (ground-truth) translation.<br /> <br /> The paper trains translation model under 3 different settings to compare the performance (Table 1). All training and testing data used was from a standard NMT dataset, WMT'14.<br /> <br /> [[File:Table1_lwali.png|600px|center]]<br /> <br /> ===Unsupervised===<br /> <br /> The model only has access to monolingual corpora, using the News Crawl corpus with articles from 2007 to 2013. The baseline for unsupervised is the method proposed by [Artetxe, 2017], which was the unsupervised word vector alignment method discussed in the Background section.<br /> <br /> The paper adds each component piece-wise when doing an evaluation to test the impact each piece has on the final score. As shown in Table1, Unsupervised results compared to the baseline of word-by-word results are strong, with improvement between 40% to 140%. Results also show that back-translation is essential. Denoising doesn't show a big improvement however it is required for back-translation, because otherwise, back-translation would translate nonsensical sentences.<br /> <br /> For the BPE experiment, results show it helps in some language pairs but detract in some other language pairs. This is because while BPE helped to translate some rare words, it increased the error rates in other words.<br /> <br /> ===Semi-supervised===<br /> <br /> Since there is often some small parallel data but not enough to train a Neural Machine Translation system, the authors test a semi-supervised setting with the same monolingual data from the unsupervised settings together with either 10,000 or 100,000 random sentence pairs from the News Commentary parallel corpus. The supervision is included to improve the model during the back-translation stage to directly predict sentences that are in the parallel corpus.<br /> <br /> Table1 shows that the model can greatly benefit from the addition of a small parallel corpus to the monolingual corpora. It is surprising that semi-supervised in row 6 outperforms supervised in row 7, one possible explanation is that both the semi-supervised training set and the test set belong to the news domain, whereas the supervised training set is all domains of corpora.<br /> <br /> ===Supervised===<br /> <br /> This setting provides an upper bound to the unsupervised proposed system. The data used was the combination of all parallel corpora provided at WMT 2014, which includes Europarl, Common Crawl and News Commentary for both language pairs plus the UN and the Gigaword corpus for French- English. Moreover, the authors use the same subsets of News Commentary alone to run the separate experiments in order to compare with the semi-supervised scenario.<br /> <br /> The Comparable NMT was trained using the same proposed model except it does not use monolingual corpora, and consequently, it was trained without denoising and back-translation. The proposed model under a supervised setting does much worse than the state of the NMT in row 10, which suggests that adding the additional constraints to enable unsupervised learning also limits the potential performance. To improve these results, the authors also suggest to use larger models, longer training times, and incorporating several well-known NMT techniques.<br /> <br /> ===Qualitative Analysis===<br /> <br /> [[File:Table2_lwali.png|600px|center]]<br /> <br /> Table 2 shows 4 examples of French to English translations, which shows that the high-quality translations are produces by the proposed system, and this system adequately models non-trivial translation relations. Example 1 and 2 show that the model is able to not only go beyond a literal word-by-word substitution but also model structural differences in the languages (ex.e, it correctly translates &quot;l’aeroport international de Los Angeles&quot; as &quot;Los Angeles International Airport&quot;, and it is capable of producing high-quality translations of long and more complex sentences. However, in Example 3 and 4, the system failed to translate the months and numbers correctly and having difficulty with comprehending odd sentence structures, which means that the proposed system has limitations. Specially, the authors points that the proposed model has difficulties to preserve some concrete details from source sentences.<br /> <br /> =Conclusions and Future Work=<br /> <br /> The paper presented an unsupervised model to perform translations with monolingual corpora by using an attention-based encoder-decoder system and training using denoise and back-translation.<br /> <br /> Although experimental results show that the proposed model is effective as an unsupervised approach, there is significant room for improvement when using the model in a supervised way, suggesting the model is limited by the architectural modifications. Some ideas for future improvement include:<br /> *Instead of using fixed cross-lingual word embeddings at the beginning which forces the encoder to learn a common representation for both languages, progressively update the weight of the embeddings as training progresses.<br /> *Decouple the shared encoder into 2 independent encoders at some point during training<br /> *Progressively reduce the noise level<br /> *Incorporate character level information into the model, which might help address some of the adequacy issues observed in our manual analysis<br /> *Use other noise/denoising techniques, and analyze their effect in relation to the typological divergences of different language pairs.<br /> <br /> = Critique =<br /> <br /> While the idea is interesting and the results are impressive for an unsupervised approach, much of the model had actually already been proposed by other papers that are referenced. The paper doesn't add a lot of new ideas but only builds on existing techniques and combines them in a different way to achieve good experimental results. The paper is not a significant algorithmic contribution. <br /> <br /> The results showed that the proposed system performed far worse than the state of the art when used in a supervised setting, which is concerning and shows that the techniques used creates a limitation and a ceiling for performance.<br /> <br /> Additionally, there was no rigorous hyperparameter exploration/optimization for the model. As a result, it is difficult to conclude whether the performance limit observed in the constrained supervised model is the absolute limit, or whether this could be overcome in both supervised/unsupervised models with the right constraints to achieve more competitive results. <br /> <br /> The best results shown are between two very closely related languages(English and French), and does much worse for English - German, even though English and German are also closely related (but less so than English and French) which suggests that the model may not be successful at translating between distant language pairs. More testing would be interesting to see.<br /> <br /> The results comparison could have shown how the semi-supervised version of the model scores compared to other semi-supervised approaches as touched on in the other works section.<br /> <br /> * (As pointed out by an annonymous reviewer [https://openreview.net/forum?id=Sy2ogebAW])Future work is vague: “we would like to detect and mitigate the specific causes…” “We also think that a better handling of rare words…” That’s great, but how will you do these things? Do you have specific reasons to think this, or ideas on how to approach them? Otherwise, this is just hand-waving.<br /> <br /> = References =<br /> #'''[Mikolov, 2013]''' Tomas Mikolov, Ilya Sutskever, Kai Chen, Greg S Corrado, and Jeff Dean. &quot;Distributed representations of words and phrases and their compositionality.&quot;<br /> #'''[Artetxe, 2017]''' Mikel Artetxe, Gorka Labaka, Eneko Agirre, &quot;Learning bilingual word embeddings with (almost) no bilingual data&quot;.<br /> #'''[Gouws,2016]''' Stephan Gouws, Yoshua Bengio, Greg Corrado, &quot;BilBOWA: Fast Bilingual Distributed Representations without Word Alignments.&quot;<br /> #'''[He, 2016]''' Di He, Yingce Xia, Tao Qin, Liwei Wang, Nenghai Yu, Tieyan Liu, and Wei-Ying Ma. &quot;Dual learning for machine translation.&quot;<br /> #'''[Sennrich,2016]''' Rico Sennrich and Barry Haddow and Alexandra Birch, &quot;Neural Machine Translation of Rare Words with Subword Units.&quot;<br /> #'''[Ravi &amp; Knight, 2011]''' Sujith Ravi and Kevin Knight, &quot;Deciphering foreign language.&quot;<br /> #'''[Dou &amp; Knight, 2012]''' Qing Dou and Kevin Knight, &quot;Large scale decipherment for out-of-domain machine translation.&quot;<br /> #'''[Johnson et al. 2017]''' Melvin Johnson,et al, &quot;Google’s multilingual neural machine translation system: Enabling zero-shot translation.&quot;</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=Deep_Reinforcement_Learning_in_Continuous_Action_Spaces_a_Case_Study_in_the_Game_of_Simulated_Curling&diff=41157 Deep Reinforcement Learning in Continuous Action Spaces a Case Study in the Game of Simulated Curling 2018-11-23T15:16:20Z <p>Jmmoosa: /* Policy Network */</p> <hr /> <div>This page provides a summary and critique of the paper '''Deep Reinforcement Learning in Continuous Action Spaces: a Case Study in the Game of Simulated Curling''' [[http://proceedings.mlr.press/v80/lee18b/lee18b.pdf Online Source]], published in ICML 2018. The source code for this paper is available [https://github.com/leekwoon/KR-DL-UCT here]<br /> <br /> = Introduction and Motivation =<br /> <br /> In recent years, Reinforcement Learning methods have been applied to many different games, such as chess and checkers. More recently, the use of CNN's has allowed neural networks to out-perform humans in many difficult games, such as Go. However, many of these cases involve a discrete state or action space; the number of actions a player can take and/or the number of possible game states are finite. <br /> <br /> Interacting with the real world (e.g.; a scenario that involves moving physical objects) typically involves working with a continuous action space. It is thus important to develop strategies for dealing with continuous action spaces. Deep neural networks that are designed to succeed in finite action spaces are not necessarily suitable for continuous action space problems. This is due to the fact that deterministic discretization of a continuous action space causes strong biases in policy evaluation and improvement. <br /> <br /> This paper introduces a method to allow learning with continuous action spaces. A CNN is used to perform learning on a discretion state and action spaces, and then a continuous action search is performed on these discrete results.<br /> <br /> Curling is chosen as a domain to test the network on. Curling was chosen due to its large action space, potential for complicated strategies, and need for precise interactions.<br /> <br /> == Curling ==<br /> <br /> Curling is a sport played by two teams on a long sheet of ice. Roughly, the goal is for each time to slide rocks closer to the target on the other end of the sheet than the other team. The next sections will provide a background on the gameplay, and potential challenges/concerns for learning algorithms. A terminology section follows.<br /> <br /> === Gameplay ===<br /> <br /> A game of curling is divided into ends. In each end, players from both teams alternate throwing (sliding) eight rocks to the other end of the ice sheet, known as the house. Rocks must land in a certain area in order to stay in play, and must touch or be inside concentric rings (12ft diameter and smaller) in order to score points. At the end of each end, the team with rocks closest to the center of the house scores points.<br /> <br /> When throwing a rock, the curling can spin the rock. This allows the rock to 'curl' its path towards the house and can allow rocks to travel around other rocks. Team members are also able to sweep the ice in front of a moving rock in order to decrease friction, which allows for fine-tuning of distance (though the physics of sweeping are not implemented in the simulation used).<br /> <br /> Curling offers many possible high-level actions, which are directed by a team member to the throwing member. An example set of these includes:<br /> <br /> * Draw: Throw a rock to a target location<br /> * Freeze: Draw a rock up against another rock<br /> * Takeout: Knock another rock out of the house. Can be combined with different ricochet directions<br /> * Guard: Place a rock in front of another, to block other rocks (ex: takeouts)<br /> <br /> === Challenges for AI ===<br /> <br /> Curling offers many challenges for curling based on its physics and rules. This section lists a few concerns.<br /> <br /> The effect of changing actions can be highly nonlinear and discontinuous. This can be seen when considering that a 1-cm deviation in a path can make the difference between a high-speed collision, or lack of collision.<br /> <br /> Curling will require both offensive and defensive strategies. For example, consider the fact that the last team to throw a rock each end only needs to place that rock closer than the opposing team's rocks to score a point and invalidate any opposing rocks in the house. The opposing team should thus be considering how to prevent this from happening, in addition to scoring points themselves.<br /> <br /> Curling also has a concept known as 'the hammer'. The hammer belongs to the team which throws the last rock each end, providing an advantage, and is given to the team that does not score points each end. It could very well be a good strategy to try not to win a single point in an end (if already ahead in points, etc), as this would give the advantage to the opposing team.<br /> <br /> Finally, curling has a rule known as the 'Free Guard Zone'. This applies to the first 4 rocks thrown (2 from each team). If they land short of the house, but still in play, then the rocks are not allowed to be removed (via collisions) until all of the first 4 rocks have been thrown.<br /> <br /> === Terminology ===<br /> <br /> * End: A round of the game<br /> * House: The end of the sheet of ice, which contains<br /> * Hammer: The team that throws the last rock of an end 'has the hammer'<br /> * Hog Line: thick line that is drawn in front of the house, orthogonal to the length of the ice sheet. Rocks must pass this line to remain in play.<br /> * Back Line: think line drawn just behind the house. Rocks that pass this line are removed from play.<br /> <br /> <br /> == Related Work ==<br /> <br /> === AlphaGo Lee ===<br /> <br /> AlphaGo Lee (Silver et al., 2016, ) refers to an algorithm used to play the game Go, which was able to defeat international champion Lee Sedol. <br /> <br /> <br /> Go game:<br /> * Start with 19x19 empty board<br /> * One player take black stones and the other take white stones<br /> * Two players take turns to put stones on the board<br /> * Rules:<br /> 1. If one connected part is completely surrounded by the opponents stones, remove it from the board<br /> <br /> 2. Ko rule: Forbids a board play to repeat a board position<br /> * End when theres no valuable moves on the board.<br /> * Count the territory of both players.<br /> * Add 7.5 points to whites points (called Komi).<br /> [[File:go.JPG|700px|center]]<br /> <br /> Two neural networks were trained on the moves of human experts, to act as both a policy network and a value network. A Monte Carlo Tree Search algorithm was used for policy improvement.<br /> <br /> The AlphaGo Lee policy network predicts the best move given a board configuration. It has a CNN architecture with 13 hidden layers, and it is trained using expert gameplay data and improved through self-play.<br /> <br /> The value network evaluates the probability of winning given a board configuration. It consists of a CNN with 14 hidden layers, and it is trained using self-play data from the policy network. <br /> <br /> Finally, the two networks are combined using Monte-Carlo Tree Search, which performs lookahead search to select the actions for gameplay.<br /> <br /> The use of both policy and value networks are reflected in this paper's work.<br /> <br /> === AlphaGo Zero ===<br /> <br /> AlphaGo Zero (Silver et al., 2017, ) is an improvement on the AlphaGo Lee algorithm. AlphaGo Zero uses a unified neural network in place of the separate policy and value networks and is trained on self-play, without the need of expert training.<br /> <br /> The unification of networks and self-play are also reflected in this paper.<br /> <br /> === Curling Algorithms ===<br /> <br /> Some past algorithms have been proposed to deal with continuous action spaces. For example, (Yammamoto et al, 2015, ) use game tree search methods in a discretized space. The value of an action is taken as the average of nearby values, with respect to some knowledge of execution uncertainty.<br /> <br /> === Monte Carlo Tree Search ===<br /> <br /> Monte Carlo Tree Search algorithms have been applied to continuous action spaces. These algorithms, to be discussed in further detail, balance exploration of different states, with knowledge of paths of execution through past games. An MCTS called &lt;math&gt;KR-UCT&lt;/math&gt; which is able to find effective selections and use kernel regression (KR) and kernel density estimation(KDE) to estimate rewards using neighborhood information has been applied to continuous action space by researchers. <br /> <br /> With bandit problem, scholars used hierarchical optimistic optimization(HOO) to create a cover tree and divide the action space into small ranges at different depths, where the most promising node will create fine granularity estimates.<br /> <br /> === Curling Physics and Simulation ===<br /> <br /> Several references in the paper refer to the study and simulation of curling physics. Scholars have analyzed friction coefficients between curling stones and ice. While modelling the changes in friction on ice is not possible, a fixe friction coefficient was predefined in the simulation. The behaviour of the stones was also modelled. Important parameters are trained from professional players. The authors used the same parameters in this paper.<br /> <br /> == General Background of Algorithms ==<br /> <br /> === Policy and Value Functions ===<br /> <br /> A policy function is trained to provide the best action to take, given a current state. Policy iteration is an algorithm used to improve a policy over time. This is done by alternating between policy evaluation and policy improvement.<br /> <br /> POLICY IMPROVEMENT: LEARNING ACTION POLICY<br /> <br /> Action policy &lt;math&gt; p_{\sigma}(a|s) &lt;/math&gt; outputs a probability distribution over all eligible moves &lt;math&gt; a &lt;/math&gt;. We can use policy gradient reinforcement learning to train action policy. It is updated by stochastic gradient ascent in the direction that maximizes the expected outcome at each time step t,<br /> $\Delta \rho \propto \frac{\partial p_{\rho}(a_t|s_t)}{\partial \rho} r(s_t)$<br /> where &lt;math&gt; r(s_t) &lt;/math&gt; is the return.<br /> <br /> POLICY EVALUATION: LEARNING VALUE FUNCTIONS<br /> <br /> A value function is trained to estimate the value of a value of being in a certain state with parameter &lt;math&gt; \theta &lt;/math&gt;. It is trained based on records of state-action-reward sets &lt;math&gt; (s, r(s)) &lt;/math&gt; by using stochastic gradient de- scent to minimize the mean squared error (MSE) between the predicted regression value and the corresponding outcome,<br /> $\Delta \theta \propto \frac{\partial v_{\theta}(s)}{\partial \theta}(r(s)-v_{\theta}(s))$<br /> <br /> === Monte Carlo Tree Search ===<br /> <br /> Monte Carlo Tree Search (MCTS) is a search algorithm used for finite-horizon tasks (ex: in curling, only 16 moves, or throw stones, are taken each end).<br /> <br /> MCTS is a tree search algorithm similar to minimax. However, MCTS is probabilistic and does not need to explore a full game tree or even a tree reduced with alpha-beta pruning. This makes it tractable for games such as GO, and curling.<br /> <br /> Nodes of the tree are game states, and branches represent actions. Each node stores statistics on how many times it has been visited by the MCTS, as well as the number of wins encountered by playouts from that position. A node has been considered 'visited' if a full playout has started from that node. A node is considered 'expanded' if all its children have been visited.<br /> <br /> MCTS begins with the '''selection''' phase, which involves traversing known states/actions. This involves expanding the tree by beginning at the root node, and selecting the child/score with the highest 'score'. From each successive node, a path down to a root node is explored in a similar fashion.<br /> <br /> The next phase, '''expansion''', begins when the algorithm reaches a node where not all children have been visited (ie: the node has not been fully expanded). In the expansion phase, children of the node are visited, and '''simulations''' run from their states.<br /> <br /> Once the new child is expanded, '''simulation''' takes place. This refers to a full playout of the game from the point of the current node, and can involve many strategies, such as randomly taken moves, the use of heuristics, etc.<br /> <br /> The final phase is '''update''' or '''back-propagation''' (unrelated to the neural network algorithm). In this phase, the result of the '''simulation''' (ie: win/lose) is update in the statistics of all parent nodes.<br /> <br /> A selection function known as Upper Confidence Bound (UCT) can be used for selecting which node to select. The formula for this equation is shown below [[https://www.baeldung.com/java-monte-carlo-tree-search source]]. Note that the first term essentially acts as an average score of games played from a certain node. The second term, meanwhile, will grow when sibling nodes are expanded. This means that unexplored nodes will gradually increase their UCT score, and be selected in the future.<br /> <br /> &lt;math&gt; \frac{w_i}{n_i} + c \sqrt{\frac{\ln t}{n_i}} &lt;/math&gt;<br /> <br /> In which<br /> <br /> * &lt;math&gt; w_i = &lt;/math&gt; number of wins after &lt;math&gt; i&lt;/math&gt;th move<br /> * &lt;math&gt; n_i = &lt;/math&gt; number of simulations after &lt;math&gt; i&lt;/math&gt;th move<br /> * &lt;math&gt; c = &lt;/math&gt; exploration parameter (theoritically eqal to &lt;math&gt; \sqrt{2}&lt;/math&gt;)<br /> * &lt;math&gt; t = &lt;/math&gt; total number of simulations for the parent node<br /> <br /> <br /> Sources: 2,3,4<br /> <br /> === Kernel Regression ===<br /> <br /> Kernel regression is a form of weighted averaging. Given two items of data, '''x''', each of which has a value '''y''' associated with them, the kernel functions outputs a weighting factor. An estimate of the value of a new, unseen point, is then calculated as the weighted average of values of surrounding points.<br /> <br /> A typical kernel is a Gaussian kernel, shown below. The formula for calculating estimated value is shown below as well (sources: Lee et al.).<br /> <br /> [[File:gaussian_kernel.png | 400 px]]<br /> <br /> [[File:kernel_regression.png | 350 px]]<br /> <br /> In this case, the combination of the two-act to weigh scores of samples closest to '''x''' more strongly.<br /> <br /> = Methods =<br /> <br /> == Variable Definitions ==<br /> <br /> The following variables are used often in the paper:<br /> <br /> * &lt;math&gt;s&lt;/math&gt;: A state in the game, as described below as the input to the network.<br /> * &lt;math&gt;s_t&lt;/math&gt;: The state at a certain time-step of the game. Time-steps refer to full turns in the game<br /> * &lt;math&gt;a_t&lt;/math&gt;: The action taken in state &lt;math&gt;s_t&lt;/math&gt;<br /> * &lt;math&gt;A_t&lt;/math&gt;: The actions taken for sibling nodes related to &lt;math&gt;a_t&lt;/math&gt; in MCTS<br /> * &lt;math&gt;n_{a_t}&lt;/math&gt;: The number of visits to node a in MCTS<br /> * &lt;math&gt;v_{a_t}&lt;/math&gt;: The MCTS value estimate of a node<br /> <br /> == Network Design ==<br /> <br /> The authors design a CNN called the 'policy-value' network. The network consists of a common network structure, which is then split into 'policy' and 'value' outputs. This network is trained to learn a probability distribution of actions to take, and expected rewards, given an input state.<br /> <br /> === Shared Structure ===<br /> <br /> The network consists of 1 convolutional layer followed by 9 residual blocks, each block consisting of 2 convolutional layers with 32 3x3 filters. The structure of this network is shown below:<br /> <br /> [[File:curling_network_layers.png]]<br /> <br /> <br /> the input to this network is the following:<br /> * Location of stones<br /> * Order to tee (the center of the sheet)<br /> * A 32x32 grid of representation of the ice sheet, representing which stones are present in each grid cell.<br /> <br /> The authors do not describe how the stone-based information is added to the 32x32 grid as input to the network.<br /> <br /> === Policy Network ===<br /> <br /> The policy head is created by adding 2 convolutional layers with 2 (two) 3x3 filters to the main body of the network. The output of the policy head is a distribution of probabilities of the actions to select the best shot out of a 32x32x2 set of actions. The actions represent target locations in the grid and spin direction of the stone.<br /> <br /> [[File:policy-value-net.PNG | 700px]]<br /> <br /> === Value Network ===<br /> <br /> The valve head is created by adding a convolution layer with 1 3x3 filter, and dense layers of 256 and 17 units, to the shared network. The 17 output units represent a probability of scores in the range of [-8,8], which are the possible scores at each end of a curling game.<br /> <br /> == Continuous Action Search ==<br /> <br /> The policy head of the network only outputs actions from a discretized action space. For real-life interactions, and especially in curling, this will not suffice, as very fine adjustments to actions can make significant differences in outcomes.<br /> <br /> Actions in the continuous space are generated using an MCTS algorithm, with the following steps:<br /> <br /> === Selection ===<br /> <br /> From a given state, the list of already-visited actions is denoted as A&lt;sub&gt;t&lt;/sub&gt;. Scores and the number of visits to each node are estimated using the equations below (the first equation shows the expectation of the end value for one-end games). These are likely estimated rather than simply taken from the MCTS statistics to help account for the differences in a continuous action space.<br /> <br /> [[File:curling_kernel_equations.png | 500px]]<br /> <br /> The UCB formula is then used to select an action to expand.<br /> <br /> The actions that are taken in the simulator appear to be drawn from a Gaussian centered around &lt;math&gt;a_t&lt;/math&gt;. This allows exploration in the continuous action space.<br /> <br /> === Expansion ===<br /> <br /> The authors use a variant of regular UCT for expansion. In this case, they expand a new node only when existing nodes have been visited a certain number of times. The authors utilize a widening approach to overcome problems with standard UCT performing a shallow search when there is a large action space.<br /> <br /> === Simulation ===<br /> <br /> Instead of simulating with a random game playout, the authors use the value network to estimate the likely score associated with a state. This speeds up simulation (assuming the network is well trained), as the game does not actually need to be simulated.<br /> <br /> === Backpropogation ===<br /> <br /> Standard backpropagation is used, updating both the values and number of visits stored in the path of parent nodes.<br /> <br /> <br /> == Supervised Learning ==<br /> <br /> During supervised training, data is gathered from the program AyumuGAT'16 (). This program is also based on both an MCTS algorithm, and a high-performance AI curling program. 400 000 state-action pairs were generated during this training.<br /> <br /> === Policy Network ===<br /> <br /> The policy network was trained to learn the action taken in each state. Here, the likelihood of the taken action was set to be 1, and the likelihood of other actions to be 0.<br /> <br /> === Value Network ===<br /> <br /> The value network was trained by 'd-depth simulations and bootstrapping of the prediction to handle the high variance in rewards resulting from a sequence of stochastic moves' (quote taken from paper). In this case, ''m'' state-action pairs were sampled from the training data. For each pair, &lt;math&gt;(s_t, a_t)&lt;/math&gt;, a state d' steps ahead was generated, &lt;math&gt;s_{t+d}&lt;/math&gt;. This process dealt with uncertainty by considering all actions in this rollout to have no uncertainty, and allowing uncertainty in the last action, ''a&lt;sub&gt;t+d-1&lt;/sub&gt;''. The value network is used to predict the value for this state, &lt;math&gt;z_t&lt;/math&gt;, and the value is used for learning the value at ''s&lt;sub&gt;t&lt;/sub&gt;''.<br /> <br /> === Policy-Value Network ===<br /> <br /> The policy-value network was trained to maximize the similarity of the predicted policy and value, and the actual policy and value from a state. The learning algorithm parameters are:<br /> <br /> * Algorithm: stochastic gradient descent<br /> * Batch size: 256<br /> * Momentum: 0.9<br /> * L2 regularization: 0.0001<br /> * Training time: ~100 epochs<br /> * Learning rate: initialized at 0.01, reduced twice<br /> <br /> A multi-task loss function was used. This takes the summation of the cross-entropy losses of each prediction:<br /> <br /> [[File:curling_loss_function.png | 300px]]<br /> <br /> == Self-Play Reinforcement Learning ==<br /> <br /> After initialization by supervised learning, the algorithm uses self-play to further train itself. During this training, the policy network learns probabilities from the MCTS process, while the value network learns from game outcomes.<br /> <br /> At a game state ''s&lt;sub&gt;t&lt;/sub&gt;'':<br /> <br /> 1) the algorithm outputs a prediction ''z&lt;sub&gt;t&lt;/sub&gt;''. This is en estimate of game score probabilities. It is based on similar past actions, and computed using kernel regression.<br /> <br /> 2) the algorithm outputs a prediction &lt;math&gt;\pi_t&lt;/math&gt;, representing a probability distribution of actions. These are proportional to estimated visit counts from MCTS, based on kernel density estimation.<br /> <br /> It is not clear how these predictions are created. It would seem likely that the policy-value network generates these, but the wording of the paper suggests they are generated from MCTS statistics.<br /> <br /> The policy-value network is updated by sampling data &lt;math&gt;(s, \pi, z)&lt;/math&gt; from recent history of self-play. The same loss function is used as before.<br /> <br /> It is not clear how the improved network is used, as MCTS seems to be the driving process at this point.<br /> <br /> == Long-Term Strategy Learning ==<br /> <br /> Finally, the authors implement a new strategy to augment their algorithm for long-term play. In this context, this refers to playing a game over many ends, where the strategy to win a single end may not be a good strategy to win a full game. For example, scoring one point in an end, while being one point ahead, gives the advantage to the other team in the next round (as they will throw the last stone). The other team could then use the advantage to score two points, taking the lead.<br /> <br /> The authors build a 'winning percentage' table. This table stores the percentage of games won, based on the number of ends left, and the difference in score (current team - opposing team). This can be computed iteratively and using the probability distribution estimation of one-end scores.<br /> <br /> == Final Algorithms ==<br /> <br /> The authors make use of the following versions of their algorithm:<br /> <br /> === KR-DL ===<br /> <br /> ''Kernel regression-deep learning'': This algorithm is trained only by supervised learning.<br /> <br /> === KR-DRL ===<br /> <br /> ''Kernel regression-deep reinforcement learning'': This algorithm is trained by supervised learning (ie: initialized as the KR-DL algorithm), and again on self-play. During self-play, each shot is selected after 400 MCTS simulations of k=20 randomly selected actions. Data for self-play was collected over a week on 5 GPUS and generated 5 million game positions. The policy-value network was continually updated using samples from the latest 1 million game positions.<br /> <br /> === KR-DRL-MES ===<br /> <br /> ''Kernel regression-deep reinforcement learning-multi-ends-strategy'': This algorithm makes use of the winning percentage table generated from self-play.<br /> <br /> = Testing and Results =<br /> The authors use data from the public program AyumuGAT’16 to test. Testing is done with a simulated curling program . This simulator does not deal with changing ice conditions, or sweeping, but does deal with stone trajectories and collisions.<br /> <br /> == Comparison of KR-DL-UCT and DL-UCT ==<br /> <br /> The first test compares an algorithm trained with kernel regression with an algorithm trained without kernel regression, to show the contribution that kernel regression adds to the performance. Both algorithms have networks initialised with the supervised learning, and then trained with two different algorithms for self-play. KR-DL-UCT uses the algorithm described above. The authors do not go into detail on how DL-UCT selects shots, but state that a constant is set to allow exploration.<br /> <br /> As an evaluation, both algorithms play 2000 games against the DL-UCT algorithm, which is frozen after supervised training. 1000 games are played with the algorithm taking the first, and 100 taking the 2nd, shots. The games were two-end games. The figure below shows each algorithm's winning percentage given different amounts of training data. While the DL-UCT outperforms the supervised-training-only-DL-UCT algorithm, the KR-DL-UCT algorithm performs much better.<br /> <br /> [[File:curling_KR_test.png | 400px]]<br /> <br /> == Matches ==<br /> <br /> Finally, to test the performance of their multiple algorithms, the authors run matches between their algorithms and other existing programs. Each algorithm plays 200 matches against each other program, 100 of which are played as the first-playing team, and 100 as the second-playing team. Only 1 program was able to out-perform the KR-DRL algorithm. The authors state that this program, ''JiritsukunGAT'17'' also uses a deep network and hand-crafted features. However, the KR-DRL-MES algorithm was still able to out-perform this. The figure below shows the Elo ratings of the different programs. Note that the programs in blue are those created by the authors.<br /> <br /> [[File:curling_ratings.png | 400px]]<br /> <br /> = Critique =<br /> <br /> == Strengths ==<br /> <br /> This algorithm out-performs other high-performance algorithms (including past competition champions).<br /> <br /> I think the paper does a decent job of comparing the performance of their algorithm to others. They are able to clearly show the benefits of many of their additions.<br /> <br /> The authors do seem to be able to adopt strategies similar to those used in Go and other games to the continuous action-space domain. In addition, the final strategy needs no hand-crafted features for learning.<br /> <br /> == Weaknesses ==<br /> <br /> I found this paper difficult to follow at times. One problem was that the algorithms were introduced first, and then how they were used as described. So when the paper stated that self-play shots were taken after 400 simulations, it seemed unclear what simulations were being run, and what stage of the algorithm (ex: MCTS simulations, simulations sped up by using the value network, full simulations on the curling simulator). In particular, both the MCTS statistics and the policy-value network could be used to estimate both action probabilities and state values, so it is difficult to tell which is used in which case. There was also no clear distinction between discrete-space actions and continuous-space actions.<br /> <br /> While I think the comparing of different algorithms was done well, I believe it still lacked some good detail. There were one-off mentions in the paper which would have been nice to see as results. These include the statement that having a policy-value network in place of two networks lead to better performance.<br /> <br /> At this point, the algorithms used still rely on initialization by a pre-made program.<br /> <br /> There was little theoretical development or justification done in this paper.<br /> <br /> While curling is an interesting choice for demonstrating the algorithm, the fact that the simulations used did not support many of the key points of curling (ice conditions, sweeping) seems very limiting. Another game, such as pool, would likely have offered some of the same challenges but offered more high-fidelity simulations/training.<br /> <br /> While the spatial placements of stones were discretized in a grid, the curl of thrown stones was discretized to only +/-1. This seems like it may limit learning high- and low-spin moves. It should be noted that having zero spins is not commonly used, to the best of my knowledge.<br /> <br /> =References=<br /> # Lee, K., Kim, S., Choi, J. &amp; Lee, S. &quot;Deep Reinforcement Learning in Continuous Action Spaces: a Case Study in the Game of Simulated Curling.&quot; Proceedings of the 35th International Conference on Machine Learning, in PMLR 80:2937-2946 (2018)<br /> # https://www.baeldung.com/java-monte-carlo-tree-search<br /> # https://jeffbradberry.com/posts/2015/09/intro-to-monte-carlo-tree-search/<br /> # https://int8.io/monte-carlo-tree-search-beginners-guide/<br /> # Silver, D., Huang, A., Maddison, C., Guez, A., Sifre, L.,Van Den Driessche, G., Schrittwieser, J., Antonoglou, I.,Panneershelvam, V., Lanctot, M., Dieleman, S., Grewe,D., Nham, J., Kalchbrenner, N.,Sutskever, I., Lillicrap, T.,Leach, M., Kavukcuoglu, K., Graepel, T., and Hassabis,D. Mastering the game of go with deep neural networksand tree search. Nature, pp. 484–489, 2016.<br /> # Silver, D., Schrittwieser, J., Simonyan, K., Antonoglou,I., Huang, A., Guez, A., Hubert, T., Baker, L., Lai, M., Bolton, A., Chen, Y., Lillicrap, T., Hui, F., Sifre, L.,van den Driessche, G., Graepel, T., and Hassabis, D.Mastering the game of go without human knowledge.Nature, pp. 354–359, 2017.<br /> # Yamamoto, M., Kato, S., and Iizuka, H. Digital curling strategy based on game tree search. In Proceedings of the IEEE Conference on Computational Intelligence and Games, CIG, pp. 474–480, 2015.<br /> # Ohto, K. and Tanaka, T. A curling agent based on the montecarlo tree search considering the similarity of the best action among similar states. In Proceedings of Advances in Computer Games, ACG, pp. 151–164, 2017.<br /> # Ito, T. and Kitasei, Y. Proposal and implementation of digital curling. In Proceedings of the IEEE Conference on Computational Intelligence and Games, CIG, pp. 469–473, 2015.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=File:policy-value-net.PNG&diff=41156 File:policy-value-net.PNG 2018-11-23T15:14:03Z <p>Jmmoosa: </p> <hr /> <div></div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=Deep_Reinforcement_Learning_in_Continuous_Action_Spaces_a_Case_Study_in_the_Game_of_Simulated_Curling&diff=41155 Deep Reinforcement Learning in Continuous Action Spaces a Case Study in the Game of Simulated Curling 2018-11-23T15:02:35Z <p>Jmmoosa: /* Monte Carlo Tree Search */</p> <hr /> <div>This page provides a summary and critique of the paper '''Deep Reinforcement Learning in Continuous Action Spaces: a Case Study in the Game of Simulated Curling''' [[http://proceedings.mlr.press/v80/lee18b/lee18b.pdf Online Source]], published in ICML 2018. The source code for this paper is available [https://github.com/leekwoon/KR-DL-UCT here]<br /> <br /> = Introduction and Motivation =<br /> <br /> In recent years, Reinforcement Learning methods have been applied to many different games, such as chess and checkers. More recently, the use of CNN's has allowed neural networks to out-perform humans in many difficult games, such as Go. However, many of these cases involve a discrete state or action space; the number of actions a player can take and/or the number of possible game states are finite. <br /> <br /> Interacting with the real world (e.g.; a scenario that involves moving physical objects) typically involves working with a continuous action space. It is thus important to develop strategies for dealing with continuous action spaces. Deep neural networks that are designed to succeed in finite action spaces are not necessarily suitable for continuous action space problems. This is due to the fact that deterministic discretization of a continuous action space causes strong biases in policy evaluation and improvement. <br /> <br /> This paper introduces a method to allow learning with continuous action spaces. A CNN is used to perform learning on a discretion state and action spaces, and then a continuous action search is performed on these discrete results.<br /> <br /> Curling is chosen as a domain to test the network on. Curling was chosen due to its large action space, potential for complicated strategies, and need for precise interactions.<br /> <br /> == Curling ==<br /> <br /> Curling is a sport played by two teams on a long sheet of ice. Roughly, the goal is for each time to slide rocks closer to the target on the other end of the sheet than the other team. The next sections will provide a background on the gameplay, and potential challenges/concerns for learning algorithms. A terminology section follows.<br /> <br /> === Gameplay ===<br /> <br /> A game of curling is divided into ends. In each end, players from both teams alternate throwing (sliding) eight rocks to the other end of the ice sheet, known as the house. Rocks must land in a certain area in order to stay in play, and must touch or be inside concentric rings (12ft diameter and smaller) in order to score points. At the end of each end, the team with rocks closest to the center of the house scores points.<br /> <br /> When throwing a rock, the curling can spin the rock. This allows the rock to 'curl' its path towards the house and can allow rocks to travel around other rocks. Team members are also able to sweep the ice in front of a moving rock in order to decrease friction, which allows for fine-tuning of distance (though the physics of sweeping are not implemented in the simulation used).<br /> <br /> Curling offers many possible high-level actions, which are directed by a team member to the throwing member. An example set of these includes:<br /> <br /> * Draw: Throw a rock to a target location<br /> * Freeze: Draw a rock up against another rock<br /> * Takeout: Knock another rock out of the house. Can be combined with different ricochet directions<br /> * Guard: Place a rock in front of another, to block other rocks (ex: takeouts)<br /> <br /> === Challenges for AI ===<br /> <br /> Curling offers many challenges for curling based on its physics and rules. This section lists a few concerns.<br /> <br /> The effect of changing actions can be highly nonlinear and discontinuous. This can be seen when considering that a 1-cm deviation in a path can make the difference between a high-speed collision, or lack of collision.<br /> <br /> Curling will require both offensive and defensive strategies. For example, consider the fact that the last team to throw a rock each end only needs to place that rock closer than the opposing team's rocks to score a point and invalidate any opposing rocks in the house. The opposing team should thus be considering how to prevent this from happening, in addition to scoring points themselves.<br /> <br /> Curling also has a concept known as 'the hammer'. The hammer belongs to the team which throws the last rock each end, providing an advantage, and is given to the team that does not score points each end. It could very well be a good strategy to try not to win a single point in an end (if already ahead in points, etc), as this would give the advantage to the opposing team.<br /> <br /> Finally, curling has a rule known as the 'Free Guard Zone'. This applies to the first 4 rocks thrown (2 from each team). If they land short of the house, but still in play, then the rocks are not allowed to be removed (via collisions) until all of the first 4 rocks have been thrown.<br /> <br /> === Terminology ===<br /> <br /> * End: A round of the game<br /> * House: The end of the sheet of ice, which contains<br /> * Hammer: The team that throws the last rock of an end 'has the hammer'<br /> * Hog Line: thick line that is drawn in front of the house, orthogonal to the length of the ice sheet. Rocks must pass this line to remain in play.<br /> * Back Line: think line drawn just behind the house. Rocks that pass this line are removed from play.<br /> <br /> <br /> == Related Work ==<br /> <br /> === AlphaGo Lee ===<br /> <br /> AlphaGo Lee (Silver et al., 2016, ) refers to an algorithm used to play the game Go, which was able to defeat international champion Lee Sedol. <br /> <br /> <br /> Go game:<br /> * Start with 19x19 empty board<br /> * One player take black stones and the other take white stones<br /> * Two players take turns to put stones on the board<br /> * Rules:<br /> 1. If one connected part is completely surrounded by the opponents stones, remove it from the board<br /> <br /> 2. Ko rule: Forbids a board play to repeat a board position<br /> * End when theres no valuable moves on the board.<br /> * Count the territory of both players.<br /> * Add 7.5 points to whites points (called Komi).<br /> [[File:go.JPG|700px|center]]<br /> <br /> Two neural networks were trained on the moves of human experts, to act as both a policy network and a value network. A Monte Carlo Tree Search algorithm was used for policy improvement.<br /> <br /> The AlphaGo Lee policy network predicts the best move given a board configuration. It has a CNN architecture with 13 hidden layers, and it is trained using expert gameplay data and improved through self-play.<br /> <br /> The value network evaluates the probability of winning given a board configuration. It consists of a CNN with 14 hidden layers, and it is trained using self-play data from the policy network. <br /> <br /> Finally, the two networks are combined using Monte-Carlo Tree Search, which performs lookahead search to select the actions for gameplay.<br /> <br /> The use of both policy and value networks are reflected in this paper's work.<br /> <br /> === AlphaGo Zero ===<br /> <br /> AlphaGo Zero (Silver et al., 2017, ) is an improvement on the AlphaGo Lee algorithm. AlphaGo Zero uses a unified neural network in place of the separate policy and value networks and is trained on self-play, without the need of expert training.<br /> <br /> The unification of networks and self-play are also reflected in this paper.<br /> <br /> === Curling Algorithms ===<br /> <br /> Some past algorithms have been proposed to deal with continuous action spaces. For example, (Yammamoto et al, 2015, ) use game tree search methods in a discretized space. The value of an action is taken as the average of nearby values, with respect to some knowledge of execution uncertainty.<br /> <br /> === Monte Carlo Tree Search ===<br /> <br /> Monte Carlo Tree Search algorithms have been applied to continuous action spaces. These algorithms, to be discussed in further detail, balance exploration of different states, with knowledge of paths of execution through past games. An MCTS called &lt;math&gt;KR-UCT&lt;/math&gt; which is able to find effective selections and use kernel regression (KR) and kernel density estimation(KDE) to estimate rewards using neighborhood information has been applied to continuous action space by researchers. <br /> <br /> With bandit problem, scholars used hierarchical optimistic optimization(HOO) to create a cover tree and divide the action space into small ranges at different depths, where the most promising node will create fine granularity estimates.<br /> <br /> === Curling Physics and Simulation ===<br /> <br /> Several references in the paper refer to the study and simulation of curling physics. Scholars have analyzed friction coefficients between curling stones and ice. While modelling the changes in friction on ice is not possible, a fixe friction coefficient was predefined in the simulation. The behaviour of the stones was also modelled. Important parameters are trained from professional players. The authors used the same parameters in this paper.<br /> <br /> == General Background of Algorithms ==<br /> <br /> === Policy and Value Functions ===<br /> <br /> A policy function is trained to provide the best action to take, given a current state. Policy iteration is an algorithm used to improve a policy over time. This is done by alternating between policy evaluation and policy improvement.<br /> <br /> POLICY IMPROVEMENT: LEARNING ACTION POLICY<br /> <br /> Action policy &lt;math&gt; p_{\sigma}(a|s) &lt;/math&gt; outputs a probability distribution over all eligible moves &lt;math&gt; a &lt;/math&gt;. We can use policy gradient reinforcement learning to train action policy. It is updated by stochastic gradient ascent in the direction that maximizes the expected outcome at each time step t,<br /> $\Delta \rho \propto \frac{\partial p_{\rho}(a_t|s_t)}{\partial \rho} r(s_t)$<br /> where &lt;math&gt; r(s_t) &lt;/math&gt; is the return.<br /> <br /> POLICY EVALUATION: LEARNING VALUE FUNCTIONS<br /> <br /> A value function is trained to estimate the value of a value of being in a certain state with parameter &lt;math&gt; \theta &lt;/math&gt;. It is trained based on records of state-action-reward sets &lt;math&gt; (s, r(s)) &lt;/math&gt; by using stochastic gradient de- scent to minimize the mean squared error (MSE) between the predicted regression value and the corresponding outcome,<br /> $\Delta \theta \propto \frac{\partial v_{\theta}(s)}{\partial \theta}(r(s)-v_{\theta}(s))$<br /> <br /> === Monte Carlo Tree Search ===<br /> <br /> Monte Carlo Tree Search (MCTS) is a search algorithm used for finite-horizon tasks (ex: in curling, only 16 moves, or throw stones, are taken each end).<br /> <br /> MCTS is a tree search algorithm similar to minimax. However, MCTS is probabilistic and does not need to explore a full game tree or even a tree reduced with alpha-beta pruning. This makes it tractable for games such as GO, and curling.<br /> <br /> Nodes of the tree are game states, and branches represent actions. Each node stores statistics on how many times it has been visited by the MCTS, as well as the number of wins encountered by playouts from that position. A node has been considered 'visited' if a full playout has started from that node. A node is considered 'expanded' if all its children have been visited.<br /> <br /> MCTS begins with the '''selection''' phase, which involves traversing known states/actions. This involves expanding the tree by beginning at the root node, and selecting the child/score with the highest 'score'. From each successive node, a path down to a root node is explored in a similar fashion.<br /> <br /> The next phase, '''expansion''', begins when the algorithm reaches a node where not all children have been visited (ie: the node has not been fully expanded). In the expansion phase, children of the node are visited, and '''simulations''' run from their states.<br /> <br /> Once the new child is expanded, '''simulation''' takes place. This refers to a full playout of the game from the point of the current node, and can involve many strategies, such as randomly taken moves, the use of heuristics, etc.<br /> <br /> The final phase is '''update''' or '''back-propagation''' (unrelated to the neural network algorithm). In this phase, the result of the '''simulation''' (ie: win/lose) is update in the statistics of all parent nodes.<br /> <br /> A selection function known as Upper Confidence Bound (UCT) can be used for selecting which node to select. The formula for this equation is shown below [[https://www.baeldung.com/java-monte-carlo-tree-search source]]. Note that the first term essentially acts as an average score of games played from a certain node. The second term, meanwhile, will grow when sibling nodes are expanded. This means that unexplored nodes will gradually increase their UCT score, and be selected in the future.<br /> <br /> &lt;math&gt; \frac{w_i}{n_i} + c \sqrt{\frac{\ln t}{n_i}} &lt;/math&gt;<br /> <br /> In which<br /> <br /> * &lt;math&gt; w_i = &lt;/math&gt; number of wins after &lt;math&gt; i&lt;/math&gt;th move<br /> * &lt;math&gt; n_i = &lt;/math&gt; number of simulations after &lt;math&gt; i&lt;/math&gt;th move<br /> * &lt;math&gt; c = &lt;/math&gt; exploration parameter (theoritically eqal to &lt;math&gt; \sqrt{2}&lt;/math&gt;)<br /> * &lt;math&gt; t = &lt;/math&gt; total number of simulations for the parent node<br /> <br /> <br /> Sources: 2,3,4<br /> <br /> === Kernel Regression ===<br /> <br /> Kernel regression is a form of weighted averaging. Given two items of data, '''x''', each of which has a value '''y''' associated with them, the kernel functions outputs a weighting factor. An estimate of the value of a new, unseen point, is then calculated as the weighted average of values of surrounding points.<br /> <br /> A typical kernel is a Gaussian kernel, shown below. The formula for calculating estimated value is shown below as well (sources: Lee et al.).<br /> <br /> [[File:gaussian_kernel.png | 400 px]]<br /> <br /> [[File:kernel_regression.png | 350 px]]<br /> <br /> In this case, the combination of the two-act to weigh scores of samples closest to '''x''' more strongly.<br /> <br /> = Methods =<br /> <br /> == Variable Definitions ==<br /> <br /> The following variables are used often in the paper:<br /> <br /> * &lt;math&gt;s&lt;/math&gt;: A state in the game, as described below as the input to the network.<br /> * &lt;math&gt;s_t&lt;/math&gt;: The state at a certain time-step of the game. Time-steps refer to full turns in the game<br /> * &lt;math&gt;a_t&lt;/math&gt;: The action taken in state &lt;math&gt;s_t&lt;/math&gt;<br /> * &lt;math&gt;A_t&lt;/math&gt;: The actions taken for sibling nodes related to &lt;math&gt;a_t&lt;/math&gt; in MCTS<br /> * &lt;math&gt;n_{a_t}&lt;/math&gt;: The number of visits to node a in MCTS<br /> * &lt;math&gt;v_{a_t}&lt;/math&gt;: The MCTS value estimate of a node<br /> <br /> == Network Design ==<br /> <br /> The authors design a CNN called the 'policy-value' network. The network consists of a common network structure, which is then split into 'policy' and 'value' outputs. This network is trained to learn a probability distribution of actions to take, and expected rewards, given an input state.<br /> <br /> === Shared Structure ===<br /> <br /> The network consists of 1 convolutional layer followed by 9 residual blocks, each block consisting of 2 convolutional layers with 32 3x3 filters. The structure of this network is shown below:<br /> <br /> [[File:curling_network_layers.png]]<br /> <br /> <br /> the input to this network is the following:<br /> * Location of stones<br /> * Order to tee (the center of the sheet)<br /> * A 32x32 grid of representation of the ice sheet, representing which stones are present in each grid cell.<br /> <br /> The authors do not describe how the stone-based information is added to the 32x32 grid as input to the network.<br /> <br /> === Policy Network ===<br /> <br /> The policy head is created by adding 2 convolutional layers with 2 3x3 filters to the main body of the network. The output of the policy head is a distribution of probabilities of the actions to select the best shot out of a 32x32x2 set of actions. The actions represent target locations in the grid and spin direction of the stone.<br /> <br /> === Value Network ===<br /> <br /> The valve head is created by adding a convolution layer with 1 3x3 filter, and dense layers of 256 and 17 units, to the shared network. The 17 output units represent a probability of scores in the range of [-8,8], which are the possible scores at each end of a curling game.<br /> <br /> == Continuous Action Search ==<br /> <br /> The policy head of the network only outputs actions from a discretized action space. For real-life interactions, and especially in curling, this will not suffice, as very fine adjustments to actions can make significant differences in outcomes.<br /> <br /> Actions in the continuous space are generated using an MCTS algorithm, with the following steps:<br /> <br /> === Selection ===<br /> <br /> From a given state, the list of already-visited actions is denoted as A&lt;sub&gt;t&lt;/sub&gt;. Scores and the number of visits to each node are estimated using the equations below (the first equation shows the expectation of the end value for one-end games). These are likely estimated rather than simply taken from the MCTS statistics to help account for the differences in a continuous action space.<br /> <br /> [[File:curling_kernel_equations.png | 500px]]<br /> <br /> The UCB formula is then used to select an action to expand.<br /> <br /> The actions that are taken in the simulator appear to be drawn from a Gaussian centered around &lt;math&gt;a_t&lt;/math&gt;. This allows exploration in the continuous action space.<br /> <br /> === Expansion ===<br /> <br /> The authors use a variant of regular UCT for expansion. In this case, they expand a new node only when existing nodes have been visited a certain number of times. The authors utilize a widening approach to overcome problems with standard UCT performing a shallow search when there is a large action space.<br /> <br /> === Simulation ===<br /> <br /> Instead of simulating with a random game playout, the authors use the value network to estimate the likely score associated with a state. This speeds up simulation (assuming the network is well trained), as the game does not actually need to be simulated.<br /> <br /> === Backpropogation ===<br /> <br /> Standard backpropagation is used, updating both the values and number of visits stored in the path of parent nodes.<br /> <br /> <br /> == Supervised Learning ==<br /> <br /> During supervised training, data is gathered from the program AyumuGAT'16 (). This program is also based on both an MCTS algorithm, and a high-performance AI curling program. 400 000 state-action pairs were generated during this training.<br /> <br /> === Policy Network ===<br /> <br /> The policy network was trained to learn the action taken in each state. Here, the likelihood of the taken action was set to be 1, and the likelihood of other actions to be 0.<br /> <br /> === Value Network ===<br /> <br /> The value network was trained by 'd-depth simulations and bootstrapping of the prediction to handle the high variance in rewards resulting from a sequence of stochastic moves' (quote taken from paper). In this case, ''m'' state-action pairs were sampled from the training data. For each pair, &lt;math&gt;(s_t, a_t)&lt;/math&gt;, a state d' steps ahead was generated, &lt;math&gt;s_{t+d}&lt;/math&gt;. This process dealt with uncertainty by considering all actions in this rollout to have no uncertainty, and allowing uncertainty in the last action, ''a&lt;sub&gt;t+d-1&lt;/sub&gt;''. The value network is used to predict the value for this state, &lt;math&gt;z_t&lt;/math&gt;, and the value is used for learning the value at ''s&lt;sub&gt;t&lt;/sub&gt;''.<br /> <br /> === Policy-Value Network ===<br /> <br /> The policy-value network was trained to maximize the similarity of the predicted policy and value, and the actual policy and value from a state. The learning algorithm parameters are:<br /> <br /> * Algorithm: stochastic gradient descent<br /> * Batch size: 256<br /> * Momentum: 0.9<br /> * L2 regularization: 0.0001<br /> * Training time: ~100 epochs<br /> * Learning rate: initialized at 0.01, reduced twice<br /> <br /> A multi-task loss function was used. This takes the summation of the cross-entropy losses of each prediction:<br /> <br /> [[File:curling_loss_function.png | 300px]]<br /> <br /> == Self-Play Reinforcement Learning ==<br /> <br /> After initialization by supervised learning, the algorithm uses self-play to further train itself. During this training, the policy network learns probabilities from the MCTS process, while the value network learns from game outcomes.<br /> <br /> At a game state ''s&lt;sub&gt;t&lt;/sub&gt;'':<br /> <br /> 1) the algorithm outputs a prediction ''z&lt;sub&gt;t&lt;/sub&gt;''. This is en estimate of game score probabilities. It is based on similar past actions, and computed using kernel regression.<br /> <br /> 2) the algorithm outputs a prediction &lt;math&gt;\pi_t&lt;/math&gt;, representing a probability distribution of actions. These are proportional to estimated visit counts from MCTS, based on kernel density estimation.<br /> <br /> It is not clear how these predictions are created. It would seem likely that the policy-value network generates these, but the wording of the paper suggests they are generated from MCTS statistics.<br /> <br /> The policy-value network is updated by sampling data &lt;math&gt;(s, \pi, z)&lt;/math&gt; from recent history of self-play. The same loss function is used as before.<br /> <br /> It is not clear how the improved network is used, as MCTS seems to be the driving process at this point.<br /> <br /> == Long-Term Strategy Learning ==<br /> <br /> Finally, the authors implement a new strategy to augment their algorithm for long-term play. In this context, this refers to playing a game over many ends, where the strategy to win a single end may not be a good strategy to win a full game. For example, scoring one point in an end, while being one point ahead, gives the advantage to the other team in the next round (as they will throw the last stone). The other team could then use the advantage to score two points, taking the lead.<br /> <br /> The authors build a 'winning percentage' table. This table stores the percentage of games won, based on the number of ends left, and the difference in score (current team - opposing team). This can be computed iteratively and using the probability distribution estimation of one-end scores.<br /> <br /> == Final Algorithms ==<br /> <br /> The authors make use of the following versions of their algorithm:<br /> <br /> === KR-DL ===<br /> <br /> ''Kernel regression-deep learning'': This algorithm is trained only by supervised learning.<br /> <br /> === KR-DRL ===<br /> <br /> ''Kernel regression-deep reinforcement learning'': This algorithm is trained by supervised learning (ie: initialized as the KR-DL algorithm), and again on self-play. During self-play, each shot is selected after 400 MCTS simulations of k=20 randomly selected actions. Data for self-play was collected over a week on 5 GPUS and generated 5 million game positions. The policy-value network was continually updated using samples from the latest 1 million game positions.<br /> <br /> === KR-DRL-MES ===<br /> <br /> ''Kernel regression-deep reinforcement learning-multi-ends-strategy'': This algorithm makes use of the winning percentage table generated from self-play.<br /> <br /> = Testing and Results =<br /> The authors use data from the public program AyumuGAT’16 to test. Testing is done with a simulated curling program . This simulator does not deal with changing ice conditions, or sweeping, but does deal with stone trajectories and collisions.<br /> <br /> == Comparison of KR-DL-UCT and DL-UCT ==<br /> <br /> The first test compares an algorithm trained with kernel regression with an algorithm trained without kernel regression, to show the contribution that kernel regression adds to the performance. Both algorithms have networks initialised with the supervised learning, and then trained with two different algorithms for self-play. KR-DL-UCT uses the algorithm described above. The authors do not go into detail on how DL-UCT selects shots, but state that a constant is set to allow exploration.<br /> <br /> As an evaluation, both algorithms play 2000 games against the DL-UCT algorithm, which is frozen after supervised training. 1000 games are played with the algorithm taking the first, and 100 taking the 2nd, shots. The games were two-end games. The figure below shows each algorithm's winning percentage given different amounts of training data. While the DL-UCT outperforms the supervised-training-only-DL-UCT algorithm, the KR-DL-UCT algorithm performs much better.<br /> <br /> [[File:curling_KR_test.png | 400px]]<br /> <br /> == Matches ==<br /> <br /> Finally, to test the performance of their multiple algorithms, the authors run matches between their algorithms and other existing programs. Each algorithm plays 200 matches against each other program, 100 of which are played as the first-playing team, and 100 as the second-playing team. Only 1 program was able to out-perform the KR-DRL algorithm. The authors state that this program, ''JiritsukunGAT'17'' also uses a deep network and hand-crafted features. However, the KR-DRL-MES algorithm was still able to out-perform this. The figure below shows the Elo ratings of the different programs. Note that the programs in blue are those created by the authors.<br /> <br /> [[File:curling_ratings.png | 400px]]<br /> <br /> = Critique =<br /> <br /> == Strengths ==<br /> <br /> This algorithm out-performs other high-performance algorithms (including past competition champions).<br /> <br /> I think the paper does a decent job of comparing the performance of their algorithm to others. They are able to clearly show the benefits of many of their additions.<br /> <br /> The authors do seem to be able to adopt strategies similar to those used in Go and other games to the continuous action-space domain. In addition, the final strategy needs no hand-crafted features for learning.<br /> <br /> == Weaknesses ==<br /> <br /> I found this paper difficult to follow at times. One problem was that the algorithms were introduced first, and then how they were used as described. So when the paper stated that self-play shots were taken after 400 simulations, it seemed unclear what simulations were being run, and what stage of the algorithm (ex: MCTS simulations, simulations sped up by using the value network, full simulations on the curling simulator). In particular, both the MCTS statistics and the policy-value network could be used to estimate both action probabilities and state values, so it is difficult to tell which is used in which case. There was also no clear distinction between discrete-space actions and continuous-space actions.<br /> <br /> While I think the comparing of different algorithms was done well, I believe it still lacked some good detail. There were one-off mentions in the paper which would have been nice to see as results. These include the statement that having a policy-value network in place of two networks lead to better performance.<br /> <br /> At this point, the algorithms used still rely on initialization by a pre-made program.<br /> <br /> There was little theoretical development or justification done in this paper.<br /> <br /> While curling is an interesting choice for demonstrating the algorithm, the fact that the simulations used did not support many of the key points of curling (ice conditions, sweeping) seems very limiting. Another game, such as pool, would likely have offered some of the same challenges but offered more high-fidelity simulations/training.<br /> <br /> While the spatial placements of stones were discretized in a grid, the curl of thrown stones was discretized to only +/-1. This seems like it may limit learning high- and low-spin moves. It should be noted that having zero spins is not commonly used, to the best of my knowledge.<br /> <br /> =References=<br /> # Lee, K., Kim, S., Choi, J. &amp; Lee, S. &quot;Deep Reinforcement Learning in Continuous Action Spaces: a Case Study in the Game of Simulated Curling.&quot; Proceedings of the 35th International Conference on Machine Learning, in PMLR 80:2937-2946 (2018)<br /> # https://www.baeldung.com/java-monte-carlo-tree-search<br /> # https://jeffbradberry.com/posts/2015/09/intro-to-monte-carlo-tree-search/<br /> # https://int8.io/monte-carlo-tree-search-beginners-guide/<br /> # Silver, D., Huang, A., Maddison, C., Guez, A., Sifre, L.,Van Den Driessche, G., Schrittwieser, J., Antonoglou, I.,Panneershelvam, V., Lanctot, M., Dieleman, S., Grewe,D., Nham, J., Kalchbrenner, N.,Sutskever, I., Lillicrap, T.,Leach, M., Kavukcuoglu, K., Graepel, T., and Hassabis,D. Mastering the game of go with deep neural networksand tree search. Nature, pp. 484–489, 2016.<br /> # Silver, D., Schrittwieser, J., Simonyan, K., Antonoglou,I., Huang, A., Guez, A., Hubert, T., Baker, L., Lai, M., Bolton, A., Chen, Y., Lillicrap, T., Hui, F., Sifre, L.,van den Driessche, G., Graepel, T., and Hassabis, D.Mastering the game of go without human knowledge.Nature, pp. 354–359, 2017.<br /> # Yamamoto, M., Kato, S., and Iizuka, H. Digital curling strategy based on game tree search. In Proceedings of the IEEE Conference on Computational Intelligence and Games, CIG, pp. 474–480, 2015.<br /> # Ohto, K. and Tanaka, T. A curling agent based on the montecarlo tree search considering the similarity of the best action among similar states. In Proceedings of Advances in Computer Games, ACG, pp. 151–164, 2017.<br /> # Ito, T. and Kitasei, Y. Proposal and implementation of digital curling. In Proceedings of the IEEE Conference on Computational Intelligence and Games, CIG, pp. 469–473, 2015.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=a_neural_representation_of_sketch_drawings&diff=41154 a neural representation of sketch drawings 2018-11-23T14:48:46Z <p>Jmmoosa: /* Unconditional Generation */</p> <hr /> <div><br /> == Introduction ==<br /> In this paper, The authors present a recurrent neural network, sketch-rnn, that can be used to construct stroke-based drawings. Besides new robust training methods, they also outline a framework for conditional and unconditional sketch generation.<br /> <br /> Neural networks have been heavily used as image generation tools. For example, Generative Adversarial Networks, Variational Inference, and Autoregressive models have been used. Most of those models are designed to generate pixels to construct images. However, people learn to draw using sequences of strokes, beginning when they are young. The authors propose a new generative model that creates vector images so that it might generalize abstract concepts in a manner more similar to how humans do. <br /> <br /> The model is trained with hand-drawn sketches as input sequences. The model is able to produce sketches in vector format. In the conditional generation model, they also explore the latent space representation for vector images and discuss a few future applications of this model. The model and dataset are now available as an open source project ([https://magenta.tensorflow.org/sketch_rnn link]).<br /> <br /> === Terminology ===<br /> Pixel images, also referred to as raster or bitmap images are files that encode image data as a set of pixels. These are the most common image type, with extensions such as .png, .jpg, .bmp. <br /> <br /> Vector images are files that encode image data as paths between points. SVG and EPS file types are used to store vector images. <br /> <br /> For a visual comparison of raster and vector images, see this [https://www.youtube.com/watch?v=-Fs2t6P5AjY video]. As mentioned, vector images are generally simpler and more abstract, whereas raster images generally are used to store detailed images. <br /> <br /> For this paper, the important distinction between the two is that the encoding of images in the model will be inherently more abstract because of the vector representation. The intuition is that generating abstract representations is more effective using a vector representation. <br /> <br /> == Related Work ==<br /> There are some works in the history that used a similar approach to generate images such as Portrait Drawing by Paul the Robot and some reinforcement learning approaches. They work more like a mimic of digitized photographs. There are also some Neural networks based approaches, but those are mostly dealing with pixel images. Little work is done on vector images generation. There are models that use Hidden Markov Models or Mixture Density Networks to generate human sketches, continuous data points or vectorized Kanji characters.<br /> <br /> The model also allows us to explore the latent space representation of vector images. There are previous works that achieved similar functions as well, such as combining Sequence-to-Sequence models with Variational Autoencoder to model sentences into latent space and using probabilistic program induction to model Omniglot dataset.<br /> <br /> The dataset they use contains 50 million vector sketches. Before this paper, there is a Sketch data with 20k vector sketches, a Sketchy dataset with 70k vector sketches along with pixel images, and a ShadowDraw system that used 30k raster images along with extracted vectorized features. They are all comparatively small.<br /> <br /> == Methodology ==<br /> === Dataset ===<br /> QuickDraw is a dataset with 50 million vector drawings collected by an online game [https://quickdraw.withgoogle.com/# Quick Draw!], where the players are required to draw objects belonging to a particular object class in less than 20 seconds. It contains hundreds of classes, each class has 70k training samples, 2.5k validation samples and 2.5k test samples.<br /> <br /> The data format of each sample is a representation of a pen stroke action event. The Origin is the initial coordinate of the drawing. The sketches are points in a list. Each point consists of 5 elements &lt;math&gt; (\Delta x, \Delta y, p_{1}, p_{2}, p_{3})&lt;/math&gt; where x and y are the offset distance in x and y directions from the previous point. The parameters &lt;math&gt;p_{1}, p_{2}, p_{3}&lt;/math&gt; represent three possible states in binary one-hot representation where &lt;math&gt;p_{1}&lt;/math&gt; indicates the pen is touching the paper, &lt;math&gt;p_{2}&lt;/math&gt; indicates the pen will be lifted from here, and &lt;math&gt;p_{3}&lt;/math&gt; represents the drawing has ended.<br /> <br /> === Sketch-RNN ===<br /> [[File:sketchfig2.png|700px|center]]<br /> <br /> The model is a Sequence-to-Sequence Variational Autoencoder(VAE). The encoder is a bidirectional RNN, the input is a sketch sequence denoted by &lt;math&gt;S&lt;/math&gt; and a reversed sketch sequence denoted by &lt;math&gt;S_{reverse}&lt;/math&gt;, so there will be two final hidden states. The output is a size &lt;math&gt;N_{z}&lt;/math&gt; latent vector.<br /> <br /> \begin{align*}<br /> h_{ \rightarrow} = encode_{ \rightarrow }(S), <br /> h_{ \leftarrow} = encode_{ \leftarrow }(S_{reverse}), <br /> h = [h_{\rightarrow}; h_{\leftarrow}].<br /> \end{align*}<br /> <br /> Then the authors project &lt;math&gt;h&lt;/math&gt; into to &lt;math&gt;\mu&lt;/math&gt; and &lt;math&gt;\hat{\sigma}&lt;/math&gt;. Both &lt;math&gt;\mu&lt;/math&gt; and &lt;math&gt;\hat{\sigma}&lt;/math&gt; are vectors of size &lt;math&gt;N_{z}&lt;/math&gt;. The projection is performed using a fully connected layer. Then, using the exponential function the authors convert &lt;math&gt;\hat{\sigma}&lt;/math&gt; into a non-negative standard deviation parameter denoted by &lt;math&gt;\sigma&lt;/math&gt;. The Authors then use &lt;math&gt;\mu&lt;/math&gt; and &lt;math&gt;\sigma&lt;/math&gt; with &lt;math&gt;\mathcal{N}(0,I)&lt;/math&gt; to construct a random vector &lt;math&gt;z\in\mathbb{R}^{N_{z}}&lt;/math&gt;.<br /> <br /> \begin{align*}<br /> \mu = W_\mu h + b_\mu, <br /> \hat \sigma = W_\sigma h + b_\sigma, <br /> \sigma = exp( \frac{\hat \sigma}{2}), <br /> z = \mu + \sigma \odot \mathcal{N}(0,I).<br /> \end{align*}<br /> <br /> <br /> Note that &lt;math&gt;z&lt;/math&gt; is not deterministic but a conditioned random vector.<br /> <br /> The decoder is an autoregressive RNN. The initial hidden states are generated using &lt;math&gt;[h_0;c_0] = \tanh(W_z z+b_z)&lt;/math&gt; where &lt;math&gt;c_0&lt;/math&gt; is utilized if applicable. &lt;math&gt;S_0&lt;/math&gt; is defined as &lt;math&gt;(0,0,1,0,0)&lt;/math&gt;. For each step i in the decoder, the input &lt;math&gt;x_i&lt;/math&gt; is the concatenation of previous point &lt;math&gt;S_{i-1}&lt;/math&gt; and latent vector &lt;math&gt;z&lt;/math&gt;. The output are probability distribution parameters for the next data point &lt;math&gt;S_i&lt;/math&gt;. The authors model &lt;math&gt;(\Delta x,\Delta y)&lt;/math&gt; as a Gaussian mixture model (GMM) with &lt;math&gt;M&lt;/math&gt; normal distributions and model the ground truth data &lt;math&gt;(p_1, p_2, p_3)&lt;/math&gt; as categorical distribution &lt;math&gt;(q_1, q_2, q_3)&lt;/math&gt; where &lt;math&gt;q_1, q_2\ \text{and}\ q_3&lt;/math&gt; sum up to 1. The generated sequence is conditioned from the latent vector &lt;math&gt;z&lt;/math&gt; that is sampled from the encoder, which is end-to-end trained together with the decoder.<br /> <br /> \begin{align*}<br /> p(\Delta x, \Delta y) = \sum_{j=1}^{M} \Pi_j \mathcal{N}(\Delta x,\Delta y | \mu_{x,j}, \mu_{y,j}, \sigma_{x,j},\sigma_{y,j}, \rho _{xy,j}), where \sum_{j=1}^{M}\Pi_j = 1<br /> \end{align*}<br /> <br /> Here the &lt;math&gt;\mathcal{N}(\Delta x,\Delta y | \mu_{x,j}, \mu_{y,j}, \sigma_{x,j},\sigma_{y,j}, \rho _{xy,j})&lt;/math&gt; is the probability distribution function for &lt;math&gt;x,y&lt;/math&gt;. Each of the M bivariate normal distributions being summed have five parameters: &lt;math&gt;(\mu_x, \mu_y, \sigma_x, \sigma_y, \rho_{xy})&lt;/math&gt;, where &lt;math&gt;\mu_x, \mu_y&lt;/math&gt; are means, &lt;math&gt;\sigma_x, \sigma_y&lt;/math&gt; are the standard deviations, and &lt;math&gt;\rho_{xy}&lt;/math&gt;is the correlation parameter for these bivariate normal distribution. The &lt;math&gt;\Pi&lt;/math&gt; is a length M categorical distribution vector are the mixture weights of the Gaussian mixture model.<br /> <br /> The output vector &lt;math&gt;y_i&lt;/math&gt; is generated using a fully-connected forward propagation in the hidden state of the RNN.<br /> <br /> \begin{align*}<br /> x_i = [S_{i-1}; z], <br /> [h_i; c_i] = forward(x_i,[h_{i-1}; c_{i-1}]), <br /> y_i = W_y h_i + b_y,<br /> y_i \in \mathbb{R}^{6M+3}.<br /> \end{align*}<br /> <br /> The output consists the probability distribution of the next data point.<br /> <br /> \begin{align*}<br /> [(\hat\Pi_1\ \mu_x\ \mu_y\ \hat\sigma_x\ \hat\sigma_y\ \hat\rho_{xy})_1\ (\hat\Pi_1\ \mu_x\ \mu_y\ \hat\sigma_x\ \hat\sigma_y\ \hat\rho_{xy})_2\ ...\ (\hat\Pi_1\ \mu_x\ \mu_y\ \hat\sigma_x\ \hat\sigma_y\ \hat\rho_{xy})_M\ (\hat{q_1}\ \hat{q_2}\ \hat{q_3})] = y_i<br /> \end{align*}<br /> <br /> &lt;math&gt;\exp&lt;/math&gt; and &lt;math&gt;\tanh&lt;/math&gt; operations are applied to ensure that the standard deviations are non-negative and the correlation value is between -1 and 1.<br /> <br /> \begin{align*}<br /> \sigma_x = \exp (\hat \sigma_x),\ <br /> \sigma_y = \exp (\hat \sigma_y),\ <br /> \rho_{xy} = \tanh(\hat \rho_{xy}). <br /> \end{align*}<br /> <br /> Categorical distribution probabilities for &lt;math&gt;(p_1, p_2, p_3)&lt;/math&gt; using &lt;math&gt;(q_1, q_2, q_3)&lt;/math&gt; can be obtained as :<br /> <br /> \begin{align*}<br /> q_k = \frac{\exp{(\hat q_k)}}{ \sum\nolimits_{j = 1}^{3} \exp {(\hat q_j)}},<br /> k \in \left\{1,2,3\right\}, <br /> \Pi _k = \frac{\exp{(\hat \Pi_k)}}{ \sum\nolimits_{j = 1}^{M} \exp {(\hat \Pi_j)}},<br /> k \in \left\{1,...,M\right\}.<br /> \end{align*}<br /> <br /> It is hard for the model to decide when to stop drawing because the probabilities of the three events &lt;math&gt;(p_1, p_2, p_3)&lt;/math&gt; are very unbalanced. Researchers in the past have used different weights for each pen event probability, but the authors found this approach lacking elegance and inadequate. They define a hyperparameter representing the max length of the longest sketch in the training set denoted by &lt;math&gt;N_{max}&lt;/math&gt;, and set the &lt;math&gt;S_i&lt;/math&gt; to be &lt;math&gt;(0, 0, 0, 0, 1)&lt;/math&gt; for &lt;math&gt;i &gt; N_s&lt;/math&gt;.<br /> <br /> The outcome sample &lt;math&gt;S_i^{'}&lt;/math&gt; can be generated in each time step during sample process and fed as input for the next time step. The process will stop when &lt;math&gt;p_3 = 1&lt;/math&gt; or &lt;math&gt;i = N_{max}&lt;/math&gt;. The output is not deterministic but conditioned random sequences. The level of randomness can be controlled using a temperature parameter &lt;math&gt;\tau&lt;/math&gt;.<br /> <br /> \begin{align*}<br /> \hat q_k \rightarrow \frac{\hat q_k}{\tau}, <br /> \hat \Pi_k \rightarrow \frac{\hat \Pi_k}{\tau}, <br /> \sigma_x^2 \rightarrow \sigma_x^2\tau, <br /> \sigma_y^2 \rightarrow \sigma_y^2\tau. <br /> \end{align*}<br /> <br /> The &lt;math&gt;\tau&lt;/math&gt; ranges from 0 to 1. When &lt;math&gt;\tau = 0&lt;/math&gt; the output will be deterministic as the sample will consist of the points on the peak of the probability density function.<br /> <br /> === Unconditional Generation ===<br /> There is a special case that only the decoder RNN module is trained. The decoder RNN could work as a standalone autoregressive model without latent variables. In this case, initial states are 0, the input &lt;math&gt;x_i&lt;/math&gt; is only &lt;math&gt;S_{i-1}&lt;/math&gt; or &lt;math&gt;S_{i-1}^{'}&lt;/math&gt;. In the Figure 3, generating sketches unconditionally from the temperature parameter &lt;math&gt;\tau = 0.2&lt;/math&gt; at the top in blue, to &lt;math&gt;\tau = 0.9&lt;/math&gt; at the bottom in red.<br /> <br /> [[File:sketchfig3.png|700px|center]]<br /> <br /> === Training ===<br /> The training process is the same as a Variational Autoencoder. The loss function is the sum of Reconstruction Loss &lt;math&gt;L_R&lt;/math&gt; and the Kullback-Leibler Divergence Loss &lt;math&gt;L_{KL}&lt;/math&gt;. The reconstruction loss &lt;math&gt;L_R&lt;/math&gt; can be obtained with generated parameters of pdf and training data &lt;math&gt;S&lt;/math&gt;. It is the sum of the &lt;math&gt;L_s&lt;/math&gt; and &lt;math&gt;L_p&lt;/math&gt;, which are the log loss of the offset &lt;math&gt;(\Delta x, \Delta y)&lt;/math&gt; and the pen state &lt;math&gt;(p_1, p_2, p_3)&lt;/math&gt;.<br /> <br /> \begin{align*}<br /> L_s = - \frac{1 }{N_{max}} \sum_{i = 1}^{N_s} \log(\sum_{i = 1}^{M} \Pi_{j,i} \mathcal{N}(\Delta x,\Delta y | \mu_{x,j,i}, \mu_{y,j,i}, \sigma_{x,j,i},\sigma_{y,j,i}, \rho _{xy,j,i})), <br /> \end{align*}<br /> \begin{align*}<br /> L_p = - \frac{1 }{N_{max}} \sum_{i = 1}^{N_{max}} \sum_{k = 1}^{3} p_{k,i} \log (q_{k,i}), <br /> L_R = L_s + L_p.<br /> \end{align*}<br /> <br /> <br /> Both terms are normalized by &lt;math&gt;N_{max}&lt;/math&gt;.<br /> <br /> &lt;math&gt;L_{KL}&lt;/math&gt; measures the difference between the distribution of the latent vector &lt;math&gt;z&lt;/math&gt; and an IID Gaussian vector with zero mean and unit variance.<br /> <br /> \begin{align*}<br /> L_{KL} = - \frac{1}{2 N_z} (1+\hat \sigma - \mu^2 - \exp(\hat \sigma))<br /> \end{align*}<br /> <br /> The overall loss is weighted as:<br /> <br /> \begin{align*}<br /> Loss = L_R + w_{KL} L_{KL}<br /> \end{align*}<br /> <br /> When &lt;math&gt;w_{KL} = 0&lt;/math&gt;, the model becomes a standalone unconditional generator. Specially, there will be no &lt;math&gt;L_{KL} &lt;/math&gt; term as we only optimize for &lt;math&gt;L_{R} &lt;/math&gt;. By removing the &lt;math&gt;L_{KL} &lt;/math&gt; term the model approaches a pure autoencoder, meaning it sacrifices the ability to enforce a prior over the latent space and gains better reconstruction loss metrics.<br /> <br /> == Experiments ==<br /> The authors experiment with the sketch-rnn model using different settings and recorded both losses. They used a Long Short-Term Memory(LSTM) model as an encoder and a HyperLSTM as a decoder. They also conduct multi-class datasets. The result is as follows.<br /> <br /> [[File:sketchtable1.png|700px]]<br /> <br /> We could see the trade-off between &lt;math&gt;L_R&lt;/math&gt; and &lt;math&gt;L_{KL}&lt;/math&gt; in this table clearly. Furthermore, &lt;math&gt;L_R&lt;/math&gt; decreases as &lt;math&gt;w_{KL} &lt;/math&gt; is halfed. <br /> <br /> === Conditional Reconstruction ===<br /> The authors assess the reconstructed sketch with a given sketch with different &lt;math&gt;\tau&lt;/math&gt; values. We could see that with high &lt;math&gt;\tau&lt;/math&gt; value on the right, the reconstructed sketches are more random.<br /> <br /> [[File:sketchfig5.png|700px|center]]<br /> <br /> They also experiment on inputting a sketch from a different class. The output will still keep some features from the class that the model is trained on.<br /> <br /> === Latent Space Interpolation ===<br /> The authors visualize the reconstruction sketches while interpolating between latent vectors using different &lt;math&gt;w_{KL}&lt;/math&gt; values. With high &lt;math&gt;w_{KL}&lt;/math&gt; values, the generated images are more coherently interpolated.<br /> <br /> [[File:sketchfig6.png|700px|center]]<br /> <br /> === Sketch Drawing Analogies ===<br /> Since the latent vector &lt;math&gt;z&lt;/math&gt; encode conceptual features of a sketch, those features can also be used to augment other sketches that do not have these features. This is possible when models are trained with low &lt;math&gt;L_{KL}&lt;/math&gt; values. The authors are able to perform vector arithmetic on latent vectors from different sketches and explore how the model generates sketches base on these latent spaces.<br /> <br /> === Predicting Different Endings of Incomplete Sketches === <br /> This model is able to predict an incomplete sketch by encoding the sketch into hidden state &lt;math&gt;h&lt;/math&gt; using the decoder and then using &lt;math&gt;h&lt;/math&gt; as an initial hidden state to generate the remaining sketch. The authors train on individual classes by using decoder-only models and set τ = 0.8 to complete samples. Figure 7 shows the results.<br /> <br /> [[File:sketchfig7.png|700px|center]]<br /> <br /> == Applications and Future Work ==<br /> The authors believe this model can assist artists by suggesting how to finish a sketch, helping them to find interesting intersections between different drawings or objects, or generating a lot of similar but different designs. In the simplest use, pattern designers can apply sketch-rnn to generate a large number of similar, but unique designs for textile or wallpaper prints. The creative designers can also come up with abstract designs which enables them to resonate more with their target audience<br /> <br /> This model may also find its place on teaching students how to draw. Even with the simple sketches in QuickDraw, the authors of this work have become much more proficient at drawing animals, insects, and various sea creatures after conducting these experiments. <br /> When the model is trained with a high &lt;math&gt;w_{KL}&lt;/math&gt; and sampled with a low &lt;math&gt;\tau&lt;/math&gt;, it may help to turn a poor sketch into a more aesthetical one. Latent vector augmentation could also help to create a better drawing by inputting user-rating data during training processes.<br /> <br /> The authors conclude by providing the following future directions to this work:<br /> # Investigate using user-rating data to augmenting the latent vector in the direction that maximizes the aesthetics of the drawing.<br /> # Look into combining variations of sequence-generation models with unsupervised, cross-domain pixel image generation models.<br /> <br /> It's exciting that they manage to combine this model with other unsupervised, cross-domain pixel image generation models to create photorealistic images from sketches.<br /> <br /> The authors have also mentioned the opposite direction of converting a photograph of an object into an unrealistic, but similar looking<br /> sketch of the object composed of a minimal number of lines to be a more interesting problem.<br /> <br /> <br /> == Conclusion ==<br /> This paper introduced an interesting model sketch-rnn that can encode and decode sketches, generate and complete unfinished sketches. The authors demonstrated how to interpolate between latent spaces from a different class and how to use it to augment sketches or generate similar looking sketches. They also showed that it's important to enforce a prior distribution on latent vector while interpolating coherent sketch generations. Finally, they created a large sketch drawings dataset to be used in future research.<br /> <br /> == Critique ==<br /> * The performance of the decoder model can hardly be evaluated. The authors present the performance of the decoder by showing the generated sketches, it is clear and straightforward, however, not very efficient. It would be great if the authors could present a way, or a metric to evaluate how well the sketches are generated rather than printing them out and evaluate with human judgment.<br /> <br /> * Same problem as the output, the authors didn't present an evaluation for the algorithms either. They provided &lt;math&gt;L_R&lt;/math&gt; and &lt;math&gt;L_{KL}&lt;/math&gt; for reference, however, a lower loss doesn't represent a better performance.<br /> <br /> * I understand that using strokes as inputs is a novel and innovative move, however, the paper does not provide a baseline or any comparison with other methods or algorithms. Some other researches were mentioned in the paper, using similar and smaller datasets. It would be great if the authors could use some basic or existing methods a baseline and compare with the new algorithm.<br /> <br /> * Besides the comparison with other algorithms, it would also be great if the authors could remove or replace some component of the algorithm in the model to show if one part is necessary, or what made them decide to include a specific component in the algorithm.<br /> <br /> * The authors proposed a few future applications for the model, however, the current output seems somehow not very close to their descriptions. But I do believe that this is a very good beginning, with the release of the sketch dataset, it must attract more scholars to research and improve with it!<br /> <br /> * ([https://openreview.net/forum?id=Hy6GHpkCW]) The paper presents both a novel large dataset of sketches and a new RNN architecture to generate new sketches.<br /> <br /> + new and large dataset<br /> <br /> + novel algorithm<br /> <br /> + well written<br /> <br /> - no evaluation of dataset<br /> <br /> - virtually no evaluation of the algorithm<br /> <br /> - no baselines or comparison<br /> <br /> == References == <br /> # Jimmy L. Ba, Jamie R. Kiros, and Geoffrey E. Hinton. Layer normalization. NIPS, 2016.<br /> # Christopher M. Bishop. Mixture density networks. Technical Report, 1994. URL http://publications.aston.ac.uk/373/.<br /> # Samuel R. Bowman, Luke Vilnis, Oriol Vinyals, Andrew M. Dai, Rafal Józefowicz, and Samy Bengio. Generating Sentences from a Continuous Space. CoRR, abs/1511.06349, 2015. URL http://arxiv.org/abs/1511.06349.<br /> # H. Dong, P. Neekhara, C. Wu, and Y. Guo. Unsupervised Image-to-Image Translation with Generative Adversarial Networks. ArXiv e-prints, January 2017.<br /> # David H. Douglas and Thomas K. Peucker. Algorithms for the reduction of the number of points required to represent a digitized line or its caricature. Cartographica: The International Journal for Geographic Information and Geovisualization, 10(2):112–122, October 1973. doi: 10.3138/fm57-6770-u75u-7727. URL http://dx.doi.org/10.3138/fm57-6770-u75u-7727.<br /> # Mathias Eitz, James Hays, and Marc Alexa. How Do Humans Sketch Objects? ACM Trans. Graph.(Proc. SIGGRAPH), 31(4):44:1–44:10, 2012.<br /> # I. Goodfellow. NIPS 2016 Tutorial: Generative Adversarial Networks. ArXiv e-prints, December 2016.<br /> # Alex Graves. Generating sequences with recurrent neural networks. arXiv:1308.0850, 2013.<br /> # David Ha. Recurrent Net Dreams Up Fake Chinese Characters in Vector Format with TensorFlow, 2015.<br /> # David Ha, Andrew M. Dai, and Quoc V. Le. HyperNetworks. In ICLR, 2017.<br /> # Sepp Hochreiter and Juergen Schmidhuber. Long short-term memory. Neural Computation, 1997.<br /> # P. Isola, J.-Y. Zhu, T. Zhou, and A. A. Efros. Image-to-Image Translation with Conditional Adversarial Networks. ArXiv e-prints, November 2016.<br /> # Jonas Jongejan, Henry Rowley, Takashi Kawashima, Jongmin Kim, and Nick Fox-Gieg. The Quick, Draw! - A.I. Experiment. https://quickdraw.withgoogle.com/, 2016. URL https: //quickdraw.withgoogle.com/.<br /> # C. Kaae Sønderby, T. Raiko, L. Maaløe, S. Kaae Sønderby, and O. Winther. Ladder Variational Autoencoders. ArXiv e-prints, February 2016.<br /> # T. Kim, M. Cha, H. Kim, J. Lee, and J. Kim. Learning to Discover cross-domain Relations with Generative Adversarial Networks. ArXiv e-prints, March 2017.<br /> # D. P Kingma and M. Welling. Auto-Encoding Variational Bayes. ArXiv e-prints, December 2013.<br /> # Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.<br /> # Diederik P. Kingma, Tim Salimans, and Max Welling. Improving variational inference with inverse autoregressive flow. CoRR, abs/1606.04934, 2016. URL http://arxiv.org/abs/1606.04934.<br /> # Brenden M. Lake, Ruslan Salakhutdinov, and Joshua B. Tenenbaum. Human level concept learning through probabilistic program induction. Science, 350(6266):1332–1338, December 2015. ISSN 1095-9203. doi: 10.1126/science.aab3050. URL http://dx.doi.org/10.1126/science.aab3050.<br /> # Yong Jae Lee, C. Lawrence Zitnick, and Michael F. Cohen. Shadowdraw: Real-time user guidance for freehand drawing. In ACM SIGGRAPH 2011 Papers, SIGGRAPH ’11, pp. 27:1–27:10, New York, NY, USA, 2011. ACM. ISBN 978-1-4503-0943-1. doi: 10.1145/1964921.1964922. URL http://doi.acm.org/10.1145/1964921.1964922.<br /> # M.-Y. Liu, T. Breuel, and J. Kautz. Unsupervised Image-to-Image Translation Networks. ArXiv e-prints, March 2017.<br /> # S. Reed, A. van den Oord, N. Kalchbrenner, S. Gómez Colmenarejo, Z. Wang, D. Belov, and N. de Freitas. Parallel Multiscale Autoregressive Density Estimation. ArXiv e-prints, March 2017.<br /> # Patsorn Sangkloy, Nathan Burnell, Cusuh Ham, and James Hays. The Sketchy Database: Learning to Retrieve Badly Drawn Bunnies. ACM Trans. Graph., 35(4):119:1–119:12, July 2016. ISSN 0730-0301. doi: 10.1145/2897824.2925954. URL http://doi.acm.org/10.1145/2897824.2925954.<br /> # Mike Schuster, Kuldip K. Paliwal, and A. General. Bidirectional recurrent neural networks. IEEE Transactions on Signal Processing, 1997.<br /> # Saul Simhon and Gregory Dudek. Sketch interpretation and refinement using statistical models. In Proceedings of the Fifteenth Eurographics Conference on Rendering Techniques, EGSR’04, pp. 23–32, Aire-la-Ville, Switzerland, Switzerland, 2004. Eurographics Association. ISBN 3-905673-12-6. doi: 10.2312/EGWR/EGSR04/023-032. URL http://dx.doi.org/10.2312/EGWR/EGSR04/023-032.<br /> # Patrick Tresset and Frederic Fol Leymarie. Portrait drawing by paul the robot. Comput. Graph.,37(5):348–363, August 2013. ISSN 0097-8493. doi: 10.1016/j.cag.2013.01.012. URL http://dx.doi.org/10.1016/j.cag.2013.01.012.<br /> # T. White. Sampling Generative Networks. ArXiv e-prints, September 2016.<br /> #Ning Xie, Hirotaka Hachiya, and Masashi Sugiyama. Artist agent: A reinforcement learning approach to automatic stroke generation in oriental ink painting. In ICML. icml.cc / Omnipress, 2012. URL http://dblp.uni-trier.de/db/conf/icml/icml2012.html#XieHS12.<br /> # Xu-Yao Zhang, Fei Yin, Yan-Ming Zhang, Cheng-Lin Liu, and Yoshua Bengio. Drawing and Recognizing Chinese Characters with Recurrent Neural Network. CoRR, abs/1606.06539, 2016. URL http://arxiv.org/abs/1606.06539.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=a_neural_representation_of_sketch_drawings&diff=41153 a neural representation of sketch drawings 2018-11-23T14:41:43Z <p>Jmmoosa: /* Dataset */</p> <hr /> <div><br /> == Introduction ==<br /> In this paper, The authors present a recurrent neural network, sketch-rnn, that can be used to construct stroke-based drawings. Besides new robust training methods, they also outline a framework for conditional and unconditional sketch generation.<br /> <br /> Neural networks have been heavily used as image generation tools. For example, Generative Adversarial Networks, Variational Inference, and Autoregressive models have been used. Most of those models are designed to generate pixels to construct images. However, people learn to draw using sequences of strokes, beginning when they are young. The authors propose a new generative model that creates vector images so that it might generalize abstract concepts in a manner more similar to how humans do. <br /> <br /> The model is trained with hand-drawn sketches as input sequences. The model is able to produce sketches in vector format. In the conditional generation model, they also explore the latent space representation for vector images and discuss a few future applications of this model. The model and dataset are now available as an open source project ([https://magenta.tensorflow.org/sketch_rnn link]).<br /> <br /> === Terminology ===<br /> Pixel images, also referred to as raster or bitmap images are files that encode image data as a set of pixels. These are the most common image type, with extensions such as .png, .jpg, .bmp. <br /> <br /> Vector images are files that encode image data as paths between points. SVG and EPS file types are used to store vector images. <br /> <br /> For a visual comparison of raster and vector images, see this [https://www.youtube.com/watch?v=-Fs2t6P5AjY video]. As mentioned, vector images are generally simpler and more abstract, whereas raster images generally are used to store detailed images. <br /> <br /> For this paper, the important distinction between the two is that the encoding of images in the model will be inherently more abstract because of the vector representation. The intuition is that generating abstract representations is more effective using a vector representation. <br /> <br /> == Related Work ==<br /> There are some works in the history that used a similar approach to generate images such as Portrait Drawing by Paul the Robot and some reinforcement learning approaches. They work more like a mimic of digitized photographs. There are also some Neural networks based approaches, but those are mostly dealing with pixel images. Little work is done on vector images generation. There are models that use Hidden Markov Models or Mixture Density Networks to generate human sketches, continuous data points or vectorized Kanji characters.<br /> <br /> The model also allows us to explore the latent space representation of vector images. There are previous works that achieved similar functions as well, such as combining Sequence-to-Sequence models with Variational Autoencoder to model sentences into latent space and using probabilistic program induction to model Omniglot dataset.<br /> <br /> The dataset they use contains 50 million vector sketches. Before this paper, there is a Sketch data with 20k vector sketches, a Sketchy dataset with 70k vector sketches along with pixel images, and a ShadowDraw system that used 30k raster images along with extracted vectorized features. They are all comparatively small.<br /> <br /> == Methodology ==<br /> === Dataset ===<br /> QuickDraw is a dataset with 50 million vector drawings collected by an online game [https://quickdraw.withgoogle.com/# Quick Draw!], where the players are required to draw objects belonging to a particular object class in less than 20 seconds. It contains hundreds of classes, each class has 70k training samples, 2.5k validation samples and 2.5k test samples.<br /> <br /> The data format of each sample is a representation of a pen stroke action event. The Origin is the initial coordinate of the drawing. The sketches are points in a list. Each point consists of 5 elements &lt;math&gt; (\Delta x, \Delta y, p_{1}, p_{2}, p_{3})&lt;/math&gt; where x and y are the offset distance in x and y directions from the previous point. The parameters &lt;math&gt;p_{1}, p_{2}, p_{3}&lt;/math&gt; represent three possible states in binary one-hot representation where &lt;math&gt;p_{1}&lt;/math&gt; indicates the pen is touching the paper, &lt;math&gt;p_{2}&lt;/math&gt; indicates the pen will be lifted from here, and &lt;math&gt;p_{3}&lt;/math&gt; represents the drawing has ended.<br /> <br /> === Sketch-RNN ===<br /> [[File:sketchfig2.png|700px|center]]<br /> <br /> The model is a Sequence-to-Sequence Variational Autoencoder(VAE). The encoder is a bidirectional RNN, the input is a sketch sequence denoted by &lt;math&gt;S&lt;/math&gt; and a reversed sketch sequence denoted by &lt;math&gt;S_{reverse}&lt;/math&gt;, so there will be two final hidden states. The output is a size &lt;math&gt;N_{z}&lt;/math&gt; latent vector.<br /> <br /> \begin{align*}<br /> h_{ \rightarrow} = encode_{ \rightarrow }(S), <br /> h_{ \leftarrow} = encode_{ \leftarrow }(S_{reverse}), <br /> h = [h_{\rightarrow}; h_{\leftarrow}].<br /> \end{align*}<br /> <br /> Then the authors project &lt;math&gt;h&lt;/math&gt; into to &lt;math&gt;\mu&lt;/math&gt; and &lt;math&gt;\hat{\sigma}&lt;/math&gt;. Both &lt;math&gt;\mu&lt;/math&gt; and &lt;math&gt;\hat{\sigma}&lt;/math&gt; are vectors of size &lt;math&gt;N_{z}&lt;/math&gt;. The projection is performed using a fully connected layer. Then, using the exponential function the authors convert &lt;math&gt;\hat{\sigma}&lt;/math&gt; into a non-negative standard deviation parameter denoted by &lt;math&gt;\sigma&lt;/math&gt;. The Authors then use &lt;math&gt;\mu&lt;/math&gt; and &lt;math&gt;\sigma&lt;/math&gt; with &lt;math&gt;\mathcal{N}(0,I)&lt;/math&gt; to construct a random vector &lt;math&gt;z\in\mathbb{R}^{N_{z}}&lt;/math&gt;.<br /> <br /> \begin{align*}<br /> \mu = W_\mu h + b_\mu, <br /> \hat \sigma = W_\sigma h + b_\sigma, <br /> \sigma = exp( \frac{\hat \sigma}{2}), <br /> z = \mu + \sigma \odot \mathcal{N}(0,I).<br /> \end{align*}<br /> <br /> <br /> Note that &lt;math&gt;z&lt;/math&gt; is not deterministic but a conditioned random vector.<br /> <br /> The decoder is an autoregressive RNN. The initial hidden states are generated using &lt;math&gt;[h_0;c_0] = \tanh(W_z z+b_z)&lt;/math&gt; where &lt;math&gt;c_0&lt;/math&gt; is utilized if applicable. &lt;math&gt;S_0&lt;/math&gt; is defined as &lt;math&gt;(0,0,1,0,0)&lt;/math&gt;. For each step i in the decoder, the input &lt;math&gt;x_i&lt;/math&gt; is the concatenation of previous point &lt;math&gt;S_{i-1}&lt;/math&gt; and latent vector &lt;math&gt;z&lt;/math&gt;. The output are probability distribution parameters for the next data point &lt;math&gt;S_i&lt;/math&gt;. The authors model &lt;math&gt;(\Delta x,\Delta y)&lt;/math&gt; as a Gaussian mixture model (GMM) with &lt;math&gt;M&lt;/math&gt; normal distributions and model the ground truth data &lt;math&gt;(p_1, p_2, p_3)&lt;/math&gt; as categorical distribution &lt;math&gt;(q_1, q_2, q_3)&lt;/math&gt; where &lt;math&gt;q_1, q_2\ \text{and}\ q_3&lt;/math&gt; sum up to 1. The generated sequence is conditioned from the latent vector &lt;math&gt;z&lt;/math&gt; that is sampled from the encoder, which is end-to-end trained together with the decoder.<br /> <br /> \begin{align*}<br /> p(\Delta x, \Delta y) = \sum_{j=1}^{M} \Pi_j \mathcal{N}(\Delta x,\Delta y | \mu_{x,j}, \mu_{y,j}, \sigma_{x,j},\sigma_{y,j}, \rho _{xy,j}), where \sum_{j=1}^{M}\Pi_j = 1<br /> \end{align*}<br /> <br /> Here the &lt;math&gt;\mathcal{N}(\Delta x,\Delta y | \mu_{x,j}, \mu_{y,j}, \sigma_{x,j},\sigma_{y,j}, \rho _{xy,j})&lt;/math&gt; is the probability distribution function for &lt;math&gt;x,y&lt;/math&gt;. Each of the M bivariate normal distributions being summed have five parameters: &lt;math&gt;(\mu_x, \mu_y, \sigma_x, \sigma_y, \rho_{xy})&lt;/math&gt;, where &lt;math&gt;\mu_x, \mu_y&lt;/math&gt; are means, &lt;math&gt;\sigma_x, \sigma_y&lt;/math&gt; are the standard deviations, and &lt;math&gt;\rho_{xy}&lt;/math&gt;is the correlation parameter for these bivariate normal distribution. The &lt;math&gt;\Pi&lt;/math&gt; is a length M categorical distribution vector are the mixture weights of the Gaussian mixture model.<br /> <br /> The output vector &lt;math&gt;y_i&lt;/math&gt; is generated using a fully-connected forward propagation in the hidden state of the RNN.<br /> <br /> \begin{align*}<br /> x_i = [S_{i-1}; z], <br /> [h_i; c_i] = forward(x_i,[h_{i-1}; c_{i-1}]), <br /> y_i = W_y h_i + b_y,<br /> y_i \in \mathbb{R}^{6M+3}.<br /> \end{align*}<br /> <br /> The output consists the probability distribution of the next data point.<br /> <br /> \begin{align*}<br /> [(\hat\Pi_1\ \mu_x\ \mu_y\ \hat\sigma_x\ \hat\sigma_y\ \hat\rho_{xy})_1\ (\hat\Pi_1\ \mu_x\ \mu_y\ \hat\sigma_x\ \hat\sigma_y\ \hat\rho_{xy})_2\ ...\ (\hat\Pi_1\ \mu_x\ \mu_y\ \hat\sigma_x\ \hat\sigma_y\ \hat\rho_{xy})_M\ (\hat{q_1}\ \hat{q_2}\ \hat{q_3})] = y_i<br /> \end{align*}<br /> <br /> &lt;math&gt;\exp&lt;/math&gt; and &lt;math&gt;\tanh&lt;/math&gt; operations are applied to ensure that the standard deviations are non-negative and the correlation value is between -1 and 1.<br /> <br /> \begin{align*}<br /> \sigma_x = \exp (\hat \sigma_x),\ <br /> \sigma_y = \exp (\hat \sigma_y),\ <br /> \rho_{xy} = \tanh(\hat \rho_{xy}). <br /> \end{align*}<br /> <br /> Categorical distribution probabilities for &lt;math&gt;(p_1, p_2, p_3)&lt;/math&gt; using &lt;math&gt;(q_1, q_2, q_3)&lt;/math&gt; can be obtained as :<br /> <br /> \begin{align*}<br /> q_k = \frac{\exp{(\hat q_k)}}{ \sum\nolimits_{j = 1}^{3} \exp {(\hat q_j)}},<br /> k \in \left\{1,2,3\right\}, <br /> \Pi _k = \frac{\exp{(\hat \Pi_k)}}{ \sum\nolimits_{j = 1}^{M} \exp {(\hat \Pi_j)}},<br /> k \in \left\{1,...,M\right\}.<br /> \end{align*}<br /> <br /> It is hard for the model to decide when to stop drawing because the probabilities of the three events &lt;math&gt;(p_1, p_2, p_3)&lt;/math&gt; are very unbalanced. Researchers in the past have used different weights for each pen event probability, but the authors found this approach lacking elegance and inadequate. They define a hyperparameter representing the max length of the longest sketch in the training set denoted by &lt;math&gt;N_{max}&lt;/math&gt;, and set the &lt;math&gt;S_i&lt;/math&gt; to be &lt;math&gt;(0, 0, 0, 0, 1)&lt;/math&gt; for &lt;math&gt;i &gt; N_s&lt;/math&gt;.<br /> <br /> The outcome sample &lt;math&gt;S_i^{'}&lt;/math&gt; can be generated in each time step during sample process and fed as input for the next time step. The process will stop when &lt;math&gt;p_3 = 1&lt;/math&gt; or &lt;math&gt;i = N_{max}&lt;/math&gt;. The output is not deterministic but conditioned random sequences. The level of randomness can be controlled using a temperature parameter &lt;math&gt;\tau&lt;/math&gt;.<br /> <br /> \begin{align*}<br /> \hat q_k \rightarrow \frac{\hat q_k}{\tau}, <br /> \hat \Pi_k \rightarrow \frac{\hat \Pi_k}{\tau}, <br /> \sigma_x^2 \rightarrow \sigma_x^2\tau, <br /> \sigma_y^2 \rightarrow \sigma_y^2\tau. <br /> \end{align*}<br /> <br /> The &lt;math&gt;\tau&lt;/math&gt; ranges from 0 to 1. When &lt;math&gt;\tau = 0&lt;/math&gt; the output will be deterministic as the sample will consist of the points on the peak of the probability density function.<br /> <br /> === Unconditional Generation ===<br /> There is a special case that only the decoder RNN module is trained. The decoder RNN could work as a standalone autoregressive model without latent variables. In this case, initial states are 0, the input &lt;math&gt;x_i&lt;/math&gt; is only &lt;math&gt;S_{i-1}&lt;/math&gt; or &lt;math&gt;S_{i-1}^{'}&lt;/math&gt;. In the Figure 3, generating sketches unconditionally from the temperature parameter τ = 0.2 at the top in blue, to τ = 0.9 at the bottom in red.<br /> <br /> [[File:sketchfig3.png|700px|center]]<br /> <br /> === Training ===<br /> The training process is the same as a Variational Autoencoder. The loss function is the sum of Reconstruction Loss &lt;math&gt;L_R&lt;/math&gt; and the Kullback-Leibler Divergence Loss &lt;math&gt;L_{KL}&lt;/math&gt;. The reconstruction loss &lt;math&gt;L_R&lt;/math&gt; can be obtained with generated parameters of pdf and training data &lt;math&gt;S&lt;/math&gt;. It is the sum of the &lt;math&gt;L_s&lt;/math&gt; and &lt;math&gt;L_p&lt;/math&gt;, which are the log loss of the offset &lt;math&gt;(\Delta x, \Delta y)&lt;/math&gt; and the pen state &lt;math&gt;(p_1, p_2, p_3)&lt;/math&gt;.<br /> <br /> \begin{align*}<br /> L_s = - \frac{1 }{N_{max}} \sum_{i = 1}^{N_s} \log(\sum_{i = 1}^{M} \Pi_{j,i} \mathcal{N}(\Delta x,\Delta y | \mu_{x,j,i}, \mu_{y,j,i}, \sigma_{x,j,i},\sigma_{y,j,i}, \rho _{xy,j,i})), <br /> \end{align*}<br /> \begin{align*}<br /> L_p = - \frac{1 }{N_{max}} \sum_{i = 1}^{N_{max}} \sum_{k = 1}^{3} p_{k,i} \log (q_{k,i}), <br /> L_R = L_s + L_p.<br /> \end{align*}<br /> <br /> <br /> Both terms are normalized by &lt;math&gt;N_{max}&lt;/math&gt;.<br /> <br /> &lt;math&gt;L_{KL}&lt;/math&gt; measures the difference between the distribution of the latent vector &lt;math&gt;z&lt;/math&gt; and an IID Gaussian vector with zero mean and unit variance.<br /> <br /> \begin{align*}<br /> L_{KL} = - \frac{1}{2 N_z} (1+\hat \sigma - \mu^2 - \exp(\hat \sigma))<br /> \end{align*}<br /> <br /> The overall loss is weighted as:<br /> <br /> \begin{align*}<br /> Loss = L_R + w_{KL} L_{KL}<br /> \end{align*}<br /> <br /> When &lt;math&gt;w_{KL} = 0&lt;/math&gt;, the model becomes a standalone unconditional generator. Specially, there will be no &lt;math&gt;L_{KL} &lt;/math&gt; term as we only optimize for &lt;math&gt;L_{R} &lt;/math&gt;. By removing the &lt;math&gt;L_{KL} &lt;/math&gt; term the model approaches a pure autoencoder, meaning it sacrifices the ability to enforce a prior over the latent space and gains better reconstruction loss metrics.<br /> <br /> == Experiments ==<br /> The authors experiment with the sketch-rnn model using different settings and recorded both losses. They used a Long Short-Term Memory(LSTM) model as an encoder and a HyperLSTM as a decoder. They also conduct multi-class datasets. The result is as follows.<br /> <br /> [[File:sketchtable1.png|700px]]<br /> <br /> We could see the trade-off between &lt;math&gt;L_R&lt;/math&gt; and &lt;math&gt;L_{KL}&lt;/math&gt; in this table clearly. Furthermore, &lt;math&gt;L_R&lt;/math&gt; decreases as &lt;math&gt;w_{KL} &lt;/math&gt; is halfed. <br /> <br /> === Conditional Reconstruction ===<br /> The authors assess the reconstructed sketch with a given sketch with different &lt;math&gt;\tau&lt;/math&gt; values. We could see that with high &lt;math&gt;\tau&lt;/math&gt; value on the right, the reconstructed sketches are more random.<br /> <br /> [[File:sketchfig5.png|700px|center]]<br /> <br /> They also experiment on inputting a sketch from a different class. The output will still keep some features from the class that the model is trained on.<br /> <br /> === Latent Space Interpolation ===<br /> The authors visualize the reconstruction sketches while interpolating between latent vectors using different &lt;math&gt;w_{KL}&lt;/math&gt; values. With high &lt;math&gt;w_{KL}&lt;/math&gt; values, the generated images are more coherently interpolated.<br /> <br /> [[File:sketchfig6.png|700px|center]]<br /> <br /> === Sketch Drawing Analogies ===<br /> Since the latent vector &lt;math&gt;z&lt;/math&gt; encode conceptual features of a sketch, those features can also be used to augment other sketches that do not have these features. This is possible when models are trained with low &lt;math&gt;L_{KL}&lt;/math&gt; values. The authors are able to perform vector arithmetic on latent vectors from different sketches and explore how the model generates sketches base on these latent spaces.<br /> <br /> === Predicting Different Endings of Incomplete Sketches === <br /> This model is able to predict an incomplete sketch by encoding the sketch into hidden state &lt;math&gt;h&lt;/math&gt; using the decoder and then using &lt;math&gt;h&lt;/math&gt; as an initial hidden state to generate the remaining sketch. The authors train on individual classes by using decoder-only models and set τ = 0.8 to complete samples. Figure 7 shows the results.<br /> <br /> [[File:sketchfig7.png|700px|center]]<br /> <br /> == Applications and Future Work ==<br /> The authors believe this model can assist artists by suggesting how to finish a sketch, helping them to find interesting intersections between different drawings or objects, or generating a lot of similar but different designs. In the simplest use, pattern designers can apply sketch-rnn to generate a large number of similar, but unique designs for textile or wallpaper prints. The creative designers can also come up with abstract designs which enables them to resonate more with their target audience<br /> <br /> This model may also find its place on teaching students how to draw. Even with the simple sketches in QuickDraw, the authors of this work have become much more proficient at drawing animals, insects, and various sea creatures after conducting these experiments. <br /> When the model is trained with a high &lt;math&gt;w_{KL}&lt;/math&gt; and sampled with a low &lt;math&gt;\tau&lt;/math&gt;, it may help to turn a poor sketch into a more aesthetical one. Latent vector augmentation could also help to create a better drawing by inputting user-rating data during training processes.<br /> <br /> The authors conclude by providing the following future directions to this work:<br /> # Investigate using user-rating data to augmenting the latent vector in the direction that maximizes the aesthetics of the drawing.<br /> # Look into combining variations of sequence-generation models with unsupervised, cross-domain pixel image generation models.<br /> <br /> It's exciting that they manage to combine this model with other unsupervised, cross-domain pixel image generation models to create photorealistic images from sketches.<br /> <br /> The authors have also mentioned the opposite direction of converting a photograph of an object into an unrealistic, but similar looking<br /> sketch of the object composed of a minimal number of lines to be a more interesting problem.<br /> <br /> <br /> == Conclusion ==<br /> This paper introduced an interesting model sketch-rnn that can encode and decode sketches, generate and complete unfinished sketches. The authors demonstrated how to interpolate between latent spaces from a different class and how to use it to augment sketches or generate similar looking sketches. They also showed that it's important to enforce a prior distribution on latent vector while interpolating coherent sketch generations. Finally, they created a large sketch drawings dataset to be used in future research.<br /> <br /> == Critique ==<br /> * The performance of the decoder model can hardly be evaluated. The authors present the performance of the decoder by showing the generated sketches, it is clear and straightforward, however, not very efficient. It would be great if the authors could present a way, or a metric to evaluate how well the sketches are generated rather than printing them out and evaluate with human judgment.<br /> <br /> * Same problem as the output, the authors didn't present an evaluation for the algorithms either. They provided &lt;math&gt;L_R&lt;/math&gt; and &lt;math&gt;L_{KL}&lt;/math&gt; for reference, however, a lower loss doesn't represent a better performance.<br /> <br /> * I understand that using strokes as inputs is a novel and innovative move, however, the paper does not provide a baseline or any comparison with other methods or algorithms. Some other researches were mentioned in the paper, using similar and smaller datasets. It would be great if the authors could use some basic or existing methods a baseline and compare with the new algorithm.<br /> <br /> * Besides the comparison with other algorithms, it would also be great if the authors could remove or replace some component of the algorithm in the model to show if one part is necessary, or what made them decide to include a specific component in the algorithm.<br /> <br /> * The authors proposed a few future applications for the model, however, the current output seems somehow not very close to their descriptions. But I do believe that this is a very good beginning, with the release of the sketch dataset, it must attract more scholars to research and improve with it!<br /> <br /> * ([https://openreview.net/forum?id=Hy6GHpkCW]) The paper presents both a novel large dataset of sketches and a new RNN architecture to generate new sketches.<br /> <br /> + new and large dataset<br /> <br /> + novel algorithm<br /> <br /> + well written<br /> <br /> - no evaluation of dataset<br /> <br /> - virtually no evaluation of the algorithm<br /> <br /> - no baselines or comparison<br /> <br /> == References == <br /> # Jimmy L. Ba, Jamie R. Kiros, and Geoffrey E. Hinton. Layer normalization. NIPS, 2016.<br /> # Christopher M. Bishop. Mixture density networks. Technical Report, 1994. URL http://publications.aston.ac.uk/373/.<br /> # Samuel R. Bowman, Luke Vilnis, Oriol Vinyals, Andrew M. Dai, Rafal Józefowicz, and Samy Bengio. Generating Sentences from a Continuous Space. CoRR, abs/1511.06349, 2015. URL http://arxiv.org/abs/1511.06349.<br /> # H. Dong, P. Neekhara, C. Wu, and Y. Guo. Unsupervised Image-to-Image Translation with Generative Adversarial Networks. ArXiv e-prints, January 2017.<br /> # David H. Douglas and Thomas K. Peucker. Algorithms for the reduction of the number of points required to represent a digitized line or its caricature. Cartographica: The International Journal for Geographic Information and Geovisualization, 10(2):112–122, October 1973. doi: 10.3138/fm57-6770-u75u-7727. URL http://dx.doi.org/10.3138/fm57-6770-u75u-7727.<br /> # Mathias Eitz, James Hays, and Marc Alexa. How Do Humans Sketch Objects? ACM Trans. Graph.(Proc. SIGGRAPH), 31(4):44:1–44:10, 2012.<br /> # I. Goodfellow. NIPS 2016 Tutorial: Generative Adversarial Networks. ArXiv e-prints, December 2016.<br /> # Alex Graves. Generating sequences with recurrent neural networks. arXiv:1308.0850, 2013.<br /> # David Ha. Recurrent Net Dreams Up Fake Chinese Characters in Vector Format with TensorFlow, 2015.<br /> # David Ha, Andrew M. Dai, and Quoc V. Le. HyperNetworks. In ICLR, 2017.<br /> # Sepp Hochreiter and Juergen Schmidhuber. Long short-term memory. Neural Computation, 1997.<br /> # P. Isola, J.-Y. Zhu, T. Zhou, and A. A. Efros. Image-to-Image Translation with Conditional Adversarial Networks. ArXiv e-prints, November 2016.<br /> # Jonas Jongejan, Henry Rowley, Takashi Kawashima, Jongmin Kim, and Nick Fox-Gieg. The Quick, Draw! - A.I. Experiment. https://quickdraw.withgoogle.com/, 2016. URL https: //quickdraw.withgoogle.com/.<br /> # C. Kaae Sønderby, T. Raiko, L. Maaløe, S. Kaae Sønderby, and O. Winther. Ladder Variational Autoencoders. ArXiv e-prints, February 2016.<br /> # T. Kim, M. Cha, H. Kim, J. Lee, and J. Kim. Learning to Discover cross-domain Relations with Generative Adversarial Networks. ArXiv e-prints, March 2017.<br /> # D. P Kingma and M. Welling. Auto-Encoding Variational Bayes. ArXiv e-prints, December 2013.<br /> # Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.<br /> # Diederik P. Kingma, Tim Salimans, and Max Welling. Improving variational inference with inverse autoregressive flow. CoRR, abs/1606.04934, 2016. URL http://arxiv.org/abs/1606.04934.<br /> # Brenden M. Lake, Ruslan Salakhutdinov, and Joshua B. Tenenbaum. Human level concept learning through probabilistic program induction. Science, 350(6266):1332–1338, December 2015. ISSN 1095-9203. doi: 10.1126/science.aab3050. URL http://dx.doi.org/10.1126/science.aab3050.<br /> # Yong Jae Lee, C. Lawrence Zitnick, and Michael F. Cohen. Shadowdraw: Real-time user guidance for freehand drawing. In ACM SIGGRAPH 2011 Papers, SIGGRAPH ’11, pp. 27:1–27:10, New York, NY, USA, 2011. ACM. ISBN 978-1-4503-0943-1. doi: 10.1145/1964921.1964922. URL http://doi.acm.org/10.1145/1964921.1964922.<br /> # M.-Y. Liu, T. Breuel, and J. Kautz. Unsupervised Image-to-Image Translation Networks. ArXiv e-prints, March 2017.<br /> # S. Reed, A. van den Oord, N. Kalchbrenner, S. Gómez Colmenarejo, Z. Wang, D. Belov, and N. de Freitas. Parallel Multiscale Autoregressive Density Estimation. ArXiv e-prints, March 2017.<br /> # Patsorn Sangkloy, Nathan Burnell, Cusuh Ham, and James Hays. The Sketchy Database: Learning to Retrieve Badly Drawn Bunnies. ACM Trans. Graph., 35(4):119:1–119:12, July 2016. ISSN 0730-0301. doi: 10.1145/2897824.2925954. URL http://doi.acm.org/10.1145/2897824.2925954.<br /> # Mike Schuster, Kuldip K. Paliwal, and A. General. Bidirectional recurrent neural networks. IEEE Transactions on Signal Processing, 1997.<br /> # Saul Simhon and Gregory Dudek. Sketch interpretation and refinement using statistical models. In Proceedings of the Fifteenth Eurographics Conference on Rendering Techniques, EGSR’04, pp. 23–32, Aire-la-Ville, Switzerland, Switzerland, 2004. Eurographics Association. ISBN 3-905673-12-6. doi: 10.2312/EGWR/EGSR04/023-032. URL http://dx.doi.org/10.2312/EGWR/EGSR04/023-032.<br /> # Patrick Tresset and Frederic Fol Leymarie. Portrait drawing by paul the robot. Comput. Graph.,37(5):348–363, August 2013. ISSN 0097-8493. doi: 10.1016/j.cag.2013.01.012. URL http://dx.doi.org/10.1016/j.cag.2013.01.012.<br /> # T. White. Sampling Generative Networks. ArXiv e-prints, September 2016.<br /> #Ning Xie, Hirotaka Hachiya, and Masashi Sugiyama. Artist agent: A reinforcement learning approach to automatic stroke generation in oriental ink painting. In ICML. icml.cc / Omnipress, 2012. URL http://dblp.uni-trier.de/db/conf/icml/icml2012.html#XieHS12.<br /> # Xu-Yao Zhang, Fei Yin, Yan-Ming Zhang, Cheng-Lin Liu, and Yoshua Bengio. Drawing and Recognizing Chinese Characters with Recurrent Neural Network. CoRR, abs/1606.06539, 2016. URL http://arxiv.org/abs/1606.06539.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=a_neural_representation_of_sketch_drawings&diff=41152 a neural representation of sketch drawings 2018-11-23T14:40:32Z <p>Jmmoosa: /* Dataset */</p> <hr /> <div><br /> == Introduction ==<br /> In this paper, The authors present a recurrent neural network, sketch-rnn, that can be used to construct stroke-based drawings. Besides new robust training methods, they also outline a framework for conditional and unconditional sketch generation.<br /> <br /> Neural networks have been heavily used as image generation tools. For example, Generative Adversarial Networks, Variational Inference, and Autoregressive models have been used. Most of those models are designed to generate pixels to construct images. However, people learn to draw using sequences of strokes, beginning when they are young. The authors propose a new generative model that creates vector images so that it might generalize abstract concepts in a manner more similar to how humans do. <br /> <br /> The model is trained with hand-drawn sketches as input sequences. The model is able to produce sketches in vector format. In the conditional generation model, they also explore the latent space representation for vector images and discuss a few future applications of this model. The model and dataset are now available as an open source project ([https://magenta.tensorflow.org/sketch_rnn link]).<br /> <br /> === Terminology ===<br /> Pixel images, also referred to as raster or bitmap images are files that encode image data as a set of pixels. These are the most common image type, with extensions such as .png, .jpg, .bmp. <br /> <br /> Vector images are files that encode image data as paths between points. SVG and EPS file types are used to store vector images. <br /> <br /> For a visual comparison of raster and vector images, see this [https://www.youtube.com/watch?v=-Fs2t6P5AjY video]. As mentioned, vector images are generally simpler and more abstract, whereas raster images generally are used to store detailed images. <br /> <br /> For this paper, the important distinction between the two is that the encoding of images in the model will be inherently more abstract because of the vector representation. The intuition is that generating abstract representations is more effective using a vector representation. <br /> <br /> == Related Work ==<br /> There are some works in the history that used a similar approach to generate images such as Portrait Drawing by Paul the Robot and some reinforcement learning approaches. They work more like a mimic of digitized photographs. There are also some Neural networks based approaches, but those are mostly dealing with pixel images. Little work is done on vector images generation. There are models that use Hidden Markov Models or Mixture Density Networks to generate human sketches, continuous data points or vectorized Kanji characters.<br /> <br /> The model also allows us to explore the latent space representation of vector images. There are previous works that achieved similar functions as well, such as combining Sequence-to-Sequence models with Variational Autoencoder to model sentences into latent space and using probabilistic program induction to model Omniglot dataset.<br /> <br /> The dataset they use contains 50 million vector sketches. Before this paper, there is a Sketch data with 20k vector sketches, a Sketchy dataset with 70k vector sketches along with pixel images, and a ShadowDraw system that used 30k raster images along with extracted vectorized features. They are all comparatively small.<br /> <br /> == Methodology ==<br /> === Dataset ===<br /> QuickDraw is a dataset with 50 million vector drawings collected by an online game Quick Draw!, where the players are required to draw objects belonging to a particular object class in less than 20 seconds. It contains hundreds of classes, each class has 70k training samples, 2.5k validation samples and 2.5k test samples.<br /> <br /> The data format of each sample is a representation of a pen stroke action event. The Origin is the initial coordinate of the drawing. The sketches are points in a list. Each point consists of 5 elements &lt;math&gt; (\Delta x, \Delta y, p_{1}, p_{2}, p_{3})&lt;/math&gt; where x and y are the offset distance in x and y directions from the previous point. The parameters &lt;math&gt;p_{1}, p_{2}, p_{3}&lt;/math&gt; represent three possible states in binary one-hot representation where &lt;math&gt;p_{1}&lt;/math&gt; indicates the pen is touching the paper, &lt;math&gt;p_{2}&lt;/math&gt; indicates the pen will be lifted from here, and &lt;math&gt;p_{3}&lt;/math&gt; represents the drawing has ended.<br /> <br /> === Sketch-RNN ===<br /> [[File:sketchfig2.png|700px|center]]<br /> <br /> The model is a Sequence-to-Sequence Variational Autoencoder(VAE). The encoder is a bidirectional RNN, the input is a sketch sequence denoted by &lt;math&gt;S&lt;/math&gt; and a reversed sketch sequence denoted by &lt;math&gt;S_{reverse}&lt;/math&gt;, so there will be two final hidden states. The output is a size &lt;math&gt;N_{z}&lt;/math&gt; latent vector.<br /> <br /> \begin{align*}<br /> h_{ \rightarrow} = encode_{ \rightarrow }(S), <br /> h_{ \leftarrow} = encode_{ \leftarrow }(S_{reverse}), <br /> h = [h_{\rightarrow}; h_{\leftarrow}].<br /> \end{align*}<br /> <br /> Then the authors project &lt;math&gt;h&lt;/math&gt; into to &lt;math&gt;\mu&lt;/math&gt; and &lt;math&gt;\hat{\sigma}&lt;/math&gt;. Both &lt;math&gt;\mu&lt;/math&gt; and &lt;math&gt;\hat{\sigma}&lt;/math&gt; are vectors of size &lt;math&gt;N_{z}&lt;/math&gt;. The projection is performed using a fully connected layer. Then, using the exponential function the authors convert &lt;math&gt;\hat{\sigma}&lt;/math&gt; into a non-negative standard deviation parameter denoted by &lt;math&gt;\sigma&lt;/math&gt;. The Authors then use &lt;math&gt;\mu&lt;/math&gt; and &lt;math&gt;\sigma&lt;/math&gt; with &lt;math&gt;\mathcal{N}(0,I)&lt;/math&gt; to construct a random vector &lt;math&gt;z\in\mathbb{R}^{N_{z}}&lt;/math&gt;.<br /> <br /> \begin{align*}<br /> \mu = W_\mu h + b_\mu, <br /> \hat \sigma = W_\sigma h + b_\sigma, <br /> \sigma = exp( \frac{\hat \sigma}{2}), <br /> z = \mu + \sigma \odot \mathcal{N}(0,I).<br /> \end{align*}<br /> <br /> <br /> Note that &lt;math&gt;z&lt;/math&gt; is not deterministic but a conditioned random vector.<br /> <br /> The decoder is an autoregressive RNN. The initial hidden states are generated using &lt;math&gt;[h_0;c_0] = \tanh(W_z z+b_z)&lt;/math&gt; where &lt;math&gt;c_0&lt;/math&gt; is utilized if applicable. &lt;math&gt;S_0&lt;/math&gt; is defined as &lt;math&gt;(0,0,1,0,0)&lt;/math&gt;. For each step i in the decoder, the input &lt;math&gt;x_i&lt;/math&gt; is the concatenation of previous point &lt;math&gt;S_{i-1}&lt;/math&gt; and latent vector &lt;math&gt;z&lt;/math&gt;. The output are probability distribution parameters for the next data point &lt;math&gt;S_i&lt;/math&gt;. The authors model &lt;math&gt;(\Delta x,\Delta y)&lt;/math&gt; as a Gaussian mixture model (GMM) with &lt;math&gt;M&lt;/math&gt; normal distributions and model the ground truth data &lt;math&gt;(p_1, p_2, p_3)&lt;/math&gt; as categorical distribution &lt;math&gt;(q_1, q_2, q_3)&lt;/math&gt; where &lt;math&gt;q_1, q_2\ \text{and}\ q_3&lt;/math&gt; sum up to 1. The generated sequence is conditioned from the latent vector &lt;math&gt;z&lt;/math&gt; that is sampled from the encoder, which is end-to-end trained together with the decoder.<br /> <br /> \begin{align*}<br /> p(\Delta x, \Delta y) = \sum_{j=1}^{M} \Pi_j \mathcal{N}(\Delta x,\Delta y | \mu_{x,j}, \mu_{y,j}, \sigma_{x,j},\sigma_{y,j}, \rho _{xy,j}), where \sum_{j=1}^{M}\Pi_j = 1<br /> \end{align*}<br /> <br /> Here the &lt;math&gt;\mathcal{N}(\Delta x,\Delta y | \mu_{x,j}, \mu_{y,j}, \sigma_{x,j},\sigma_{y,j}, \rho _{xy,j})&lt;/math&gt; is the probability distribution function for &lt;math&gt;x,y&lt;/math&gt;. Each of the M bivariate normal distributions being summed have five parameters: &lt;math&gt;(\mu_x, \mu_y, \sigma_x, \sigma_y, \rho_{xy})&lt;/math&gt;, where &lt;math&gt;\mu_x, \mu_y&lt;/math&gt; are means, &lt;math&gt;\sigma_x, \sigma_y&lt;/math&gt; are the standard deviations, and &lt;math&gt;\rho_{xy}&lt;/math&gt;is the correlation parameter for these bivariate normal distribution. The &lt;math&gt;\Pi&lt;/math&gt; is a length M categorical distribution vector are the mixture weights of the Gaussian mixture model.<br /> <br /> The output vector &lt;math&gt;y_i&lt;/math&gt; is generated using a fully-connected forward propagation in the hidden state of the RNN.<br /> <br /> \begin{align*}<br /> x_i = [S_{i-1}; z], <br /> [h_i; c_i] = forward(x_i,[h_{i-1}; c_{i-1}]), <br /> y_i = W_y h_i + b_y,<br /> y_i \in \mathbb{R}^{6M+3}.<br /> \end{align*}<br /> <br /> The output consists the probability distribution of the next data point.<br /> <br /> \begin{align*}<br /> [(\hat\Pi_1\ \mu_x\ \mu_y\ \hat\sigma_x\ \hat\sigma_y\ \hat\rho_{xy})_1\ (\hat\Pi_1\ \mu_x\ \mu_y\ \hat\sigma_x\ \hat\sigma_y\ \hat\rho_{xy})_2\ ...\ (\hat\Pi_1\ \mu_x\ \mu_y\ \hat\sigma_x\ \hat\sigma_y\ \hat\rho_{xy})_M\ (\hat{q_1}\ \hat{q_2}\ \hat{q_3})] = y_i<br /> \end{align*}<br /> <br /> &lt;math&gt;\exp&lt;/math&gt; and &lt;math&gt;\tanh&lt;/math&gt; operations are applied to ensure that the standard deviations are non-negative and the correlation value is between -1 and 1.<br /> <br /> \begin{align*}<br /> \sigma_x = \exp (\hat \sigma_x),\ <br /> \sigma_y = \exp (\hat \sigma_y),\ <br /> \rho_{xy} = \tanh(\hat \rho_{xy}). <br /> \end{align*}<br /> <br /> Categorical distribution probabilities for &lt;math&gt;(p_1, p_2, p_3)&lt;/math&gt; using &lt;math&gt;(q_1, q_2, q_3)&lt;/math&gt; can be obtained as :<br /> <br /> \begin{align*}<br /> q_k = \frac{\exp{(\hat q_k)}}{ \sum\nolimits_{j = 1}^{3} \exp {(\hat q_j)}},<br /> k \in \left\{1,2,3\right\}, <br /> \Pi _k = \frac{\exp{(\hat \Pi_k)}}{ \sum\nolimits_{j = 1}^{M} \exp {(\hat \Pi_j)}},<br /> k \in \left\{1,...,M\right\}.<br /> \end{align*}<br /> <br /> It is hard for the model to decide when to stop drawing because the probabilities of the three events &lt;math&gt;(p_1, p_2, p_3)&lt;/math&gt; are very unbalanced. Researchers in the past have used different weights for each pen event probability, but the authors found this approach lacking elegance and inadequate. They define a hyperparameter representing the max length of the longest sketch in the training set denoted by &lt;math&gt;N_{max}&lt;/math&gt;, and set the &lt;math&gt;S_i&lt;/math&gt; to be &lt;math&gt;(0, 0, 0, 0, 1)&lt;/math&gt; for &lt;math&gt;i &gt; N_s&lt;/math&gt;.<br /> <br /> The outcome sample &lt;math&gt;S_i^{'}&lt;/math&gt; can be generated in each time step during sample process and fed as input for the next time step. The process will stop when &lt;math&gt;p_3 = 1&lt;/math&gt; or &lt;math&gt;i = N_{max}&lt;/math&gt;. The output is not deterministic but conditioned random sequences. The level of randomness can be controlled using a temperature parameter &lt;math&gt;\tau&lt;/math&gt;.<br /> <br /> \begin{align*}<br /> \hat q_k \rightarrow \frac{\hat q_k}{\tau}, <br /> \hat \Pi_k \rightarrow \frac{\hat \Pi_k}{\tau}, <br /> \sigma_x^2 \rightarrow \sigma_x^2\tau, <br /> \sigma_y^2 \rightarrow \sigma_y^2\tau. <br /> \end{align*}<br /> <br /> The &lt;math&gt;\tau&lt;/math&gt; ranges from 0 to 1. When &lt;math&gt;\tau = 0&lt;/math&gt; the output will be deterministic as the sample will consist of the points on the peak of the probability density function.<br /> <br /> === Unconditional Generation ===<br /> There is a special case that only the decoder RNN module is trained. The decoder RNN could work as a standalone autoregressive model without latent variables. In this case, initial states are 0, the input &lt;math&gt;x_i&lt;/math&gt; is only &lt;math&gt;S_{i-1}&lt;/math&gt; or &lt;math&gt;S_{i-1}^{'}&lt;/math&gt;. In the Figure 3, generating sketches unconditionally from the temperature parameter τ = 0.2 at the top in blue, to τ = 0.9 at the bottom in red.<br /> <br /> [[File:sketchfig3.png|700px|center]]<br /> <br /> === Training ===<br /> The training process is the same as a Variational Autoencoder. The loss function is the sum of Reconstruction Loss &lt;math&gt;L_R&lt;/math&gt; and the Kullback-Leibler Divergence Loss &lt;math&gt;L_{KL}&lt;/math&gt;. The reconstruction loss &lt;math&gt;L_R&lt;/math&gt; can be obtained with generated parameters of pdf and training data &lt;math&gt;S&lt;/math&gt;. It is the sum of the &lt;math&gt;L_s&lt;/math&gt; and &lt;math&gt;L_p&lt;/math&gt;, which are the log loss of the offset &lt;math&gt;(\Delta x, \Delta y)&lt;/math&gt; and the pen state &lt;math&gt;(p_1, p_2, p_3)&lt;/math&gt;.<br /> <br /> \begin{align*}<br /> L_s = - \frac{1 }{N_{max}} \sum_{i = 1}^{N_s} \log(\sum_{i = 1}^{M} \Pi_{j,i} \mathcal{N}(\Delta x,\Delta y | \mu_{x,j,i}, \mu_{y,j,i}, \sigma_{x,j,i},\sigma_{y,j,i}, \rho _{xy,j,i})), <br /> \end{align*}<br /> \begin{align*}<br /> L_p = - \frac{1 }{N_{max}} \sum_{i = 1}^{N_{max}} \sum_{k = 1}^{3} p_{k,i} \log (q_{k,i}), <br /> L_R = L_s + L_p.<br /> \end{align*}<br /> <br /> <br /> Both terms are normalized by &lt;math&gt;N_{max}&lt;/math&gt;.<br /> <br /> &lt;math&gt;L_{KL}&lt;/math&gt; measures the difference between the distribution of the latent vector &lt;math&gt;z&lt;/math&gt; and an IID Gaussian vector with zero mean and unit variance.<br /> <br /> \begin{align*}<br /> L_{KL} = - \frac{1}{2 N_z} (1+\hat \sigma - \mu^2 - \exp(\hat \sigma))<br /> \end{align*}<br /> <br /> The overall loss is weighted as:<br /> <br /> \begin{align*}<br /> Loss = L_R + w_{KL} L_{KL}<br /> \end{align*}<br /> <br /> When &lt;math&gt;w_{KL} = 0&lt;/math&gt;, the model becomes a standalone unconditional generator. Specially, there will be no &lt;math&gt;L_{KL} &lt;/math&gt; term as we only optimize for &lt;math&gt;L_{R} &lt;/math&gt;. By removing the &lt;math&gt;L_{KL} &lt;/math&gt; term the model approaches a pure autoencoder, meaning it sacrifices the ability to enforce a prior over the latent space and gains better reconstruction loss metrics.<br /> <br /> == Experiments ==<br /> The authors experiment with the sketch-rnn model using different settings and recorded both losses. They used a Long Short-Term Memory(LSTM) model as an encoder and a HyperLSTM as a decoder. They also conduct multi-class datasets. The result is as follows.<br /> <br /> [[File:sketchtable1.png|700px]]<br /> <br /> We could see the trade-off between &lt;math&gt;L_R&lt;/math&gt; and &lt;math&gt;L_{KL}&lt;/math&gt; in this table clearly. Furthermore, &lt;math&gt;L_R&lt;/math&gt; decreases as &lt;math&gt;w_{KL} &lt;/math&gt; is halfed. <br /> <br /> === Conditional Reconstruction ===<br /> The authors assess the reconstructed sketch with a given sketch with different &lt;math&gt;\tau&lt;/math&gt; values. We could see that with high &lt;math&gt;\tau&lt;/math&gt; value on the right, the reconstructed sketches are more random.<br /> <br /> [[File:sketchfig5.png|700px|center]]<br /> <br /> They also experiment on inputting a sketch from a different class. The output will still keep some features from the class that the model is trained on.<br /> <br /> === Latent Space Interpolation ===<br /> The authors visualize the reconstruction sketches while interpolating between latent vectors using different &lt;math&gt;w_{KL}&lt;/math&gt; values. With high &lt;math&gt;w_{KL}&lt;/math&gt; values, the generated images are more coherently interpolated.<br /> <br /> [[File:sketchfig6.png|700px|center]]<br /> <br /> === Sketch Drawing Analogies ===<br /> Since the latent vector &lt;math&gt;z&lt;/math&gt; encode conceptual features of a sketch, those features can also be used to augment other sketches that do not have these features. This is possible when models are trained with low &lt;math&gt;L_{KL}&lt;/math&gt; values. The authors are able to perform vector arithmetic on latent vectors from different sketches and explore how the model generates sketches base on these latent spaces.<br /> <br /> === Predicting Different Endings of Incomplete Sketches === <br /> This model is able to predict an incomplete sketch by encoding the sketch into hidden state &lt;math&gt;h&lt;/math&gt; using the decoder and then using &lt;math&gt;h&lt;/math&gt; as an initial hidden state to generate the remaining sketch. The authors train on individual classes by using decoder-only models and set τ = 0.8 to complete samples. Figure 7 shows the results.<br /> <br /> [[File:sketchfig7.png|700px|center]]<br /> <br /> == Applications and Future Work ==<br /> The authors believe this model can assist artists by suggesting how to finish a sketch, helping them to find interesting intersections between different drawings or objects, or generating a lot of similar but different designs. In the simplest use, pattern designers can apply sketch-rnn to generate a large number of similar, but unique designs for textile or wallpaper prints. The creative designers can also come up with abstract designs which enables them to resonate more with their target audience<br /> <br /> This model may also find its place on teaching students how to draw. Even with the simple sketches in QuickDraw, the authors of this work have become much more proficient at drawing animals, insects, and various sea creatures after conducting these experiments. <br /> When the model is trained with a high &lt;math&gt;w_{KL}&lt;/math&gt; and sampled with a low &lt;math&gt;\tau&lt;/math&gt;, it may help to turn a poor sketch into a more aesthetical one. Latent vector augmentation could also help to create a better drawing by inputting user-rating data during training processes.<br /> <br /> The authors conclude by providing the following future directions to this work:<br /> # Investigate using user-rating data to augmenting the latent vector in the direction that maximizes the aesthetics of the drawing.<br /> # Look into combining variations of sequence-generation models with unsupervised, cross-domain pixel image generation models.<br /> <br /> It's exciting that they manage to combine this model with other unsupervised, cross-domain pixel image generation models to create photorealistic images from sketches.<br /> <br /> The authors have also mentioned the opposite direction of converting a photograph of an object into an unrealistic, but similar looking<br /> sketch of the object composed of a minimal number of lines to be a more interesting problem.<br /> <br /> <br /> == Conclusion ==<br /> This paper introduced an interesting model sketch-rnn that can encode and decode sketches, generate and complete unfinished sketches. The authors demonstrated how to interpolate between latent spaces from a different class and how to use it to augment sketches or generate similar looking sketches. They also showed that it's important to enforce a prior distribution on latent vector while interpolating coherent sketch generations. Finally, they created a large sketch drawings dataset to be used in future research.<br /> <br /> == Critique ==<br /> * The performance of the decoder model can hardly be evaluated. The authors present the performance of the decoder by showing the generated sketches, it is clear and straightforward, however, not very efficient. It would be great if the authors could present a way, or a metric to evaluate how well the sketches are generated rather than printing them out and evaluate with human judgment.<br /> <br /> * Same problem as the output, the authors didn't present an evaluation for the algorithms either. They provided &lt;math&gt;L_R&lt;/math&gt; and &lt;math&gt;L_{KL}&lt;/math&gt; for reference, however, a lower loss doesn't represent a better performance.<br /> <br /> * I understand that using strokes as inputs is a novel and innovative move, however, the paper does not provide a baseline or any comparison with other methods or algorithms. Some other researches were mentioned in the paper, using similar and smaller datasets. It would be great if the authors could use some basic or existing methods a baseline and compare with the new algorithm.<br /> <br /> * Besides the comparison with other algorithms, it would also be great if the authors could remove or replace some component of the algorithm in the model to show if one part is necessary, or what made them decide to include a specific component in the algorithm.<br /> <br /> * The authors proposed a few future applications for the model, however, the current output seems somehow not very close to their descriptions. But I do believe that this is a very good beginning, with the release of the sketch dataset, it must attract more scholars to research and improve with it!<br /> <br /> * ([https://openreview.net/forum?id=Hy6GHpkCW]) The paper presents both a novel large dataset of sketches and a new RNN architecture to generate new sketches.<br /> <br /> + new and large dataset<br /> <br /> + novel algorithm<br /> <br /> + well written<br /> <br /> - no evaluation of dataset<br /> <br /> - virtually no evaluation of the algorithm<br /> <br /> - no baselines or comparison<br /> <br /> == References == <br /> # Jimmy L. Ba, Jamie R. Kiros, and Geoffrey E. Hinton. Layer normalization. NIPS, 2016.<br /> # Christopher M. Bishop. Mixture density networks. Technical Report, 1994. URL http://publications.aston.ac.uk/373/.<br /> # Samuel R. Bowman, Luke Vilnis, Oriol Vinyals, Andrew M. Dai, Rafal Józefowicz, and Samy Bengio. Generating Sentences from a Continuous Space. CoRR, abs/1511.06349, 2015. URL http://arxiv.org/abs/1511.06349.<br /> # H. Dong, P. Neekhara, C. Wu, and Y. Guo. Unsupervised Image-to-Image Translation with Generative Adversarial Networks. ArXiv e-prints, January 2017.<br /> # David H. Douglas and Thomas K. Peucker. Algorithms for the reduction of the number of points required to represent a digitized line or its caricature. Cartographica: The International Journal for Geographic Information and Geovisualization, 10(2):112–122, October 1973. doi: 10.3138/fm57-6770-u75u-7727. URL http://dx.doi.org/10.3138/fm57-6770-u75u-7727.<br /> # Mathias Eitz, James Hays, and Marc Alexa. How Do Humans Sketch Objects? ACM Trans. Graph.(Proc. SIGGRAPH), 31(4):44:1–44:10, 2012.<br /> # I. Goodfellow. NIPS 2016 Tutorial: Generative Adversarial Networks. ArXiv e-prints, December 2016.<br /> # Alex Graves. Generating sequences with recurrent neural networks. arXiv:1308.0850, 2013.<br /> # David Ha. Recurrent Net Dreams Up Fake Chinese Characters in Vector Format with TensorFlow, 2015.<br /> # David Ha, Andrew M. Dai, and Quoc V. Le. HyperNetworks. In ICLR, 2017.<br /> # Sepp Hochreiter and Juergen Schmidhuber. Long short-term memory. Neural Computation, 1997.<br /> # P. Isola, J.-Y. Zhu, T. Zhou, and A. A. Efros. Image-to-Image Translation with Conditional Adversarial Networks. ArXiv e-prints, November 2016.<br /> # Jonas Jongejan, Henry Rowley, Takashi Kawashima, Jongmin Kim, and Nick Fox-Gieg. The Quick, Draw! - A.I. Experiment. https://quickdraw.withgoogle.com/, 2016. URL https: //quickdraw.withgoogle.com/.<br /> # C. Kaae Sønderby, T. Raiko, L. Maaløe, S. Kaae Sønderby, and O. Winther. Ladder Variational Autoencoders. ArXiv e-prints, February 2016.<br /> # T. Kim, M. Cha, H. Kim, J. Lee, and J. Kim. Learning to Discover cross-domain Relations with Generative Adversarial Networks. ArXiv e-prints, March 2017.<br /> # D. P Kingma and M. Welling. Auto-Encoding Variational Bayes. ArXiv e-prints, December 2013.<br /> # Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In ICLR, 2015.<br /> # Diederik P. Kingma, Tim Salimans, and Max Welling. Improving variational inference with inverse autoregressive flow. CoRR, abs/1606.04934, 2016. URL http://arxiv.org/abs/1606.04934.<br /> # Brenden M. Lake, Ruslan Salakhutdinov, and Joshua B. Tenenbaum. Human level concept learning through probabilistic program induction. Science, 350(6266):1332–1338, December 2015. ISSN 1095-9203. doi: 10.1126/science.aab3050. URL http://dx.doi.org/10.1126/science.aab3050.<br /> # Yong Jae Lee, C. Lawrence Zitnick, and Michael F. Cohen. Shadowdraw: Real-time user guidance for freehand drawing. In ACM SIGGRAPH 2011 Papers, SIGGRAPH ’11, pp. 27:1–27:10, New York, NY, USA, 2011. ACM. ISBN 978-1-4503-0943-1. doi: 10.1145/1964921.1964922. URL http://doi.acm.org/10.1145/1964921.1964922.<br /> # M.-Y. Liu, T. Breuel, and J. Kautz. Unsupervised Image-to-Image Translation Networks. ArXiv e-prints, March 2017.<br /> # S. Reed, A. van den Oord, N. Kalchbrenner, S. Gómez Colmenarejo, Z. Wang, D. Belov, and N. de Freitas. Parallel Multiscale Autoregressive Density Estimation. ArXiv e-prints, March 2017.<br /> # Patsorn Sangkloy, Nathan Burnell, Cusuh Ham, and James Hays. The Sketchy Database: Learning to Retrieve Badly Drawn Bunnies. ACM Trans. Graph., 35(4):119:1–119:12, July 2016. ISSN 0730-0301. doi: 10.1145/2897824.2925954. URL http://doi.acm.org/10.1145/2897824.2925954.<br /> # Mike Schuster, Kuldip K. Paliwal, and A. General. Bidirectional recurrent neural networks. IEEE Transactions on Signal Processing, 1997.<br /> # Saul Simhon and Gregory Dudek. Sketch interpretation and refinement using statistical models. In Proceedings of the Fifteenth Eurographics Conference on Rendering Techniques, EGSR’04, pp. 23–32, Aire-la-Ville, Switzerland, Switzerland, 2004. Eurographics Association. ISBN 3-905673-12-6. doi: 10.2312/EGWR/EGSR04/023-032. URL http://dx.doi.org/10.2312/EGWR/EGSR04/023-032.<br /> # Patrick Tresset and Frederic Fol Leymarie. Portrait drawing by paul the robot. Comput. Graph.,37(5):348–363, August 2013. ISSN 0097-8493. doi: 10.1016/j.cag.2013.01.012. URL http://dx.doi.org/10.1016/j.cag.2013.01.012.<br /> # T. White. Sampling Generative Networks. ArXiv e-prints, September 2016.<br /> #Ning Xie, Hirotaka Hachiya, and Masashi Sugiyama. Artist agent: A reinforcement learning approach to automatic stroke generation in oriental ink painting. In ICML. icml.cc / Omnipress, 2012. URL http://dblp.uni-trier.de/db/conf/icml/icml2012.html#XieHS12.<br /> # Xu-Yao Zhang, Fei Yin, Yan-Ming Zhang, Cheng-Lin Liu, and Yoshua Bengio. Drawing and Recognizing Chinese Characters with Recurrent Neural Network. CoRR, abs/1606.06539, 2016. URL http://arxiv.org/abs/1606.06539.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=conditional_neural_process&diff=40921 conditional neural process 2018-11-22T17:41:20Z <p>Jmmoosa: /* Gaussian Process Framework */</p> <hr /> <div>== Introduction ==<br /> <br /> To train a model effectively, deep neural networks typically require large datasets. To mitigate this data efficiency problem, learning in two phases is one approach: the first phase learns the statistics of a generic domain without committing to a specific learning task; the second phase learns a function for a specific task but does so using only a small number of data points by exploiting the domain-wide statistics already learned. Taking a probabilistic stance and specifying a distribution over functions (stochastic processes) is another approach -- Gaussian Processes being a commonly used example of this. Such Bayesian methods can be computationally expensive, however. <br /> <br /> The authors of the paper propose a family of models that represent solutions to the supervised problem, and an end-to-end training approach to learning them that combines neural networks with features reminiscent of Gaussian Processes. They call this family of models Conditional Neural Processes (CNPs). CNPs can be trained on very few data points to make accurate predictions, while they also have the capacity to scale to complex functions and large datasets. <br /> <br /> == Model ==<br /> Consider a data set &lt;math display=&quot;inline&quot;&gt; \{x_i, y_i\} &lt;/math&gt; with evaluations &lt;math display=&quot;inline&quot;&gt;y_i = f(x_i) &lt;/math&gt; for some unknown function &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt;. Assume &lt;math display=&quot;inline&quot;&gt;g&lt;/math&gt; is an approximating function of f. The aim is to minimize the loss between &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;g&lt;/math&gt; on the entire space &lt;math display=&quot;inline&quot;&gt;X&lt;/math&gt;. In practice, the routine is evaluated on a finite set of observations.<br /> <br /> <br /> Let training set be &lt;math display=&quot;inline&quot;&gt; O = \{x_i, y_i\}_{i = 0} ^{n-1}&lt;/math&gt;, and test set be &lt;math display=&quot;inline&quot;&gt; T = \{x_i, y_i\}_{i = n} ^ {n + m - 1} \subset X&lt;/math&gt; of unlabelled points.<br /> <br /> P be a probability distribution over functions &lt;math display=&quot;inline&quot;&gt; F : X \to Y&lt;/math&gt;, formally known as a stochastic process. Thus, P defines a joint distribution over the random variables &lt;math display=&quot;inline&quot;&gt; {f(x_i)}_{i = 0} ^{n + m - 1}&lt;/math&gt;. Therefore, for &lt;math display=&quot;inline&quot;&gt; P(f(x)|O, T)&lt;/math&gt;, our task is to predict the output values &lt;math display=&quot;inline&quot;&gt;f(x_i)&lt;/math&gt; for &lt;math display=&quot;inline&quot;&gt; x_i \in T&lt;/math&gt;, given &lt;math display=&quot;inline&quot;&gt; O&lt;/math&gt;. <br /> <br /> A common assumption made on P is that all function evaluations of &lt;math display=&quot;inline&quot;&gt; f &lt;/math&gt; is Gaussian distributed. The random functions class is called Gaussian Processes (GPs). This framework of the stochastic process allows a model to be data efficient, however, it's hard to get appropriate priors and stochastic processes are expensive in computation, scaling poorly with &lt;math&gt;n&lt;/math&gt; and &lt;math&gt;m&lt;/math&gt;. One of the examples is GPs, which has running time &lt;math&gt;O(n+3)^3&lt;/math&gt;.<br /> <br /> [[File:001.jpg|300px|center]]<br /> <br /> == Conditional Neural Process ==<br /> <br /> Conditional Neural Process models directly parametrize conditional stochastic processes without imposing consistency with respect to some prior process. CNP parametrize distributions over &lt;math display=&quot;inline&quot;&gt;f(T)&lt;/math&gt; given a distributed representation of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; of fixed dimensionality. Thus, the mathematical guarantees associated with stochastic processes is traded off for functional flexibility and scalability.<br /> <br /> CNP is a conditional stochastic process &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; defines distributions over &lt;math display=&quot;inline&quot;&gt;f(x_i)&lt;/math&gt; for &lt;math display=&quot;inline&quot;&gt;x_i \in T&lt;/math&gt;, given a set of observations &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt;. For stochastic processs, the authors assume that &lt;math display=&quot;inline&quot;&gt;Q_{\theta}&lt;/math&gt; is invariant to permutations, and &lt;math display=&quot;inline&quot;&gt;Q_\theta(f(T) | O, T)= Q_\theta(f(T') | O, T')=Q_\theta(f(T) | O', T) &lt;/math&gt; when &lt;math&gt; O', T'&lt;/math&gt; are permutations of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;T &lt;/math&gt;. In this work, we generally enforce permutation invariance with respect to &lt;math display=&quot;inline&quot;&gt;T&lt;/math&gt; be assuming a factored structure, which is the easiest way to ensure a valid stochastic process. That is, &lt;math display=&quot;inline&quot;&gt;Q_\theta(f(T) | O, T) = \prod _{x \in T} Q_\theta(f(x) | O, x)&lt;/math&gt;. Moreover, this framework can be extended to non-factored distributions.<br /> <br /> In detail, the following architecture is used<br /> <br /> &lt;math display=&quot;inline&quot;&gt;r_i = h_\theta(x_i, y_i)&lt;/math&gt; for any &lt;math display=&quot;inline&quot;&gt;(x_i, y_i) \in O&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;h_\theta : X \times Y \to \mathbb{R} ^ d&lt;/math&gt;<br /> <br /> &lt;math display=&quot;inline&quot;&gt;r = r_i * r_2 * ... * r_n&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;*&lt;/math&gt; is a commutative operation that takes elements in &lt;math display=&quot;inline&quot;&gt;\mathbb{R}^d&lt;/math&gt; and maps them into a single element of &lt;math display=&quot;inline&quot;&gt;\mathbb{R} ^ d&lt;/math&gt;<br /> <br /> &lt;math display=&quot;inline&quot;&gt;\Phi_i = g_\theta&lt;/math&gt; for any &lt;math display=&quot;inline&quot;&gt;x_i \in T&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;g_\theta : X \times \mathbb{R} ^ d \to \mathbb{R} ^ e&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;\Phi_i&lt;/math&gt; are parameters for &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt;<br /> <br /> Note that this architecture ensures permutation invariance and &lt;math display=&quot;inline&quot;&gt;O(n + m)&lt;/math&gt; scaling for conditional prediction. Also, &lt;math display=&quot;inline&quot;&gt;r = r_i * r_2 * ... * r_n&lt;/math&gt; can be computed in &lt;math display=&quot;inline&quot;&gt;O(n)&lt;/math&gt;, this architecture supports streaming observation with minimal overhead.<br /> <br /> We train &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; by asking it to predict &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; conditioned on a randomly<br /> chosen subset of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt;. This gives the model a signal of the uncertainty over the space X inherent in the distribution<br /> P given a set of observations. The authors let &lt;math display=&quot;inline&quot;&gt; f \sim P&lt;/math&gt;, &lt;math display=&quot;inline&quot;&gt; O = \{(x_i, y_i)\}_{i = 0} ^{n-1}&lt;/math&gt;, and N ~ uniform[0, 1, ..... ,n-1]. Subset &lt;math display=&quot;inline&quot;&gt; O = \{(x_i, y_i)\}_{i = 0} ^{N}&lt;/math&gt; that is first N elements of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; is regarded as condition. The negative conditional log probability is given by<br /> $\mathcal{L}(\theta)=-\mathbb{E}_{f \sim p}[\mathbb{E}_{N}[\log Q_\theta(\{y_i\}_{i = 0} ^{n-1}|O_{N}, \{x_i\}_{i = 0} ^{n-1})]]$<br /> Thus, the targets it scores &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; on include both the observed <br /> and unobserved values. In practice, Monte Carlo estimates of the gradient of this loss is taken by sampling &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;N&lt;/math&gt;. <br /> <br /> This approach shifts the burden of imposing prior knowledge from an analytic prior to empirical data. This has the advantage of liberating a practitioner from having to specify an analytic form for the prior, which is ultimately<br /> intended to summarize their empirical experience. Still, we emphasize that the &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; are not necessarily a consistent set of conditionals for all observation sets, and the training routine does not guarantee that.<br /> <br /> In summary,<br /> <br /> 1. A CNP is a conditional distribution over functions<br /> trained to model the empirical conditional distributions<br /> of functions &lt;math display=&quot;inline&quot;&gt;f \sim P&lt;/math&gt;.<br /> <br /> 2. A CNP is permutation invariant in &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;T&lt;/math&gt;.<br /> <br /> 3. A CNP is scalable, achieving a running time complexity<br /> of &lt;math display=&quot;inline&quot;&gt;O(n + m)&lt;/math&gt; for making &lt;math display=&quot;inline&quot;&gt;m&lt;/math&gt; predictions with &lt;math display=&quot;inline&quot;&gt;n&lt;/math&gt;<br /> observations.<br /> <br /> == Related Work ==<br /> <br /> ===Gaussian Process Framework===<br /> <br /> A Gaussian Process (GP) is a non-parametric method for regression, used extensively for regression and classification problems in the machine learning community. A GP is defined as a collection of random variables, any finite number of which have a joint Gaussian distribution.<br /> A standard approach is to model data as &lt;math&gt;y = m(X, φ) + \epsilon&lt;/math&gt;<br /> where m is the mean function with parameter vector &lt;math&gt;φ&lt;/math&gt;, and &lt;math&gt;\epsilon&lt;/math&gt; represents independent and identically distributed (i.i.d.) Gaussian noise: &lt;math&gt;N\sim (0,\sigma^2)&lt;/math&gt;<br /> <br /> For more info on Gaussian Process Framework:<br /> [https://arxiv.org/abs/1506.07304 A Gaussian process framework for modelling instrumental systematics: application to transmission spectroscopy]<br /> <br /> Several papers attempt to address various issues with GPs. These include:<br /> * Using sparse GPs to aid in scaling (Snelson &amp; Ghahramani, 2006)<br /> * Using Deep GPs to achieve more expressivity (Damianou &amp; Lawrence, 2013; Salimbeni &amp; Deisenroth, 2017)<br /> * Using neural networks to learn more expressive kernels (Wilson et al., 2016)<br /> <br /> A Python resource for Gaussian Process Framework implementation: [https://github.com/SheffieldML/GPyimplementation Gaussian Process Framework in Python]<br /> <br /> <br /> The goal of this paper is to incorporate ideas from standard neural networks with Gaussian processes in order to overcome drawbacks of both. Bayesian techniques work better with less data, but complex Bayesian networks become intractable on even moderate sized data sizes. NNs on the other hand, cannot make use of prior knowledge and often have to be retrained from scratch. Without sufficient data, they also perform poorly. Combining both frameworks, we get Conditional Neural Processes serves to learn the kernels of the Gaussian Process through neural networks, and uses these learned kernels on a framework similar to GPs for prediction.<br /> <br /> ===Meta Learning===<br /> <br /> Meta-Learning attempts to allow neural networks to learn more generalizable functions, as opposed to only approximating one function. This can be done by learning deep generative models which can do few-shot estimations of data. This can be implemented with attention mechanisms or additional memory.<br /> <br /> Classification is another common task in meta-learning, few-shot classification algorithms usually rely on some distance metric in feature space to compare target images and the observations. Matching networks(Vinyals et al., 2016; Bartunov &amp; Vetrov, 2016) are closely related to CNPs.<br /> <br /> Finally, the latest variant of Conditional Neural Process can also be seen as an approximated amortized version of Bayesian DL(Gal &amp; Ghahramani, 2016; Blundell et al., 2015; Louizos et al., 2017; Louizos &amp; Welling, 2017). For example, Gal &amp; Ghahramani 2016 develop a new theoretical framework casting dropout training in deep neural networks as approximate Bayesian inference in deep Gaussian processes. Their theory extracts information from existing models and gives us tools to model uncertainty.<br /> <br /> == Experimental Result I: Function Regression ==<br /> <br /> Classical 1D regression task that used as a common baseline for GP is the first example. <br /> They generated two different datasets that consisted of functions<br /> generated from a GP with an exponential kernel. In the first dataset they used a kernel with fixed parameters, and in the second dataset, the function switched at some random point. on the real line between two functions, each sampled with<br /> different kernel parameters. At every training step, they sampled a curve from the GP, select<br /> a subset of n points as observations, and a subset of t points as target points. Using the model, the observed points are encoded using a three-layer MLP encoder h with a 128-dimensional output representation. The representations are aggregated into a single representation<br /> &lt;math display=&quot;inline&quot;&gt;r = \frac{1}{n} \sum r_i&lt;/math&gt;<br /> , which is concatenated to &lt;math display=&quot;inline&quot;&gt;x_t&lt;/math&gt; and passed to a decoder g consisting of a five layer<br /> MLP. The function outputs a Gaussian mean and variance for the target outputs. The model is trained to maximize the log-likelihood of the target points using the Adam optimizer. <br /> <br /> Two examples of the regression results obtained for each<br /> of the datasets are shown in the following figure.<br /> <br /> [[File:007.jpg|300px|center]]<br /> <br /> They compared the model to the predictions generated by a GP with the correct<br /> hyperparameters, which constitutes an upper bound on our<br /> performance. Although the prediction generated by the GP<br /> is smoother than the CNP's prediction both for the mean<br /> and variance, the model is able to learn to regress from a few<br /> context points for both the fixed kernels and switching kernels.<br /> As the number of context points grows, the accuracy<br /> of the model improves and the approximated uncertainty<br /> of the model decreases. Crucially, we see the model learns<br /> to estimate its own uncertainty given the observations very<br /> accurately. Nonetheless, it provides a good approximation<br /> that increases in accuracy as the number of context points<br /> increases.<br /> Furthermore, the model achieves similarly good performance<br /> on the switching kernel task. This type of regression task<br /> is not trivial for GPs whereas in our case we only have to<br /> change the dataset used for training<br /> <br /> == Experimental Result II: Image Completion for Digits ==<br /> <br /> [[File:002.jpg|600px|center]]<br /> <br /> They also tested CNP on the MNIST dataset and use the test<br /> set to evaluate its performance. As shown in the above figure the<br /> model learns to make good predictions of the underlying<br /> digit even for a small number of context points. Crucially,<br /> when conditioned only on one non-informative context point the model’s prediction corresponds<br /> to the average overall MNIST digits. As the number<br /> of context points increases the predictions become more<br /> similar to the underlying ground truth. This demonstrates<br /> the model’s capacity to extract dataset specific prior knowledge.<br /> It is worth mentioning that even with a complete set<br /> of observations, the model does not achieve pixel-perfect<br /> reconstruction, as we have a bottleneck at the representation<br /> level.<br /> Since this implementation of CNP returns factored outputs,<br /> the best prediction it can produce given limited context<br /> information is to average over all possible predictions that<br /> agree with the context. An alternative to this is to add<br /> latent variables in the model such that they can be sampled<br /> conditioned on the context to produce predictions with high<br /> probability in the data distribution. <br /> <br /> <br /> An important aspect of the model is its ability to estimate<br /> the uncertainty of the prediction. As shown in the bottom<br /> row of the above figure, as they added more observations, the variance<br /> shifts from being almost uniformly spread over the digit<br /> positions to being localized around areas that are specific<br /> to the underlying digit, specifically its edges. Being able to<br /> model the uncertainty given some context can be helpful for<br /> many tasks. One example is active exploration, where the<br /> model has a choice over where to observe.<br /> They tested this by<br /> comparing the predictions of CNP when the observations<br /> are chosen according to uncertainty, versus random pixels. This method is a very simple way of doing active<br /> exploration, but it already produces better prediction results<br /> then selecting the conditioning points at random.<br /> <br /> == Experimental Result III: Image Completion for Faces ==<br /> <br /> <br /> [[File:003.jpg|400px|center]]<br /> <br /> <br /> They also applied CNP to CelebA, a dataset of images of<br /> celebrity faces and reported performance obtained on the<br /> test set.<br /> <br /> As shown in the above figure our model is able to capture<br /> the complex shapes and colors of this dataset with predictions<br /> conditioned on less than 10% of the pixels being<br /> already close to the ground truth. As before, given a few contexts<br /> points the model averages over all possible faces, but as<br /> the number of context pairs increases the predictions capture<br /> image-specific details like face orientation and facial<br /> expression. Furthermore, as the number of context points<br /> increases the variance is shifted towards the edges in the<br /> image.<br /> <br /> [[File:004.jpg|400px|center]]<br /> <br /> An important aspect of CNPs demonstrated in the above figure is<br /> it's flexibility not only in the number of observations and<br /> targets it receives but also with regards to their input values.<br /> It is interesting to compare this property to GPs on one hand,<br /> and to trained generative models (van den Oord et al., 2016;<br /> Gregor et al., 2015) on the other hand.<br /> The first type of flexibility can be seen when conditioning on<br /> subsets that the model has not encountered during training.<br /> Consider conditioning the model on one half of the image,<br /> fox example. This forces the model to not only predict the pixel<br /> values according to some stationary smoothness property of<br /> the images, but also according to global spatial properties,<br /> e.g. symmetry and the relative location of different parts of<br /> faces. As seen in the first row of the figure, CNPs are able to<br /> capture those properties. A GP with a stationary kernel cannot<br /> capture this, and in the absence of observations would<br /> revert to its mean (the mean itself can be non-stationary but<br /> usually, this would not be enough to capture the interesting<br /> properties).<br /> <br /> In addition, the model is flexible with regards to the target<br /> input values. This means, e.g., we can query the model<br /> at resolutions it has not seen during training. We take a<br /> model that has only been trained using pixel coordinates of<br /> a specific resolution and predict at test time subpixel values<br /> for targets between the original coordinates. As shown in<br /> Figure 5, with one forward pass we can query the model at<br /> different resolutions. While GPs also exhibit this type of<br /> flexibility, it is not the case for trained generative models,<br /> which can only predict values for the pixel coordinates on<br /> which they were trained. In this sense, CNPs capture the best<br /> of both worlds – it is flexible in regards to the conditioning<br /> and prediction task and has the capacity to extract domain<br /> knowledge from a training set.<br /> <br /> [[File:010.jpg|400px|center]]<br /> <br /> <br /> They compared CNPs quantitatively to two related models:<br /> kNNs and GPs. As shown in the above table CNPs outperform<br /> the latter when a number of context points are small (empirically<br /> when half of the image or less is provided as context).<br /> When the majority of the image is given as context exact<br /> methods like GPs and kNN will perform better. From the table<br /> we can also see that the order in which the context points<br /> are provided is less important for CNPs, since providing the<br /> context points in order from top to bottom still results in<br /> good performance. Both insights point to the fact that CNPs<br /> learn a data-specific ‘prior’ that will generate good samples<br /> even when the number of context points is very small.<br /> <br /> == Experimental Result IV: Classification ==<br /> Finally, they applied the model to one-shot classification using the Omniglot dataset. This dataset consists of 1,623 classes of characters from 50 different alphabets. Each class has only 20 examples and as such this dataset is particularly suitable for few-shot learning algorithms. The authors used 1,200 randomly selected classes as their training set and the remainder as the testing data set.<br /> <br /> Additionally, to apply data augmentation the authors cropped the image from 32 × 32 to 28 × 28, applied small random<br /> translations and rotations to the inputs, and also increased<br /> the number of classes by rotating every character by 90<br /> degrees and defining that to be a new class. They generated<br /> the labels for an N-way classification task by choosing N<br /> random classes at each training step and arbitrarily assigning<br /> the labels 0, ..., N − 1 to each.<br /> <br /> <br /> [[File:008.jpg|400px|center]]<br /> <br /> Given that the input points are images, they modified the architecture<br /> of the encoder h to include convolution layers as<br /> mentioned in section 2. In addition, they only aggregated over<br /> inputs of the same class by using the information provided<br /> by the input label. The aggregated class-specific representations<br /> are then concatenated to form the final representation.<br /> Given that both the size of the class-specific representations<br /> and the number of classes is constant, the size of the final<br /> representation is still constant and thus the O(n + m)<br /> runtime still holds.<br /> The results of the classification are summarized in the following table<br /> CNPs achieve higher accuracy than models that are significantly<br /> more complex (like MANN). While CNPs do not<br /> beat state of the art for one-shot classification our accuracy<br /> values are comparable. Crucially, they reached those values<br /> using a significantly simpler architecture (three convolutional<br /> layers for the encoder and a three-layer MLP for the<br /> decoder) and with a lower runtime of O(n + m) at test time<br /> as opposed to O(nm)<br /> <br /> == Conclusion ==<br /> <br /> In this paper, they had introduced Conditional Neural Processes,<br /> a model that is both flexible at test time and has the<br /> capacity to extract prior knowledge from training data.<br /> <br /> We had demonstrated its ability to perform a variety of tasks<br /> including regression, classification and image completion.<br /> We compared CNPs to Gaussian Processes on one hand, and<br /> deep learning methods on the other, and also discussed the<br /> relation to meta-learning and few-shot learning.<br /> It is important to note that the specific CNP implementations<br /> described here are just simple proofs-of-concept and can<br /> be substantially extended, e.g. by including more elaborate<br /> architectures in line with modern deep learning advances.<br /> To summarize, this work can be seen as a step towards learning<br /> high-level abstractions, one of the grand challenges of<br /> contemporary machine learning. Functions learned by most<br /> Conditional Neural Processes<br /> conventional deep learning models are tied to a specific, constrained<br /> statistical context at any stage of training. A trained<br /> CNP is more general, in that it encapsulates the high-level<br /> statistics of a family of functions. As such it constitutes a<br /> high-level abstraction that can be reused for multiple tasks.<br /> In future work, they are going to explore how far these models can<br /> help in tackling the many key machine learning problems<br /> that seem to hinge on abstraction, such as transfer learning,<br /> meta-learning, and data efficiency.<br /> <br /> <br /> == Critiques ==<br /> <br /> This paper introduces a method, for reducing the computational complexity of the more famous Gaussian Processes model, but they have mentioned a complexity of O(n + m) which is almost the same order of RBF kernel GP. With respect to performances in a sequence of tasks, the authors have not made metric comparisons to GP methods to prove the superiority of their approach. <br /> <br /> == Other Sources ==<br /> # Code for this model and a simpler explanation can be found at [https://github.com/deepmind/conditional-neural-process]<br /> # A newer version of the model is described in this paper [https://arxiv.org/pdf/1807.01622.pdf]<br /> # A good blog post on neural processes [https://kasparmartens.rbind.io/post/np/]<br /> <br /> == Reference ==<br /> Bartunov, S. and Vetrov, D. P. Fast adaptation in generative<br /> models with generative matching networks. arXiv<br /> preprint arXiv:1612.02192, 2016.<br /> <br /> Blundell, C., Cornebise, J., Kavukcuoglu, K., and Wierstra,<br /> D. Weight uncertainty in neural networks. arXiv preprint<br /> arXiv:1505.05424, 2015.<br /> <br /> Bornschein, J., Mnih, A., Zoran, D., and J. Rezende, D.<br /> Variational memory addressing in generative models. In<br /> Advances in Neural Information Processing Systems, pp.<br /> 3923–3932, 2017.<br /> <br /> Damianou, A. and Lawrence, N. Deep gaussian processes.<br /> In Artificial Intelligence and Statistics, pp. 207–215,<br /> 2013.<br /> <br /> Devlin, J., Bunel, R. R., Singh, R., Hausknecht, M., and<br /> Kohli, P. Neural program meta-induction. In Advances in<br /> Neural Information Processing Systems, pp. 2077–2085,<br /> 2017.<br /> <br /> Edwards, H. and Storkey, A. Towards a neural statistician.<br /> 2016.<br /> <br /> Finn, C., Abbeel, P., and Levine, S. Model-agnostic metalearning<br /> for fast adaptation of deep networks. arXiv<br /> preprint arXiv:1703.03400, 2017.<br /> <br /> Gal, Y. and Ghahramani, Z. Dropout as a bayesian approximation:<br /> Representing model uncertainty in deep learning.<br /> In international conference on machine learning, pp.<br /> 1050–1059, 2016.<br /> <br /> Garnelo, M., Arulkumaran, K., and Shanahan, M. Towards<br /> deep symbolic reinforcement learning. arXiv preprint<br /> arXiv:1609.05518, 2016.<br /> <br /> Gregor, K., Danihelka, I., Graves, A., Rezende, D. J., and<br /> Wierstra, D. Draw: A recurrent neural network for image<br /> generation. arXiv preprint arXiv:1502.04623, 2015.<br /> <br /> Hewitt, L., Gane, A., Jaakkola, T., and Tenenbaum, J. B. The<br /> variational homoencoder: Learning to infer high-capacity<br /> generative models from few examples. 2018.<br /> <br /> J. Rezende, D., Danihelka, I., Gregor, K., Wierstra, D.,<br /> et al. One-shot generalization in deep generative models.<br /> In International Conference on Machine Learning, pp.<br /> 1521–1529, 2016.<br /> <br /> Kingma, D. P. and Ba, J. Adam: A method for stochastic<br /> optimization. arXiv preprint arXiv:1412.6980, 2014.<br /> <br /> Kingma, D. P. and Welling, M. Auto-encoding variational<br /> bayes. arXiv preprint arXiv:1312.6114, 2013.<br /> <br /> Koch, G., Zemel, R., and Salakhutdinov, R. Siamese neural<br /> networks for one-shot image recognition. In ICML Deep<br /> Learning Workshop, volume 2, 2015.<br /> <br /> Lake, B. M., Salakhutdinov, R., and Tenenbaum, J. B.<br /> Human-level concept learning through probabilistic program<br /> induction. Science, 350(6266):1332–1338, 2015.<br /> <br /> Lake, B. M., Ullman, T. D., Tenenbaum, J. B., and Gershman,<br /> S. J. Building machines that learn and think like<br /> people. Behavioral and Brain Sciences, 40, 2017.<br /> <br /> LeCun, Y., Bottou, L., Bengio, Y., and Haffner, P. Gradientbased<br /> learning applied to document recognition. Proceedings<br /> of the IEEE, 86(11):2278–2324, 1998.<br /> <br /> Liu, Z., Luo, P., Wang, X., and Tang, X. Deep learning face<br /> attributes in the wild. In Proceedings of International<br /> Conference on Computer Vision (ICCV), December 2015.<br /> <br /> Louizos, C. and Welling, M. Multiplicative normalizing<br /> flows for variational bayesian neural networks. arXiv<br /> preprint arXiv:1703.01961, 2017.<br /> <br /> Louizos, C., Ullrich, K., and Welling, M. Bayesian compression<br /> for deep learning. In Advances in Neural Information<br /> Processing Systems, pp. 3290–3300, 2017.<br /> <br /> Rasmussen, C. E. and Williams, C. K. Gaussian processes<br /> in machine learning. In Advanced lectures on machine<br /> learning, pp. 63–71. Springer, 2004.<br /> <br /> Reed, S., Chen, Y., Paine, T., Oord, A. v. d., Eslami, S.,<br /> J. Rezende, D., Vinyals, O., and de Freitas, N. Few-shot<br /> autoregressive density estimation: Towards learning to<br /> learn distributions. 2017.<br /> <br /> Rezende, D. J., Mohamed, S., and Wierstra, D. Stochastic<br /> backpropagation and approximate inference in deep generative<br /> models. arXiv preprint arXiv:1401.4082, 2014.<br /> <br /> Salimbeni, H. and Deisenroth, M. Doubly stochastic variational<br /> inference for deep gaussian processes. In Advances<br /> in Neural Information Processing Systems, pp.<br /> 4591–4602, 2017.<br /> <br /> Santoro, A., Bartunov, S., Botvinick, M., Wierstra, D., and<br /> Lillicrap, T. One-shot learning with memory-augmented<br /> neural networks. arXiv preprint arXiv:1605.06065, 2016.<br /> <br /> Snell, J., Swersky, K., and Zemel, R. Prototypical networks<br /> for few-shot learning. In Advances in Neural Information<br /> Processing Systems, pp. 4080–4090, 2017.<br /> <br /> Snelson, E. and Ghahramani, Z. Sparse gaussian processes<br /> using pseudo-inputs. In Advances in neural information<br /> processing systems, pp. 1257–1264, 2006.<br /> <br /> van den Oord, A., Kalchbrenner, N., Espeholt, L., Vinyals,<br /> O., Graves, A., et al. Conditional image generation with<br /> pixelcnn decoders. In Advances in Neural Information<br /> Processing Systems, pp. 4790–4798, 2016.<br /> <br /> Vinyals, O., Blundell, C., Lillicrap, T., Wierstra, D., et al.<br /> Matching networks for one shot learning. In Advances in<br /> Neural Information Processing Systems, pp. 3630–3638,<br /> 2016.<br /> <br /> Wang, J. X., Kurth-Nelson, Z., Tirumala, D., Soyer, H.,<br /> Leibo, J. Z., Munos, R., Blundell, C., Kumaran, D., and<br /> Botvinick, M. Learning to reinforcement learn. arXiv<br /> preprint arXiv:1611.05763, 2016.<br /> <br /> Wilson, A. G., Hu, Z., Salakhutdinov, R., and Xing, E. P.<br /> Deep kernel learning. In Artificial Intelligence and Statistics,<br /> pp. 370–378, 2016.<br /> <br /> Damianou, A. and Lawrence, N. Deep gaussian processes.<br /> In Artificial Intelligence and Statistics, pp. 207–215,<br /> 2013.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=conditional_neural_process&diff=40920 conditional neural process 2018-11-22T17:41:03Z <p>Jmmoosa: /* Gaussian Process Framework */</p> <hr /> <div>== Introduction ==<br /> <br /> To train a model effectively, deep neural networks typically require large datasets. To mitigate this data efficiency problem, learning in two phases is one approach: the first phase learns the statistics of a generic domain without committing to a specific learning task; the second phase learns a function for a specific task but does so using only a small number of data points by exploiting the domain-wide statistics already learned. Taking a probabilistic stance and specifying a distribution over functions (stochastic processes) is another approach -- Gaussian Processes being a commonly used example of this. Such Bayesian methods can be computationally expensive, however. <br /> <br /> The authors of the paper propose a family of models that represent solutions to the supervised problem, and an end-to-end training approach to learning them that combines neural networks with features reminiscent of Gaussian Processes. They call this family of models Conditional Neural Processes (CNPs). CNPs can be trained on very few data points to make accurate predictions, while they also have the capacity to scale to complex functions and large datasets. <br /> <br /> == Model ==<br /> Consider a data set &lt;math display=&quot;inline&quot;&gt; \{x_i, y_i\} &lt;/math&gt; with evaluations &lt;math display=&quot;inline&quot;&gt;y_i = f(x_i) &lt;/math&gt; for some unknown function &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt;. Assume &lt;math display=&quot;inline&quot;&gt;g&lt;/math&gt; is an approximating function of f. The aim is to minimize the loss between &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;g&lt;/math&gt; on the entire space &lt;math display=&quot;inline&quot;&gt;X&lt;/math&gt;. In practice, the routine is evaluated on a finite set of observations.<br /> <br /> <br /> Let training set be &lt;math display=&quot;inline&quot;&gt; O = \{x_i, y_i\}_{i = 0} ^{n-1}&lt;/math&gt;, and test set be &lt;math display=&quot;inline&quot;&gt; T = \{x_i, y_i\}_{i = n} ^ {n + m - 1} \subset X&lt;/math&gt; of unlabelled points.<br /> <br /> P be a probability distribution over functions &lt;math display=&quot;inline&quot;&gt; F : X \to Y&lt;/math&gt;, formally known as a stochastic process. Thus, P defines a joint distribution over the random variables &lt;math display=&quot;inline&quot;&gt; {f(x_i)}_{i = 0} ^{n + m - 1}&lt;/math&gt;. Therefore, for &lt;math display=&quot;inline&quot;&gt; P(f(x)|O, T)&lt;/math&gt;, our task is to predict the output values &lt;math display=&quot;inline&quot;&gt;f(x_i)&lt;/math&gt; for &lt;math display=&quot;inline&quot;&gt; x_i \in T&lt;/math&gt;, given &lt;math display=&quot;inline&quot;&gt; O&lt;/math&gt;. <br /> <br /> A common assumption made on P is that all function evaluations of &lt;math display=&quot;inline&quot;&gt; f &lt;/math&gt; is Gaussian distributed. The random functions class is called Gaussian Processes (GPs). This framework of the stochastic process allows a model to be data efficient, however, it's hard to get appropriate priors and stochastic processes are expensive in computation, scaling poorly with &lt;math&gt;n&lt;/math&gt; and &lt;math&gt;m&lt;/math&gt;. One of the examples is GPs, which has running time &lt;math&gt;O(n+3)^3&lt;/math&gt;.<br /> <br /> [[File:001.jpg|300px|center]]<br /> <br /> == Conditional Neural Process ==<br /> <br /> Conditional Neural Process models directly parametrize conditional stochastic processes without imposing consistency with respect to some prior process. CNP parametrize distributions over &lt;math display=&quot;inline&quot;&gt;f(T)&lt;/math&gt; given a distributed representation of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; of fixed dimensionality. Thus, the mathematical guarantees associated with stochastic processes is traded off for functional flexibility and scalability.<br /> <br /> CNP is a conditional stochastic process &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; defines distributions over &lt;math display=&quot;inline&quot;&gt;f(x_i)&lt;/math&gt; for &lt;math display=&quot;inline&quot;&gt;x_i \in T&lt;/math&gt;, given a set of observations &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt;. For stochastic processs, the authors assume that &lt;math display=&quot;inline&quot;&gt;Q_{\theta}&lt;/math&gt; is invariant to permutations, and &lt;math display=&quot;inline&quot;&gt;Q_\theta(f(T) | O, T)= Q_\theta(f(T') | O, T')=Q_\theta(f(T) | O', T) &lt;/math&gt; when &lt;math&gt; O', T'&lt;/math&gt; are permutations of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;T &lt;/math&gt;. In this work, we generally enforce permutation invariance with respect to &lt;math display=&quot;inline&quot;&gt;T&lt;/math&gt; be assuming a factored structure, which is the easiest way to ensure a valid stochastic process. That is, &lt;math display=&quot;inline&quot;&gt;Q_\theta(f(T) | O, T) = \prod _{x \in T} Q_\theta(f(x) | O, x)&lt;/math&gt;. Moreover, this framework can be extended to non-factored distributions.<br /> <br /> In detail, the following architecture is used<br /> <br /> &lt;math display=&quot;inline&quot;&gt;r_i = h_\theta(x_i, y_i)&lt;/math&gt; for any &lt;math display=&quot;inline&quot;&gt;(x_i, y_i) \in O&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;h_\theta : X \times Y \to \mathbb{R} ^ d&lt;/math&gt;<br /> <br /> &lt;math display=&quot;inline&quot;&gt;r = r_i * r_2 * ... * r_n&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;*&lt;/math&gt; is a commutative operation that takes elements in &lt;math display=&quot;inline&quot;&gt;\mathbb{R}^d&lt;/math&gt; and maps them into a single element of &lt;math display=&quot;inline&quot;&gt;\mathbb{R} ^ d&lt;/math&gt;<br /> <br /> &lt;math display=&quot;inline&quot;&gt;\Phi_i = g_\theta&lt;/math&gt; for any &lt;math display=&quot;inline&quot;&gt;x_i \in T&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;g_\theta : X \times \mathbb{R} ^ d \to \mathbb{R} ^ e&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;\Phi_i&lt;/math&gt; are parameters for &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt;<br /> <br /> Note that this architecture ensures permutation invariance and &lt;math display=&quot;inline&quot;&gt;O(n + m)&lt;/math&gt; scaling for conditional prediction. Also, &lt;math display=&quot;inline&quot;&gt;r = r_i * r_2 * ... * r_n&lt;/math&gt; can be computed in &lt;math display=&quot;inline&quot;&gt;O(n)&lt;/math&gt;, this architecture supports streaming observation with minimal overhead.<br /> <br /> We train &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; by asking it to predict &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; conditioned on a randomly<br /> chosen subset of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt;. This gives the model a signal of the uncertainty over the space X inherent in the distribution<br /> P given a set of observations. The authors let &lt;math display=&quot;inline&quot;&gt; f \sim P&lt;/math&gt;, &lt;math display=&quot;inline&quot;&gt; O = \{(x_i, y_i)\}_{i = 0} ^{n-1}&lt;/math&gt;, and N ~ uniform[0, 1, ..... ,n-1]. Subset &lt;math display=&quot;inline&quot;&gt; O = \{(x_i, y_i)\}_{i = 0} ^{N}&lt;/math&gt; that is first N elements of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; is regarded as condition. The negative conditional log probability is given by<br /> $\mathcal{L}(\theta)=-\mathbb{E}_{f \sim p}[\mathbb{E}_{N}[\log Q_\theta(\{y_i\}_{i = 0} ^{n-1}|O_{N}, \{x_i\}_{i = 0} ^{n-1})]]$<br /> Thus, the targets it scores &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; on include both the observed <br /> and unobserved values. In practice, Monte Carlo estimates of the gradient of this loss is taken by sampling &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;N&lt;/math&gt;. <br /> <br /> This approach shifts the burden of imposing prior knowledge from an analytic prior to empirical data. This has the advantage of liberating a practitioner from having to specify an analytic form for the prior, which is ultimately<br /> intended to summarize their empirical experience. Still, we emphasize that the &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; are not necessarily a consistent set of conditionals for all observation sets, and the training routine does not guarantee that.<br /> <br /> In summary,<br /> <br /> 1. A CNP is a conditional distribution over functions<br /> trained to model the empirical conditional distributions<br /> of functions &lt;math display=&quot;inline&quot;&gt;f \sim P&lt;/math&gt;.<br /> <br /> 2. A CNP is permutation invariant in &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;T&lt;/math&gt;.<br /> <br /> 3. A CNP is scalable, achieving a running time complexity<br /> of &lt;math display=&quot;inline&quot;&gt;O(n + m)&lt;/math&gt; for making &lt;math display=&quot;inline&quot;&gt;m&lt;/math&gt; predictions with &lt;math display=&quot;inline&quot;&gt;n&lt;/math&gt;<br /> observations.<br /> <br /> == Related Work ==<br /> <br /> ===Gaussian Process Framework===<br /> <br /> A Gaussian Process (GP) is a non-parametric method for regression, used extensively for regression and classification problems in the machine learning community. A GP is defined as a collection of random variables, any finite number of which have a joint Gaussian distribution.<br /> A standard approach is to model data as &lt;math&gt;y = m(X, φ) + \epsilon&lt;/math&gt;<br /> where m is the mean function with parameter vector &lt;math&gt;φ&lt;/math&gt;, and &lt;math&gt;\epsilon&lt;/math&gt; represents independent and identically distributed (i.i.d.) Gaussian noise: &lt;math&gt;N\sim (0,\sigma^2)&lt;/math&gt;<br /> <br /> For more info on Gaussian Process Framework:<br /> [https://arxiv.org/abs/1506.07304 A Gaussian process framework for modelling instrumental systematics: application to transmission spectroscopy]<br /> <br /> Several papers attempt to address various issues with GPs. These include:<br /> * Using sparse GPs to aid in scaling (Snelson &amp; Ghahramani, 2006)<br /> * Using Deep GPs to achieve more expressivity (Damianou &amp; Lawrence, 2013; Salimbeni &amp; Deisenroth, 2017)<br /> * Using neural networks to learn more expressive kernels (Wilson et al., 2016)<br /> <br /> A Python resource for Gaussian Process Framework implementation:[https://github.com/SheffieldML/GPyimplementation Gaussian Process Framework in Python]<br /> <br /> <br /> The goal of this paper is to incorporate ideas from standard neural networks with Gaussian processes in order to overcome drawbacks of both. Bayesian techniques work better with less data, but complex Bayesian networks become intractable on even moderate sized data sizes. NNs on the other hand, cannot make use of prior knowledge and often have to be retrained from scratch. Without sufficient data, they also perform poorly. Combining both frameworks, we get Conditional Neural Processes serves to learn the kernels of the Gaussian Process through neural networks, and uses these learned kernels on a framework similar to GPs for prediction.<br /> <br /> ===Meta Learning===<br /> <br /> Meta-Learning attempts to allow neural networks to learn more generalizable functions, as opposed to only approximating one function. This can be done by learning deep generative models which can do few-shot estimations of data. This can be implemented with attention mechanisms or additional memory.<br /> <br /> Classification is another common task in meta-learning, few-shot classification algorithms usually rely on some distance metric in feature space to compare target images and the observations. Matching networks(Vinyals et al., 2016; Bartunov &amp; Vetrov, 2016) are closely related to CNPs.<br /> <br /> Finally, the latest variant of Conditional Neural Process can also be seen as an approximated amortized version of Bayesian DL(Gal &amp; Ghahramani, 2016; Blundell et al., 2015; Louizos et al., 2017; Louizos &amp; Welling, 2017). For example, Gal &amp; Ghahramani 2016 develop a new theoretical framework casting dropout training in deep neural networks as approximate Bayesian inference in deep Gaussian processes. Their theory extracts information from existing models and gives us tools to model uncertainty.<br /> <br /> == Experimental Result I: Function Regression ==<br /> <br /> Classical 1D regression task that used as a common baseline for GP is the first example. <br /> They generated two different datasets that consisted of functions<br /> generated from a GP with an exponential kernel. In the first dataset they used a kernel with fixed parameters, and in the second dataset, the function switched at some random point. on the real line between two functions, each sampled with<br /> different kernel parameters. At every training step, they sampled a curve from the GP, select<br /> a subset of n points as observations, and a subset of t points as target points. Using the model, the observed points are encoded using a three-layer MLP encoder h with a 128-dimensional output representation. The representations are aggregated into a single representation<br /> &lt;math display=&quot;inline&quot;&gt;r = \frac{1}{n} \sum r_i&lt;/math&gt;<br /> , which is concatenated to &lt;math display=&quot;inline&quot;&gt;x_t&lt;/math&gt; and passed to a decoder g consisting of a five layer<br /> MLP. The function outputs a Gaussian mean and variance for the target outputs. The model is trained to maximize the log-likelihood of the target points using the Adam optimizer. <br /> <br /> Two examples of the regression results obtained for each<br /> of the datasets are shown in the following figure.<br /> <br /> [[File:007.jpg|300px|center]]<br /> <br /> They compared the model to the predictions generated by a GP with the correct<br /> hyperparameters, which constitutes an upper bound on our<br /> performance. Although the prediction generated by the GP<br /> is smoother than the CNP's prediction both for the mean<br /> and variance, the model is able to learn to regress from a few<br /> context points for both the fixed kernels and switching kernels.<br /> As the number of context points grows, the accuracy<br /> of the model improves and the approximated uncertainty<br /> of the model decreases. Crucially, we see the model learns<br /> to estimate its own uncertainty given the observations very<br /> accurately. Nonetheless, it provides a good approximation<br /> that increases in accuracy as the number of context points<br /> increases.<br /> Furthermore, the model achieves similarly good performance<br /> on the switching kernel task. This type of regression task<br /> is not trivial for GPs whereas in our case we only have to<br /> change the dataset used for training<br /> <br /> == Experimental Result II: Image Completion for Digits ==<br /> <br /> [[File:002.jpg|600px|center]]<br /> <br /> They also tested CNP on the MNIST dataset and use the test<br /> set to evaluate its performance. As shown in the above figure the<br /> model learns to make good predictions of the underlying<br /> digit even for a small number of context points. Crucially,<br /> when conditioned only on one non-informative context point the model’s prediction corresponds<br /> to the average overall MNIST digits. As the number<br /> of context points increases the predictions become more<br /> similar to the underlying ground truth. This demonstrates<br /> the model’s capacity to extract dataset specific prior knowledge.<br /> It is worth mentioning that even with a complete set<br /> of observations, the model does not achieve pixel-perfect<br /> reconstruction, as we have a bottleneck at the representation<br /> level.<br /> Since this implementation of CNP returns factored outputs,<br /> the best prediction it can produce given limited context<br /> information is to average over all possible predictions that<br /> agree with the context. An alternative to this is to add<br /> latent variables in the model such that they can be sampled<br /> conditioned on the context to produce predictions with high<br /> probability in the data distribution. <br /> <br /> <br /> An important aspect of the model is its ability to estimate<br /> the uncertainty of the prediction. As shown in the bottom<br /> row of the above figure, as they added more observations, the variance<br /> shifts from being almost uniformly spread over the digit<br /> positions to being localized around areas that are specific<br /> to the underlying digit, specifically its edges. Being able to<br /> model the uncertainty given some context can be helpful for<br /> many tasks. One example is active exploration, where the<br /> model has a choice over where to observe.<br /> They tested this by<br /> comparing the predictions of CNP when the observations<br /> are chosen according to uncertainty, versus random pixels. This method is a very simple way of doing active<br /> exploration, but it already produces better prediction results<br /> then selecting the conditioning points at random.<br /> <br /> == Experimental Result III: Image Completion for Faces ==<br /> <br /> <br /> [[File:003.jpg|400px|center]]<br /> <br /> <br /> They also applied CNP to CelebA, a dataset of images of<br /> celebrity faces and reported performance obtained on the<br /> test set.<br /> <br /> As shown in the above figure our model is able to capture<br /> the complex shapes and colors of this dataset with predictions<br /> conditioned on less than 10% of the pixels being<br /> already close to the ground truth. As before, given a few contexts<br /> points the model averages over all possible faces, but as<br /> the number of context pairs increases the predictions capture<br /> image-specific details like face orientation and facial<br /> expression. Furthermore, as the number of context points<br /> increases the variance is shifted towards the edges in the<br /> image.<br /> <br /> [[File:004.jpg|400px|center]]<br /> <br /> An important aspect of CNPs demonstrated in the above figure is<br /> it's flexibility not only in the number of observations and<br /> targets it receives but also with regards to their input values.<br /> It is interesting to compare this property to GPs on one hand,<br /> and to trained generative models (van den Oord et al., 2016;<br /> Gregor et al., 2015) on the other hand.<br /> The first type of flexibility can be seen when conditioning on<br /> subsets that the model has not encountered during training.<br /> Consider conditioning the model on one half of the image,<br /> fox example. This forces the model to not only predict the pixel<br /> values according to some stationary smoothness property of<br /> the images, but also according to global spatial properties,<br /> e.g. symmetry and the relative location of different parts of<br /> faces. As seen in the first row of the figure, CNPs are able to<br /> capture those properties. A GP with a stationary kernel cannot<br /> capture this, and in the absence of observations would<br /> revert to its mean (the mean itself can be non-stationary but<br /> usually, this would not be enough to capture the interesting<br /> properties).<br /> <br /> In addition, the model is flexible with regards to the target<br /> input values. This means, e.g., we can query the model<br /> at resolutions it has not seen during training. We take a<br /> model that has only been trained using pixel coordinates of<br /> a specific resolution and predict at test time subpixel values<br /> for targets between the original coordinates. As shown in<br /> Figure 5, with one forward pass we can query the model at<br /> different resolutions. While GPs also exhibit this type of<br /> flexibility, it is not the case for trained generative models,<br /> which can only predict values for the pixel coordinates on<br /> which they were trained. In this sense, CNPs capture the best<br /> of both worlds – it is flexible in regards to the conditioning<br /> and prediction task and has the capacity to extract domain<br /> knowledge from a training set.<br /> <br /> [[File:010.jpg|400px|center]]<br /> <br /> <br /> They compared CNPs quantitatively to two related models:<br /> kNNs and GPs. As shown in the above table CNPs outperform<br /> the latter when a number of context points are small (empirically<br /> when half of the image or less is provided as context).<br /> When the majority of the image is given as context exact<br /> methods like GPs and kNN will perform better. From the table<br /> we can also see that the order in which the context points<br /> are provided is less important for CNPs, since providing the<br /> context points in order from top to bottom still results in<br /> good performance. Both insights point to the fact that CNPs<br /> learn a data-specific ‘prior’ that will generate good samples<br /> even when the number of context points is very small.<br /> <br /> == Experimental Result IV: Classification ==<br /> Finally, they applied the model to one-shot classification using the Omniglot dataset. This dataset consists of 1,623 classes of characters from 50 different alphabets. Each class has only 20 examples and as such this dataset is particularly suitable for few-shot learning algorithms. The authors used 1,200 randomly selected classes as their training set and the remainder as the testing data set.<br /> <br /> Additionally, to apply data augmentation the authors cropped the image from 32 × 32 to 28 × 28, applied small random<br /> translations and rotations to the inputs, and also increased<br /> the number of classes by rotating every character by 90<br /> degrees and defining that to be a new class. They generated<br /> the labels for an N-way classification task by choosing N<br /> random classes at each training step and arbitrarily assigning<br /> the labels 0, ..., N − 1 to each.<br /> <br /> <br /> [[File:008.jpg|400px|center]]<br /> <br /> Given that the input points are images, they modified the architecture<br /> of the encoder h to include convolution layers as<br /> mentioned in section 2. In addition, they only aggregated over<br /> inputs of the same class by using the information provided<br /> by the input label. The aggregated class-specific representations<br /> are then concatenated to form the final representation.<br /> Given that both the size of the class-specific representations<br /> and the number of classes is constant, the size of the final<br /> representation is still constant and thus the O(n + m)<br /> runtime still holds.<br /> The results of the classification are summarized in the following table<br /> CNPs achieve higher accuracy than models that are significantly<br /> more complex (like MANN). While CNPs do not<br /> beat state of the art for one-shot classification our accuracy<br /> values are comparable. Crucially, they reached those values<br /> using a significantly simpler architecture (three convolutional<br /> layers for the encoder and a three-layer MLP for the<br /> decoder) and with a lower runtime of O(n + m) at test time<br /> as opposed to O(nm)<br /> <br /> == Conclusion ==<br /> <br /> In this paper, they had introduced Conditional Neural Processes,<br /> a model that is both flexible at test time and has the<br /> capacity to extract prior knowledge from training data.<br /> <br /> We had demonstrated its ability to perform a variety of tasks<br /> including regression, classification and image completion.<br /> We compared CNPs to Gaussian Processes on one hand, and<br /> deep learning methods on the other, and also discussed the<br /> relation to meta-learning and few-shot learning.<br /> It is important to note that the specific CNP implementations<br /> described here are just simple proofs-of-concept and can<br /> be substantially extended, e.g. by including more elaborate<br /> architectures in line with modern deep learning advances.<br /> To summarize, this work can be seen as a step towards learning<br /> high-level abstractions, one of the grand challenges of<br /> contemporary machine learning. Functions learned by most<br /> Conditional Neural Processes<br /> conventional deep learning models are tied to a specific, constrained<br /> statistical context at any stage of training. A trained<br /> CNP is more general, in that it encapsulates the high-level<br /> statistics of a family of functions. As such it constitutes a<br /> high-level abstraction that can be reused for multiple tasks.<br /> In future work, they are going to explore how far these models can<br /> help in tackling the many key machine learning problems<br /> that seem to hinge on abstraction, such as transfer learning,<br /> meta-learning, and data efficiency.<br /> <br /> <br /> == Critiques ==<br /> <br /> This paper introduces a method, for reducing the computational complexity of the more famous Gaussian Processes model, but they have mentioned a complexity of O(n + m) which is almost the same order of RBF kernel GP. With respect to performances in a sequence of tasks, the authors have not made metric comparisons to GP methods to prove the superiority of their approach. <br /> <br /> == Other Sources ==<br /> # Code for this model and a simpler explanation can be found at [https://github.com/deepmind/conditional-neural-process]<br /> # A newer version of the model is described in this paper [https://arxiv.org/pdf/1807.01622.pdf]<br /> # A good blog post on neural processes [https://kasparmartens.rbind.io/post/np/]<br /> <br /> == Reference ==<br /> Bartunov, S. and Vetrov, D. P. Fast adaptation in generative<br /> models with generative matching networks. arXiv<br /> preprint arXiv:1612.02192, 2016.<br /> <br /> Blundell, C., Cornebise, J., Kavukcuoglu, K., and Wierstra,<br /> D. Weight uncertainty in neural networks. arXiv preprint<br /> arXiv:1505.05424, 2015.<br /> <br /> Bornschein, J., Mnih, A., Zoran, D., and J. Rezende, D.<br /> Variational memory addressing in generative models. In<br /> Advances in Neural Information Processing Systems, pp.<br /> 3923–3932, 2017.<br /> <br /> Damianou, A. and Lawrence, N. Deep gaussian processes.<br /> In Artificial Intelligence and Statistics, pp. 207–215,<br /> 2013.<br /> <br /> Devlin, J., Bunel, R. R., Singh, R., Hausknecht, M., and<br /> Kohli, P. Neural program meta-induction. In Advances in<br /> Neural Information Processing Systems, pp. 2077–2085,<br /> 2017.<br /> <br /> Edwards, H. and Storkey, A. Towards a neural statistician.<br /> 2016.<br /> <br /> Finn, C., Abbeel, P., and Levine, S. Model-agnostic metalearning<br /> for fast adaptation of deep networks. arXiv<br /> preprint arXiv:1703.03400, 2017.<br /> <br /> Gal, Y. and Ghahramani, Z. Dropout as a bayesian approximation:<br /> Representing model uncertainty in deep learning.<br /> In international conference on machine learning, pp.<br /> 1050–1059, 2016.<br /> <br /> Garnelo, M., Arulkumaran, K., and Shanahan, M. Towards<br /> deep symbolic reinforcement learning. arXiv preprint<br /> arXiv:1609.05518, 2016.<br /> <br /> Gregor, K., Danihelka, I., Graves, A., Rezende, D. J., and<br /> Wierstra, D. Draw: A recurrent neural network for image<br /> generation. arXiv preprint arXiv:1502.04623, 2015.<br /> <br /> Hewitt, L., Gane, A., Jaakkola, T., and Tenenbaum, J. B. The<br /> variational homoencoder: Learning to infer high-capacity<br /> generative models from few examples. 2018.<br /> <br /> J. Rezende, D., Danihelka, I., Gregor, K., Wierstra, D.,<br /> et al. One-shot generalization in deep generative models.<br /> In International Conference on Machine Learning, pp.<br /> 1521–1529, 2016.<br /> <br /> Kingma, D. P. and Ba, J. Adam: A method for stochastic<br /> optimization. arXiv preprint arXiv:1412.6980, 2014.<br /> <br /> Kingma, D. P. and Welling, M. Auto-encoding variational<br /> bayes. arXiv preprint arXiv:1312.6114, 2013.<br /> <br /> Koch, G., Zemel, R., and Salakhutdinov, R. Siamese neural<br /> networks for one-shot image recognition. In ICML Deep<br /> Learning Workshop, volume 2, 2015.<br /> <br /> Lake, B. M., Salakhutdinov, R., and Tenenbaum, J. B.<br /> Human-level concept learning through probabilistic program<br /> induction. Science, 350(6266):1332–1338, 2015.<br /> <br /> Lake, B. M., Ullman, T. D., Tenenbaum, J. B., and Gershman,<br /> S. J. Building machines that learn and think like<br /> people. Behavioral and Brain Sciences, 40, 2017.<br /> <br /> LeCun, Y., Bottou, L., Bengio, Y., and Haffner, P. Gradientbased<br /> learning applied to document recognition. Proceedings<br /> of the IEEE, 86(11):2278–2324, 1998.<br /> <br /> Liu, Z., Luo, P., Wang, X., and Tang, X. Deep learning face<br /> attributes in the wild. In Proceedings of International<br /> Conference on Computer Vision (ICCV), December 2015.<br /> <br /> Louizos, C. and Welling, M. Multiplicative normalizing<br /> flows for variational bayesian neural networks. arXiv<br /> preprint arXiv:1703.01961, 2017.<br /> <br /> Louizos, C., Ullrich, K., and Welling, M. Bayesian compression<br /> for deep learning. In Advances in Neural Information<br /> Processing Systems, pp. 3290–3300, 2017.<br /> <br /> Rasmussen, C. E. and Williams, C. K. Gaussian processes<br /> in machine learning. In Advanced lectures on machine<br /> learning, pp. 63–71. Springer, 2004.<br /> <br /> Reed, S., Chen, Y., Paine, T., Oord, A. v. d., Eslami, S.,<br /> J. Rezende, D., Vinyals, O., and de Freitas, N. Few-shot<br /> autoregressive density estimation: Towards learning to<br /> learn distributions. 2017.<br /> <br /> Rezende, D. J., Mohamed, S., and Wierstra, D. Stochastic<br /> backpropagation and approximate inference in deep generative<br /> models. arXiv preprint arXiv:1401.4082, 2014.<br /> <br /> Salimbeni, H. and Deisenroth, M. Doubly stochastic variational<br /> inference for deep gaussian processes. In Advances<br /> in Neural Information Processing Systems, pp.<br /> 4591–4602, 2017.<br /> <br /> Santoro, A., Bartunov, S., Botvinick, M., Wierstra, D., and<br /> Lillicrap, T. One-shot learning with memory-augmented<br /> neural networks. arXiv preprint arXiv:1605.06065, 2016.<br /> <br /> Snell, J., Swersky, K., and Zemel, R. Prototypical networks<br /> for few-shot learning. In Advances in Neural Information<br /> Processing Systems, pp. 4080–4090, 2017.<br /> <br /> Snelson, E. and Ghahramani, Z. Sparse gaussian processes<br /> using pseudo-inputs. In Advances in neural information<br /> processing systems, pp. 1257–1264, 2006.<br /> <br /> van den Oord, A., Kalchbrenner, N., Espeholt, L., Vinyals,<br /> O., Graves, A., et al. Conditional image generation with<br /> pixelcnn decoders. In Advances in Neural Information<br /> Processing Systems, pp. 4790–4798, 2016.<br /> <br /> Vinyals, O., Blundell, C., Lillicrap, T., Wierstra, D., et al.<br /> Matching networks for one shot learning. In Advances in<br /> Neural Information Processing Systems, pp. 3630–3638,<br /> 2016.<br /> <br /> Wang, J. X., Kurth-Nelson, Z., Tirumala, D., Soyer, H.,<br /> Leibo, J. Z., Munos, R., Blundell, C., Kumaran, D., and<br /> Botvinick, M. Learning to reinforcement learn. arXiv<br /> preprint arXiv:1611.05763, 2016.<br /> <br /> Wilson, A. G., Hu, Z., Salakhutdinov, R., and Xing, E. P.<br /> Deep kernel learning. In Artificial Intelligence and Statistics,<br /> pp. 370–378, 2016.<br /> <br /> Damianou, A. and Lawrence, N. Deep gaussian processes.<br /> In Artificial Intelligence and Statistics, pp. 207–215,<br /> 2013.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=conditional_neural_process&diff=40918 conditional neural process 2018-11-22T17:39:15Z <p>Jmmoosa: /* Experimental Result I: Function Regression */</p> <hr /> <div>== Introduction ==<br /> <br /> To train a model effectively, deep neural networks typically require large datasets. To mitigate this data efficiency problem, learning in two phases is one approach: the first phase learns the statistics of a generic domain without committing to a specific learning task; the second phase learns a function for a specific task but does so using only a small number of data points by exploiting the domain-wide statistics already learned. Taking a probabilistic stance and specifying a distribution over functions (stochastic processes) is another approach -- Gaussian Processes being a commonly used example of this. Such Bayesian methods can be computationally expensive, however. <br /> <br /> The authors of the paper propose a family of models that represent solutions to the supervised problem, and an end-to-end training approach to learning them that combines neural networks with features reminiscent of Gaussian Processes. They call this family of models Conditional Neural Processes (CNPs). CNPs can be trained on very few data points to make accurate predictions, while they also have the capacity to scale to complex functions and large datasets. <br /> <br /> == Model ==<br /> Consider a data set &lt;math display=&quot;inline&quot;&gt; \{x_i, y_i\} &lt;/math&gt; with evaluations &lt;math display=&quot;inline&quot;&gt;y_i = f(x_i) &lt;/math&gt; for some unknown function &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt;. Assume &lt;math display=&quot;inline&quot;&gt;g&lt;/math&gt; is an approximating function of f. The aim is to minimize the loss between &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;g&lt;/math&gt; on the entire space &lt;math display=&quot;inline&quot;&gt;X&lt;/math&gt;. In practice, the routine is evaluated on a finite set of observations.<br /> <br /> <br /> Let training set be &lt;math display=&quot;inline&quot;&gt; O = \{x_i, y_i\}_{i = 0} ^{n-1}&lt;/math&gt;, and test set be &lt;math display=&quot;inline&quot;&gt; T = \{x_i, y_i\}_{i = n} ^ {n + m - 1} \subset X&lt;/math&gt; of unlabelled points.<br /> <br /> P be a probability distribution over functions &lt;math display=&quot;inline&quot;&gt; F : X \to Y&lt;/math&gt;, formally known as a stochastic process. Thus, P defines a joint distribution over the random variables &lt;math display=&quot;inline&quot;&gt; {f(x_i)}_{i = 0} ^{n + m - 1}&lt;/math&gt;. Therefore, for &lt;math display=&quot;inline&quot;&gt; P(f(x)|O, T)&lt;/math&gt;, our task is to predict the output values &lt;math display=&quot;inline&quot;&gt;f(x_i)&lt;/math&gt; for &lt;math display=&quot;inline&quot;&gt; x_i \in T&lt;/math&gt;, given &lt;math display=&quot;inline&quot;&gt; O&lt;/math&gt;. <br /> <br /> A common assumption made on P is that all function evaluations of &lt;math display=&quot;inline&quot;&gt; f &lt;/math&gt; is Gaussian distributed. The random functions class is called Gaussian Processes (GPs). This framework of the stochastic process allows a model to be data efficient, however, it's hard to get appropriate priors and stochastic processes are expensive in computation, scaling poorly with &lt;math&gt;n&lt;/math&gt; and &lt;math&gt;m&lt;/math&gt;. One of the examples is GPs, which has running time &lt;math&gt;O(n+3)^3&lt;/math&gt;.<br /> <br /> [[File:001.jpg|300px|center]]<br /> <br /> == Conditional Neural Process ==<br /> <br /> Conditional Neural Process models directly parametrize conditional stochastic processes without imposing consistency with respect to some prior process. CNP parametrize distributions over &lt;math display=&quot;inline&quot;&gt;f(T)&lt;/math&gt; given a distributed representation of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; of fixed dimensionality. Thus, the mathematical guarantees associated with stochastic processes is traded off for functional flexibility and scalability.<br /> <br /> CNP is a conditional stochastic process &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; defines distributions over &lt;math display=&quot;inline&quot;&gt;f(x_i)&lt;/math&gt; for &lt;math display=&quot;inline&quot;&gt;x_i \in T&lt;/math&gt;, given a set of observations &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt;. For stochastic processs, the authors assume that &lt;math display=&quot;inline&quot;&gt;Q_{\theta}&lt;/math&gt; is invariant to permutations, and &lt;math display=&quot;inline&quot;&gt;Q_\theta(f(T) | O, T)= Q_\theta(f(T') | O, T')=Q_\theta(f(T) | O', T) &lt;/math&gt; when &lt;math&gt; O', T'&lt;/math&gt; are permutations of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;T &lt;/math&gt;. In this work, we generally enforce permutation invariance with respect to &lt;math display=&quot;inline&quot;&gt;T&lt;/math&gt; be assuming a factored structure, which is the easiest way to ensure a valid stochastic process. That is, &lt;math display=&quot;inline&quot;&gt;Q_\theta(f(T) | O, T) = \prod _{x \in T} Q_\theta(f(x) | O, x)&lt;/math&gt;. Moreover, this framework can be extended to non-factored distributions.<br /> <br /> In detail, the following architecture is used<br /> <br /> &lt;math display=&quot;inline&quot;&gt;r_i = h_\theta(x_i, y_i)&lt;/math&gt; for any &lt;math display=&quot;inline&quot;&gt;(x_i, y_i) \in O&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;h_\theta : X \times Y \to \mathbb{R} ^ d&lt;/math&gt;<br /> <br /> &lt;math display=&quot;inline&quot;&gt;r = r_i * r_2 * ... * r_n&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;*&lt;/math&gt; is a commutative operation that takes elements in &lt;math display=&quot;inline&quot;&gt;\mathbb{R}^d&lt;/math&gt; and maps them into a single element of &lt;math display=&quot;inline&quot;&gt;\mathbb{R} ^ d&lt;/math&gt;<br /> <br /> &lt;math display=&quot;inline&quot;&gt;\Phi_i = g_\theta&lt;/math&gt; for any &lt;math display=&quot;inline&quot;&gt;x_i \in T&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;g_\theta : X \times \mathbb{R} ^ d \to \mathbb{R} ^ e&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;\Phi_i&lt;/math&gt; are parameters for &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt;<br /> <br /> Note that this architecture ensures permutation invariance and &lt;math display=&quot;inline&quot;&gt;O(n + m)&lt;/math&gt; scaling for conditional prediction. Also, &lt;math display=&quot;inline&quot;&gt;r = r_i * r_2 * ... * r_n&lt;/math&gt; can be computed in &lt;math display=&quot;inline&quot;&gt;O(n)&lt;/math&gt;, this architecture supports streaming observation with minimal overhead.<br /> <br /> We train &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; by asking it to predict &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; conditioned on a randomly<br /> chosen subset of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt;. This gives the model a signal of the uncertainty over the space X inherent in the distribution<br /> P given a set of observations. The authors let &lt;math display=&quot;inline&quot;&gt; f \sim P&lt;/math&gt;, &lt;math display=&quot;inline&quot;&gt; O = \{(x_i, y_i)\}_{i = 0} ^{n-1}&lt;/math&gt;, and N ~ uniform[0, 1, ..... ,n-1]. Subset &lt;math display=&quot;inline&quot;&gt; O = \{(x_i, y_i)\}_{i = 0} ^{N}&lt;/math&gt; that is first N elements of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; is regarded as condition. The negative conditional log probability is given by<br /> $\mathcal{L}(\theta)=-\mathbb{E}_{f \sim p}[\mathbb{E}_{N}[\log Q_\theta(\{y_i\}_{i = 0} ^{n-1}|O_{N}, \{x_i\}_{i = 0} ^{n-1})]]$<br /> Thus, the targets it scores &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; on include both the observed <br /> and unobserved values. In practice, Monte Carlo estimates of the gradient of this loss is taken by sampling &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;N&lt;/math&gt;. <br /> <br /> This approach shifts the burden of imposing prior knowledge from an analytic prior to empirical data. This has the advantage of liberating a practitioner from having to specify an analytic form for the prior, which is ultimately<br /> intended to summarize their empirical experience. Still, we emphasize that the &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; are not necessarily a consistent set of conditionals for all observation sets, and the training routine does not guarantee that.<br /> <br /> In summary,<br /> <br /> 1. A CNP is a conditional distribution over functions<br /> trained to model the empirical conditional distributions<br /> of functions &lt;math display=&quot;inline&quot;&gt;f \sim P&lt;/math&gt;.<br /> <br /> 2. A CNP is permutation invariant in &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;T&lt;/math&gt;.<br /> <br /> 3. A CNP is scalable, achieving a running time complexity<br /> of &lt;math display=&quot;inline&quot;&gt;O(n + m)&lt;/math&gt; for making &lt;math display=&quot;inline&quot;&gt;m&lt;/math&gt; predictions with &lt;math display=&quot;inline&quot;&gt;n&lt;/math&gt;<br /> observations.<br /> <br /> == Related Work ==<br /> <br /> ===Gaussian Process Framework===<br /> <br /> A Gaussian Process (GP) is a non-parametric method for regression, used extensively for regression and classification problems in the machine learning community. A GP is defined as a collection of random variables, any finite number of which have a joint Gaussian distribution.<br /> A standard approach is to model data as &lt;math&gt;y = m(X, φ) + \epsilon&lt;/math&gt;<br /> where m is the mean function with parameter vector &lt;math&gt;φ&lt;/math&gt;, and &lt;math&gt;\epsilon&lt;/math&gt; represents independent and identically distributed (i.i.d.) Gaussian noise: &lt;math&gt;N\sim (0,\sigma^2)&lt;/math&gt;<br /> <br /> For more info on Gaussian Process Framework:<br /> [https://arxiv.org/abs/1506.07304 A Gaussian process framework for modelling instrumental systematics: application to transmission spectroscopy]<br /> <br /> Several papers attempt to address various issues with GPs. These include:<br /> * Using sparse GPs to aid in scaling (Snelson &amp; Ghahramani, 2006)<br /> * Using Deep GPs to achieve more expressivity (Damianou &amp; Lawrence,<br /> 2013; Salimbeni &amp; Deisenroth, 2017)<br /> * Using neural networks to learn more expressive kernels (Wilson et al., 2016)<br /> <br /> A Python resource for Gaussian Process Framework implementation:[https://github.com/SheffieldML/GPyimplementation Gaussian Process Framework in Python]<br /> <br /> ===Meta Learning===<br /> <br /> Meta-Learning attempts to allow neural networks to learn more generalizable functions, as opposed to only approximating one function. This can be done by learning deep generative models which can do few-shot estimations of data. This can be implemented with attention mechanisms or additional memory.<br /> <br /> Classification is another common task in meta-learning, few-shot classification algorithms usually rely on some distance metric in feature space to compare target images and the observations. Matching networks(Vinyals et al., 2016; Bartunov &amp; Vetrov, 2016) are closely related to CNPs.<br /> <br /> Finally, the latest variant of Conditional Neural Process can also be seen as an approximated amortized version of Bayesian DL(Gal &amp; Ghahramani, 2016; Blundell et al., 2015; Louizos et al., 2017; Louizos &amp; Welling, 2017). For example, Gal &amp; Ghahramani 2016 develop a new theoretical framework casting dropout training in deep neural networks as approximate Bayesian inference in deep Gaussian processes. Their theory extracts information from existing models and gives us tools to model uncertainty.<br /> <br /> == Experimental Result I: Function Regression ==<br /> <br /> Classical 1D regression task that used as a common baseline for GP is the first example. <br /> They generated two different datasets that consisted of functions<br /> generated from a GP with an exponential kernel. In the first dataset they used a kernel with fixed parameters, and in the second dataset, the function switched at some random point. on the real line between two functions, each sampled with<br /> different kernel parameters. At every training step, they sampled a curve from the GP, select<br /> a subset of n points as observations, and a subset of t points as target points. Using the model, the observed points are encoded using a three-layer MLP encoder h with a 128-dimensional output representation. The representations are aggregated into a single representation<br /> &lt;math display=&quot;inline&quot;&gt;r = \frac{1}{n} \sum r_i&lt;/math&gt;<br /> , which is concatenated to &lt;math display=&quot;inline&quot;&gt;x_t&lt;/math&gt; and passed to a decoder g consisting of a five layer<br /> MLP. The function outputs a Gaussian mean and variance for the target outputs. The model is trained to maximize the log-likelihood of the target points using the Adam optimizer. <br /> <br /> Two examples of the regression results obtained for each<br /> of the datasets are shown in the following figure.<br /> <br /> [[File:007.jpg|300px|center]]<br /> <br /> They compared the model to the predictions generated by a GP with the correct<br /> hyperparameters, which constitutes an upper bound on our<br /> performance. Although the prediction generated by the GP<br /> is smoother than the CNP's prediction both for the mean<br /> and variance, the model is able to learn to regress from a few<br /> context points for both the fixed kernels and switching kernels.<br /> As the number of context points grows, the accuracy<br /> of the model improves and the approximated uncertainty<br /> of the model decreases. Crucially, we see the model learns<br /> to estimate its own uncertainty given the observations very<br /> accurately. Nonetheless, it provides a good approximation<br /> that increases in accuracy as the number of context points<br /> increases.<br /> Furthermore, the model achieves similarly good performance<br /> on the switching kernel task. This type of regression task<br /> is not trivial for GPs whereas in our case we only have to<br /> change the dataset used for training<br /> <br /> == Experimental Result II: Image Completion for Digits ==<br /> <br /> [[File:002.jpg|600px|center]]<br /> <br /> They also tested CNP on the MNIST dataset and use the test<br /> set to evaluate its performance. As shown in the above figure the<br /> model learns to make good predictions of the underlying<br /> digit even for a small number of context points. Crucially,<br /> when conditioned only on one non-informative context point the model’s prediction corresponds<br /> to the average overall MNIST digits. As the number<br /> of context points increases the predictions become more<br /> similar to the underlying ground truth. This demonstrates<br /> the model’s capacity to extract dataset specific prior knowledge.<br /> It is worth mentioning that even with a complete set<br /> of observations, the model does not achieve pixel-perfect<br /> reconstruction, as we have a bottleneck at the representation<br /> level.<br /> Since this implementation of CNP returns factored outputs,<br /> the best prediction it can produce given limited context<br /> information is to average over all possible predictions that<br /> agree with the context. An alternative to this is to add<br /> latent variables in the model such that they can be sampled<br /> conditioned on the context to produce predictions with high<br /> probability in the data distribution. <br /> <br /> <br /> An important aspect of the model is its ability to estimate<br /> the uncertainty of the prediction. As shown in the bottom<br /> row of the above figure, as they added more observations, the variance<br /> shifts from being almost uniformly spread over the digit<br /> positions to being localized around areas that are specific<br /> to the underlying digit, specifically its edges. Being able to<br /> model the uncertainty given some context can be helpful for<br /> many tasks. One example is active exploration, where the<br /> model has a choice over where to observe.<br /> They tested this by<br /> comparing the predictions of CNP when the observations<br /> are chosen according to uncertainty, versus random pixels. This method is a very simple way of doing active<br /> exploration, but it already produces better prediction results<br /> then selecting the conditioning points at random.<br /> <br /> == Experimental Result III: Image Completion for Faces ==<br /> <br /> <br /> [[File:003.jpg|400px|center]]<br /> <br /> <br /> They also applied CNP to CelebA, a dataset of images of<br /> celebrity faces and reported performance obtained on the<br /> test set.<br /> <br /> As shown in the above figure our model is able to capture<br /> the complex shapes and colors of this dataset with predictions<br /> conditioned on less than 10% of the pixels being<br /> already close to the ground truth. As before, given a few contexts<br /> points the model averages over all possible faces, but as<br /> the number of context pairs increases the predictions capture<br /> image-specific details like face orientation and facial<br /> expression. Furthermore, as the number of context points<br /> increases the variance is shifted towards the edges in the<br /> image.<br /> <br /> [[File:004.jpg|400px|center]]<br /> <br /> An important aspect of CNPs demonstrated in the above figure is<br /> it's flexibility not only in the number of observations and<br /> targets it receives but also with regards to their input values.<br /> It is interesting to compare this property to GPs on one hand,<br /> and to trained generative models (van den Oord et al., 2016;<br /> Gregor et al., 2015) on the other hand.<br /> The first type of flexibility can be seen when conditioning on<br /> subsets that the model has not encountered during training.<br /> Consider conditioning the model on one half of the image,<br /> fox example. This forces the model to not only predict the pixel<br /> values according to some stationary smoothness property of<br /> the images, but also according to global spatial properties,<br /> e.g. symmetry and the relative location of different parts of<br /> faces. As seen in the first row of the figure, CNPs are able to<br /> capture those properties. A GP with a stationary kernel cannot<br /> capture this, and in the absence of observations would<br /> revert to its mean (the mean itself can be non-stationary but<br /> usually, this would not be enough to capture the interesting<br /> properties).<br /> <br /> In addition, the model is flexible with regards to the target<br /> input values. This means, e.g., we can query the model<br /> at resolutions it has not seen during training. We take a<br /> model that has only been trained using pixel coordinates of<br /> a specific resolution and predict at test time subpixel values<br /> for targets between the original coordinates. As shown in<br /> Figure 5, with one forward pass we can query the model at<br /> different resolutions. While GPs also exhibit this type of<br /> flexibility, it is not the case for trained generative models,<br /> which can only predict values for the pixel coordinates on<br /> which they were trained. In this sense, CNPs capture the best<br /> of both worlds – it is flexible in regards to the conditioning<br /> and prediction task and has the capacity to extract domain<br /> knowledge from a training set.<br /> <br /> [[File:010.jpg|400px|center]]<br /> <br /> <br /> They compared CNPs quantitatively to two related models:<br /> kNNs and GPs. As shown in the above table CNPs outperform<br /> the latter when a number of context points are small (empirically<br /> when half of the image or less is provided as context).<br /> When the majority of the image is given as context exact<br /> methods like GPs and kNN will perform better. From the table<br /> we can also see that the order in which the context points<br /> are provided is less important for CNPs, since providing the<br /> context points in order from top to bottom still results in<br /> good performance. Both insights point to the fact that CNPs<br /> learn a data-specific ‘prior’ that will generate good samples<br /> even when the number of context points is very small.<br /> <br /> == Experimental Result IV: Classification ==<br /> Finally, they applied the model to one-shot classification using the Omniglot dataset. This dataset consists of 1,623 classes of characters from 50 different alphabets. Each class has only 20 examples and as such this dataset is particularly suitable for few-shot learning algorithms. The authors used 1,200 randomly selected classes as their training set and the remainder as the testing data set.<br /> <br /> Additionally, to apply data augmentation the authors cropped the image from 32 × 32 to 28 × 28, applied small random<br /> translations and rotations to the inputs, and also increased<br /> the number of classes by rotating every character by 90<br /> degrees and defining that to be a new class. They generated<br /> the labels for an N-way classification task by choosing N<br /> random classes at each training step and arbitrarily assigning<br /> the labels 0, ..., N − 1 to each.<br /> <br /> <br /> [[File:008.jpg|400px|center]]<br /> <br /> Given that the input points are images, they modified the architecture<br /> of the encoder h to include convolution layers as<br /> mentioned in section 2. In addition, they only aggregated over<br /> inputs of the same class by using the information provided<br /> by the input label. The aggregated class-specific representations<br /> are then concatenated to form the final representation.<br /> Given that both the size of the class-specific representations<br /> and the number of classes is constant, the size of the final<br /> representation is still constant and thus the O(n + m)<br /> runtime still holds.<br /> The results of the classification are summarized in the following table<br /> CNPs achieve higher accuracy than models that are significantly<br /> more complex (like MANN). While CNPs do not<br /> beat state of the art for one-shot classification our accuracy<br /> values are comparable. Crucially, they reached those values<br /> using a significantly simpler architecture (three convolutional<br /> layers for the encoder and a three-layer MLP for the<br /> decoder) and with a lower runtime of O(n + m) at test time<br /> as opposed to O(nm)<br /> <br /> == Conclusion ==<br /> <br /> In this paper, they had introduced Conditional Neural Processes,<br /> a model that is both flexible at test time and has the<br /> capacity to extract prior knowledge from training data.<br /> <br /> We had demonstrated its ability to perform a variety of tasks<br /> including regression, classification and image completion.<br /> We compared CNPs to Gaussian Processes on one hand, and<br /> deep learning methods on the other, and also discussed the<br /> relation to meta-learning and few-shot learning.<br /> It is important to note that the specific CNP implementations<br /> described here are just simple proofs-of-concept and can<br /> be substantially extended, e.g. by including more elaborate<br /> architectures in line with modern deep learning advances.<br /> To summarize, this work can be seen as a step towards learning<br /> high-level abstractions, one of the grand challenges of<br /> contemporary machine learning. Functions learned by most<br /> Conditional Neural Processes<br /> conventional deep learning models are tied to a specific, constrained<br /> statistical context at any stage of training. A trained<br /> CNP is more general, in that it encapsulates the high-level<br /> statistics of a family of functions. As such it constitutes a<br /> high-level abstraction that can be reused for multiple tasks.<br /> In future work, they are going to explore how far these models can<br /> help in tackling the many key machine learning problems<br /> that seem to hinge on abstraction, such as transfer learning,<br /> meta-learning, and data efficiency.<br /> <br /> <br /> == Critiques ==<br /> <br /> This paper introduces a method, for reducing the computational complexity of the more famous Gaussian Processes model, but they have mentioned a complexity of O(n + m) which is almost the same order of RBF kernel GP. With respect to performances in a sequence of tasks, the authors have not made metric comparisons to GP methods to prove the superiority of their approach. <br /> <br /> == Other Sources ==<br /> # Code for this model and a simpler explanation can be found at [https://github.com/deepmind/conditional-neural-process]<br /> # A newer version of the model is described in this paper [https://arxiv.org/pdf/1807.01622.pdf]<br /> # A good blog post on neural processes [https://kasparmartens.rbind.io/post/np/]<br /> <br /> == Reference ==<br /> Bartunov, S. and Vetrov, D. P. Fast adaptation in generative<br /> models with generative matching networks. arXiv<br /> preprint arXiv:1612.02192, 2016.<br /> <br /> Blundell, C., Cornebise, J., Kavukcuoglu, K., and Wierstra,<br /> D. Weight uncertainty in neural networks. arXiv preprint<br /> arXiv:1505.05424, 2015.<br /> <br /> Bornschein, J., Mnih, A., Zoran, D., and J. Rezende, D.<br /> Variational memory addressing in generative models. In<br /> Advances in Neural Information Processing Systems, pp.<br /> 3923–3932, 2017.<br /> <br /> Damianou, A. and Lawrence, N. Deep gaussian processes.<br /> In Artificial Intelligence and Statistics, pp. 207–215,<br /> 2013.<br /> <br /> Devlin, J., Bunel, R. R., Singh, R., Hausknecht, M., and<br /> Kohli, P. Neural program meta-induction. In Advances in<br /> Neural Information Processing Systems, pp. 2077–2085,<br /> 2017.<br /> <br /> Edwards, H. and Storkey, A. Towards a neural statistician.<br /> 2016.<br /> <br /> Finn, C., Abbeel, P., and Levine, S. Model-agnostic metalearning<br /> for fast adaptation of deep networks. arXiv<br /> preprint arXiv:1703.03400, 2017.<br /> <br /> Gal, Y. and Ghahramani, Z. Dropout as a bayesian approximation:<br /> Representing model uncertainty in deep learning.<br /> In international conference on machine learning, pp.<br /> 1050–1059, 2016.<br /> <br /> Garnelo, M., Arulkumaran, K., and Shanahan, M. Towards<br /> deep symbolic reinforcement learning. arXiv preprint<br /> arXiv:1609.05518, 2016.<br /> <br /> Gregor, K., Danihelka, I., Graves, A., Rezende, D. J., and<br /> Wierstra, D. Draw: A recurrent neural network for image<br /> generation. arXiv preprint arXiv:1502.04623, 2015.<br /> <br /> Hewitt, L., Gane, A., Jaakkola, T., and Tenenbaum, J. B. The<br /> variational homoencoder: Learning to infer high-capacity<br /> generative models from few examples. 2018.<br /> <br /> J. Rezende, D., Danihelka, I., Gregor, K., Wierstra, D.,<br /> et al. One-shot generalization in deep generative models.<br /> In International Conference on Machine Learning, pp.<br /> 1521–1529, 2016.<br /> <br /> Kingma, D. P. and Ba, J. Adam: A method for stochastic<br /> optimization. arXiv preprint arXiv:1412.6980, 2014.<br /> <br /> Kingma, D. P. and Welling, M. Auto-encoding variational<br /> bayes. arXiv preprint arXiv:1312.6114, 2013.<br /> <br /> Koch, G., Zemel, R., and Salakhutdinov, R. Siamese neural<br /> networks for one-shot image recognition. In ICML Deep<br /> Learning Workshop, volume 2, 2015.<br /> <br /> Lake, B. M., Salakhutdinov, R., and Tenenbaum, J. B.<br /> Human-level concept learning through probabilistic program<br /> induction. Science, 350(6266):1332–1338, 2015.<br /> <br /> Lake, B. M., Ullman, T. D., Tenenbaum, J. B., and Gershman,<br /> S. J. Building machines that learn and think like<br /> people. Behavioral and Brain Sciences, 40, 2017.<br /> <br /> LeCun, Y., Bottou, L., Bengio, Y., and Haffner, P. Gradientbased<br /> learning applied to document recognition. Proceedings<br /> of the IEEE, 86(11):2278–2324, 1998.<br /> <br /> Liu, Z., Luo, P., Wang, X., and Tang, X. Deep learning face<br /> attributes in the wild. In Proceedings of International<br /> Conference on Computer Vision (ICCV), December 2015.<br /> <br /> Louizos, C. and Welling, M. Multiplicative normalizing<br /> flows for variational bayesian neural networks. arXiv<br /> preprint arXiv:1703.01961, 2017.<br /> <br /> Louizos, C., Ullrich, K., and Welling, M. Bayesian compression<br /> for deep learning. In Advances in Neural Information<br /> Processing Systems, pp. 3290–3300, 2017.<br /> <br /> Rasmussen, C. E. and Williams, C. K. Gaussian processes<br /> in machine learning. In Advanced lectures on machine<br /> learning, pp. 63–71. Springer, 2004.<br /> <br /> Reed, S., Chen, Y., Paine, T., Oord, A. v. d., Eslami, S.,<br /> J. Rezende, D., Vinyals, O., and de Freitas, N. Few-shot<br /> autoregressive density estimation: Towards learning to<br /> learn distributions. 2017.<br /> <br /> Rezende, D. J., Mohamed, S., and Wierstra, D. Stochastic<br /> backpropagation and approximate inference in deep generative<br /> models. arXiv preprint arXiv:1401.4082, 2014.<br /> <br /> Salimbeni, H. and Deisenroth, M. Doubly stochastic variational<br /> inference for deep gaussian processes. In Advances<br /> in Neural Information Processing Systems, pp.<br /> 4591–4602, 2017.<br /> <br /> Santoro, A., Bartunov, S., Botvinick, M., Wierstra, D., and<br /> Lillicrap, T. One-shot learning with memory-augmented<br /> neural networks. arXiv preprint arXiv:1605.06065, 2016.<br /> <br /> Snell, J., Swersky, K., and Zemel, R. Prototypical networks<br /> for few-shot learning. In Advances in Neural Information<br /> Processing Systems, pp. 4080–4090, 2017.<br /> <br /> Snelson, E. and Ghahramani, Z. Sparse gaussian processes<br /> using pseudo-inputs. In Advances in neural information<br /> processing systems, pp. 1257–1264, 2006.<br /> <br /> van den Oord, A., Kalchbrenner, N., Espeholt, L., Vinyals,<br /> O., Graves, A., et al. Conditional image generation with<br /> pixelcnn decoders. In Advances in Neural Information<br /> Processing Systems, pp. 4790–4798, 2016.<br /> <br /> Vinyals, O., Blundell, C., Lillicrap, T., Wierstra, D., et al.<br /> Matching networks for one shot learning. In Advances in<br /> Neural Information Processing Systems, pp. 3630–3638,<br /> 2016.<br /> <br /> Wang, J. X., Kurth-Nelson, Z., Tirumala, D., Soyer, H.,<br /> Leibo, J. Z., Munos, R., Blundell, C., Kumaran, D., and<br /> Botvinick, M. Learning to reinforcement learn. arXiv<br /> preprint arXiv:1611.05763, 2016.<br /> <br /> Wilson, A. G., Hu, Z., Salakhutdinov, R., and Xing, E. P.<br /> Deep kernel learning. In Artificial Intelligence and Statistics,<br /> pp. 370–378, 2016.<br /> <br /> Damianou, A. and Lawrence, N. Deep gaussian processes.<br /> In Artificial Intelligence and Statistics, pp. 207–215,<br /> 2013.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=conditional_neural_process&diff=40917 conditional neural process 2018-11-22T17:37:21Z <p>Jmmoosa: /* Conditional Neural Process */</p> <hr /> <div>== Introduction ==<br /> <br /> To train a model effectively, deep neural networks typically require large datasets. To mitigate this data efficiency problem, learning in two phases is one approach: the first phase learns the statistics of a generic domain without committing to a specific learning task; the second phase learns a function for a specific task but does so using only a small number of data points by exploiting the domain-wide statistics already learned. Taking a probabilistic stance and specifying a distribution over functions (stochastic processes) is another approach -- Gaussian Processes being a commonly used example of this. Such Bayesian methods can be computationally expensive, however. <br /> <br /> The authors of the paper propose a family of models that represent solutions to the supervised problem, and an end-to-end training approach to learning them that combines neural networks with features reminiscent of Gaussian Processes. They call this family of models Conditional Neural Processes (CNPs). CNPs can be trained on very few data points to make accurate predictions, while they also have the capacity to scale to complex functions and large datasets. <br /> <br /> == Model ==<br /> Consider a data set &lt;math display=&quot;inline&quot;&gt; \{x_i, y_i\} &lt;/math&gt; with evaluations &lt;math display=&quot;inline&quot;&gt;y_i = f(x_i) &lt;/math&gt; for some unknown function &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt;. Assume &lt;math display=&quot;inline&quot;&gt;g&lt;/math&gt; is an approximating function of f. The aim is to minimize the loss between &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;g&lt;/math&gt; on the entire space &lt;math display=&quot;inline&quot;&gt;X&lt;/math&gt;. In practice, the routine is evaluated on a finite set of observations.<br /> <br /> <br /> Let training set be &lt;math display=&quot;inline&quot;&gt; O = \{x_i, y_i\}_{i = 0} ^{n-1}&lt;/math&gt;, and test set be &lt;math display=&quot;inline&quot;&gt; T = \{x_i, y_i\}_{i = n} ^ {n + m - 1} \subset X&lt;/math&gt; of unlabelled points.<br /> <br /> P be a probability distribution over functions &lt;math display=&quot;inline&quot;&gt; F : X \to Y&lt;/math&gt;, formally known as a stochastic process. Thus, P defines a joint distribution over the random variables &lt;math display=&quot;inline&quot;&gt; {f(x_i)}_{i = 0} ^{n + m - 1}&lt;/math&gt;. Therefore, for &lt;math display=&quot;inline&quot;&gt; P(f(x)|O, T)&lt;/math&gt;, our task is to predict the output values &lt;math display=&quot;inline&quot;&gt;f(x_i)&lt;/math&gt; for &lt;math display=&quot;inline&quot;&gt; x_i \in T&lt;/math&gt;, given &lt;math display=&quot;inline&quot;&gt; O&lt;/math&gt;. <br /> <br /> A common assumption made on P is that all function evaluations of &lt;math display=&quot;inline&quot;&gt; f &lt;/math&gt; is Gaussian distributed. The random functions class is called Gaussian Processes (GPs). This framework of the stochastic process allows a model to be data efficient, however, it's hard to get appropriate priors and stochastic processes are expensive in computation, scaling poorly with &lt;math&gt;n&lt;/math&gt; and &lt;math&gt;m&lt;/math&gt;. One of the examples is GPs, which has running time &lt;math&gt;O(n+3)^3&lt;/math&gt;.<br /> <br /> [[File:001.jpg|300px|center]]<br /> <br /> == Conditional Neural Process ==<br /> <br /> Conditional Neural Process models directly parametrize conditional stochastic processes without imposing consistency with respect to some prior process. CNP parametrize distributions over &lt;math display=&quot;inline&quot;&gt;f(T)&lt;/math&gt; given a distributed representation of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; of fixed dimensionality. Thus, the mathematical guarantees associated with stochastic processes is traded off for functional flexibility and scalability.<br /> <br /> CNP is a conditional stochastic process &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; defines distributions over &lt;math display=&quot;inline&quot;&gt;f(x_i)&lt;/math&gt; for &lt;math display=&quot;inline&quot;&gt;x_i \in T&lt;/math&gt;, given a set of observations &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt;. For stochastic processs, the authors assume that &lt;math display=&quot;inline&quot;&gt;Q_{\theta}&lt;/math&gt; is invariant to permutations, and &lt;math display=&quot;inline&quot;&gt;Q_\theta(f(T) | O, T)= Q_\theta(f(T') | O, T')=Q_\theta(f(T) | O', T) &lt;/math&gt; when &lt;math&gt; O', T'&lt;/math&gt; are permutations of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;T &lt;/math&gt;. In this work, we generally enforce permutation invariance with respect to &lt;math display=&quot;inline&quot;&gt;T&lt;/math&gt; be assuming a factored structure, which is the easiest way to ensure a valid stochastic process. That is, &lt;math display=&quot;inline&quot;&gt;Q_\theta(f(T) | O, T) = \prod _{x \in T} Q_\theta(f(x) | O, x)&lt;/math&gt;. Moreover, this framework can be extended to non-factored distributions.<br /> <br /> In detail, the following architecture is used<br /> <br /> &lt;math display=&quot;inline&quot;&gt;r_i = h_\theta(x_i, y_i)&lt;/math&gt; for any &lt;math display=&quot;inline&quot;&gt;(x_i, y_i) \in O&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;h_\theta : X \times Y \to \mathbb{R} ^ d&lt;/math&gt;<br /> <br /> &lt;math display=&quot;inline&quot;&gt;r = r_i * r_2 * ... * r_n&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;*&lt;/math&gt; is a commutative operation that takes elements in &lt;math display=&quot;inline&quot;&gt;\mathbb{R}^d&lt;/math&gt; and maps them into a single element of &lt;math display=&quot;inline&quot;&gt;\mathbb{R} ^ d&lt;/math&gt;<br /> <br /> &lt;math display=&quot;inline&quot;&gt;\Phi_i = g_\theta&lt;/math&gt; for any &lt;math display=&quot;inline&quot;&gt;x_i \in T&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;g_\theta : X \times \mathbb{R} ^ d \to \mathbb{R} ^ e&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;\Phi_i&lt;/math&gt; are parameters for &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt;<br /> <br /> Note that this architecture ensures permutation invariance and &lt;math display=&quot;inline&quot;&gt;O(n + m)&lt;/math&gt; scaling for conditional prediction. Also, &lt;math display=&quot;inline&quot;&gt;r = r_i * r_2 * ... * r_n&lt;/math&gt; can be computed in &lt;math display=&quot;inline&quot;&gt;O(n)&lt;/math&gt;, this architecture supports streaming observation with minimal overhead.<br /> <br /> We train &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; by asking it to predict &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; conditioned on a randomly<br /> chosen subset of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt;. This gives the model a signal of the uncertainty over the space X inherent in the distribution<br /> P given a set of observations. The authors let &lt;math display=&quot;inline&quot;&gt; f \sim P&lt;/math&gt;, &lt;math display=&quot;inline&quot;&gt; O = \{(x_i, y_i)\}_{i = 0} ^{n-1}&lt;/math&gt;, and N ~ uniform[0, 1, ..... ,n-1]. Subset &lt;math display=&quot;inline&quot;&gt; O = \{(x_i, y_i)\}_{i = 0} ^{N}&lt;/math&gt; that is first N elements of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; is regarded as condition. The negative conditional log probability is given by<br /> $\mathcal{L}(\theta)=-\mathbb{E}_{f \sim p}[\mathbb{E}_{N}[\log Q_\theta(\{y_i\}_{i = 0} ^{n-1}|O_{N}, \{x_i\}_{i = 0} ^{n-1})]]$<br /> Thus, the targets it scores &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; on include both the observed <br /> and unobserved values. In practice, Monte Carlo estimates of the gradient of this loss is taken by sampling &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;N&lt;/math&gt;. <br /> <br /> This approach shifts the burden of imposing prior knowledge from an analytic prior to empirical data. This has the advantage of liberating a practitioner from having to specify an analytic form for the prior, which is ultimately<br /> intended to summarize their empirical experience. Still, we emphasize that the &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; are not necessarily a consistent set of conditionals for all observation sets, and the training routine does not guarantee that.<br /> <br /> In summary,<br /> <br /> 1. A CNP is a conditional distribution over functions<br /> trained to model the empirical conditional distributions<br /> of functions &lt;math display=&quot;inline&quot;&gt;f \sim P&lt;/math&gt;.<br /> <br /> 2. A CNP is permutation invariant in &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;T&lt;/math&gt;.<br /> <br /> 3. A CNP is scalable, achieving a running time complexity<br /> of &lt;math display=&quot;inline&quot;&gt;O(n + m)&lt;/math&gt; for making &lt;math display=&quot;inline&quot;&gt;m&lt;/math&gt; predictions with &lt;math display=&quot;inline&quot;&gt;n&lt;/math&gt;<br /> observations.<br /> <br /> == Related Work ==<br /> <br /> ===Gaussian Process Framework===<br /> <br /> A Gaussian Process (GP) is a non-parametric method for regression, used extensively for regression and classification problems in the machine learning community. A GP is defined as a collection of random variables, any finite number of which have a joint Gaussian distribution.<br /> A standard approach is to model data as &lt;math&gt;y = m(X, φ) + \epsilon&lt;/math&gt;<br /> where m is the mean function with parameter vector &lt;math&gt;φ&lt;/math&gt;, and &lt;math&gt;\epsilon&lt;/math&gt; represents independent and identically distributed (i.i.d.) Gaussian noise: &lt;math&gt;N\sim (0,\sigma^2)&lt;/math&gt;<br /> <br /> For more info on Gaussian Process Framework:<br /> [https://arxiv.org/abs/1506.07304 A Gaussian process framework for modelling instrumental systematics: application to transmission spectroscopy]<br /> <br /> Several papers attempt to address various issues with GPs. These include:<br /> * Using sparse GPs to aid in scaling (Snelson &amp; Ghahramani, 2006)<br /> * Using Deep GPs to achieve more expressivity (Damianou &amp; Lawrence,<br /> 2013; Salimbeni &amp; Deisenroth, 2017)<br /> * Using neural networks to learn more expressive kernels (Wilson et al., 2016)<br /> <br /> A Python resource for Gaussian Process Framework implementation:[https://github.com/SheffieldML/GPyimplementation Gaussian Process Framework in Python]<br /> <br /> ===Meta Learning===<br /> <br /> Meta-Learning attempts to allow neural networks to learn more generalizable functions, as opposed to only approximating one function. This can be done by learning deep generative models which can do few-shot estimations of data. This can be implemented with attention mechanisms or additional memory.<br /> <br /> Classification is another common task in meta-learning, few-shot classification algorithms usually rely on some distance metric in feature space to compare target images and the observations. Matching networks(Vinyals et al., 2016; Bartunov &amp; Vetrov, 2016) are closely related to CNPs.<br /> <br /> Finally, the latest variant of Conditional Neural Process can also be seen as an approximated amortized version of Bayesian DL(Gal &amp; Ghahramani, 2016; Blundell et al., 2015; Louizos et al., 2017; Louizos &amp; Welling, 2017). For example, Gal &amp; Ghahramani 2016 develop a new theoretical framework casting dropout training in deep neural networks as approximate Bayesian inference in deep Gaussian processes. Their theory extracts information from existing models and gives us tools to model uncertainty.<br /> <br /> == Experimental Result I: Function Regression ==<br /> <br /> Classical 1D regression task that used as a common baseline for GP is our first example. <br /> They generated two different datasets that consisted of functions<br /> generated from a GP with an exponential kernel. In the first dataset they used a kernel with fixed parameters, and in the second dataset, the function switched at some random point. on the real line between two functions, each sampled with<br /> different kernel parameters. At every training step, they sampled a curve from the GP, select<br /> a subset of n points as observations, and a subset of t points as target points. Using the model, the observed points are encoded using a three-layer MLP encoder h with a 128-dimensional output representation. The representations are aggregated into a single representation<br /> &lt;math display=&quot;inline&quot;&gt;r = \frac{1}{n} \sum r_i&lt;/math&gt;<br /> , which is concatenated to &lt;math display=&quot;inline&quot;&gt;x_t&lt;/math&gt; and passed to a decoder g consisting of a five layer<br /> MLP. The function outputs a Gaussian mean and variance for the target outputs. The model is trained to maximize the log-likelihood of the target points using the Adam optimizer. <br /> <br /> Two examples of the regression results obtained for each<br /> of the datasets are shown in the following figure.<br /> <br /> [[File:007.jpg|300px|center]]<br /> <br /> They compared the model to the predictions generated by a GP with the correct<br /> hyperparameters, which constitutes an upper bound on our<br /> performance. Although the prediction generated by the GP<br /> is smoother than the CNP's prediction both for the mean<br /> and variance, the model is able to learn to regress from a few<br /> context points for both the fixed kernels and switching kernels.<br /> As the number of context points grows, the accuracy<br /> of the model improves and the approximated uncertainty<br /> of the model decreases. Crucially, we see the model learns<br /> to estimate its own uncertainty given the observations very<br /> accurately. Nonetheless, it provides a good approximation<br /> that increases in accuracy as the number of context points<br /> increases.<br /> Furthermore, the model achieves similarly good performance<br /> on the switching kernel task. This type of regression task<br /> is not trivial for GPs whereas in our case we only have to<br /> change the dataset used for training<br /> <br /> == Experimental Result II: Image Completion for Digits ==<br /> <br /> [[File:002.jpg|600px|center]]<br /> <br /> They also tested CNP on the MNIST dataset and use the test<br /> set to evaluate its performance. As shown in the above figure the<br /> model learns to make good predictions of the underlying<br /> digit even for a small number of context points. Crucially,<br /> when conditioned only on one non-informative context point the model’s prediction corresponds<br /> to the average overall MNIST digits. As the number<br /> of context points increases the predictions become more<br /> similar to the underlying ground truth. This demonstrates<br /> the model’s capacity to extract dataset specific prior knowledge.<br /> It is worth mentioning that even with a complete set<br /> of observations, the model does not achieve pixel-perfect<br /> reconstruction, as we have a bottleneck at the representation<br /> level.<br /> Since this implementation of CNP returns factored outputs,<br /> the best prediction it can produce given limited context<br /> information is to average over all possible predictions that<br /> agree with the context. An alternative to this is to add<br /> latent variables in the model such that they can be sampled<br /> conditioned on the context to produce predictions with high<br /> probability in the data distribution. <br /> <br /> <br /> An important aspect of the model is its ability to estimate<br /> the uncertainty of the prediction. As shown in the bottom<br /> row of the above figure, as they added more observations, the variance<br /> shifts from being almost uniformly spread over the digit<br /> positions to being localized around areas that are specific<br /> to the underlying digit, specifically its edges. Being able to<br /> model the uncertainty given some context can be helpful for<br /> many tasks. One example is active exploration, where the<br /> model has a choice over where to observe.<br /> They tested this by<br /> comparing the predictions of CNP when the observations<br /> are chosen according to uncertainty, versus random pixels. This method is a very simple way of doing active<br /> exploration, but it already produces better prediction results<br /> then selecting the conditioning points at random.<br /> <br /> == Experimental Result III: Image Completion for Faces ==<br /> <br /> <br /> [[File:003.jpg|400px|center]]<br /> <br /> <br /> They also applied CNP to CelebA, a dataset of images of<br /> celebrity faces and reported performance obtained on the<br /> test set.<br /> <br /> As shown in the above figure our model is able to capture<br /> the complex shapes and colors of this dataset with predictions<br /> conditioned on less than 10% of the pixels being<br /> already close to the ground truth. As before, given a few contexts<br /> points the model averages over all possible faces, but as<br /> the number of context pairs increases the predictions capture<br /> image-specific details like face orientation and facial<br /> expression. Furthermore, as the number of context points<br /> increases the variance is shifted towards the edges in the<br /> image.<br /> <br /> [[File:004.jpg|400px|center]]<br /> <br /> An important aspect of CNPs demonstrated in the above figure is<br /> it's flexibility not only in the number of observations and<br /> targets it receives but also with regards to their input values.<br /> It is interesting to compare this property to GPs on one hand,<br /> and to trained generative models (van den Oord et al., 2016;<br /> Gregor et al., 2015) on the other hand.<br /> The first type of flexibility can be seen when conditioning on<br /> subsets that the model has not encountered during training.<br /> Consider conditioning the model on one half of the image,<br /> fox example. This forces the model to not only predict the pixel<br /> values according to some stationary smoothness property of<br /> the images, but also according to global spatial properties,<br /> e.g. symmetry and the relative location of different parts of<br /> faces. As seen in the first row of the figure, CNPs are able to<br /> capture those properties. A GP with a stationary kernel cannot<br /> capture this, and in the absence of observations would<br /> revert to its mean (the mean itself can be non-stationary but<br /> usually, this would not be enough to capture the interesting<br /> properties).<br /> <br /> In addition, the model is flexible with regards to the target<br /> input values. This means, e.g., we can query the model<br /> at resolutions it has not seen during training. We take a<br /> model that has only been trained using pixel coordinates of<br /> a specific resolution and predict at test time subpixel values<br /> for targets between the original coordinates. As shown in<br /> Figure 5, with one forward pass we can query the model at<br /> different resolutions. While GPs also exhibit this type of<br /> flexibility, it is not the case for trained generative models,<br /> which can only predict values for the pixel coordinates on<br /> which they were trained. In this sense, CNPs capture the best<br /> of both worlds – it is flexible in regards to the conditioning<br /> and prediction task and has the capacity to extract domain<br /> knowledge from a training set.<br /> <br /> [[File:010.jpg|400px|center]]<br /> <br /> <br /> They compared CNPs quantitatively to two related models:<br /> kNNs and GPs. As shown in the above table CNPs outperform<br /> the latter when a number of context points are small (empirically<br /> when half of the image or less is provided as context).<br /> When the majority of the image is given as context exact<br /> methods like GPs and kNN will perform better. From the table<br /> we can also see that the order in which the context points<br /> are provided is less important for CNPs, since providing the<br /> context points in order from top to bottom still results in<br /> good performance. Both insights point to the fact that CNPs<br /> learn a data-specific ‘prior’ that will generate good samples<br /> even when the number of context points is very small.<br /> <br /> == Experimental Result IV: Classification ==<br /> Finally, they applied the model to one-shot classification using the Omniglot dataset. This dataset consists of 1,623 classes of characters from 50 different alphabets. Each class has only 20 examples and as such this dataset is particularly suitable for few-shot learning algorithms. The authors used 1,200 randomly selected classes as their training set and the remainder as the testing data set.<br /> <br /> Additionally, to apply data augmentation the authors cropped the image from 32 × 32 to 28 × 28, applied small random<br /> translations and rotations to the inputs, and also increased<br /> the number of classes by rotating every character by 90<br /> degrees and defining that to be a new class. They generated<br /> the labels for an N-way classification task by choosing N<br /> random classes at each training step and arbitrarily assigning<br /> the labels 0, ..., N − 1 to each.<br /> <br /> <br /> [[File:008.jpg|400px|center]]<br /> <br /> Given that the input points are images, they modified the architecture<br /> of the encoder h to include convolution layers as<br /> mentioned in section 2. In addition, they only aggregated over<br /> inputs of the same class by using the information provided<br /> by the input label. The aggregated class-specific representations<br /> are then concatenated to form the final representation.<br /> Given that both the size of the class-specific representations<br /> and the number of classes is constant, the size of the final<br /> representation is still constant and thus the O(n + m)<br /> runtime still holds.<br /> The results of the classification are summarized in the following table<br /> CNPs achieve higher accuracy than models that are significantly<br /> more complex (like MANN). While CNPs do not<br /> beat state of the art for one-shot classification our accuracy<br /> values are comparable. Crucially, they reached those values<br /> using a significantly simpler architecture (three convolutional<br /> layers for the encoder and a three-layer MLP for the<br /> decoder) and with a lower runtime of O(n + m) at test time<br /> as opposed to O(nm)<br /> <br /> == Conclusion ==<br /> <br /> In this paper, they had introduced Conditional Neural Processes,<br /> a model that is both flexible at test time and has the<br /> capacity to extract prior knowledge from training data.<br /> <br /> We had demonstrated its ability to perform a variety of tasks<br /> including regression, classification and image completion.<br /> We compared CNPs to Gaussian Processes on one hand, and<br /> deep learning methods on the other, and also discussed the<br /> relation to meta-learning and few-shot learning.<br /> It is important to note that the specific CNP implementations<br /> described here are just simple proofs-of-concept and can<br /> be substantially extended, e.g. by including more elaborate<br /> architectures in line with modern deep learning advances.<br /> To summarize, this work can be seen as a step towards learning<br /> high-level abstractions, one of the grand challenges of<br /> contemporary machine learning. Functions learned by most<br /> Conditional Neural Processes<br /> conventional deep learning models are tied to a specific, constrained<br /> statistical context at any stage of training. A trained<br /> CNP is more general, in that it encapsulates the high-level<br /> statistics of a family of functions. As such it constitutes a<br /> high-level abstraction that can be reused for multiple tasks.<br /> In future work, they are going to explore how far these models can<br /> help in tackling the many key machine learning problems<br /> that seem to hinge on abstraction, such as transfer learning,<br /> meta-learning, and data efficiency.<br /> <br /> <br /> == Critiques ==<br /> <br /> This paper introduces a method, for reducing the computational complexity of the more famous Gaussian Processes model, but they have mentioned a complexity of O(n + m) which is almost the same order of RBF kernel GP. With respect to performances in a sequence of tasks, the authors have not made metric comparisons to GP methods to prove the superiority of their approach. <br /> <br /> == Other Sources ==<br /> # Code for this model and a simpler explanation can be found at [https://github.com/deepmind/conditional-neural-process]<br /> # A newer version of the model is described in this paper [https://arxiv.org/pdf/1807.01622.pdf]<br /> # A good blog post on neural processes [https://kasparmartens.rbind.io/post/np/]<br /> <br /> == Reference ==<br /> Bartunov, S. and Vetrov, D. P. Fast adaptation in generative<br /> models with generative matching networks. arXiv<br /> preprint arXiv:1612.02192, 2016.<br /> <br /> Blundell, C., Cornebise, J., Kavukcuoglu, K., and Wierstra,<br /> D. Weight uncertainty in neural networks. arXiv preprint<br /> arXiv:1505.05424, 2015.<br /> <br /> Bornschein, J., Mnih, A., Zoran, D., and J. Rezende, D.<br /> Variational memory addressing in generative models. In<br /> Advances in Neural Information Processing Systems, pp.<br /> 3923–3932, 2017.<br /> <br /> Damianou, A. and Lawrence, N. Deep gaussian processes.<br /> In Artificial Intelligence and Statistics, pp. 207–215,<br /> 2013.<br /> <br /> Devlin, J., Bunel, R. R., Singh, R., Hausknecht, M., and<br /> Kohli, P. Neural program meta-induction. In Advances in<br /> Neural Information Processing Systems, pp. 2077–2085,<br /> 2017.<br /> <br /> Edwards, H. and Storkey, A. Towards a neural statistician.<br /> 2016.<br /> <br /> Finn, C., Abbeel, P., and Levine, S. Model-agnostic metalearning<br /> for fast adaptation of deep networks. arXiv<br /> preprint arXiv:1703.03400, 2017.<br /> <br /> Gal, Y. and Ghahramani, Z. Dropout as a bayesian approximation:<br /> Representing model uncertainty in deep learning.<br /> In international conference on machine learning, pp.<br /> 1050–1059, 2016.<br /> <br /> Garnelo, M., Arulkumaran, K., and Shanahan, M. Towards<br /> deep symbolic reinforcement learning. arXiv preprint<br /> arXiv:1609.05518, 2016.<br /> <br /> Gregor, K., Danihelka, I., Graves, A., Rezende, D. J., and<br /> Wierstra, D. Draw: A recurrent neural network for image<br /> generation. arXiv preprint arXiv:1502.04623, 2015.<br /> <br /> Hewitt, L., Gane, A., Jaakkola, T., and Tenenbaum, J. B. The<br /> variational homoencoder: Learning to infer high-capacity<br /> generative models from few examples. 2018.<br /> <br /> J. Rezende, D., Danihelka, I., Gregor, K., Wierstra, D.,<br /> et al. One-shot generalization in deep generative models.<br /> In International Conference on Machine Learning, pp.<br /> 1521–1529, 2016.<br /> <br /> Kingma, D. P. and Ba, J. Adam: A method for stochastic<br /> optimization. arXiv preprint arXiv:1412.6980, 2014.<br /> <br /> Kingma, D. P. and Welling, M. Auto-encoding variational<br /> bayes. arXiv preprint arXiv:1312.6114, 2013.<br /> <br /> Koch, G., Zemel, R., and Salakhutdinov, R. Siamese neural<br /> networks for one-shot image recognition. In ICML Deep<br /> Learning Workshop, volume 2, 2015.<br /> <br /> Lake, B. M., Salakhutdinov, R., and Tenenbaum, J. B.<br /> Human-level concept learning through probabilistic program<br /> induction. Science, 350(6266):1332–1338, 2015.<br /> <br /> Lake, B. M., Ullman, T. D., Tenenbaum, J. B., and Gershman,<br /> S. J. Building machines that learn and think like<br /> people. Behavioral and Brain Sciences, 40, 2017.<br /> <br /> LeCun, Y., Bottou, L., Bengio, Y., and Haffner, P. Gradientbased<br /> learning applied to document recognition. Proceedings<br /> of the IEEE, 86(11):2278–2324, 1998.<br /> <br /> Liu, Z., Luo, P., Wang, X., and Tang, X. Deep learning face<br /> attributes in the wild. In Proceedings of International<br /> Conference on Computer Vision (ICCV), December 2015.<br /> <br /> Louizos, C. and Welling, M. Multiplicative normalizing<br /> flows for variational bayesian neural networks. arXiv<br /> preprint arXiv:1703.01961, 2017.<br /> <br /> Louizos, C., Ullrich, K., and Welling, M. Bayesian compression<br /> for deep learning. In Advances in Neural Information<br /> Processing Systems, pp. 3290–3300, 2017.<br /> <br /> Rasmussen, C. E. and Williams, C. K. Gaussian processes<br /> in machine learning. In Advanced lectures on machine<br /> learning, pp. 63–71. Springer, 2004.<br /> <br /> Reed, S., Chen, Y., Paine, T., Oord, A. v. d., Eslami, S.,<br /> J. Rezende, D., Vinyals, O., and de Freitas, N. Few-shot<br /> autoregressive density estimation: Towards learning to<br /> learn distributions. 2017.<br /> <br /> Rezende, D. J., Mohamed, S., and Wierstra, D. Stochastic<br /> backpropagation and approximate inference in deep generative<br /> models. arXiv preprint arXiv:1401.4082, 2014.<br /> <br /> Salimbeni, H. and Deisenroth, M. Doubly stochastic variational<br /> inference for deep gaussian processes. In Advances<br /> in Neural Information Processing Systems, pp.<br /> 4591–4602, 2017.<br /> <br /> Santoro, A., Bartunov, S., Botvinick, M., Wierstra, D., and<br /> Lillicrap, T. One-shot learning with memory-augmented<br /> neural networks. arXiv preprint arXiv:1605.06065, 2016.<br /> <br /> Snell, J., Swersky, K., and Zemel, R. Prototypical networks<br /> for few-shot learning. In Advances in Neural Information<br /> Processing Systems, pp. 4080–4090, 2017.<br /> <br /> Snelson, E. and Ghahramani, Z. Sparse gaussian processes<br /> using pseudo-inputs. In Advances in neural information<br /> processing systems, pp. 1257–1264, 2006.<br /> <br /> van den Oord, A., Kalchbrenner, N., Espeholt, L., Vinyals,<br /> O., Graves, A., et al. Conditional image generation with<br /> pixelcnn decoders. In Advances in Neural Information<br /> Processing Systems, pp. 4790–4798, 2016.<br /> <br /> Vinyals, O., Blundell, C., Lillicrap, T., Wierstra, D., et al.<br /> Matching networks for one shot learning. In Advances in<br /> Neural Information Processing Systems, pp. 3630–3638,<br /> 2016.<br /> <br /> Wang, J. X., Kurth-Nelson, Z., Tirumala, D., Soyer, H.,<br /> Leibo, J. Z., Munos, R., Blundell, C., Kumaran, D., and<br /> Botvinick, M. Learning to reinforcement learn. arXiv<br /> preprint arXiv:1611.05763, 2016.<br /> <br /> Wilson, A. G., Hu, Z., Salakhutdinov, R., and Xing, E. P.<br /> Deep kernel learning. In Artificial Intelligence and Statistics,<br /> pp. 370–378, 2016.<br /> <br /> Damianou, A. and Lawrence, N. Deep gaussian processes.<br /> In Artificial Intelligence and Statistics, pp. 207–215,<br /> 2013.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=conditional_neural_process&diff=40916 conditional neural process 2018-11-22T17:35:11Z <p>Jmmoosa: /* Conditional Neural Process */</p> <hr /> <div>== Introduction ==<br /> <br /> To train a model effectively, deep neural networks typically require large datasets. To mitigate this data efficiency problem, learning in two phases is one approach: the first phase learns the statistics of a generic domain without committing to a specific learning task; the second phase learns a function for a specific task but does so using only a small number of data points by exploiting the domain-wide statistics already learned. Taking a probabilistic stance and specifying a distribution over functions (stochastic processes) is another approach -- Gaussian Processes being a commonly used example of this. Such Bayesian methods can be computationally expensive, however. <br /> <br /> The authors of the paper propose a family of models that represent solutions to the supervised problem, and an end-to-end training approach to learning them that combines neural networks with features reminiscent of Gaussian Processes. They call this family of models Conditional Neural Processes (CNPs). CNPs can be trained on very few data points to make accurate predictions, while they also have the capacity to scale to complex functions and large datasets. <br /> <br /> == Model ==<br /> Consider a data set &lt;math display=&quot;inline&quot;&gt; \{x_i, y_i\} &lt;/math&gt; with evaluations &lt;math display=&quot;inline&quot;&gt;y_i = f(x_i) &lt;/math&gt; for some unknown function &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt;. Assume &lt;math display=&quot;inline&quot;&gt;g&lt;/math&gt; is an approximating function of f. The aim is to minimize the loss between &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;g&lt;/math&gt; on the entire space &lt;math display=&quot;inline&quot;&gt;X&lt;/math&gt;. In practice, the routine is evaluated on a finite set of observations.<br /> <br /> <br /> Let training set be &lt;math display=&quot;inline&quot;&gt; O = \{x_i, y_i\}_{i = 0} ^{n-1}&lt;/math&gt;, and test set be &lt;math display=&quot;inline&quot;&gt; T = \{x_i, y_i\}_{i = n} ^ {n + m - 1} \subset X&lt;/math&gt; of unlabelled points.<br /> <br /> P be a probability distribution over functions &lt;math display=&quot;inline&quot;&gt; F : X \to Y&lt;/math&gt;, formally known as a stochastic process. Thus, P defines a joint distribution over the random variables &lt;math display=&quot;inline&quot;&gt; {f(x_i)}_{i = 0} ^{n + m - 1}&lt;/math&gt;. Therefore, for &lt;math display=&quot;inline&quot;&gt; P(f(x)|O, T)&lt;/math&gt;, our task is to predict the output values &lt;math display=&quot;inline&quot;&gt;f(x_i)&lt;/math&gt; for &lt;math display=&quot;inline&quot;&gt; x_i \in T&lt;/math&gt;, given &lt;math display=&quot;inline&quot;&gt; O&lt;/math&gt;. <br /> <br /> A common assumption made on P is that all function evaluations of &lt;math display=&quot;inline&quot;&gt; f &lt;/math&gt; is Gaussian distributed. The random functions class is called Gaussian Processes (GPs). This framework of the stochastic process allows a model to be data efficient, however, it's hard to get appropriate priors and stochastic processes are expensive in computation, scaling poorly with &lt;math&gt;n&lt;/math&gt; and &lt;math&gt;m&lt;/math&gt;. One of the examples is GPs, which has running time &lt;math&gt;O(n+3)^3&lt;/math&gt;.<br /> <br /> [[File:001.jpg|300px|center]]<br /> <br /> == Conditional Neural Process ==<br /> <br /> Conditional Neural Process models directly parametrize conditional stochastic processes without imposing consistency with respect to some prior process. CNP parametrize distributions over &lt;math display=&quot;inline&quot;&gt;f(T)&lt;/math&gt; given a distributed representation of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; of fixed dimensionality. Thus, the mathematical guarantees associated with stochastic processes is traded off for functional flexibility and scalability.<br /> <br /> CNP is a conditional stochastic process &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; defines distributions over &lt;math display=&quot;inline&quot;&gt;f(x_i)&lt;/math&gt; for &lt;math display=&quot;inline&quot;&gt;x_i \in T&lt;/math&gt;, given a set of observations &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt;. For stochastic processs, we assume &lt;math display=&quot;inline&quot;&gt;Q_{\theta}&lt;/math&gt; is invariant to permutations, and &lt;math display=&quot;inline&quot;&gt;Q_\theta(f(T) | O, T)= Q_\theta(f(T') | O, T')=Q_\theta(f(T) | O', T) &lt;/math&gt; when &lt;math&gt; O', T'&lt;/math&gt; are permutations of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;T &lt;/math&gt;. In this work, we generally enforce permutation invariance with respect to &lt;math display=&quot;inline&quot;&gt;T&lt;/math&gt; be assuming a factored structure, which is the easiest way to ensure a valid stochastic process. That is, &lt;math display=&quot;inline&quot;&gt;Q_\theta(f(T) | O, T) = \prod _{x \in T} Q_\theta(f(x) | O, x)&lt;/math&gt;. Moreover, this framework can be extended to non-factored distributions.<br /> <br /> In detail, the following architecture is used<br /> <br /> &lt;math display=&quot;inline&quot;&gt;r_i = h_\theta(x_i, y_i)&lt;/math&gt; for any &lt;math display=&quot;inline&quot;&gt;(x_i, y_i) \in O&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;h_\theta : X \times Y \to \mathbb{R} ^ d&lt;/math&gt;<br /> <br /> &lt;math display=&quot;inline&quot;&gt;r = r_i * r_2 * ... * r_n&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;*&lt;/math&gt; is a commutative operation that takes elements in &lt;math display=&quot;inline&quot;&gt;\mathbb{R}^d&lt;/math&gt; and maps them into a single element of &lt;math display=&quot;inline&quot;&gt;\mathbb{R} ^ d&lt;/math&gt;<br /> <br /> &lt;math display=&quot;inline&quot;&gt;\Phi_i = g_\theta&lt;/math&gt; for any &lt;math display=&quot;inline&quot;&gt;x_i \in T&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;g_\theta : X \times \mathbb{R} ^ d \to \mathbb{R} ^ e&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;\Phi_i&lt;/math&gt; are parameters for &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt;<br /> <br /> Note that this architecture ensures permutation invariance and &lt;math display=&quot;inline&quot;&gt;O(n + m)&lt;/math&gt; scaling for conditional prediction. Also, &lt;math display=&quot;inline&quot;&gt;r = r_i * r_2 * ... * r_n&lt;/math&gt; can be computed in &lt;math display=&quot;inline&quot;&gt;O(n)&lt;/math&gt;, this architecture supports streaming observation with minimal overhead.<br /> <br /> We train &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; by asking it to predict &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; conditioned on a randomly<br /> chosen subset of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt;. This gives the model a signal of the uncertainty over the space X inherent in the distribution<br /> P given a set of observations. The authors let &lt;math display=&quot;inline&quot;&gt; f \sim P&lt;/math&gt;, &lt;math display=&quot;inline&quot;&gt; O = \{(x_i, y_i)\}_{i = 0} ^{n-1}&lt;/math&gt;, and N ~ uniform[0, 1, ..... ,n-1]. Subset &lt;math display=&quot;inline&quot;&gt; O = \{(x_i, y_i)\}_{i = 0} ^{N}&lt;/math&gt; that is first N elements of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; is regarded as condition. The negative conditional log probability is given by<br /> $\mathcal{L}(\theta)=-\mathbb{E}_{f \sim p}[\mathbb{E}_{N}[\log Q_\theta(\{y_i\}_{i = 0} ^{n-1}|O_{N}, \{x_i\}_{i = 0} ^{n-1})]]$<br /> Thus, the targets it scores &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; on include both the observed <br /> and unobserved values. In practice, we take Monte Carlo<br /> estimates of the gradient of this loss by sampling &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;N&lt;/math&gt;. <br /> <br /> This approach shifts the burden of imposing prior knowledge from an analytic prior to empirical data. This has the advantage of liberating a practitioner from having to specify an analytic form for the prior, which is ultimately<br /> intended to summarize their empirical experience. Still, we emphasize that the &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; are not necessarily a consistent set of conditionals for all observation sets, and the training routine does not guarantee that.<br /> <br /> In summary,<br /> <br /> 1. A CNP is a conditional distribution over functions<br /> trained to model the empirical conditional distributions<br /> of functions &lt;math display=&quot;inline&quot;&gt;f \sim P&lt;/math&gt;.<br /> <br /> 2. A CNP is permutation invariant in &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;T&lt;/math&gt;.<br /> <br /> 3. A CNP is scalable, achieving a running time complexity<br /> of &lt;math display=&quot;inline&quot;&gt;O(n + m)&lt;/math&gt; for making &lt;math display=&quot;inline&quot;&gt;m&lt;/math&gt; predictions with &lt;math display=&quot;inline&quot;&gt;n&lt;/math&gt;<br /> observations.<br /> <br /> == Related Work ==<br /> <br /> ===Gaussian Process Framework===<br /> <br /> A Gaussian Process (GP) is a non-parametric method for regression, used extensively for regression and classification problems in the machine learning community. A GP is defined as a collection of random variables, any finite number of which have a joint Gaussian distribution.<br /> A standard approach is to model data as &lt;math&gt;y = m(X, φ) + \epsilon&lt;/math&gt;<br /> where m is the mean function with parameter vector &lt;math&gt;φ&lt;/math&gt;, and &lt;math&gt;\epsilon&lt;/math&gt; represents independent and identically distributed (i.i.d.) Gaussian noise: &lt;math&gt;N\sim (0,\sigma^2)&lt;/math&gt;<br /> <br /> For more info on Gaussian Process Framework:<br /> [https://arxiv.org/abs/1506.07304 A Gaussian process framework for modelling instrumental systematics: application to transmission spectroscopy]<br /> <br /> Several papers attempt to address various issues with GPs. These include:<br /> * Using sparse GPs to aid in scaling (Snelson &amp; Ghahramani, 2006)<br /> * Using Deep GPs to achieve more expressivity (Damianou &amp; Lawrence,<br /> 2013; Salimbeni &amp; Deisenroth, 2017)<br /> * Using neural networks to learn more expressive kernels (Wilson et al., 2016)<br /> <br /> A Python resource for Gaussian Process Framework implementation:[https://github.com/SheffieldML/GPyimplementation Gaussian Process Framework in Python]<br /> <br /> ===Meta Learning===<br /> <br /> Meta-Learning attempts to allow neural networks to learn more generalizable functions, as opposed to only approximating one function. This can be done by learning deep generative models which can do few-shot estimations of data. This can be implemented with attention mechanisms or additional memory.<br /> <br /> Classification is another common task in meta-learning, few-shot classification algorithms usually rely on some distance metric in feature space to compare target images and the observations. Matching networks(Vinyals et al., 2016; Bartunov &amp; Vetrov, 2016) are closely related to CNPs.<br /> <br /> Finally, the latest variant of Conditional Neural Process can also be seen as an approximated amortized version of Bayesian DL(Gal &amp; Ghahramani, 2016; Blundell et al., 2015; Louizos et al., 2017; Louizos &amp; Welling, 2017). For example, Gal &amp; Ghahramani 2016 develop a new theoretical framework casting dropout training in deep neural networks as approximate Bayesian inference in deep Gaussian processes. Their theory extracts information from existing models and gives us tools to model uncertainty.<br /> <br /> == Experimental Result I: Function Regression ==<br /> <br /> Classical 1D regression task that used as a common baseline for GP is our first example. <br /> They generated two different datasets that consisted of functions<br /> generated from a GP with an exponential kernel. In the first dataset they used a kernel with fixed parameters, and in the second dataset, the function switched at some random point. on the real line between two functions, each sampled with<br /> different kernel parameters. At every training step, they sampled a curve from the GP, select<br /> a subset of n points as observations, and a subset of t points as target points. Using the model, the observed points are encoded using a three-layer MLP encoder h with a 128-dimensional output representation. The representations are aggregated into a single representation<br /> &lt;math display=&quot;inline&quot;&gt;r = \frac{1}{n} \sum r_i&lt;/math&gt;<br /> , which is concatenated to &lt;math display=&quot;inline&quot;&gt;x_t&lt;/math&gt; and passed to a decoder g consisting of a five layer<br /> MLP. The function outputs a Gaussian mean and variance for the target outputs. The model is trained to maximize the log-likelihood of the target points using the Adam optimizer. <br /> <br /> Two examples of the regression results obtained for each<br /> of the datasets are shown in the following figure.<br /> <br /> [[File:007.jpg|300px|center]]<br /> <br /> They compared the model to the predictions generated by a GP with the correct<br /> hyperparameters, which constitutes an upper bound on our<br /> performance. Although the prediction generated by the GP<br /> is smoother than the CNP's prediction both for the mean<br /> and variance, the model is able to learn to regress from a few<br /> context points for both the fixed kernels and switching kernels.<br /> As the number of context points grows, the accuracy<br /> of the model improves and the approximated uncertainty<br /> of the model decreases. Crucially, we see the model learns<br /> to estimate its own uncertainty given the observations very<br /> accurately. Nonetheless, it provides a good approximation<br /> that increases in accuracy as the number of context points<br /> increases.<br /> Furthermore, the model achieves similarly good performance<br /> on the switching kernel task. This type of regression task<br /> is not trivial for GPs whereas in our case we only have to<br /> change the dataset used for training<br /> <br /> == Experimental Result II: Image Completion for Digits ==<br /> <br /> [[File:002.jpg|600px|center]]<br /> <br /> They also tested CNP on the MNIST dataset and use the test<br /> set to evaluate its performance. As shown in the above figure the<br /> model learns to make good predictions of the underlying<br /> digit even for a small number of context points. Crucially,<br /> when conditioned only on one non-informative context point the model’s prediction corresponds<br /> to the average overall MNIST digits. As the number<br /> of context points increases the predictions become more<br /> similar to the underlying ground truth. This demonstrates<br /> the model’s capacity to extract dataset specific prior knowledge.<br /> It is worth mentioning that even with a complete set<br /> of observations, the model does not achieve pixel-perfect<br /> reconstruction, as we have a bottleneck at the representation<br /> level.<br /> Since this implementation of CNP returns factored outputs,<br /> the best prediction it can produce given limited context<br /> information is to average over all possible predictions that<br /> agree with the context. An alternative to this is to add<br /> latent variables in the model such that they can be sampled<br /> conditioned on the context to produce predictions with high<br /> probability in the data distribution. <br /> <br /> <br /> An important aspect of the model is its ability to estimate<br /> the uncertainty of the prediction. As shown in the bottom<br /> row of the above figure, as they added more observations, the variance<br /> shifts from being almost uniformly spread over the digit<br /> positions to being localized around areas that are specific<br /> to the underlying digit, specifically its edges. Being able to<br /> model the uncertainty given some context can be helpful for<br /> many tasks. One example is active exploration, where the<br /> model has a choice over where to observe.<br /> They tested this by<br /> comparing the predictions of CNP when the observations<br /> are chosen according to uncertainty, versus random pixels. This method is a very simple way of doing active<br /> exploration, but it already produces better prediction results<br /> then selecting the conditioning points at random.<br /> <br /> == Experimental Result III: Image Completion for Faces ==<br /> <br /> <br /> [[File:003.jpg|400px|center]]<br /> <br /> <br /> They also applied CNP to CelebA, a dataset of images of<br /> celebrity faces and reported performance obtained on the<br /> test set.<br /> <br /> As shown in the above figure our model is able to capture<br /> the complex shapes and colors of this dataset with predictions<br /> conditioned on less than 10% of the pixels being<br /> already close to the ground truth. As before, given a few contexts<br /> points the model averages over all possible faces, but as<br /> the number of context pairs increases the predictions capture<br /> image-specific details like face orientation and facial<br /> expression. Furthermore, as the number of context points<br /> increases the variance is shifted towards the edges in the<br /> image.<br /> <br /> [[File:004.jpg|400px|center]]<br /> <br /> An important aspect of CNPs demonstrated in the above figure is<br /> it's flexibility not only in the number of observations and<br /> targets it receives but also with regards to their input values.<br /> It is interesting to compare this property to GPs on one hand,<br /> and to trained generative models (van den Oord et al., 2016;<br /> Gregor et al., 2015) on the other hand.<br /> The first type of flexibility can be seen when conditioning on<br /> subsets that the model has not encountered during training.<br /> Consider conditioning the model on one half of the image,<br /> fox example. This forces the model to not only predict the pixel<br /> values according to some stationary smoothness property of<br /> the images, but also according to global spatial properties,<br /> e.g. symmetry and the relative location of different parts of<br /> faces. As seen in the first row of the figure, CNPs are able to<br /> capture those properties. A GP with a stationary kernel cannot<br /> capture this, and in the absence of observations would<br /> revert to its mean (the mean itself can be non-stationary but<br /> usually, this would not be enough to capture the interesting<br /> properties).<br /> <br /> In addition, the model is flexible with regards to the target<br /> input values. This means, e.g., we can query the model<br /> at resolutions it has not seen during training. We take a<br /> model that has only been trained using pixel coordinates of<br /> a specific resolution and predict at test time subpixel values<br /> for targets between the original coordinates. As shown in<br /> Figure 5, with one forward pass we can query the model at<br /> different resolutions. While GPs also exhibit this type of<br /> flexibility, it is not the case for trained generative models,<br /> which can only predict values for the pixel coordinates on<br /> which they were trained. In this sense, CNPs capture the best<br /> of both worlds – it is flexible in regards to the conditioning<br /> and prediction task and has the capacity to extract domain<br /> knowledge from a training set.<br /> <br /> [[File:010.jpg|400px|center]]<br /> <br /> <br /> They compared CNPs quantitatively to two related models:<br /> kNNs and GPs. As shown in the above table CNPs outperform<br /> the latter when a number of context points are small (empirically<br /> when half of the image or less is provided as context).<br /> When the majority of the image is given as context exact<br /> methods like GPs and kNN will perform better. From the table<br /> we can also see that the order in which the context points<br /> are provided is less important for CNPs, since providing the<br /> context points in order from top to bottom still results in<br /> good performance. Both insights point to the fact that CNPs<br /> learn a data-specific ‘prior’ that will generate good samples<br /> even when the number of context points is very small.<br /> <br /> == Experimental Result IV: Classification ==<br /> Finally, they applied the model to one-shot classification using the Omniglot dataset. This dataset consists of 1,623 classes of characters from 50 different alphabets. Each class has only 20 examples and as such this dataset is particularly suitable for few-shot learning algorithms. The authors used 1,200 randomly selected classes as their training set and the remainder as the testing data set.<br /> <br /> Additionally, to apply data augmentation the authors cropped the image from 32 × 32 to 28 × 28, applied small random<br /> translations and rotations to the inputs, and also increased<br /> the number of classes by rotating every character by 90<br /> degrees and defining that to be a new class. They generated<br /> the labels for an N-way classification task by choosing N<br /> random classes at each training step and arbitrarily assigning<br /> the labels 0, ..., N − 1 to each.<br /> <br /> <br /> [[File:008.jpg|400px|center]]<br /> <br /> Given that the input points are images, they modified the architecture<br /> of the encoder h to include convolution layers as<br /> mentioned in section 2. In addition, they only aggregated over<br /> inputs of the same class by using the information provided<br /> by the input label. The aggregated class-specific representations<br /> are then concatenated to form the final representation.<br /> Given that both the size of the class-specific representations<br /> and the number of classes is constant, the size of the final<br /> representation is still constant and thus the O(n + m)<br /> runtime still holds.<br /> The results of the classification are summarized in the following table<br /> CNPs achieve higher accuracy than models that are significantly<br /> more complex (like MANN). While CNPs do not<br /> beat state of the art for one-shot classification our accuracy<br /> values are comparable. Crucially, they reached those values<br /> using a significantly simpler architecture (three convolutional<br /> layers for the encoder and a three-layer MLP for the<br /> decoder) and with a lower runtime of O(n + m) at test time<br /> as opposed to O(nm)<br /> <br /> == Conclusion ==<br /> <br /> In this paper, they had introduced Conditional Neural Processes,<br /> a model that is both flexible at test time and has the<br /> capacity to extract prior knowledge from training data.<br /> <br /> We had demonstrated its ability to perform a variety of tasks<br /> including regression, classification and image completion.<br /> We compared CNPs to Gaussian Processes on one hand, and<br /> deep learning methods on the other, and also discussed the<br /> relation to meta-learning and few-shot learning.<br /> It is important to note that the specific CNP implementations<br /> described here are just simple proofs-of-concept and can<br /> be substantially extended, e.g. by including more elaborate<br /> architectures in line with modern deep learning advances.<br /> To summarize, this work can be seen as a step towards learning<br /> high-level abstractions, one of the grand challenges of<br /> contemporary machine learning. Functions learned by most<br /> Conditional Neural Processes<br /> conventional deep learning models are tied to a specific, constrained<br /> statistical context at any stage of training. A trained<br /> CNP is more general, in that it encapsulates the high-level<br /> statistics of a family of functions. As such it constitutes a<br /> high-level abstraction that can be reused for multiple tasks.<br /> In future work, they are going to explore how far these models can<br /> help in tackling the many key machine learning problems<br /> that seem to hinge on abstraction, such as transfer learning,<br /> meta-learning, and data efficiency.<br /> <br /> <br /> == Critiques ==<br /> <br /> This paper introduces a method, for reducing the computational complexity of the more famous Gaussian Processes model, but they have mentioned a complexity of O(n + m) which is almost the same order of RBF kernel GP. With respect to performances in a sequence of tasks, the authors have not made metric comparisons to GP methods to prove the superiority of their approach. <br /> <br /> == Other Sources ==<br /> # Code for this model and a simpler explanation can be found at [https://github.com/deepmind/conditional-neural-process]<br /> # A newer version of the model is described in this paper [https://arxiv.org/pdf/1807.01622.pdf]<br /> # A good blog post on neural processes [https://kasparmartens.rbind.io/post/np/]<br /> <br /> == Reference ==<br /> Bartunov, S. and Vetrov, D. P. Fast adaptation in generative<br /> models with generative matching networks. arXiv<br /> preprint arXiv:1612.02192, 2016.<br /> <br /> Blundell, C., Cornebise, J., Kavukcuoglu, K., and Wierstra,<br /> D. Weight uncertainty in neural networks. arXiv preprint<br /> arXiv:1505.05424, 2015.<br /> <br /> Bornschein, J., Mnih, A., Zoran, D., and J. Rezende, D.<br /> Variational memory addressing in generative models. In<br /> Advances in Neural Information Processing Systems, pp.<br /> 3923–3932, 2017.<br /> <br /> Damianou, A. and Lawrence, N. Deep gaussian processes.<br /> In Artificial Intelligence and Statistics, pp. 207–215,<br /> 2013.<br /> <br /> Devlin, J., Bunel, R. R., Singh, R., Hausknecht, M., and<br /> Kohli, P. Neural program meta-induction. In Advances in<br /> Neural Information Processing Systems, pp. 2077–2085,<br /> 2017.<br /> <br /> Edwards, H. and Storkey, A. Towards a neural statistician.<br /> 2016.<br /> <br /> Finn, C., Abbeel, P., and Levine, S. Model-agnostic metalearning<br /> for fast adaptation of deep networks. arXiv<br /> preprint arXiv:1703.03400, 2017.<br /> <br /> Gal, Y. and Ghahramani, Z. Dropout as a bayesian approximation:<br /> Representing model uncertainty in deep learning.<br /> In international conference on machine learning, pp.<br /> 1050–1059, 2016.<br /> <br /> Garnelo, M., Arulkumaran, K., and Shanahan, M. Towards<br /> deep symbolic reinforcement learning. arXiv preprint<br /> arXiv:1609.05518, 2016.<br /> <br /> Gregor, K., Danihelka, I., Graves, A., Rezende, D. J., and<br /> Wierstra, D. Draw: A recurrent neural network for image<br /> generation. arXiv preprint arXiv:1502.04623, 2015.<br /> <br /> Hewitt, L., Gane, A., Jaakkola, T., and Tenenbaum, J. B. The<br /> variational homoencoder: Learning to infer high-capacity<br /> generative models from few examples. 2018.<br /> <br /> J. Rezende, D., Danihelka, I., Gregor, K., Wierstra, D.,<br /> et al. One-shot generalization in deep generative models.<br /> In International Conference on Machine Learning, pp.<br /> 1521–1529, 2016.<br /> <br /> Kingma, D. P. and Ba, J. Adam: A method for stochastic<br /> optimization. arXiv preprint arXiv:1412.6980, 2014.<br /> <br /> Kingma, D. P. and Welling, M. Auto-encoding variational<br /> bayes. arXiv preprint arXiv:1312.6114, 2013.<br /> <br /> Koch, G., Zemel, R., and Salakhutdinov, R. Siamese neural<br /> networks for one-shot image recognition. In ICML Deep<br /> Learning Workshop, volume 2, 2015.<br /> <br /> Lake, B. M., Salakhutdinov, R., and Tenenbaum, J. B.<br /> Human-level concept learning through probabilistic program<br /> induction. Science, 350(6266):1332–1338, 2015.<br /> <br /> Lake, B. M., Ullman, T. D., Tenenbaum, J. B., and Gershman,<br /> S. J. Building machines that learn and think like<br /> people. Behavioral and Brain Sciences, 40, 2017.<br /> <br /> LeCun, Y., Bottou, L., Bengio, Y., and Haffner, P. Gradientbased<br /> learning applied to document recognition. Proceedings<br /> of the IEEE, 86(11):2278–2324, 1998.<br /> <br /> Liu, Z., Luo, P., Wang, X., and Tang, X. Deep learning face<br /> attributes in the wild. In Proceedings of International<br /> Conference on Computer Vision (ICCV), December 2015.<br /> <br /> Louizos, C. and Welling, M. Multiplicative normalizing<br /> flows for variational bayesian neural networks. arXiv<br /> preprint arXiv:1703.01961, 2017.<br /> <br /> Louizos, C., Ullrich, K., and Welling, M. Bayesian compression<br /> for deep learning. In Advances in Neural Information<br /> Processing Systems, pp. 3290–3300, 2017.<br /> <br /> Rasmussen, C. E. and Williams, C. K. Gaussian processes<br /> in machine learning. In Advanced lectures on machine<br /> learning, pp. 63–71. Springer, 2004.<br /> <br /> Reed, S., Chen, Y., Paine, T., Oord, A. v. d., Eslami, S.,<br /> J. Rezende, D., Vinyals, O., and de Freitas, N. Few-shot<br /> autoregressive density estimation: Towards learning to<br /> learn distributions. 2017.<br /> <br /> Rezende, D. J., Mohamed, S., and Wierstra, D. Stochastic<br /> backpropagation and approximate inference in deep generative<br /> models. arXiv preprint arXiv:1401.4082, 2014.<br /> <br /> Salimbeni, H. and Deisenroth, M. Doubly stochastic variational<br /> inference for deep gaussian processes. In Advances<br /> in Neural Information Processing Systems, pp.<br /> 4591–4602, 2017.<br /> <br /> Santoro, A., Bartunov, S., Botvinick, M., Wierstra, D., and<br /> Lillicrap, T. One-shot learning with memory-augmented<br /> neural networks. arXiv preprint arXiv:1605.06065, 2016.<br /> <br /> Snell, J., Swersky, K., and Zemel, R. Prototypical networks<br /> for few-shot learning. In Advances in Neural Information<br /> Processing Systems, pp. 4080–4090, 2017.<br /> <br /> Snelson, E. and Ghahramani, Z. Sparse gaussian processes<br /> using pseudo-inputs. In Advances in neural information<br /> processing systems, pp. 1257–1264, 2006.<br /> <br /> van den Oord, A., Kalchbrenner, N., Espeholt, L., Vinyals,<br /> O., Graves, A., et al. Conditional image generation with<br /> pixelcnn decoders. In Advances in Neural Information<br /> Processing Systems, pp. 4790–4798, 2016.<br /> <br /> Vinyals, O., Blundell, C., Lillicrap, T., Wierstra, D., et al.<br /> Matching networks for one shot learning. In Advances in<br /> Neural Information Processing Systems, pp. 3630–3638,<br /> 2016.<br /> <br /> Wang, J. X., Kurth-Nelson, Z., Tirumala, D., Soyer, H.,<br /> Leibo, J. Z., Munos, R., Blundell, C., Kumaran, D., and<br /> Botvinick, M. Learning to reinforcement learn. arXiv<br /> preprint arXiv:1611.05763, 2016.<br /> <br /> Wilson, A. G., Hu, Z., Salakhutdinov, R., and Xing, E. P.<br /> Deep kernel learning. In Artificial Intelligence and Statistics,<br /> pp. 370–378, 2016.<br /> <br /> Damianou, A. and Lawrence, N. Deep gaussian processes.<br /> In Artificial Intelligence and Statistics, pp. 207–215,<br /> 2013.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=conditional_neural_process&diff=40902 conditional neural process 2018-11-22T17:16:27Z <p>Jmmoosa: /* Experimental Result IV: Classification */</p> <hr /> <div>== Introduction ==<br /> <br /> To train a model effectively, deep neural networks typically require large datasets. To mitigate this data efficiency problem, learning in two phases is one approach: the first phase learns the statistics of a generic domain without committing to a specific learning task; the second phase learns a function for a specific task but does so using only a small number of data points by exploiting the domain-wide statistics already learned. Taking a probabilistic stance and specifying a distribution over functions (stochastic processes) is another approach -- Gaussian Processes being a commonly used example of this. Such Bayesian methods can be computationally expensive, however. <br /> <br /> The authors of the paper propose a family of models that represent solutions to the supervised problem, and an end-to-end training approach to learning them that combines neural networks with features reminiscent of Gaussian Processes. They call this family of models Conditional Neural Processes (CNPs). CNPs can be trained on very few data points to make accurate predictions, while they also have the capacity to scale to complex functions and large datasets. <br /> <br /> == Model ==<br /> Consider a data set &lt;math display=&quot;inline&quot;&gt; \{x_i, y_i\} &lt;/math&gt; with evaluations &lt;math display=&quot;inline&quot;&gt;y_i = f(x_i) &lt;/math&gt; for some unknown function &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt;. Assume &lt;math display=&quot;inline&quot;&gt;g&lt;/math&gt; is an approximating function of f. The aim is to minimize the loss between &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;g&lt;/math&gt; on the entire space &lt;math display=&quot;inline&quot;&gt;X&lt;/math&gt;. In practice, the routine is evaluated on a finite set of observations.<br /> <br /> <br /> Let training set be &lt;math display=&quot;inline&quot;&gt; O = \{x_i, y_i\}_{i = 0} ^{n-1}&lt;/math&gt;, and test set be &lt;math display=&quot;inline&quot;&gt; T = \{x_i, y_i\}_{i = n} ^ {n + m - 1} \subset X&lt;/math&gt; of unlabelled points.<br /> <br /> P be a probability distribution over functions &lt;math display=&quot;inline&quot;&gt; F : X \to Y&lt;/math&gt;, formally known as a stochastic process. Thus, P defines a joint distribution over the random variables &lt;math display=&quot;inline&quot;&gt; {f(x_i)}_{i = 0} ^{n + m - 1}&lt;/math&gt;. Therefore, for &lt;math display=&quot;inline&quot;&gt; P(f(x)|O, T)&lt;/math&gt;, our task is to predict the output values &lt;math display=&quot;inline&quot;&gt;f(x_i)&lt;/math&gt; for &lt;math display=&quot;inline&quot;&gt; x_i \in T&lt;/math&gt;, given &lt;math display=&quot;inline&quot;&gt; O&lt;/math&gt;. <br /> <br /> A common assumption made on P is that all function evaluations of &lt;math display=&quot;inline&quot;&gt; f &lt;/math&gt; is Gaussian distributed. The random functions class is called Gaussian Processes (GPs). This framework of the stochastic process allows a model to be data efficient, however, it's hard to get appropriate priors and stochastic processes are expensive in computation, scaling poorly with &lt;math&gt;n&lt;/math&gt; and &lt;math&gt;m&lt;/math&gt;. One of the examples is GPs, which has running time &lt;math&gt;O(n+3)^3&lt;/math&gt;.<br /> <br /> [[File:001.jpg|300px|center]]<br /> <br /> == Conditional Neural Process ==<br /> <br /> Conditional Neural Process models directly parametrize conditional stochastic processes without imposing consistency with respect to some prior process. CNP parametrize distributions over &lt;math display=&quot;inline&quot;&gt;f(T)&lt;/math&gt; given a distributed representation of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; of fixed dimensionality. Thus, the mathematical guarantees associated with stochastic processes is traded off for functional flexibility and scalability.<br /> <br /> CNP is a conditional stochastic process &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; defines distributions over &lt;math display=&quot;inline&quot;&gt;f(x_i)&lt;/math&gt; for &lt;math display=&quot;inline&quot;&gt;x_i \in T&lt;/math&gt;, given a set of observations &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt;. For stochastic processs, we assume &lt;math display=&quot;inline&quot;&gt;Q_{\theta}&lt;/math&gt; is invariant to permutations, and &lt;math display=&quot;inline&quot;&gt;Q_\theta(f(T) | O, T)= Q_\theta(f(T') | O, T')=Q_\theta(f(T) | O', T) &lt;/math&gt; when &lt;math&gt; O', T'&lt;/math&gt; are permutations of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;T &lt;/math&gt;. In this work, we generally enforce permutation invariance with respect to &lt;math display=&quot;inline&quot;&gt;T&lt;/math&gt; be assuming a factored structure, which is the easiest way to ensure a valid stochastic process. That is, &lt;math display=&quot;inline&quot;&gt;Q_\theta(f(T) | O, T) = \prod _{x \in T} Q_\theta(f(x) | O, x)&lt;/math&gt;. Moreover, this framework can be extended to non-factored distributions.<br /> <br /> In detail, we use the following architecture<br /> <br /> &lt;math display=&quot;inline&quot;&gt;r_i = h_\theta(x_i, y_i)&lt;/math&gt; for any &lt;math display=&quot;inline&quot;&gt;(x_i, y_i) \in O&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;h_\theta : X \times Y \to \mathbb{R} ^ d&lt;/math&gt;<br /> <br /> &lt;math display=&quot;inline&quot;&gt;r = r_i * r_2 * ... * r_n&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;*&lt;/math&gt; is a commutative operation that takes elements in &lt;math display=&quot;inline&quot;&gt;\mathbb{R}^d&lt;/math&gt; and maps them into a single element of &lt;math display=&quot;inline&quot;&gt;\mathbb{R} ^ d&lt;/math&gt;<br /> <br /> &lt;math display=&quot;inline&quot;&gt;\Phi_i = g_\theta&lt;/math&gt; for any &lt;math display=&quot;inline&quot;&gt;x_i \in T&lt;/math&gt;, where &lt;math display=&quot;inline&quot;&gt;g_\theta : X \times \mathbb{R} ^ d \to \mathbb{R} ^ e&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;\Phi_i&lt;/math&gt; are parameters for &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt;<br /> <br /> Note that this architecture ensures permutation invariance and &lt;math display=&quot;inline&quot;&gt;O(n + m)&lt;/math&gt; scaling for conditional prediction. Also, &lt;math display=&quot;inline&quot;&gt;r = r_i * r_2 * ... * r_n&lt;/math&gt; can be computed in &lt;math display=&quot;inline&quot;&gt;O(n)&lt;/math&gt;, this architecture supports streaming observation with minimal overhead.<br /> <br /> We train &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; by asking it to predict &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; conditioned on a randomly<br /> chosen subset of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt;. This gives the model a signal of the uncertainty over the space X inherent in the distribution<br /> P given a set of observations. The authors let &lt;math display=&quot;inline&quot;&gt; f \sim P&lt;/math&gt;, &lt;math display=&quot;inline&quot;&gt; O = \{(x_i, y_i)\}_{i = 0} ^{n-1}&lt;/math&gt;, and N ~ uniform[0, 1, ..... ,n-1]. Subset &lt;math display=&quot;inline&quot;&gt; O = \{(x_i, y_i)\}_{i = 0} ^{N}&lt;/math&gt; that is first N elements of &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; is regarded as condition. The negative conditional log probability is given by<br /> $\mathcal{L}(\theta)=-\mathbb{E}_{f \sim p}[\mathbb{E}_{N}[\log Q_\theta(\{y_i\}_{i = 0} ^{n-1}|O_{N}, \{x_i\}_{i = 0} ^{n-1})]]$<br /> Thus, the targets it scores &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; on include both the observed <br /> and unobserved values. In practice, we take Monte Carlo<br /> estimates of the gradient of this loss by sampling &lt;math display=&quot;inline&quot;&gt;f&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;N&lt;/math&gt;. <br /> <br /> This approach shifts the burden of imposing prior knowledge from an analytic prior to empirical data. This has the advantage of liberating a practitioner from having to specify an analytic form for the prior, which is ultimately<br /> intended to summarize their empirical experience. Still, we emphasize that the &lt;math display=&quot;inline&quot;&gt;Q_\theta&lt;/math&gt; are not necessarily a consistent set of conditionals for all observation sets, and the training routine does not guarantee that.<br /> <br /> In summary,<br /> <br /> 1. A CNP is a conditional distribution over functions<br /> trained to model the empirical conditional distributions<br /> of functions &lt;math display=&quot;inline&quot;&gt;f \sim P&lt;/math&gt;.<br /> <br /> 2. A CNP is permutation invariant in &lt;math display=&quot;inline&quot;&gt;O&lt;/math&gt; and &lt;math display=&quot;inline&quot;&gt;T&lt;/math&gt;.<br /> <br /> 3. A CNP is scalable, achieving a running time complexity<br /> of &lt;math display=&quot;inline&quot;&gt;O(n + m)&lt;/math&gt; for making &lt;math display=&quot;inline&quot;&gt;m&lt;/math&gt; predictions with &lt;math display=&quot;inline&quot;&gt;n&lt;/math&gt;<br /> observations.<br /> <br /> == Related Work ==<br /> <br /> ===Gaussian Process Framework===<br /> <br /> A Gaussian Process (GP) is a non-parametric method for regression, used extensively for regression and classification problems in the machine learning community. A GP is defined as a collection of random variables, any finite number of which have a joint Gaussian distribution.<br /> A standard approach is to model data as &lt;math&gt;y = m(X, φ) + \epsilon&lt;/math&gt;<br /> where m is the mean function with parameter vector &lt;math&gt;φ&lt;/math&gt;, and &lt;math&gt;\epsilon&lt;/math&gt; represents independent and identically distributed (i.i.d.) Gaussian noise: &lt;math&gt;N\sim (0,\sigma^2)&lt;/math&gt;<br /> <br /> For more info on Gaussian Process Framework:<br /> [https://arxiv.org/abs/1506.07304 A Gaussian process framework for modelling instrumental systematics: application to transmission spectroscopy]<br /> <br /> Several papers attempt to address various issues with GPs. These include:<br /> * Using sparse GPs to aid in scaling (Snelson &amp; Ghahramani, 2006)<br /> * Using Deep GPs to achieve more expressivity (Damianou &amp; Lawrence,<br /> 2013; Salimbeni &amp; Deisenroth, 2017)<br /> * Using neural networks to learn more expressive kernels (Wilson et al., 2016)<br /> <br /> A Python resource for Gaussian Process Framework implementation:[https://github.com/SheffieldML/GPyimplementation Gaussian Process Framework in Python]<br /> <br /> ===Meta Learning===<br /> <br /> Meta-Learning attempts to allow neural networks to learn more generalizable functions, as opposed to only approximating one function. This can be done by learning deep generative models which can do few-shot estimations of data. This can be implemented with attention mechanisms or additional memory.<br /> <br /> Classification is another common task in meta-learning, few-shot classification algorithms usually rely on some distance metric in feature space to compare target images and the observations. Matching networks(Vinyals et al., 2016; Bartunov &amp; Vetrov, 2016) are closely related to CNPs.<br /> <br /> Finally, the latest variant of Conditional Neural Process can also be seen as an approximated amortized version of Bayesian DL(Gal &amp; Ghahramani, 2016; Blundell et al., 2015; Louizos et al., 2017; Louizos &amp; Welling, 2017). For example, Gal &amp; Ghahramani 2016 develop a new theoretical framework casting dropout training in deep neural networks as approximate Bayesian inference in deep Gaussian processes. Their theory extracts information from existing models and gives us tools to model uncertainty.<br /> <br /> == Experimental Result I: Function Regression ==<br /> <br /> Classical 1D regression task that used as a common baseline for GP is our first example. <br /> They generated two different datasets that consisted of functions<br /> generated from a GP with an exponential kernel. In the first dataset they used a kernel with fixed parameters, and in the second dataset, the function switched at some random point. on the real line between two functions, each sampled with<br /> different kernel parameters. At every training step, they sampled a curve from the GP, select<br /> a subset of n points as observations, and a subset of t points as target points. Using the model, the observed points are encoded using a three-layer MLP encoder h with a 128-dimensional output representation. The representations are aggregated into a single representation<br /> &lt;math display=&quot;inline&quot;&gt;r = \frac{1}{n} \sum r_i&lt;/math&gt;<br /> , which is concatenated to &lt;math display=&quot;inline&quot;&gt;x_t&lt;/math&gt; and passed to a decoder g consisting of a five layer<br /> MLP. The function outputs a Gaussian mean and variance for the target outputs. The model is trained to maximize the log-likelihood of the target points using the Adam optimizer. <br /> <br /> Two examples of the regression results obtained for each<br /> of the datasets are shown in the following figure.<br /> <br /> [[File:007.jpg|300px|center]]<br /> <br /> They compared the model to the predictions generated by a GP with the correct<br /> hyperparameters, which constitutes an upper bound on our<br /> performance. Although the prediction generated by the GP<br /> is smoother than the CNP's prediction both for the mean<br /> and variance, the model is able to learn to regress from a few<br /> context points for both the fixed kernels and switching kernels.<br /> As the number of context points grows, the accuracy<br /> of the model improves and the approximated uncertainty<br /> of the model decreases. Crucially, we see the model learns<br /> to estimate its own uncertainty given the observations very<br /> accurately. Nonetheless, it provides a good approximation<br /> that increases in accuracy as the number of context points<br /> increases.<br /> Furthermore, the model achieves similarly good performance<br /> on the switching kernel task. This type of regression task<br /> is not trivial for GPs whereas in our case we only have to<br /> change the dataset used for training<br /> <br /> == Experimental Result II: Image Completion for Digits ==<br /> <br /> [[File:002.jpg|600px|center]]<br /> <br /> They also tested CNP on the MNIST dataset and use the test<br /> set to evaluate its performance. As shown in the above figure the<br /> model learns to make good predictions of the underlying<br /> digit even for a small number of context points. Crucially,<br /> when conditioned only on one non-informative context point the model’s prediction corresponds<br /> to the average overall MNIST digits. As the number<br /> of context points increases the predictions become more<br /> similar to the underlying ground truth. This demonstrates<br /> the model’s capacity to extract dataset specific prior knowledge.<br /> It is worth mentioning that even with a complete set<br /> of observations, the model does not achieve pixel-perfect<br /> reconstruction, as we have a bottleneck at the representation<br /> level.<br /> Since this implementation of CNP returns factored outputs,<br /> the best prediction it can produce given limited context<br /> information is to average over all possible predictions that<br /> agree with the context. An alternative to this is to add<br /> latent variables in the model such that they can be sampled<br /> conditioned on the context to produce predictions with high<br /> probability in the data distribution. <br /> <br /> <br /> An important aspect of the model is its ability to estimate<br /> the uncertainty of the prediction. As shown in the bottom<br /> row of the above figure, as they added more observations, the variance<br /> shifts from being almost uniformly spread over the digit<br /> positions to being localized around areas that are specific<br /> to the underlying digit, specifically its edges. Being able to<br /> model the uncertainty given some context can be helpful for<br /> many tasks. One example is active exploration, where the<br /> model has a choice over where to observe.<br /> They tested this by<br /> comparing the predictions of CNP when the observations<br /> are chosen according to uncertainty, versus random pixels. This method is a very simple way of doing active<br /> exploration, but it already produces better prediction results<br /> then selecting the conditioning points at random.<br /> <br /> == Experimental Result III: Image Completion for Faces ==<br /> <br /> <br /> [[File:003.jpg|400px|center]]<br /> <br /> <br /> They also applied CNP to CelebA, a dataset of images of<br /> celebrity faces and reported performance obtained on the<br /> test set.<br /> <br /> As shown in the above figure our model is able to capture<br /> the complex shapes and colors of this dataset with predictions<br /> conditioned on less than 10% of the pixels being<br /> already close to the ground truth. As before, given a few contexts<br /> points the model averages over all possible faces, but as<br /> the number of context pairs increases the predictions capture<br /> image-specific details like face orientation and facial<br /> expression. Furthermore, as the number of context points<br /> increases the variance is shifted towards the edges in the<br /> image.<br /> <br /> [[File:004.jpg|400px|center]]<br /> <br /> An important aspect of CNPs demonstrated in the above figure is<br /> it's flexibility not only in the number of observations and<br /> targets it receives but also with regards to their input values.<br /> It is interesting to compare this property to GPs on one hand,<br /> and to trained generative models (van den Oord et al., 2016;<br /> Gregor et al., 2015) on the other hand.<br /> The first type of flexibility can be seen when conditioning on<br /> subsets that the model has not encountered during training.<br /> Consider conditioning the model on one half of the image,<br /> fox example. This forces the model to not only predict the pixel<br /> values according to some stationary smoothness property of<br /> the images, but also according to global spatial properties,<br /> e.g. symmetry and the relative location of different parts of<br /> faces. As seen in the first row of the figure, CNPs are able to<br /> capture those properties. A GP with a stationary kernel cannot<br /> capture this, and in the absence of observations would<br /> revert to its mean (the mean itself can be non-stationary but<br /> usually, this would not be enough to capture the interesting<br /> properties).<br /> <br /> In addition, the model is flexible with regards to the target<br /> input values. This means, e.g., we can query the model<br /> at resolutions it has not seen during training. We take a<br /> model that has only been trained using pixel coordinates of<br /> a specific resolution and predict at test time subpixel values<br /> for targets between the original coordinates. As shown in<br /> Figure 5, with one forward pass we can query the model at<br /> different resolutions. While GPs also exhibit this type of<br /> flexibility, it is not the case for trained generative models,<br /> which can only predict values for the pixel coordinates on<br /> which they were trained. In this sense, CNPs capture the best<br /> of both worlds – it is flexible in regards to the conditioning<br /> and prediction task and has the capacity to extract domain<br /> knowledge from a training set.<br /> <br /> [[File:010.jpg|400px|center]]<br /> <br /> <br /> They compared CNPs quantitatively to two related models:<br /> kNNs and GPs. As shown in the above table CNPs outperform<br /> the latter when a number of context points are small (empirically<br /> when half of the image or less is provided as context).<br /> When the majority of the image is given as context exact<br /> methods like GPs and kNN will perform better. From the table<br /> we can also see that the order in which the context points<br /> are provided is less important for CNPs, since providing the<br /> context points in order from top to bottom still results in<br /> good performance. Both insights point to the fact that CNPs<br /> learn a data-specific ‘prior’ that will generate good samples<br /> even when the number of context points is very small.<br /> <br /> == Experimental Result IV: Classification ==<br /> Finally, they applied the model to one-shot classification using the Omniglot dataset. This dataset consists of 1,623 classes of characters from 50 different alphabets. Each class has only 20 examples and as such this dataset is particularly suitable for few-shot learning algorithms. The authors used 1,200 randomly selected classes as their training set and the remainder as the testing data set.<br /> <br /> Additionally, to apply data augmentation the authors cropped the image from 32 × 32 to 28 × 28, applied small random<br /> translations and rotations to the inputs, and also increased<br /> the number of classes by rotating every character by 90<br /> degrees and defining that to be a new class. They generated<br /> the labels for an N-way classification task by choosing N<br /> random classes at each training step and arbitrarily assigning<br /> the labels 0, ..., N − 1 to each.<br /> <br /> <br /> [[File:008.jpg|400px|center]]<br /> <br /> Given that the input points are images, they modified the architecture<br /> of the encoder h to include convolution layers as<br /> mentioned in section 2. In addition, they only aggregated over<br /> inputs of the same class by using the information provided<br /> by the input label. The aggregated class-specific representations<br /> are then concatenated to form the final representation.<br /> Given that both the size of the class-specific representations<br /> and the number of classes is constant, the size of the final<br /> representation is still constant and thus the O(n + m)<br /> runtime still holds.<br /> The results of the classification are summarized in the following table<br /> CNPs achieve higher accuracy than models that are significantly<br /> more complex (like MANN). While CNPs do not<br /> beat state of the art for one-shot classification our accuracy<br /> values are comparable. Crucially, they reached those values<br /> using a significantly simpler architecture (three convolutional<br /> layers for the encoder and a three-layer MLP for the<br /> decoder) and with a lower runtime of O(n + m) at test time<br /> as opposed to O(nm)<br /> <br /> == Conclusion ==<br /> <br /> In this paper, they had introduced Conditional Neural Processes,<br /> a model that is both flexible at test time and has the<br /> capacity to extract prior knowledge from training data.<br /> <br /> We had demonstrated its ability to perform a variety of tasks<br /> including regression, classification and image completion.<br /> We compared CNPs to Gaussian Processes on one hand, and<br /> deep learning methods on the other, and also discussed the<br /> relation to meta-learning and few-shot learning.<br /> It is important to note that the specific CNP implementations<br /> described here are just simple proofs-of-concept and can<br /> be substantially extended, e.g. by including more elaborate<br /> architectures in line with modern deep learning advances.<br /> To summarize, this work can be seen as a step towards learning<br /> high-level abstractions, one of the grand challenges of<br /> contemporary machine learning. Functions learned by most<br /> Conditional Neural Processes<br /> conventional deep learning models are tied to a specific, constrained<br /> statistical context at any stage of training. A trained<br /> CNP is more general, in that it encapsulates the high-level<br /> statistics of a family of functions. As such it constitutes a<br /> high-level abstraction that can be reused for multiple tasks.<br /> In future work, they are going to explore how far these models can<br /> help in tackling the many key machine learning problems<br /> that seem to hinge on abstraction, such as transfer learning,<br /> meta-learning, and data efficiency.<br /> <br /> <br /> == Critiques ==<br /> <br /> This paper introduces a method, for reducing the computational complexity of the more famous Gaussian Processes model, but they have mentioned a complexity of O(n + m) which is almost the same order of RBF kernel GP. With respect to performances in a sequence of tasks, the authors have not made metric comparisons to GP methods to prove the superiority of their approach. <br /> <br /> == Other Sources ==<br /> # Code for this model and a simpler explanation can be found at [https://github.com/deepmind/conditional-neural-process]<br /> # A newer version of the model is described in this paper [https://arxiv.org/pdf/1807.01622.pdf]<br /> # A good blog post on neural processes [https://kasparmartens.rbind.io/post/np/]<br /> <br /> == Reference ==<br /> Bartunov, S. and Vetrov, D. P. Fast adaptation in generative<br /> models with generative matching networks. arXiv<br /> preprint arXiv:1612.02192, 2016.<br /> <br /> Blundell, C., Cornebise, J., Kavukcuoglu, K., and Wierstra,<br /> D. Weight uncertainty in neural networks. arXiv preprint<br /> arXiv:1505.05424, 2015.<br /> <br /> Bornschein, J., Mnih, A., Zoran, D., and J. Rezende, D.<br /> Variational memory addressing in generative models. In<br /> Advances in Neural Information Processing Systems, pp.<br /> 3923–3932, 2017.<br /> <br /> Damianou, A. and Lawrence, N. Deep gaussian processes.<br /> In Artificial Intelligence and Statistics, pp. 207–215,<br /> 2013.<br /> <br /> Devlin, J., Bunel, R. R., Singh, R., Hausknecht, M., and<br /> Kohli, P. Neural program meta-induction. In Advances in<br /> Neural Information Processing Systems, pp. 2077–2085,<br /> 2017.<br /> <br /> Edwards, H. and Storkey, A. Towards a neural statistician.<br /> 2016.<br /> <br /> Finn, C., Abbeel, P., and Levine, S. Model-agnostic metalearning<br /> for fast adaptation of deep networks. arXiv<br /> preprint arXiv:1703.03400, 2017.<br /> <br /> Gal, Y. and Ghahramani, Z. Dropout as a bayesian approximation:<br /> Representing model uncertainty in deep learning.<br /> In international conference on machine learning, pp.<br /> 1050–1059, 2016.<br /> <br /> Garnelo, M., Arulkumaran, K., and Shanahan, M. Towards<br /> deep symbolic reinforcement learning. arXiv preprint<br /> arXiv:1609.05518, 2016.<br /> <br /> Gregor, K., Danihelka, I., Graves, A., Rezende, D. J., and<br /> Wierstra, D. Draw: A recurrent neural network for image<br /> generation. arXiv preprint arXiv:1502.04623, 2015.<br /> <br /> Hewitt, L., Gane, A., Jaakkola, T., and Tenenbaum, J. B. The<br /> variational homoencoder: Learning to infer high-capacity<br /> generative models from few examples. 2018.<br /> <br /> J. Rezende, D., Danihelka, I., Gregor, K., Wierstra, D.,<br /> et al. One-shot generalization in deep generative models.<br /> In International Conference on Machine Learning, pp.<br /> 1521–1529, 2016.<br /> <br /> Kingma, D. P. and Ba, J. Adam: A method for stochastic<br /> optimization. arXiv preprint arXiv:1412.6980, 2014.<br /> <br /> Kingma, D. P. and Welling, M. Auto-encoding variational<br /> bayes. arXiv preprint arXiv:1312.6114, 2013.<br /> <br /> Koch, G., Zemel, R., and Salakhutdinov, R. Siamese neural<br /> networks for one-shot image recognition. In ICML Deep<br /> Learning Workshop, volume 2, 2015.<br /> <br /> Lake, B. M., Salakhutdinov, R., and Tenenbaum, J. B.<br /> Human-level concept learning through probabilistic program<br /> induction. Science, 350(6266):1332–1338, 2015.<br /> <br /> Lake, B. M., Ullman, T. D., Tenenbaum, J. B., and Gershman,<br /> S. J. Building machines that learn and think like<br /> people. Behavioral and Brain Sciences, 40, 2017.<br /> <br /> LeCun, Y., Bottou, L., Bengio, Y., and Haffner, P. Gradientbased<br /> learning applied to document recognition. Proceedings<br /> of the IEEE, 86(11):2278–2324, 1998.<br /> <br /> Liu, Z., Luo, P., Wang, X., and Tang, X. Deep learning face<br /> attributes in the wild. In Proceedings of International<br /> Conference on Computer Vision (ICCV), December 2015.<br /> <br /> Louizos, C. and Welling, M. Multiplicative normalizing<br /> flows for variational bayesian neural networks. arXiv<br /> preprint arXiv:1703.01961, 2017.<br /> <br /> Louizos, C., Ullrich, K., and Welling, M. Bayesian compression<br /> for deep learning. In Advances in Neural Information<br /> Processing Systems, pp. 3290–3300, 2017.<br /> <br /> Rasmussen, C. E. and Williams, C. K. Gaussian processes<br /> in machine learning. In Advanced lectures on machine<br /> learning, pp. 63–71. Springer, 2004.<br /> <br /> Reed, S., Chen, Y., Paine, T., Oord, A. v. d., Eslami, S.,<br /> J. Rezende, D., Vinyals, O., and de Freitas, N. Few-shot<br /> autoregressive density estimation: Towards learning to<br /> learn distributions. 2017.<br /> <br /> Rezende, D. J., Mohamed, S., and Wierstra, D. Stochastic<br /> backpropagation and approximate inference in deep generative<br /> models. arXiv preprint arXiv:1401.4082, 2014.<br /> <br /> Salimbeni, H. and Deisenroth, M. Doubly stochastic variational<br /> inference for deep gaussian processes. In Advances<br /> in Neural Information Processing Systems, pp.<br /> 4591–4602, 2017.<br /> <br /> Santoro, A., Bartunov, S., Botvinick, M., Wierstra, D., and<br /> Lillicrap, T. One-shot learning with memory-augmented<br /> neural networks. arXiv preprint arXiv:1605.06065, 2016.<br /> <br /> Snell, J., Swersky, K., and Zemel, R. Prototypical networks<br /> for few-shot learning. In Advances in Neural Information<br /> Processing Systems, pp. 4080–4090, 2017.<br /> <br /> Snelson, E. and Ghahramani, Z. Sparse gaussian processes<br /> using pseudo-inputs. In Advances in neural information<br /> processing systems, pp. 1257–1264, 2006.<br /> <br /> van den Oord, A., Kalchbrenner, N., Espeholt, L., Vinyals,<br /> O., Graves, A., et al. Conditional image generation with<br /> pixelcnn decoders. In Advances in Neural Information<br /> Processing Systems, pp. 4790–4798, 2016.<br /> <br /> Vinyals, O., Blundell, C., Lillicrap, T., Wierstra, D., et al.<br /> Matching networks for one shot learning. In Advances in<br /> Neural Information Processing Systems, pp. 3630–3638,<br /> 2016.<br /> <br /> Wang, J. X., Kurth-Nelson, Z., Tirumala, D., Soyer, H.,<br /> Leibo, J. Z., Munos, R., Blundell, C., Kumaran, D., and<br /> Botvinick, M. Learning to reinforcement learn. arXiv<br /> preprint arXiv:1611.05763, 2016.<br /> <br /> Wilson, A. G., Hu, Z., Salakhutdinov, R., and Xing, E. P.<br /> Deep kernel learning. In Artificial Intelligence and Statistics,<br /> pp. 370–378, 2016.<br /> <br /> Damianou, A. and Lawrence, N. Deep gaussian processes.<br /> In Artificial Intelligence and Statistics, pp. 207–215,<br /> 2013.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=Mapping_Images_to_Scene_Graphs_with_Permutation-Invariant_Structured_Prediction&diff=40886 Mapping Images to Scene Graphs with Permutation-Invariant Structured Prediction 2018-11-22T16:50:52Z <p>Jmmoosa: /* References */</p> <hr /> <div>The paper ''Mapping Images to Scene Graphs with Permutation-Invariant Structured Prediction'' was written by Roei Herzig* from Tel Aviv University, Moshiko Raboh* from Tel Aviv University, Gal Chechik from Google Brain, Bar-Ilan University, Jonathan Berant from Tel Aviv University, and Amir Globerson from Tel Aviv University. This paper is part of the NIPS 2018 conference to be hosted in December 2018 at Montréal, Canada. This paper summary is based on version 3 of the pre-print (as of May 2018) obtained from [https://arxiv.org/pdf/1802.05451v3.pdf arXiv] <br /> <br /> (*) Equal contribution<br /> <br /> =Motivation=<br /> In the field of artificial intelligence, a major goal is to enable machines to understand complex images, such as the underlying relationships between objects that exist in each scene. Although there are models today that capture both complex labels and interactions between labels, there is a disconnect for what guidelines should be used when leveraging deep learning. This paper introduces a design principle for such models that stem from the concept of permutation invariance and proves state of the art performance on models that follow this principle.<br /> <br /> The primary contributions that this paper makes include:<br /> # Deriving sufficient and necessary conditions for respecting graph-permutation invariance in deep structured prediction architectures<br /> # Empirically proving the benefit of graph-permutation invariance<br /> # Developing a state-of-the-art model for scene graph predictions over a large set of complex visual scenes<br /> <br /> =Introduction=<br /> In order to make a machine to interpret complex visual scenes, it must recognize and understand both objects and relationships between the objects in the scene. A '''scene graph''' is a representation of the set of objects and relations that exist in the scene, where objects are represented as nodes, relations are represented as edges connecting the different nodes. Hence, the prediction of the scene graph is analogous to inferring the joint set of objects and relations of a visual scene.<br /> <br /> [[File:scene_graph_example.png|600px|center]]<br /> <br /> Given that objects in scenes are interdependent on each other, joint prediction of the objects and relations is necessary. The field of structured prediction, which involves the general problem of inferring multiple inter-dependent labels, is of interest for this problem.<br /> <br /> In structured prediction models, a score function &lt;math&gt;s(x, y)&lt;/math&gt; is defined to evaluate the compatibility between label &lt;math&gt;y&lt;/math&gt; and input &lt;math&gt;x&lt;/math&gt;. For instance, when interpreting the scene of an image, &lt;math&gt;x&lt;/math&gt; refers to the image itself, and &lt;math&gt;y&lt;/math&gt; refers to a complex label, which contains both the objects and the relations between objects. As with most other inference methods, the goal is to find the label &lt;math&gt;y^*&lt;/math&gt; such that &lt;math&gt;s(x,y)&lt;/math&gt; is maximized, &lt;math&gt; y^*=argmax_y s(x,y)&lt;/math&gt;. However, the major concern is that the space for possible label assignments grows exponentially with respect to input size. For example, although an image may seem very simple, the corpus containing possible labels for objects may be very large, rendering it difficult to optimize the scoring function. <br /> <br /> The paper presents an alternative approach, for which input &lt;math&gt;x&lt;/math&gt; is mapped to structured output &lt;math&gt;y&lt;/math&gt; using a &quot;black box&quot; neural network, omitting the definition of a score function. The main concern for this approach is the determination of the network architecture.<br /> <br /> The model is evaluated by firstly demonstrating the importance of permutation invariance on a synthetic data set. The approach laid out by the authors is then shown to respect permutation invariance, and results are compared to a competitive benchmark. This method achieves state-of-the-art results.<br /> <br /> =Structured prediction=<br /> This paper further considers structured predictions using score-based methods. For structured predictions that follow a score-based approach, a score function &lt;math&gt;s(x, y)&lt;/math&gt; is used to measure how compatible label &lt;math&gt;y&lt;/math&gt; is for input &lt;math&gt;x&lt;/math&gt; and is also used to infer a label by maximizing &lt;math&gt;s(x, y)&lt;/math&gt;. To optimize the score function, previous works have decomposed &lt;math&gt;s(x,y) = \sum_i f_i(x,y)&lt;/math&gt; in order to facilitate efficient optimization which is done by optimizing the local score function, &lt;math&gt;\max_y f_i(x,y)&lt;/math&gt;, with a small subset of the &lt;math&gt;y&lt;/math&gt; variables.<br /> <br /> Recently, modeling the &lt;math&gt;f_i &lt;/math&gt; functions as deep networks is a new interest. In such area of structured predictions, the most commonly-used score functions include the singleton score function &lt;math&gt;f_i(y_i, x)&lt;/math&gt; and pairwise score function &lt;math&gt;f_{ij} (y_i, y_j, x)&lt;/math&gt;. Previous works explored a two-stage architectures (learn local scores independently of the structured prediction goal), end-to-end architectures (to include the inference algorithm within the computation graph), and modelling global factors. <br /> <br /> ==Advantages of using score-based methods==<br /> # Allow for intuitive specification of local dependencies between labels, and how they map to global dependencies<br /> # Linear score functions offer natural convex surrogates<br /> # Inference in large label space is sometimes possible via exact algorithms or empirically accurate approximations<br /> <br /> The concern for modelling score functions using deep networks is that learning may no longer be convex. Hence, the paper presents properties for how deep networks can be used for structured predictions by considering architectures that do not require explicit maximization of a score function.<br /> <br /> =Background, Notations, and Definitions=<br /> We denote &lt;math&gt;y&lt;/math&gt; as a structured label where &lt;math&gt;y = [y_1, \dots, y_n]&lt;/math&gt;<br /> <br /> '''Score functions:''' for score-based methods, the score is defined as either the sum of a set of singleton scores &lt;math&gt;f_i = f_i(y_i, x)&lt;/math&gt; or the sum of pairwise scores &lt;math&gt;f_{ij} = f_{ij}(y_i, y_j, x)&lt;/math&gt;.<br /> <br /> Let &lt;math&gt;s(x,y)&lt;/math&gt; be the score of a score-based method. Then:<br /> <br /> &lt;div align=&quot;center&quot;&gt;<br /> &lt;math&gt;s(x,y) = \begin{cases}<br /> \sum_i f_i ~ \text{if we have a set of singleton scores}\\<br /> \sum_{ij} f_{ij} ~ \text{if we have a set of pairwise scores } \\<br /> \end{cases}&lt;/math&gt;<br /> &lt;/div&gt;<br /> <br /> '''Inference algorithm:''' an inference algorithm takes input set of local scores (either &lt;math&gt;f_i&lt;/math&gt; or &lt;math&gt;f_{ij}&lt;/math&gt;) and outputs an assignment of labels &lt;math&gt;y_1, \dots, y_n&lt;/math&gt; that maximizes score function &lt;math&gt;s(x,y)&lt;/math&gt;<br /> <br /> '''Graph labeling function:''' a graph labeling function &lt;math&gt;\mathcal{F} : (V,E) \rightarrow Y&lt;/math&gt; is a function that takes input of: an ordered set of node features &lt;math&gt;V = [z_1, \dots, z_n]&lt;/math&gt; and an ordered set of edge features &lt;math&gt;E = [z_{1,2},\dots,z_{i,j},\dots,z_{n,n-1}]&lt;/math&gt; to output set of node labels &lt;math&gt;\mathbf{y} = [y_1, \dots, y_n]&lt;/math&gt;. For instance, &lt;math&gt;z_i&lt;/math&gt; can be set equal to &lt;math&gt;f_i&lt;/math&gt; and &lt;math&gt;z_{ij}&lt;/math&gt; can be set equal to &lt;math&gt;f_{ij}&lt;/math&gt;.<br /> <br /> For convenience, the joint set of nodes and edges will be denoted as &lt;math&gt;\mathbf{z}&lt;/math&gt; to be a size &lt;math&gt;n^2&lt;/math&gt; vector (&lt;math&gt;n&lt;/math&gt; nodes and &lt;math&gt;n(n-1)&lt;/math&gt; edges).<br /> <br /> '''Permutation:''' Let &lt;math&gt;z&lt;/math&gt; be a set of node and edge features. Given a permutation &lt;math&gt;\sigma&lt;/math&gt; of &lt;math&gt;\{1,\dots,n\}&lt;/math&gt;, let &lt;math&gt;\sigma(z)&lt;/math&gt; be a new set of node and edge features given by [&lt;math&gt;\sigma(z)]_i = z_{\sigma(i)}&lt;/math&gt; and &lt;math&gt;[\sigma(z)]_{i,j} = z_{\sigma(i), \sigma(j)}&lt;/math&gt;<br /> <br /> '''One-hot representation:''' &lt;math&gt;\mathbf{1}[j]&lt;/math&gt; be a one-hot vector with 1 in the &lt;math&gt;j^{th}&lt;/math&gt; coordinate<br /> <br /> =Permutation-Invariant Structured prediction=<br /> <br /> With permutation-invariant structured prediction, we would expect the algorithm to produce the same result given the same score function. For instance, consider the case where we have label space for 3 variables &lt;math&gt;y_1, y_2, y_3&lt;/math&gt; with input &lt;math&gt;\mathbf{z} = (f_1, f_2, f_3, f_{12}, f_{13}, f_{23})&lt;/math&gt; that outputs label &lt;math&gt;\mathbf{y} = (y_1^*, y_2^*, y_3^*)&lt;/math&gt;. Then if the algorithm is run on a permuted version input &lt;math&gt;z' = (f_2, f_1, f_3, f_{21}, f_{23}, f_{13})&lt;/math&gt;, we would expect &lt;math&gt;\mathbf{y} = (y_2^*, y_1^*, y_3^*)&lt;/math&gt; given the same score function.<br /> <br /> '''Graph permutation invariance (GPI):''' a graph labeling function &lt;math&gt;\mathcal{F}&lt;/math&gt; is graph-permutation invariant, if for all permutations &lt;math&gt;\sigma&lt;/math&gt; of &lt;math&gt;\{1, \dots, n\}&lt;/math&gt; and for all nodes &lt;math&gt;z&lt;/math&gt;, &lt;math&gt;\mathcal{F}(\sigma(\mathbf{z})) = \sigma(\mathcal{F}(\mathbf{z}))&lt;/math&gt;<br /> <br /> The paper presents a theorem on the necessary and sufficient conditions for a function &lt;math&gt;\mathcal{F}&lt;/math&gt; to be graph permutation invariant. Intuitively, because &lt;math&gt;\mathcal{F}&lt;/math&gt; is a function that takes an ordered set &lt;math&gt;z&lt;/math&gt; as input, the output on &lt;math&gt;\mathbf{z}&lt;/math&gt; could very well be different from &lt;math&gt;\sigma(\mathbf{z})&lt;/math&gt;, which means &lt;math&gt;\mathcal{F}&lt;/math&gt; needs to have some sort of symmetry in order to sustain &lt;math&gt;[\mathcal{F}(\sigma(\mathbf{z}))]]_k = [\mathcal{F}(\mathbf{z})]_{\sigma(k)}&lt;/math&gt;.<br /> <br /> [[File:graph_permutation_invariance.jpg|400px|center]]<br /> <br /> ==Theorem 1==<br /> Let &lt;math&gt;\mathcal{F}&lt;/math&gt; be a graph labeling function. Then &lt;math&gt;\mathcal{F}&lt;/math&gt; is graph-permutation invariant if and only if there exist functions &lt;math&gt;\alpha, \rho, \phi&lt;/math&gt; such that for all &lt;math&gt;k=1, .., n&lt;/math&gt;:<br /> \begin{align}<br /> [\mathcal{F}(\mathbf{z})]_k = \rho(\mathbf{z}_k, \sum_{i=1}^n \alpha(\mathbf{z}_i, \sum_{i\neq j} \phi(\mathbf{z}_i, \mathbf{z}_{i,j}, \mathbf{z}_j)))<br /> \end{align}<br /> where &lt;math&gt;\phi: \mathbb{R}^{2d+e} \rightarrow \mathbb{R}^L, \alpha: \mathbb{R}^{d + L} \rightarrow \mathbb{R}^{W}, p: \mathbb{R}^{W+d} \rightarrow \mathbb{R}&lt;/math&gt;.<br /> <br /> Notice that for the dimensions of inputs and outputs, &lt;math&gt;d&lt;/math&gt; refers to the number of singleton features in &lt;math&gt;z&lt;/math&gt; and &lt;math&gt;e&lt;/math&gt; refers to the number of edges. <br /> <br /> [[File:GPI_architecture.jpg|thumb|A schematic representation of the GPI architecture. Singleton features &lt;math&gt;z_i&lt;/math&gt; are omitted for simplicity. First, the features &lt;math&gt;z_{i,j}&lt;/math&gt; are processed element-wise by &lt;math&gt;\phi&lt;/math&gt;. Next, they are summed to create a vector &lt;math&gt;s_i&lt;/math&gt;, which is concatenated with &lt;math&gt;z_i&lt;/math&gt;. Third, a representation of the entire graph is created by applying &lt;math&gt;\alpha\ n&lt;/math&gt; times and summing the created vector. The graph representation is then finally processed by &lt;math&gt;\rho&lt;/math&gt; together with &lt;math&gt;z_k&lt;/math&gt;.|600px|center]]<br /> <br /> ==Proof Sketch for Theorem 1==<br /> The proof of this theorem can be found in the paper. A proof sketch is provided below:<br /> <br /> '''For the forward direction''' (function that follows the form set out in equation (1) is GPI):<br /> # Using definition of permutation &lt;math&gt;\sigma&lt;/math&gt;, and rewriting &lt;math&gt;[F(z)]_{\sigma(k)}&lt;/math&gt; in the form from equation (1)<br /> # Second argument of &lt;math&gt;\rho&lt;/math&gt; is invariant under &lt;math&gt;\sigma&lt;/math&gt;, since it takes the sum of all indices &lt;math&gt;i&lt;/math&gt; and all other indices &lt;math&gt;j \neq i &lt;/math&gt;.<br /> <br /> '''For the backward direction''' (any black-box GPI function can be expressed in the form of equation 1):<br /> # Construct &lt;math&gt;\phi, \alpha&lt;/math&gt; such that second argument of &lt;math&gt;\rho&lt;/math&gt; contains all information about graph features of &lt;math&gt;z&lt;/math&gt;, including edges that the features originate from<br /> # Assume each &lt;math&gt;z_k&lt;/math&gt; uniquely identifies the node and &lt;math&gt;\mathcal{F}&lt;/math&gt; is a function only of pairwise features &lt;math&gt;z_{i,j}&lt;/math&gt;<br /> # Construct &lt;math&gt;H&lt;/math&gt; be a perfect hash function with &lt;math&gt;L&lt;/math&gt; buckets, and &lt;math&gt;\phi&lt;/math&gt; which maps '''pairwise features''' to a vector of size &lt;math&gt;L&lt;/math&gt;<br /> # &lt;math&gt;*&lt;/math&gt;Construct &lt;math&gt;\phi(z_i, z_{i,j}, z_j) = \mathbf{1}[H(z_j)] z_{i,j}&lt;/math&gt;, which intuitively means that &lt;math&gt;\phi&lt;/math&gt; stores &lt;math&gt;z_{i,j}&lt;/math&gt; in the unique bucket for node &lt;math&gt;j&lt;/math&gt;<br /> # Construct function &lt;math&gt;\alpha&lt;/math&gt; to output a matrix &lt;math&gt;\mathbb{R}^{L \times L}&lt;/math&gt; that maps each pairwise feature into unique positions (&lt;math&gt;\alpha(z_i, s_i) = \mathbf{1}[H(z_i)]s_i^T&lt;/math&gt;)<br /> # Construct matrix &lt;math&gt;M = \sum_i \alpha(z_i,s_i)&lt;/math&gt; by discarding rows/columns in &lt;math&gt;M&lt;/math&gt; that do not correspond to original nodes (which reduces dimension to &lt;math&gt;n\times n&lt;/math&gt;; set &lt;math&gt;\rho&lt;/math&gt; to have same outcome as &lt;math&gt;\mathcal{F}&lt;/math&gt;, and set the output of &lt;math&gt;\mathcal{F}&lt;/math&gt; on &lt;math&gt;M&lt;/math&gt; to be the labels &lt;math&gt;\mathbf{y} = y_1, \dots, y_n&lt;/math&gt;<br /> <br /> &lt;math&gt;*&lt;/math&gt;The paper presents the proof for the edge features &lt;math&gt;z_{ij}&lt;/math&gt; being scalar (&lt;math&gt;e = 1&lt;/math&gt;) for simplicity, which can be extended easily to vectors with additional indexing.<br /> <br /> Although the results discussed previously apply to complete graphs (edges apply to all feature pairs), it can be easily extended to incomplete graphs. For incomplete graphs, the input to F only contains the features corresponding to valid edges of the graph. The authors are only interested in invariances that preserve the graph structure. Thus, in place of permutation-invariance, it is now an automorphism-invariance.<br /> <br /> ==Implications and Applications of Theorem 1==<br /> ===Key Implications of Theorem 1===<br /> # Architecture &quot;collects&quot; information from the different edges of the graph, and does so in an invariant fashion using &lt;math&gt;\alpha&lt;/math&gt; and &lt;math&gt;\phi&lt;/math&gt;<br /> # Architecture is parallelizable, since all &lt;math&gt;\phi&lt;/math&gt; functions can be applied simultaneously<br /> <br /> ===Some applications of Theorem 1===<br /> # '''Attention:''' the concept of attention can be implemented in the GPI characterization, with slight alterations to the functions &lt;math&gt;\alpha&lt;/math&gt; and &lt;math&gt;\phi&lt;/math&gt;. In attention each node aggregates features of neighbours through a function of neighbour's relevance. Which means the lable of an entity could depend strongly on its close entity. The complete details can be found in the supplementary materials of the paper.<br /> <br /> # '''RNN:''' recurrent architectures can maintain GPI property, since all GPI function &lt;math&gt;\mathcal{F}&lt;/math&gt; are closed under composition. The output of one step after running &lt;math&gt;\mathcal{F}&lt;/math&gt; will act as input for the next step, but maintain the GPI property throughout.<br /> <br /> =Related Work=<br /> # '''Architectural invariance:''' suggested recently in a 2017 paper called Deep Sets by Zaheer et al., which considers the case of invariance that is more restrictive.<br /> # '''Deep structured prediction:''' previous work applied deep learning to structured prediction, for instance, semantic segmentation. Some algorithms include message passing algorithms, gradient descent for maximizing score functions, greedy decoding (inference of labels based on time of previous labels). For example, Xu et al. 2017 proposes a novel end-to-end model that generates structured scene representation, and their model solves the scene graph inference problem using standard RNNs and learns to iteratively improves its predictions via message passing. Apart from those algorithms, deep learning has been applied to other graph-based problems such as the Travelling Salesman Problem (Bello et al., 2016; Gilmer et al., 2017; Khalil et al., 2017). However, none of the previous work specifically address the notion of invariance in the general architecture, but rather focus on message passing architectures that can be generalized by this paper.<br /> # '''Scene graph prediction:''' scene graph extraction allows for reasoning, question answering, and image retrieval (Johnson et al., 2015; Lu et al., 2016; Raposo et al., 2017). Some other works in this area include object detection, action recognition, and even detection of human-object interactions (Liao et al., 2016; Plummer et al., 2017). Additional work has been done with the use of message passing algorithms (Xu et al., 2017), word embeddings (Lu et al., 2016), and end-to-end prediction directly from pixels (Newell &amp; Deng, 2017). A notable mention is NeuralMotif (Zellers et al., 2017), which the authors describe as the current state-of-the-art model for scene graph predictions on Visual Genome dataset.<br /> # '''Burst Image Deblurring Using Permutation Invariant Convolutional Neural Networks:''' similar ideas were applied, where Permutation Invariant CNN, are used to restore sharp and noise-free images from bursts of photographs affected by hand tremor and noise. This presented good quality images with lots of details for challenging datasets.<br /> <br /> =Experimental Results=<br /> <br /> The authors evaluated the advantage of GPI architectures empirically. They first utilized synthetic graph labeling and then used scene-graph classification for mapping images.<br /> <br /> ==Synthetic Graph Labeling==<br /> The authors created a synthetic problem to study GPI. This involved using an input graph &lt;math&gt;G = (V,E)&lt;/math&gt; where each node &lt;math&gt;i&lt;/math&gt; belongs to the set &lt;math&gt;\Gamma(i) \in \{1, \dots, K\}&lt;/math&gt; where &lt;math&gt;K&lt;/math&gt; is the number of samples. The task is to compute for each node, the number of neighbours that belong to the same set (i.e. finding the label of the node &lt;math&gt;i&lt;/math&gt; if &lt;math&gt;y_i = \sum_{j \in N(i)} \mathbf{1}[\Gamma(i) = \Gamma(j)]&lt;/math&gt;) . Then, random graphs (each with 10 nodes) were generated by sampling edges, and the set &lt;math&gt;\Gamma(i) \in \{1, \dots, K\}&lt;/math&gt;for each node independently and uniformly.<br /> The node features of the graph &lt;math&gt;z_i \in \{0,1\}^K&lt;/math&gt; are one-hot vectors of &lt;math&gt;\Gamma(i)&lt;/math&gt;, and each pairwise edge feature &lt;math&gt;z_{ij} \in \{0, 1\}&lt;/math&gt; denote whether the edge &lt;math&gt;ij&lt;/math&gt; is in the edge set &lt;math&gt;E&lt;/math&gt;. <br /> 3 architectures were studied in this paper:<br /> # '''GPI-architecture for graph prediction''' (without attention and RNN)<br /> # '''LSTM''': replacing &lt;math&gt;\sum \phi(\cdot)&lt;/math&gt; and &lt;math&gt;\sum \alpha(\cdot)&lt;/math&gt; in the form of Theorem 1 using two LSTMs with state size 200, reading their input in random order<br /> # '''Fully connected feed-forward network''': with 2 hidden layers, each layer containing 1,000 nodes; the input is a concatenation of all nodes and pairwise features, and the output is all node predictions<br /> <br /> The results show that the GPI architecture requires far fewer samples to converge to the correct solution.<br /> [[File:GPI_synthetic_example.jpg|450px|center]]<br /> <br /> ==Scene-Graph Classification==<br /> Applying the concept of GPI to Scene-Graph Prediction (SGP) is the main task of this paper. The input to this problem is an image, along with a set of annotated bounding boxes for the entities in the image. The goal is to correctly label each entity within the bounding boxes and the relationship between every pair of entities, resulting in a coherent scene graph.<br /> <br /> The authors describe two different types of variables to predict. The first type is entity variables &lt;math&gt;[y_1, \dots, y_n]&lt;/math&gt; for all bounding boxes, where each &lt;math&gt;y_i&lt;/math&gt; can take one of L values and refers to objects such as &quot;dog&quot; or &quot;man&quot;. The second type is relation variables &lt;math&gt;[y_{n+1}, \cdots, y_{n^2}]&lt;/math&gt;, where each &lt;math&gt;y_i&lt;/math&gt; represents the relation (e.g. &quot;on&quot;, &quot;below&quot;) between a pair of bounding boxes (entities).<br /> <br /> The scene graph and contain two types of edges:<br /> # '''Entity-entity edge''': connecting two entities &lt;math&gt;y_i&lt;/math&gt; and &lt;math&gt;y_j&lt;/math&gt; for &lt;math&gt;1 \leq i \neq j \leq n&lt;/math&gt;<br /> # '''Entity-relation edges''': connecting every relation variable &lt;math&gt;y_k&lt;/math&gt; for &lt;math&gt;k &gt; n&lt;/math&gt; to two entities<br /> <br /> The feature set &lt;math&gt;\mathbf{z}&lt;/math&gt; is based on the baseline model from Zellers et al. (2017). For entity variables &lt;math&gt;y_i&lt;/math&gt;, the vector &lt;math&gt;\mathbf{z}_i \in \mathbb{R}^L&lt;/math&gt; models the probability of the entity appearing in &lt;math&gt;y_i&lt;/math&gt;. &lt;math&gt;\mathbf{z}_i&lt;/math&gt; is augmented by the coordinates of the bounding box. Similarly for relation variables &lt;math&gt;y_j&lt;/math&gt;, the vector &lt;math&gt;\mathbf{z}_j \in \mathbb{R}^R&lt;/math&gt;, models the probability of the relations between the two entities in &lt;math&gt;j&lt;/math&gt;. For entity-entity pairwise features &lt;math&gt;\mathbf{z}_{i,j}&lt;/math&gt;, there is a similar representation of the probabilities for the pair. The SGP outputs probability distributions over all entities and relations, which will then be used as input recurrently to maintain GPI. Finally, word embeddings are used and concatenated for the most probable entity-relation labels.<br /> <br /> '''Components of the GPI architecture''' (ent for entity, rel for relation)<br /> # &lt;math&gt;\phi_{ent}&lt;/math&gt;: network that integrates two entity variables &lt;math&gt;y_i&lt;/math&gt; and &lt;math&gt;y_j&lt;/math&gt;, with input &lt;math&gt;z_i, z_j, z_{i,j}&lt;/math&gt; and output vector of &lt;math&gt;\mathbb{R}^{n_1}&lt;/math&gt; <br /> # &lt;math&gt;\alpha_{ent}&lt;/math&gt;: network with inputs from &lt;math&gt;\phi_{ent}&lt;/math&gt; for all neighbours of an entity, and uses attention mechanism to output vector &lt;math&gt;\mathbb{R}^{n_2}&lt;/math&gt; <br /> # &lt;math&gt;\rho_{ent}&lt;/math&gt;: network with inputs from the various &lt;math&gt;\mathbb{R}^{n_2}&lt;/math&gt; vectors, and outputs &lt;math&gt;L&lt;/math&gt; logits to predict entity value<br /> # &lt;math&gt;\rho_{rel}&lt;/math&gt;: network with inputs &lt;math&gt;\alpha_{ent}&lt;/math&gt; of two entities and &lt;math&gt;z_{i,j}&lt;/math&gt;, and output into &lt;math&gt;R&lt;/math&gt; logits<br /> <br /> ==Set-up and Results==<br /> '''Dataset''': based on Visual Genome (VG) by (Krishna et al., 2017), which contains a total of 108,077 images annotated with bounding boxes, entities, and relations. An average of 12 entities and 7 relations exist per image. For a fair comparison with previous works, data from (Xu et al., 2017) for train and test splits were used. The authors used the same 150 entities and 50 relations as in (Xu et al., 2017; Newell &amp; Deng, 2017; Zellers et al., 2017). Hyperparameters were tuned using a 70K/5K/32K split for training, validation, and testing respectively.<br /> <br /> '''Training''': all networks were trained using the Adam optimizer, with a batch size of 20. The loss function was the sum of cross-entropy losses over all of entities and relations. Penalties for misclassified entities were 4 times stronger than that of relations. Penalties for misclassified negative relations were 10 times weaker than that of positive relations.<br /> <br /> '''Evaluation''': there are three major tasks when inferring from the scene graph. The authors focus on the following:<br /> # '''SGCIs''': given ground-truth entity bounding boxes, predict all entity and relations categories<br /> # '''PredCIs''': given annotated bounding boxes with entity labels, predict all relations<br /> <br /> The evaluation metric Recall@K (shortened to R@K) is drawn from (Lu et al., 2016). This metric is the fraction of correct ground-truth triplets that appear within the &lt;math&gt;K&lt;/math&gt; most confident triplets predicted by the model. Graph-constrained protocol requires the top-&lt;math&gt;K&lt;/math&gt; triplets to assign one consistent class per entity and relation. The unconstrained protocol does not enforce such constraint.<br /> <br /> '''Models and baselines''': The authors compared variants of the GPI approach against four baselines, state-of-the-art models on completing scene graph sub-tasks. To maintain consistency, all models used the same training/testing data split, in addition to the preprocessing as per (Xu et al., 2017).<br /> <br /> '''Baselines from existing state-of-the-art models'''<br /> # (Lu et al., 2016): use of word embeddings to fine-tune the likelihood of predicted relations<br /> # (Xu et al., 2017): message passing algorithm between entities and relations to iteratively improve feature map for prediction<br /> # (Newell &amp; Deng, 2017): Pixel2Graph, uses associative embeddings to produce a full graph from image<br /> # (Zellers et al., 2017): NeuralMotif method, encodes global context to capture higher-order motif in scene graphs; Baseline outputs entities and relations distributions without using global context<br /> <br /> '''GPI models'''<br /> # '''GPI with no attention mechanism''': simply following Theorem 1's functional form, with summation over features<br /> # '''GPI NeighborAttention''': same GPI model, but considers attention over neighbours features<br /> # '''GPI Linguistic''': similar to NeighborAttention model, but concatenates word embedding vectors<br /> <br /> '''Key Results''': The GPI Linguistic approach outperforms all baseline for SGCIs, and has similar performance to the state of the art NeuralMotifs method. The authors argue that PredCI is an easier task with less structure, yielding high performance for the existing state of the art models.<br /> <br /> [[File:GPI_table_results.png|700px|center]]<br /> <br /> =Conclusion=<br /> <br /> A deep learning approach was presented in this paper to structured prediction, which constrains the architecture to be invariant to structurally identical inputs. This approach relies on pairwise features which are capable of describing inter-label correlations and inherits the intuitive aspect of score-based approaches. The output produced is invariant to equivalent representation of the pairwise terms. <br /> <br /> As future work, the axiomatic approach can be extended; for example in image labeling, geometric variances such as shifts or rotations may be desired (or in other cases invariance to feature permutations may be desired). Additionally, exploring algorithms that discover symmetries for deep structured prediction when invariant structure is unknown and should be discovered from data is also an interesting extension of this work.<br /> <br /> =Critique=<br /> The paper's contribution comes from the novelty of the permutation invariance as a design guideline for structured prediction. Although not explicitly considered in many of the previous works, the idea of invariance in architecture has already been considered in Deep Sets by (Zaheer et al., 2017). This paper characterizes relaxes the condition on the invariance as compared to that of previous works. In the evaluation of the benefit of GPI models, the paper used a synthetic problem to illustrate the fact that far fewer samples are required for the GPI model to converge to 100% accuracy. However, when comparing the true task of scene graph prediction against the state-of-the-art baselines, the GPI variants had only marginal higher Recall@K scores. The true benefit of this paper's discovery is the avoidance of maximizing a score function (leading computationally difficult problem), and instead directly producing output invariant to how we represent the pairwise terms.<br /> <br /> =References=<br /> <br /> [Lu et al., 2016] Lu, Cewu, Krishna, Ranjay, Bernstein, Michael S., and Li, Fei-Fei. Visual relationship detection with<br /> language priors. In European Conf. Comput. Vision, pp. 852–869, 2016.<br /> <br /> Roei Herzig, Moshiko Raboh, Gal Chechik, Jonathan Berant, Amir Globerson, Mapping Images to Scene Graphs with Permutation-Invariant Structured Prediction, 2018.<br /> <br /> Additional resources from Moshiko Raboh's [https://github.com/shikorab/SceneGraph GitHub]</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=Mapping_Images_to_Scene_Graphs_with_Permutation-Invariant_Structured_Prediction&diff=40885 Mapping Images to Scene Graphs with Permutation-Invariant Structured Prediction 2018-11-22T16:50:33Z <p>Jmmoosa: /* References */</p> <hr /> <div>The paper ''Mapping Images to Scene Graphs with Permutation-Invariant Structured Prediction'' was written by Roei Herzig* from Tel Aviv University, Moshiko Raboh* from Tel Aviv University, Gal Chechik from Google Brain, Bar-Ilan University, Jonathan Berant from Tel Aviv University, and Amir Globerson from Tel Aviv University. This paper is part of the NIPS 2018 conference to be hosted in December 2018 at Montréal, Canada. This paper summary is based on version 3 of the pre-print (as of May 2018) obtained from [https://arxiv.org/pdf/1802.05451v3.pdf arXiv] <br /> <br /> (*) Equal contribution<br /> <br /> =Motivation=<br /> In the field of artificial intelligence, a major goal is to enable machines to understand complex images, such as the underlying relationships between objects that exist in each scene. Although there are models today that capture both complex labels and interactions between labels, there is a disconnect for what guidelines should be used when leveraging deep learning. This paper introduces a design principle for such models that stem from the concept of permutation invariance and proves state of the art performance on models that follow this principle.<br /> <br /> The primary contributions that this paper makes include:<br /> # Deriving sufficient and necessary conditions for respecting graph-permutation invariance in deep structured prediction architectures<br /> # Empirically proving the benefit of graph-permutation invariance<br /> # Developing a state-of-the-art model for scene graph predictions over a large set of complex visual scenes<br /> <br /> =Introduction=<br /> In order to make a machine to interpret complex visual scenes, it must recognize and understand both objects and relationships between the objects in the scene. A '''scene graph''' is a representation of the set of objects and relations that exist in the scene, where objects are represented as nodes, relations are represented as edges connecting the different nodes. Hence, the prediction of the scene graph is analogous to inferring the joint set of objects and relations of a visual scene.<br /> <br /> [[File:scene_graph_example.png|600px|center]]<br /> <br /> Given that objects in scenes are interdependent on each other, joint prediction of the objects and relations is necessary. The field of structured prediction, which involves the general problem of inferring multiple inter-dependent labels, is of interest for this problem.<br /> <br /> In structured prediction models, a score function &lt;math&gt;s(x, y)&lt;/math&gt; is defined to evaluate the compatibility between label &lt;math&gt;y&lt;/math&gt; and input &lt;math&gt;x&lt;/math&gt;. For instance, when interpreting the scene of an image, &lt;math&gt;x&lt;/math&gt; refers to the image itself, and &lt;math&gt;y&lt;/math&gt; refers to a complex label, which contains both the objects and the relations between objects. As with most other inference methods, the goal is to find the label &lt;math&gt;y^*&lt;/math&gt; such that &lt;math&gt;s(x,y)&lt;/math&gt; is maximized, &lt;math&gt; y^*=argmax_y s(x,y)&lt;/math&gt;. However, the major concern is that the space for possible label assignments grows exponentially with respect to input size. For example, although an image may seem very simple, the corpus containing possible labels for objects may be very large, rendering it difficult to optimize the scoring function. <br /> <br /> The paper presents an alternative approach, for which input &lt;math&gt;x&lt;/math&gt; is mapped to structured output &lt;math&gt;y&lt;/math&gt; using a &quot;black box&quot; neural network, omitting the definition of a score function. The main concern for this approach is the determination of the network architecture.<br /> <br /> The model is evaluated by firstly demonstrating the importance of permutation invariance on a synthetic data set. The approach laid out by the authors is then shown to respect permutation invariance, and results are compared to a competitive benchmark. This method achieves state-of-the-art results.<br /> <br /> =Structured prediction=<br /> This paper further considers structured predictions using score-based methods. For structured predictions that follow a score-based approach, a score function &lt;math&gt;s(x, y)&lt;/math&gt; is used to measure how compatible label &lt;math&gt;y&lt;/math&gt; is for input &lt;math&gt;x&lt;/math&gt; and is also used to infer a label by maximizing &lt;math&gt;s(x, y)&lt;/math&gt;. To optimize the score function, previous works have decomposed &lt;math&gt;s(x,y) = \sum_i f_i(x,y)&lt;/math&gt; in order to facilitate efficient optimization which is done by optimizing the local score function, &lt;math&gt;\max_y f_i(x,y)&lt;/math&gt;, with a small subset of the &lt;math&gt;y&lt;/math&gt; variables.<br /> <br /> Recently, modeling the &lt;math&gt;f_i &lt;/math&gt; functions as deep networks is a new interest. In such area of structured predictions, the most commonly-used score functions include the singleton score function &lt;math&gt;f_i(y_i, x)&lt;/math&gt; and pairwise score function &lt;math&gt;f_{ij} (y_i, y_j, x)&lt;/math&gt;. Previous works explored a two-stage architectures (learn local scores independently of the structured prediction goal), end-to-end architectures (to include the inference algorithm within the computation graph), and modelling global factors. <br /> <br /> ==Advantages of using score-based methods==<br /> # Allow for intuitive specification of local dependencies between labels, and how they map to global dependencies<br /> # Linear score functions offer natural convex surrogates<br /> # Inference in large label space is sometimes possible via exact algorithms or empirically accurate approximations<br /> <br /> The concern for modelling score functions using deep networks is that learning may no longer be convex. Hence, the paper presents properties for how deep networks can be used for structured predictions by considering architectures that do not require explicit maximization of a score function.<br /> <br /> =Background, Notations, and Definitions=<br /> We denote &lt;math&gt;y&lt;/math&gt; as a structured label where &lt;math&gt;y = [y_1, \dots, y_n]&lt;/math&gt;<br /> <br /> '''Score functions:''' for score-based methods, the score is defined as either the sum of a set of singleton scores &lt;math&gt;f_i = f_i(y_i, x)&lt;/math&gt; or the sum of pairwise scores &lt;math&gt;f_{ij} = f_{ij}(y_i, y_j, x)&lt;/math&gt;.<br /> <br /> Let &lt;math&gt;s(x,y)&lt;/math&gt; be the score of a score-based method. Then:<br /> <br /> &lt;div align=&quot;center&quot;&gt;<br /> &lt;math&gt;s(x,y) = \begin{cases}<br /> \sum_i f_i ~ \text{if we have a set of singleton scores}\\<br /> \sum_{ij} f_{ij} ~ \text{if we have a set of pairwise scores } \\<br /> \end{cases}&lt;/math&gt;<br /> &lt;/div&gt;<br /> <br /> '''Inference algorithm:''' an inference algorithm takes input set of local scores (either &lt;math&gt;f_i&lt;/math&gt; or &lt;math&gt;f_{ij}&lt;/math&gt;) and outputs an assignment of labels &lt;math&gt;y_1, \dots, y_n&lt;/math&gt; that maximizes score function &lt;math&gt;s(x,y)&lt;/math&gt;<br /> <br /> '''Graph labeling function:''' a graph labeling function &lt;math&gt;\mathcal{F} : (V,E) \rightarrow Y&lt;/math&gt; is a function that takes input of: an ordered set of node features &lt;math&gt;V = [z_1, \dots, z_n]&lt;/math&gt; and an ordered set of edge features &lt;math&gt;E = [z_{1,2},\dots,z_{i,j},\dots,z_{n,n-1}]&lt;/math&gt; to output set of node labels &lt;math&gt;\mathbf{y} = [y_1, \dots, y_n]&lt;/math&gt;. For instance, &lt;math&gt;z_i&lt;/math&gt; can be set equal to &lt;math&gt;f_i&lt;/math&gt; and &lt;math&gt;z_{ij}&lt;/math&gt; can be set equal to &lt;math&gt;f_{ij}&lt;/math&gt;.<br /> <br /> For convenience, the joint set of nodes and edges will be denoted as &lt;math&gt;\mathbf{z}&lt;/math&gt; to be a size &lt;math&gt;n^2&lt;/math&gt; vector (&lt;math&gt;n&lt;/math&gt; nodes and &lt;math&gt;n(n-1)&lt;/math&gt; edges).<br /> <br /> '''Permutation:''' Let &lt;math&gt;z&lt;/math&gt; be a set of node and edge features. Given a permutation &lt;math&gt;\sigma&lt;/math&gt; of &lt;math&gt;\{1,\dots,n\}&lt;/math&gt;, let &lt;math&gt;\sigma(z)&lt;/math&gt; be a new set of node and edge features given by [&lt;math&gt;\sigma(z)]_i = z_{\sigma(i)}&lt;/math&gt; and &lt;math&gt;[\sigma(z)]_{i,j} = z_{\sigma(i), \sigma(j)}&lt;/math&gt;<br /> <br /> '''One-hot representation:''' &lt;math&gt;\mathbf{1}[j]&lt;/math&gt; be a one-hot vector with 1 in the &lt;math&gt;j^{th}&lt;/math&gt; coordinate<br /> <br /> =Permutation-Invariant Structured prediction=<br /> <br /> With permutation-invariant structured prediction, we would expect the algorithm to produce the same result given the same score function. For instance, consider the case where we have label space for 3 variables &lt;math&gt;y_1, y_2, y_3&lt;/math&gt; with input &lt;math&gt;\mathbf{z} = (f_1, f_2, f_3, f_{12}, f_{13}, f_{23})&lt;/math&gt; that outputs label &lt;math&gt;\mathbf{y} = (y_1^*, y_2^*, y_3^*)&lt;/math&gt;. Then if the algorithm is run on a permuted version input &lt;math&gt;z' = (f_2, f_1, f_3, f_{21}, f_{23}, f_{13})&lt;/math&gt;, we would expect &lt;math&gt;\mathbf{y} = (y_2^*, y_1^*, y_3^*)&lt;/math&gt; given the same score function.<br /> <br /> '''Graph permutation invariance (GPI):''' a graph labeling function &lt;math&gt;\mathcal{F}&lt;/math&gt; is graph-permutation invariant, if for all permutations &lt;math&gt;\sigma&lt;/math&gt; of &lt;math&gt;\{1, \dots, n\}&lt;/math&gt; and for all nodes &lt;math&gt;z&lt;/math&gt;, &lt;math&gt;\mathcal{F}(\sigma(\mathbf{z})) = \sigma(\mathcal{F}(\mathbf{z}))&lt;/math&gt;<br /> <br /> The paper presents a theorem on the necessary and sufficient conditions for a function &lt;math&gt;\mathcal{F}&lt;/math&gt; to be graph permutation invariant. Intuitively, because &lt;math&gt;\mathcal{F}&lt;/math&gt; is a function that takes an ordered set &lt;math&gt;z&lt;/math&gt; as input, the output on &lt;math&gt;\mathbf{z}&lt;/math&gt; could very well be different from &lt;math&gt;\sigma(\mathbf{z})&lt;/math&gt;, which means &lt;math&gt;\mathcal{F}&lt;/math&gt; needs to have some sort of symmetry in order to sustain &lt;math&gt;[\mathcal{F}(\sigma(\mathbf{z}))]]_k = [\mathcal{F}(\mathbf{z})]_{\sigma(k)}&lt;/math&gt;.<br /> <br /> [[File:graph_permutation_invariance.jpg|400px|center]]<br /> <br /> ==Theorem 1==<br /> Let &lt;math&gt;\mathcal{F}&lt;/math&gt; be a graph labeling function. Then &lt;math&gt;\mathcal{F}&lt;/math&gt; is graph-permutation invariant if and only if there exist functions &lt;math&gt;\alpha, \rho, \phi&lt;/math&gt; such that for all &lt;math&gt;k=1, .., n&lt;/math&gt;:<br /> \begin{align}<br /> [\mathcal{F}(\mathbf{z})]_k = \rho(\mathbf{z}_k, \sum_{i=1}^n \alpha(\mathbf{z}_i, \sum_{i\neq j} \phi(\mathbf{z}_i, \mathbf{z}_{i,j}, \mathbf{z}_j)))<br /> \end{align}<br /> where &lt;math&gt;\phi: \mathbb{R}^{2d+e} \rightarrow \mathbb{R}^L, \alpha: \mathbb{R}^{d + L} \rightarrow \mathbb{R}^{W}, p: \mathbb{R}^{W+d} \rightarrow \mathbb{R}&lt;/math&gt;.<br /> <br /> Notice that for the dimensions of inputs and outputs, &lt;math&gt;d&lt;/math&gt; refers to the number of singleton features in &lt;math&gt;z&lt;/math&gt; and &lt;math&gt;e&lt;/math&gt; refers to the number of edges. <br /> <br /> [[File:GPI_architecture.jpg|thumb|A schematic representation of the GPI architecture. Singleton features &lt;math&gt;z_i&lt;/math&gt; are omitted for simplicity. First, the features &lt;math&gt;z_{i,j}&lt;/math&gt; are processed element-wise by &lt;math&gt;\phi&lt;/math&gt;. Next, they are summed to create a vector &lt;math&gt;s_i&lt;/math&gt;, which is concatenated with &lt;math&gt;z_i&lt;/math&gt;. Third, a representation of the entire graph is created by applying &lt;math&gt;\alpha\ n&lt;/math&gt; times and summing the created vector. The graph representation is then finally processed by &lt;math&gt;\rho&lt;/math&gt; together with &lt;math&gt;z_k&lt;/math&gt;.|600px|center]]<br /> <br /> ==Proof Sketch for Theorem 1==<br /> The proof of this theorem can be found in the paper. A proof sketch is provided below:<br /> <br /> '''For the forward direction''' (function that follows the form set out in equation (1) is GPI):<br /> # Using definition of permutation &lt;math&gt;\sigma&lt;/math&gt;, and rewriting &lt;math&gt;[F(z)]_{\sigma(k)}&lt;/math&gt; in the form from equation (1)<br /> # Second argument of &lt;math&gt;\rho&lt;/math&gt; is invariant under &lt;math&gt;\sigma&lt;/math&gt;, since it takes the sum of all indices &lt;math&gt;i&lt;/math&gt; and all other indices &lt;math&gt;j \neq i &lt;/math&gt;.<br /> <br /> '''For the backward direction''' (any black-box GPI function can be expressed in the form of equation 1):<br /> # Construct &lt;math&gt;\phi, \alpha&lt;/math&gt; such that second argument of &lt;math&gt;\rho&lt;/math&gt; contains all information about graph features of &lt;math&gt;z&lt;/math&gt;, including edges that the features originate from<br /> # Assume each &lt;math&gt;z_k&lt;/math&gt; uniquely identifies the node and &lt;math&gt;\mathcal{F}&lt;/math&gt; is a function only of pairwise features &lt;math&gt;z_{i,j}&lt;/math&gt;<br /> # Construct &lt;math&gt;H&lt;/math&gt; be a perfect hash function with &lt;math&gt;L&lt;/math&gt; buckets, and &lt;math&gt;\phi&lt;/math&gt; which maps '''pairwise features''' to a vector of size &lt;math&gt;L&lt;/math&gt;<br /> # &lt;math&gt;*&lt;/math&gt;Construct &lt;math&gt;\phi(z_i, z_{i,j}, z_j) = \mathbf{1}[H(z_j)] z_{i,j}&lt;/math&gt;, which intuitively means that &lt;math&gt;\phi&lt;/math&gt; stores &lt;math&gt;z_{i,j}&lt;/math&gt; in the unique bucket for node &lt;math&gt;j&lt;/math&gt;<br /> # Construct function &lt;math&gt;\alpha&lt;/math&gt; to output a matrix &lt;math&gt;\mathbb{R}^{L \times L}&lt;/math&gt; that maps each pairwise feature into unique positions (&lt;math&gt;\alpha(z_i, s_i) = \mathbf{1}[H(z_i)]s_i^T&lt;/math&gt;)<br /> # Construct matrix &lt;math&gt;M = \sum_i \alpha(z_i,s_i)&lt;/math&gt; by discarding rows/columns in &lt;math&gt;M&lt;/math&gt; that do not correspond to original nodes (which reduces dimension to &lt;math&gt;n\times n&lt;/math&gt;; set &lt;math&gt;\rho&lt;/math&gt; to have same outcome as &lt;math&gt;\mathcal{F}&lt;/math&gt;, and set the output of &lt;math&gt;\mathcal{F}&lt;/math&gt; on &lt;math&gt;M&lt;/math&gt; to be the labels &lt;math&gt;\mathbf{y} = y_1, \dots, y_n&lt;/math&gt;<br /> <br /> &lt;math&gt;*&lt;/math&gt;The paper presents the proof for the edge features &lt;math&gt;z_{ij}&lt;/math&gt; being scalar (&lt;math&gt;e = 1&lt;/math&gt;) for simplicity, which can be extended easily to vectors with additional indexing.<br /> <br /> Although the results discussed previously apply to complete graphs (edges apply to all feature pairs), it can be easily extended to incomplete graphs. For incomplete graphs, the input to F only contains the features corresponding to valid edges of the graph. The authors are only interested in invariances that preserve the graph structure. Thus, in place of permutation-invariance, it is now an automorphism-invariance.<br /> <br /> ==Implications and Applications of Theorem 1==<br /> ===Key Implications of Theorem 1===<br /> # Architecture &quot;collects&quot; information from the different edges of the graph, and does so in an invariant fashion using &lt;math&gt;\alpha&lt;/math&gt; and &lt;math&gt;\phi&lt;/math&gt;<br /> # Architecture is parallelizable, since all &lt;math&gt;\phi&lt;/math&gt; functions can be applied simultaneously<br /> <br /> ===Some applications of Theorem 1===<br /> # '''Attention:''' the concept of attention can be implemented in the GPI characterization, with slight alterations to the functions &lt;math&gt;\alpha&lt;/math&gt; and &lt;math&gt;\phi&lt;/math&gt;. In attention each node aggregates features of neighbours through a function of neighbour's relevance. Which means the lable of an entity could depend strongly on its close entity. The complete details can be found in the supplementary materials of the paper.<br /> <br /> # '''RNN:''' recurrent architectures can maintain GPI property, since all GPI function &lt;math&gt;\mathcal{F}&lt;/math&gt; are closed under composition. The output of one step after running &lt;math&gt;\mathcal{F}&lt;/math&gt; will act as input for the next step, but maintain the GPI property throughout.<br /> <br /> =Related Work=<br /> # '''Architectural invariance:''' suggested recently in a 2017 paper called Deep Sets by Zaheer et al., which considers the case of invariance that is more restrictive.<br /> # '''Deep structured prediction:''' previous work applied deep learning to structured prediction, for instance, semantic segmentation. Some algorithms include message passing algorithms, gradient descent for maximizing score functions, greedy decoding (inference of labels based on time of previous labels). For example, Xu et al. 2017 proposes a novel end-to-end model that generates structured scene representation, and their model solves the scene graph inference problem using standard RNNs and learns to iteratively improves its predictions via message passing. Apart from those algorithms, deep learning has been applied to other graph-based problems such as the Travelling Salesman Problem (Bello et al., 2016; Gilmer et al., 2017; Khalil et al., 2017). However, none of the previous work specifically address the notion of invariance in the general architecture, but rather focus on message passing architectures that can be generalized by this paper.<br /> # '''Scene graph prediction:''' scene graph extraction allows for reasoning, question answering, and image retrieval (Johnson et al., 2015; Lu et al., 2016; Raposo et al., 2017). Some other works in this area include object detection, action recognition, and even detection of human-object interactions (Liao et al., 2016; Plummer et al., 2017). Additional work has been done with the use of message passing algorithms (Xu et al., 2017), word embeddings (Lu et al., 2016), and end-to-end prediction directly from pixels (Newell &amp; Deng, 2017). A notable mention is NeuralMotif (Zellers et al., 2017), which the authors describe as the current state-of-the-art model for scene graph predictions on Visual Genome dataset.<br /> # '''Burst Image Deblurring Using Permutation Invariant Convolutional Neural Networks:''' similar ideas were applied, where Permutation Invariant CNN, are used to restore sharp and noise-free images from bursts of photographs affected by hand tremor and noise. This presented good quality images with lots of details for challenging datasets.<br /> <br /> =Experimental Results=<br /> <br /> The authors evaluated the advantage of GPI architectures empirically. They first utilized synthetic graph labeling and then used scene-graph classification for mapping images.<br /> <br /> ==Synthetic Graph Labeling==<br /> The authors created a synthetic problem to study GPI. This involved using an input graph &lt;math&gt;G = (V,E)&lt;/math&gt; where each node &lt;math&gt;i&lt;/math&gt; belongs to the set &lt;math&gt;\Gamma(i) \in \{1, \dots, K\}&lt;/math&gt; where &lt;math&gt;K&lt;/math&gt; is the number of samples. The task is to compute for each node, the number of neighbours that belong to the same set (i.e. finding the label of the node &lt;math&gt;i&lt;/math&gt; if &lt;math&gt;y_i = \sum_{j \in N(i)} \mathbf{1}[\Gamma(i) = \Gamma(j)]&lt;/math&gt;) . Then, random graphs (each with 10 nodes) were generated by sampling edges, and the set &lt;math&gt;\Gamma(i) \in \{1, \dots, K\}&lt;/math&gt;for each node independently and uniformly.<br /> The node features of the graph &lt;math&gt;z_i \in \{0,1\}^K&lt;/math&gt; are one-hot vectors of &lt;math&gt;\Gamma(i)&lt;/math&gt;, and each pairwise edge feature &lt;math&gt;z_{ij} \in \{0, 1\}&lt;/math&gt; denote whether the edge &lt;math&gt;ij&lt;/math&gt; is in the edge set &lt;math&gt;E&lt;/math&gt;. <br /> 3 architectures were studied in this paper:<br /> # '''GPI-architecture for graph prediction''' (without attention and RNN)<br /> # '''LSTM''': replacing &lt;math&gt;\sum \phi(\cdot)&lt;/math&gt; and &lt;math&gt;\sum \alpha(\cdot)&lt;/math&gt; in the form of Theorem 1 using two LSTMs with state size 200, reading their input in random order<br /> # '''Fully connected feed-forward network''': with 2 hidden layers, each layer containing 1,000 nodes; the input is a concatenation of all nodes and pairwise features, and the output is all node predictions<br /> <br /> The results show that the GPI architecture requires far fewer samples to converge to the correct solution.<br /> [[File:GPI_synthetic_example.jpg|450px|center]]<br /> <br /> ==Scene-Graph Classification==<br /> Applying the concept of GPI to Scene-Graph Prediction (SGP) is the main task of this paper. The input to this problem is an image, along with a set of annotated bounding boxes for the entities in the image. The goal is to correctly label each entity within the bounding boxes and the relationship between every pair of entities, resulting in a coherent scene graph.<br /> <br /> The authors describe two different types of variables to predict. The first type is entity variables &lt;math&gt;[y_1, \dots, y_n]&lt;/math&gt; for all bounding boxes, where each &lt;math&gt;y_i&lt;/math&gt; can take one of L values and refers to objects such as &quot;dog&quot; or &quot;man&quot;. The second type is relation variables &lt;math&gt;[y_{n+1}, \cdots, y_{n^2}]&lt;/math&gt;, where each &lt;math&gt;y_i&lt;/math&gt; represents the relation (e.g. &quot;on&quot;, &quot;below&quot;) between a pair of bounding boxes (entities).<br /> <br /> The scene graph and contain two types of edges:<br /> # '''Entity-entity edge''': connecting two entities &lt;math&gt;y_i&lt;/math&gt; and &lt;math&gt;y_j&lt;/math&gt; for &lt;math&gt;1 \leq i \neq j \leq n&lt;/math&gt;<br /> # '''Entity-relation edges''': connecting every relation variable &lt;math&gt;y_k&lt;/math&gt; for &lt;math&gt;k &gt; n&lt;/math&gt; to two entities<br /> <br /> The feature set &lt;math&gt;\mathbf{z}&lt;/math&gt; is based on the baseline model from Zellers et al. (2017). For entity variables &lt;math&gt;y_i&lt;/math&gt;, the vector &lt;math&gt;\mathbf{z}_i \in \mathbb{R}^L&lt;/math&gt; models the probability of the entity appearing in &lt;math&gt;y_i&lt;/math&gt;. &lt;math&gt;\mathbf{z}_i&lt;/math&gt; is augmented by the coordinates of the bounding box. Similarly for relation variables &lt;math&gt;y_j&lt;/math&gt;, the vector &lt;math&gt;\mathbf{z}_j \in \mathbb{R}^R&lt;/math&gt;, models the probability of the relations between the two entities in &lt;math&gt;j&lt;/math&gt;. For entity-entity pairwise features &lt;math&gt;\mathbf{z}_{i,j}&lt;/math&gt;, there is a similar representation of the probabilities for the pair. The SGP outputs probability distributions over all entities and relations, which will then be used as input recurrently to maintain GPI. Finally, word embeddings are used and concatenated for the most probable entity-relation labels.<br /> <br /> '''Components of the GPI architecture''' (ent for entity, rel for relation)<br /> # &lt;math&gt;\phi_{ent}&lt;/math&gt;: network that integrates two entity variables &lt;math&gt;y_i&lt;/math&gt; and &lt;math&gt;y_j&lt;/math&gt;, with input &lt;math&gt;z_i, z_j, z_{i,j}&lt;/math&gt; and output vector of &lt;math&gt;\mathbb{R}^{n_1}&lt;/math&gt; <br /> # &lt;math&gt;\alpha_{ent}&lt;/math&gt;: network with inputs from &lt;math&gt;\phi_{ent}&lt;/math&gt; for all neighbours of an entity, and uses attention mechanism to output vector &lt;math&gt;\mathbb{R}^{n_2}&lt;/math&gt; <br /> # &lt;math&gt;\rho_{ent}&lt;/math&gt;: network with inputs from the various &lt;math&gt;\mathbb{R}^{n_2}&lt;/math&gt; vectors, and outputs &lt;math&gt;L&lt;/math&gt; logits to predict entity value<br /> # &lt;math&gt;\rho_{rel}&lt;/math&gt;: network with inputs &lt;math&gt;\alpha_{ent}&lt;/math&gt; of two entities and &lt;math&gt;z_{i,j}&lt;/math&gt;, and output into &lt;math&gt;R&lt;/math&gt; logits<br /> <br /> ==Set-up and Results==<br /> '''Dataset''': based on Visual Genome (VG) by (Krishna et al., 2017), which contains a total of 108,077 images annotated with bounding boxes, entities, and relations. An average of 12 entities and 7 relations exist per image. For a fair comparison with previous works, data from (Xu et al., 2017) for train and test splits were used. The authors used the same 150 entities and 50 relations as in (Xu et al., 2017; Newell &amp; Deng, 2017; Zellers et al., 2017). Hyperparameters were tuned using a 70K/5K/32K split for training, validation, and testing respectively.<br /> <br /> '''Training''': all networks were trained using the Adam optimizer, with a batch size of 20. The loss function was the sum of cross-entropy losses over all of entities and relations. Penalties for misclassified entities were 4 times stronger than that of relations. Penalties for misclassified negative relations were 10 times weaker than that of positive relations.<br /> <br /> '''Evaluation''': there are three major tasks when inferring from the scene graph. The authors focus on the following:<br /> # '''SGCIs''': given ground-truth entity bounding boxes, predict all entity and relations categories<br /> # '''PredCIs''': given annotated bounding boxes with entity labels, predict all relations<br /> <br /> The evaluation metric Recall@K (shortened to R@K) is drawn from (Lu et al., 2016). This metric is the fraction of correct ground-truth triplets that appear within the &lt;math&gt;K&lt;/math&gt; most confident triplets predicted by the model. Graph-constrained protocol requires the top-&lt;math&gt;K&lt;/math&gt; triplets to assign one consistent class per entity and relation. The unconstrained protocol does not enforce such constraint.<br /> <br /> '''Models and baselines''': The authors compared variants of the GPI approach against four baselines, state-of-the-art models on completing scene graph sub-tasks. To maintain consistency, all models used the same training/testing data split, in addition to the preprocessing as per (Xu et al., 2017).<br /> <br /> '''Baselines from existing state-of-the-art models'''<br /> # (Lu et al., 2016): use of word embeddings to fine-tune the likelihood of predicted relations<br /> # (Xu et al., 2017): message passing algorithm between entities and relations to iteratively improve feature map for prediction<br /> # (Newell &amp; Deng, 2017): Pixel2Graph, uses associative embeddings to produce a full graph from image<br /> # (Zellers et al., 2017): NeuralMotif method, encodes global context to capture higher-order motif in scene graphs; Baseline outputs entities and relations distributions without using global context<br /> <br /> '''GPI models'''<br /> # '''GPI with no attention mechanism''': simply following Theorem 1's functional form, with summation over features<br /> # '''GPI NeighborAttention''': same GPI model, but considers attention over neighbours features<br /> # '''GPI Linguistic''': similar to NeighborAttention model, but concatenates word embedding vectors<br /> <br /> '''Key Results''': The GPI Linguistic approach outperforms all baseline for SGCIs, and has similar performance to the state of the art NeuralMotifs method. The authors argue that PredCI is an easier task with less structure, yielding high performance for the existing state of the art models.<br /> <br /> [[File:GPI_table_results.png|700px|center]]<br /> <br /> =Conclusion=<br /> <br /> A deep learning approach was presented in this paper to structured prediction, which constrains the architecture to be invariant to structurally identical inputs. This approach relies on pairwise features which are capable of describing inter-label correlations and inherits the intuitive aspect of score-based approaches. The output produced is invariant to equivalent representation of the pairwise terms. <br /> <br /> As future work, the axiomatic approach can be extended; for example in image labeling, geometric variances such as shifts or rotations may be desired (or in other cases invariance to feature permutations may be desired). Additionally, exploring algorithms that discover symmetries for deep structured prediction when invariant structure is unknown and should be discovered from data is also an interesting extension of this work.<br /> <br /> =Critique=<br /> The paper's contribution comes from the novelty of the permutation invariance as a design guideline for structured prediction. Although not explicitly considered in many of the previous works, the idea of invariance in architecture has already been considered in Deep Sets by (Zaheer et al., 2017). This paper characterizes relaxes the condition on the invariance as compared to that of previous works. In the evaluation of the benefit of GPI models, the paper used a synthetic problem to illustrate the fact that far fewer samples are required for the GPI model to converge to 100% accuracy. However, when comparing the true task of scene graph prediction against the state-of-the-art baselines, the GPI variants had only marginal higher Recall@K scores. The true benefit of this paper's discovery is the avoidance of maximizing a score function (leading computationally difficult problem), and instead directly producing output invariant to how we represent the pairwise terms.<br /> <br /> =References=<br /> <br /> [Lu et. al, 2016] Lu, Cewu, Krishna, Ranjay, Bernstein, Michael S., and Li, Fei-Fei. Visual relationship detection with<br /> language priors. In European Conf. Comput. Vision, pp. 852–869, 2016.<br /> <br /> Roei Herzig, Moshiko Raboh, Gal Chechik, Jonathan Berant, Amir Globerson, Mapping Images to Scene Graphs with Permutation-Invariant Structured Prediction, 2018.<br /> <br /> Additional resources from Moshiko Raboh's [https://github.com/shikorab/SceneGraph GitHub]</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=Learning_to_Navigate_in_Cities_Without_a_Map&diff=40884 Learning to Navigate in Cities Without a Map 2018-11-22T16:42:01Z <p>Jmmoosa: </p> <hr /> <div>Paper: <br /> [https://arxiv.org/pdf/1804.00168.pdf Learning to Navigate in Cities Without a Map]<br /> A video of the paper is available [https://sites.google.com/view/streetlearn here].<br /> <br /> == Introduction ==<br /> Navigation is an attractive topic in many research disciplines and technology related domains such as neuroscience and robotics. The majority of algorithms are based on the following steps.<br /> <br /> 1. Building an explicit map<br /> <br /> 2. Planning and acting using that map. <br /> <br /> In this article, based on this fact that human can learn to navigate through cities without using any special tool such as maps or GPS, authors propose new methods to show that a neural network agent can do the same thing by using visual observations. To do so, an interactive environment using Google StreetView Images and a dual pathway agent architecture is designed. As shown in figure 1, some parts of the environment are built using Google StreetView images of New York City (Times Square, Central Park) and London (St. Paul’s Cathedral). The green cone represents the agent’s location and orientation. Although learning to navigate using visual aids is shown to be successful in some domains such as games and simulated environments using deep reinforcement learning (RL), it suffers from data inefficiency and sensitivity to changes in the environment. Thus, it is unclear whether this method could be used for large-scale navigation. That’s why it became the subject of investigation in this paper.<br /> [[File:figure1-soroush.png|600px|thumb|center|Figure 1. Our environment is built of real-world places from StreetView. The figure shows diverse views and corresponding local maps (neither map nor current position have not been used by the agent) in New York City (Times Square, Central Park) and London (St. Paul’s Cathedral). The green cone represents the agent’s location and orientation.]]<br /> <br /> ==Contribution==<br /> This paper has made the following contributions:<br /> <br /> 1. Designing a dual pathway agent architecture. This agent can navigate through a real city and is trained with end-to-end reinforcement learning to handle real-world navigations.<br /> <br /> 2. Using Goal-dependent learning. This means that the policy and value functions must adapt themselves to a sequence of goals that are provided as input.<br /> <br /> 3. Leveraging a recurrent neural architecture. Using that, not only could navigation through a city be possible, but also the model is scalable for navigation in new cities. This architecture supports both locale-specific learnings and general transferable navigations. The authors achieved these by separating a recurrent neural pathway. This pathway receives and interprets the current goal as well as encapsulates and memorizes features of a single region.<br /> <br /> 4. Using a new environment which is built on top of Google StreetView images. This provides real-world images for agent’s observation. Using this environment, the agent can navigate from an arbitrary starting point to a goal and then to another goal etc. Also, London, Paris, and New York City are chosen for navigation.<br /> <br /> ==Related Work==<br /> <br /> 1. Localization from real-world imagery. For example, (Weyand et al., 2016), a CNN was able to achieve excellent results on geolocation task. This paper provides novel work by not including supervised training with ground-truth labels, and by including planning as a goal. Some other works also improve by exploiting spatiotemporal continuity or estimating camera pose or depth estimation from pixels. These methods rely on supervised training with ground truth labels, which is not possible in every environment. <br /> <br /> 2. Deep RL methods for navigation. For instance, (Mirowski et al., 2016; Jaderberg et al., 2016) used self-supervised auxiliary tasks to produce visual navigation in several created mazes. Some other researches used text descriptions to incorporate goal instructions. Researchers developed realistic, higher-fidelity environment simulations to make the experiment more realistic, but that still came with lack of diversities. This paper makes use of real-world data, in contrast to many related papers in this area. It's diverse and visually realistic but still, it does not contain dynamic elements, and the street topology cannot be regenerated or altered.<br /> <br /> 3. Deep RL for path planning and mapping. For example, (Zhang et al., 2017) created an agent that represented a global map via an RL agent with external memory; some other work uses a hierarchical control strategy to propose a structured memory and Memory Augmented Control Maps. Explicit neural mapper and navigation planner with joint training was also used. Among all these works, the target-driven visual navigation with a goal-conditional policy approach was most related to our method.<br /> <br /> ==Environment==<br /> Google StreetView consists of both high-resolution 360-degree imagery and graph connectivity. Also, it provides a public API. These features make it a valuable resource. In this work, large areas of New York, Paris, and London that contain between 7,000 and 65,500 nodes<br /> (and between 7,200 and 128,600 edges, respectively), have a mean node spacing of 10m and cover a range of up to<br /> 5km chosen (Figure 2), without simplifying the underlying connections. This means that there are many areas 'congested' with nodes, occlusions, available footpaths, etc. The agent only sees RGB images that are visible in StreetView images (Figure 1) and is not aware of the underlying graph.<br /> <br /> [[File:figure2-soroush.png|700px|thumb|center|Figure 2. Map of the 5 environments in New York City; our experiments focus on the NYU area as well as on transfer learning from the other areas to Wall Street (see Section 5.3). In the zoomed in area, each green dot corresponds to a unique panorama, the goal is marked in blue, and landmark locations are marked with red pins.]]<br /> <br /> ==Agent Interface and the Courier Task==<br /> In an RL environment, we need to define observations and actions in addition to tasks. The inputs to the agent are the image &lt;math&gt;x_t&lt;/math&gt; and the goal &lt;math&gt;g_t&lt;/math&gt;. Also, a first-person view of the 3D environment is simulated by cropping &lt;math&gt;x_t&lt;/math&gt; to a 60-degree square RGB image that is scaled to 84*84 pixels. Furthermore, the action space consists of 5 movements: “slow” rotate left or right (±22:5), “fast” rotate left or right (±67.5), or move forward (implemented as a ''noop'' in the case where this is not a viable action). The most central edge is chosen if there are multiple edges in the agents viewing cone.<br /> <br /> There are lots of ways to specify the goal to the agent. In this paper, the current goal is chosen to be represented in terms of its proximity to a set L of fixed landmarks &lt;math&gt; L={(Lat_k, Long_k)}&lt;/math&gt; which are specified using Latitude and Longitude coordinate system. For distance to the &lt;math&gt; k_{th}&lt;/math&gt; landmark &lt;math&gt;{(d_{(t,k)}^g})_k&lt;/math&gt; the goal vector contains &lt;math&gt; g_{(t,i)}=\tfrac{exp⁡(-αd_{(t,i)}^g)}{∑_k exp⁡(-αd_{(t,k)}^g)} &lt;/math&gt;for &lt;math&gt;i_{th}&lt;/math&gt; landmark with &lt;math&gt;α=0.002&lt;/math&gt; (Figure 3).<br /> <br /> [[File:figure3-soroush.PNG|400px|thumb|center|Figure 3. We illustrate the goal description by showing a goal and a set of 5 landmarks that are nearby, plus 4 that are more distant. The code &lt;math&gt;g_i&lt;/math&gt; is a vector with a softmax-normalised distance to each landmark.]]<br /> <br /> This form of representation has several advantages: <br /> <br /> 1. It could easily be extended to new environments.<br /> <br /> 2. It is intuitive. Even humans and animals use landmarks to be able to move from one place to another.<br /> <br /> 3. It does not rely on arbitrary map coordinates, and provides an absolute (as opposed to relative) goal.<br /> <br /> In this work, 644 landmarks for New York, Paris, and London are manually defined. The courier task is the problem of navigating to a list of random locations within a city. In each episode, which consists of 1000 steps, the agent starts from a random place with random orientation. when an agent gets within 100 meters of goal, the next goal is randomly chosen. An episode ends after 1000 agent steps. Finally, the reward is proportional to the shortest path between agent and goal when the goal is first assigned (providing more reward for longer journeys). Thus the agent needs to learn the mapping between the images observed at the goal location and the goal vector in order to solve the courier task problem. Furthermore, the agent must learn the association between the images observed at its current location and the policy to reach the goal destination.<br /> <br /> ==Methods==<br /> <br /> ===Goal-dependent Actor-Critic Reinforcement Learning===<br /> In this paper, the learning problem is based on Markov Decision Process, with state space &lt;math&gt;\mathcal{S}&lt;/math&gt;, action space &lt;math&gt;\mathcal{A}&lt;/math&gt;, environment &lt;math&gt;\mathcal{E}&lt;/math&gt;, and a set of possible goals &lt;math&gt;\mathcal{G}&lt;/math&gt;. The reward function depends on the current goal and state: &lt;math&gt;\mathcal{R}: \mathcal{S} \times \mathcal{G} \times \mathcal{A} &amp;rarr; \mathbb{R}&lt;/math&gt;. Typically, in reinforcement learning the main goal is to find the policy which maximizes the expected return. Expected return is defined as the sum of<br /> discounted rewards starting from state &lt;math&gt;s_0&lt;/math&gt; with discount &lt;math&gt;\gamma&lt;/math&gt;. Also, the expected return from a state &lt;math&gt;s_t&lt;/math&gt; depends on the goals that are sampled. The policy is defined as a distribution over the actions, given the current state &lt;math&gt;s_t&lt;/math&gt; and the goal &lt;math&gt;g_t&lt;/math&gt;: <br /> <br /> \begin{align}<br /> \pi(\alpha|s,g)=Pr(\alpha_t=\alpha|s_t=s, g_t=g)<br /> \end{align}<br /> <br /> Value function is defined as the expected return obtained by sampling actions from policy &lt;math&gt;\pi&lt;/math&gt; from state &lt;math&gt;s_t&lt;/math&gt; with goal &lt;math&gt;g_t&lt;/math&gt;:<br /> <br /> \begin{align}<br /> V^{\pi}(s,g)=E[R_t]=E[Σ_{k=0}^{\infty}\gamma^kr_{t+k}|s_t=s, g_t=g]<br /> \end{align}<br /> <br /> Also, an architecture with multiple pathways is designed to support two types of learning that is required for this problem. First, an agent needs an internal representation which is general and gives an understanding of a scene. Second, to better understand a scene the agent needs to remember unique features of the scene which then help the agent to organize and remember the scenes.<br /> <br /> ===Architectures===<br /> <br /> [[File:figure4-soroush.png|400px|thumb|center|Figure 4. Comparison of architectures. Left: GoalNav is a convolutional encoder plus policy LSTM with goal description input. Middle: CityNav is a single-city navigation architecture with a separate goal LSTM and optional auxiliary heading (θ). Right: MultiCityNav is a multi-city architecture with individual goal LSTM pathways for each city.]]<br /> <br /> The authors use neural networks to parameterize policy and value functions. These neural networks share weights in all layers except the final linear layer. The agent takes image pixels as input. These pixels are passed through a convolutional network. The output of the Convolution network is fed to a Long Short-Term Memory (LSTM) as well as the past reward &lt;math&gt;r_{t-1}&lt;/math&gt; and previous action &lt;math&gt;\alpha_{t-1}&lt;/math&gt;.<br /> <br /> Three different architectures are described below.<br /> <br /> The '''GoalNav''' architecture (Fig. 4a) which consists of a convolutional architecture and policy LSTM. Goal description &lt;math&gt;g_t&lt;/math&gt;, previous action, and reward are the inputs of this LSTM.<br /> <br /> The '''CityNav''' architecture (Fig. 4b) consists of the previous architecture alongside an additional LSTM, called the goal LSTM. Inputs of this LSTM are visual features and the goal description. The CityNav agent also adds an auxiliary heading (θ) prediction task which is defined as an angle between the north direction and the agent’s pose. This auxiliary task can speed up learning and provides relevant information. <br /> <br /> The '''MultiCityNav''' architecture (Fig. 4c) is an extension of CityNav for learning in different cities. This is done using the parallel connection of goal LSTMs for encapsulating locale-specific features, for each city. Moreover, the convolutional architecture and the policy LSTM become general after training on a number of cities. So, new goal LSTMs are required to be trained in new cities.<br /> <br /> In this paper, the authors use IMPALA  to train the agents because IMPALA can get similar performance to A3C . The authors use 256 actors for CityNav and 512 actors for MultiCityNav, with batch sizes of 256 or 512 respectively, and sequences are unrolled to length 50.<br /> <br /> ===Curriculum Learning===<br /> In curriculum learning, the model is trained using simple examples in first steps. As soon as the model learns those examples, more complex and difficult examples would be fed to the model. In this paper, this approach is used to teach agent to navigate to further destinations. This courier task suffers from a common problem of RL tasks which is sparse rewards (similar to Montezuma’s Revenge) . To overcome this problem, a natural curriculum scheme is defined, in which sampling each new goal would be within 500m of the agent’s position. This is called phase 1. In phase 2, the maximum range is gradually increased to cover the full graph (3.5km in the smaller New York areas, or 5km for central London or Downtown Manhattan)<br /> <br /> ==Results==<br /> In this section, the performance of the proposed architectures on the courier task is shown.<br /> <br /> [[File:figure5-2.png|600px|thumb|center|Figure 5. Average per-episode goal rewards (y-axis) are plotted vs. learning steps (x-axis) for the courier task in the NYU (New York City) environment (top), and in central London (bottom). We compare the GoalNav agent, the CityNav agent, and the CityNav agent without skip connection on the NYU environment, and the CityNav agent in London. We also compare the Oracle performance and a Heuristic agent, described below. The London agents were trained with a 2-phase curriculum– we indicate the end of phase 1 (500m only) and the end of phase 2 (500m to 5000m). Results on the Rive Gauche part of Paris (trained in the same way<br /> as in London) are comparable and the agent achieved mean goal reward 426.]]<br /> <br /> It is first shown that the CityNav agent, trained with curriculum learning, succeeds in learning the courier task in New York, London and Paris. Figure 5 compares the following agents:<br /> <br /> 1. Goal Navigation agent.<br /> <br /> 2. City Navigation Agent.<br /> <br /> 3. A City Navigation agent without the skip connection from the vision layers to the policy LSTM. This is needed to regularise the interface between the goal LSTM and the policy LSTM in multi-city transfer scenario.<br /> <br /> Also, a lower bound (Heuristic) and an upper bound(Oracle) on the performance is considered. As it is said in the paper: &quot;Heuristic is a random walk on the street graph, where the agent turns in a random direction if it cannot move forward; if at an intersection it will turn with a probability &lt;math&gt;P=0.95&lt;/math&gt;. Oracle uses the full graph to compute the optimal path using breadth-first search.&quot;. As it is clear in Figure 5, CityNav architecture with the previously mentioned architecture attains a higher performance and is more stable than the simpler GoalNav agent.<br /> <br /> The trajectories of the trained agent over two 1000 step episodes and the value function of the agent during navigation to a destination is shown in Figure 6.<br /> <br /> [[File:figure6-soroush.png|400px|thumb|center|Figure 6. Trained CityNav agent’s performance in two environments: Central London (left panes), and NYU (right panes). Top: examples of the agent’s trajectory during one 1000-step episode, showing successful consecutive goal acquisitions. The arrows show the direction of travel of the agent. Bottom: We visualize the value function of the agent during 100 trajectories with random starting points and the same goal (respectively St Paul’s Cathedral and Washington Square). Thicker and warmer color lines correspond to higher value functions.]]<br /> <br /> Figure 7 shows that navigation policy is learned by agent successfully in St Paul’s Cathedral in London and Washington Square in New York.<br /> [[File:figure7-soroush.png|400px|thumb|center|Figure 7. Number of steps required for the CityNav agent to reach<br /> a goal (Washington Square in New York or St Paul’s Cathedral in<br /> London) from 100 start locations vs. the straight-line distance to<br /> the goal in meters. One agent step corresponds to a forward movement<br /> of about 10m or a left/right turn by 22.5 or 67.5 degrees.]]<br /> <br /> The authors mask 25% of the possible goals and train on the remaining ones in order to investigate the generalisation capability of a trained agent. Figure 8 Showa that the agent is still able to traverse through these areas, it just never samples a goal there. <br /> [[File:fff8.png|600px|center]]<br /> <br /> A critical test for this article is to transfer model to new cities by learning a new set of landmarks, but without re-learning visual representation, behaviors, etc. Therefore, the MultiCityNav agent is trained on a number of cities besides freezing both the policy LSTM and the convolutional encoder. Then a new locale-specific goal LSTM is trained. The performance is compared using three different training regimes, illustrated in Fig. 9: Training on only the target city (single training); training on multiple cities, including the target city, together (joint training); and joint training on all but the target city, followed by training on the target city with the rest of the architecture frozen (pre-train and transfer). Figure 10 shows that transferring to other cities is possible. Also, training the model on more cities would increase its effectiveness. According to the paper: &quot;Remarkably, the agent that is pre-trained on 4 regions and then transferred to Wall Street achieves comparable performance to an agent trained jointly on all the regions, and only slightly worse than single-city training on Wall Street alone&quot;. Training the model in a single city using skip connection is useful. However, it is not useful in multi-city transferring.<br /> [[File:figure9-soroush.png|400px|thumb|center|Figure 9. Illustration of training regimes: (a) training on a single city (equivalent to CityNav); (b) joint training over multiple cities with a dedicated per-city pathway and shared convolutional net and policy LSTM; (c) joint pre-training on a number of cities followed by training on a target city with convolutional net and policy LSTM frozen (only the target city pathway is optimized).]]<br /> [[File:figure10-soroush.png|400px|thumb|center|Figure 10. Joint multi-city training and transfer learning performance of variants of the MultiCityNav agent evaluated only on the target city (Wall Street). We compare single-city training on the target environment alone vs. joint training on multiple cities (3, 4, or 5-way joint training including Wall Street), vs. pre-training on multiple cities and then transferring to Wall Street while freezing the entire agent except for the new pathway (see Fig. 10). One variant has skip connections between the convolutional encoder and the policy LSTM, the other does not (no-skip).]]<br /> <br /> Giving early rewards before agent reaches the goal or adding random rewards (coins) to encourage exploration is investigated in this article. Figure 11a suggests that coins by themselves are ineffective as our task does not benefit from wide explorations. Also, as it is clear from Figure 11b, reducing the density of the landmarks does not seem to reduce the performance. Based on the results, authors chose to start sampling the goal within a radius of 500m from the agent’s location, and then progressively extend it to the maximum distance an agent could travel within the environment. In addition, to asses the importance of the goal-conditioned agents, a Goal-less CityNav agent is trained by removing inputs gt. The poor performance of this agent is clear in Figure 11b. Furthermore, reducing the density of the landmarks by the ratio of 50%, 25%, and 12:5% does not reduce the performance that much. Finally, some alternative for goal representation is investigated:<br /> <br /> a) Latitude and longitude scalar coordinates normalized to be between 0 and 1.<br /> <br /> b) Binned representation. <br /> <br /> The latitude and longitude scalar goal representations perform the best. However, since the all landmarks representation performs well while remaining independent of the coordinate system, we use this representation as the canonical one.<br /> <br /> [[File:figure11-soroush.PNG|300px|thumb|center|Figure 11. Top: Learning curves of the CityNav agent on NYU, comparing reward shaping with different radii of early rewards (ER) vs. ER with random coins vs. curriculum learning with ER 200m and no coins (ER 200m, Curr.). Bottom: Learning curves for CityNav agents with different goal representations: landmark-based, as well as latitude and longitude classification-based and regression-based.]]<br /> <br /> ==Conclusion==<br /> In this paper, a deep reinforcement learning approach that enables navigation in cities is presented through the use of Google StreetView for its photographic content and worldwide coverage. Furthermore, the authors discussed a new courier task and a multi-city neural network agent architecture that is able to be transferred to new cities. A successful navigation architecture is presented which relies on integration of general policies with locale-specific knowledge.<br /> <br /> ==Critique==<br /> 1. It is not clear how this model is applicable in the real world. A real-world navigation problem needs to detect objects, people, and cars. However, it is not clear whether they are modelling them or not. From what I understood, they did not care about the collision, which is against their claim that it is a real-world problem.<br /> <br /> 2. This paper is only using static Google Street View images as its primary source of data. But the authors must at least complement this with other dynamic data like traffic and road blockage information for a realistic model of navigation in the world. Also, this is quite understandable not to use maps but is not clear why have they not used GPS to know their position and maybe even made up with a map. This can be something useful in an emergency or even for investigating places that are not known or there is no access to them. The resulting map could be easily compared with the real one and could also be used in training to achieve higher performance. The availability should not be a serious problem because if they are simulating a real city and the google images are available, why should not GPS be? What is the intuition? At lease a complementary description on this could be helpful.<br /> <br /> 3. The 'Transfer in Multi-City Experiments' results could be strengthened significantly via cross-validation (only Wall Street, which covers the smallest area of the four regions, is used as the test case). Additionally, the results do not show true 'multi-city' transfer learning, since all regions are within New York City. It is stated in the paper that not having to re-learn visual representations when transferring between cities is one of the outcomes, but the tests do not actually check for this. There are likely significant differences in the features that would be learned in NYC vs. Waterloo, for example, and this type of transfer has not been evaluated.<br /> <br /> ==Reference==<br />  Espeholt, Lasse, Soyer, Hubert, Munos, Remi, Simonyan, Karen, Mnih, Volodymir, Ward, Tom, Doron, Yotam, Firoiu, Vlad, Harley, Tim, Dunning, Iain, Legg, Shane, and Kavukcuoglu, Koray. Impala: Scalable distributed deep-rl with importance weighted actor-learner architec- tures. arXiv preprint arXiv:1802.01561, 2018.<br /> <br />  Mnih, Volodymyr, Badia, Adria Puigdomenech, Mirza, Mehdi, Graves, Alex, Lillicrap, Timothy, Harley, Tim, Silver, David, and Kavukcuoglu, Koray. Asynchronous methods for deep reinforcement learning. In Interna- tional Conference on Machine Learning, pp. 1928–1937, 2016.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=Learning_to_Navigate_in_Cities_Without_a_Map&diff=40883 Learning to Navigate in Cities Without a Map 2018-11-22T16:39:51Z <p>Jmmoosa: /* Architectures */</p> <hr /> <div>Paper: <br /> Learning to Navigate in Cities Without a Map[https://arxiv.org/pdf/1804.00168.pdf]<br /> A video of the paper is available here[https://sites.google.com/view/streetlearn].<br /> <br /> == Introduction ==<br /> Navigation is an attractive topic in many research disciplines and technology related domains such as neuroscience and robotics. The majority of algorithms are based on the following steps.<br /> <br /> 1. Building an explicit map<br /> <br /> 2. Planning and acting using that map. <br /> <br /> In this article, based on this fact that human can learn to navigate through cities without using any special tool such as maps or GPS, authors propose new methods to show that a neural network agent can do the same thing by using visual observations. To do so, an interactive environment using Google StreetView Images and a dual pathway agent architecture is designed. As shown in figure 1, some parts of the environment are built using Google StreetView images of New York City (Times Square, Central Park) and London (St. Paul’s Cathedral). The green cone represents the agent’s location and orientation. Although learning to navigate using visual aids is shown to be successful in some domains such as games and simulated environments using deep reinforcement learning (RL), it suffers from data inefficiency and sensitivity to changes in the environment. Thus, it is unclear whether this method could be used for large-scale navigation. That’s why it became the subject of investigation in this paper.<br /> [[File:figure1-soroush.png|600px|thumb|center|Figure 1. Our environment is built of real-world places from StreetView. The figure shows diverse views and corresponding local maps (neither map nor current position have not been used by the agent) in New York City (Times Square, Central Park) and London (St. Paul’s Cathedral). The green cone represents the agent’s location and orientation.]]<br /> <br /> ==Contribution==<br /> This paper has made the following contributions:<br /> <br /> 1. Designing a dual pathway agent architecture. This agent can navigate through a real city and is trained with end-to-end reinforcement learning to handle real-world navigations.<br /> <br /> 2. Using Goal-dependent learning. This means that the policy and value functions must adapt themselves to a sequence of goals that are provided as input.<br /> <br /> 3. Leveraging a recurrent neural architecture. Using that, not only could navigation through a city be possible, but also the model is scalable for navigation in new cities. This architecture supports both locale-specific learnings and general transferable navigations. The authors achieved these by separating a recurrent neural pathway. This pathway receives and interprets the current goal as well as encapsulates and memorizes features of a single region.<br /> <br /> 4. Using a new environment which is built on top of Google StreetView images. This provides real-world images for agent’s observation. Using this environment, the agent can navigate from an arbitrary starting point to a goal and then to another goal etc. Also, London, Paris, and New York City are chosen for navigation.<br /> <br /> ==Related Work==<br /> <br /> 1. Localization from real-world imagery. For example, (Weyand et al., 2016), a CNN was able to achieve excellent results on geolocation task. This paper provides novel work by not including supervised training with ground-truth labels, and by including planning as a goal. Some other works also improve by exploiting spatiotemporal continuity or estimating camera pose or depth estimation from pixels. These methods rely on supervised training with ground truth labels, which is not possible in every environment. <br /> <br /> 2. Deep RL methods for navigation. For instance, (Mirowski et al., 2016; Jaderberg et al., 2016) used self-supervised auxiliary tasks to produce visual navigation in several created mazes. Some other researches used text descriptions to incorporate goal instructions. Researchers developed realistic, higher-fidelity environment simulations to make the experiment more realistic, but that still came with lack of diversities. This paper makes use of real-world data, in contrast to many related papers in this area. It's diverse and visually realistic but still, it does not contain dynamic elements, and the street topology cannot be regenerated or altered.<br /> <br /> 3. Deep RL for path planning and mapping. For example, (Zhang et al., 2017) created an agent that represented a global map via an RL agent with external memory; some other work uses a hierarchical control strategy to propose a structured memory and Memory Augmented Control Maps. Explicit neural mapper and navigation planner with joint training was also used. Among all these works, the target-driven visual navigation with a goal-conditional policy approach was most related to our method.<br /> <br /> ==Environment==<br /> Google StreetView consists of both high-resolution 360-degree imagery and graph connectivity. Also, it provides a public API. These features make it a valuable resource. In this work, large areas of New York, Paris, and London that contain between 7,000 and 65,500 nodes<br /> (and between 7,200 and 128,600 edges, respectively), have a mean node spacing of 10m and cover a range of up to<br /> 5km chosen (Figure 2), without simplifying the underlying connections. This means that there are many areas 'congested' with nodes, occlusions, available footpaths, etc. The agent only sees RGB images that are visible in StreetView images (Figure 1) and is not aware of the underlying graph.<br /> <br /> [[File:figure2-soroush.png|700px|thumb|center|Figure 2. Map of the 5 environments in New York City; our experiments focus on the NYU area as well as on transfer learning from the other areas to Wall Street (see Section 5.3). In the zoomed in area, each green dot corresponds to a unique panorama, the goal is marked in blue, and landmark locations are marked with red pins.]]<br /> <br /> ==Agent Interface and the Courier Task==<br /> In an RL environment, we need to define observations and actions in addition to tasks. The inputs to the agent are the image &lt;math&gt;x_t&lt;/math&gt; and the goal &lt;math&gt;g_t&lt;/math&gt;. Also, a first-person view of the 3D environment is simulated by cropping &lt;math&gt;x_t&lt;/math&gt; to a 60-degree square RGB image that is scaled to 84*84 pixels. Furthermore, the action space consists of 5 movements: “slow” rotate left or right (±22:5), “fast” rotate left or right (±67.5), or move forward (implemented as a ''noop'' in the case where this is not a viable action). The most central edge is chosen if there are multiple edges in the agents viewing cone.<br /> <br /> There are lots of ways to specify the goal to the agent. In this paper, the current goal is chosen to be represented in terms of its proximity to a set L of fixed landmarks &lt;math&gt; L={(Lat_k, Long_k)}&lt;/math&gt; which are specified using Latitude and Longitude coordinate system. For distance to the &lt;math&gt; k_{th}&lt;/math&gt; landmark &lt;math&gt;{(d_{(t,k)}^g})_k&lt;/math&gt; the goal vector contains &lt;math&gt; g_{(t,i)}=\tfrac{exp⁡(-αd_{(t,i)}^g)}{∑_k exp⁡(-αd_{(t,k)}^g)} &lt;/math&gt;for &lt;math&gt;i_{th}&lt;/math&gt; landmark with &lt;math&gt;α=0.002&lt;/math&gt; (Figure 3).<br /> <br /> [[File:figure3-soroush.PNG|400px|thumb|center|Figure 3. We illustrate the goal description by showing a goal and a set of 5 landmarks that are nearby, plus 4 that are more distant. The code &lt;math&gt;g_i&lt;/math&gt; is a vector with a softmax-normalised distance to each landmark.]]<br /> <br /> This form of representation has several advantages: <br /> <br /> 1. It could easily be extended to new environments.<br /> <br /> 2. It is intuitive. Even humans and animals use landmarks to be able to move from one place to another.<br /> <br /> 3. It does not rely on arbitrary map coordinates, and provides an absolute (as opposed to relative) goal.<br /> <br /> In this work, 644 landmarks for New York, Paris, and London are manually defined. The courier task is the problem of navigating to a list of random locations within a city. In each episode, which consists of 1000 steps, the agent starts from a random place with random orientation. when an agent gets within 100 meters of goal, the next goal is randomly chosen. An episode ends after 1000 agent steps. Finally, the reward is proportional to the shortest path between agent and goal when the goal is first assigned (providing more reward for longer journeys). Thus the agent needs to learn the mapping between the images observed at the goal location and the goal vector in order to solve the courier task problem. Furthermore, the agent must learn the association between the images observed at its current location and the policy to reach the goal destination.<br /> <br /> ==Methods==<br /> <br /> ===Goal-dependent Actor-Critic Reinforcement Learning===<br /> In this paper, the learning problem is based on Markov Decision Process, with state space &lt;math&gt;\mathcal{S}&lt;/math&gt;, action space &lt;math&gt;\mathcal{A}&lt;/math&gt;, environment &lt;math&gt;\mathcal{E}&lt;/math&gt;, and a set of possible goals &lt;math&gt;\mathcal{G}&lt;/math&gt;. The reward function depends on the current goal and state: &lt;math&gt;\mathcal{R}: \mathcal{S} \times \mathcal{G} \times \mathcal{A} &amp;rarr; \mathbb{R}&lt;/math&gt;. Typically, in reinforcement learning the main goal is to find the policy which maximizes the expected return. Expected return is defined as the sum of<br /> discounted rewards starting from state &lt;math&gt;s_0&lt;/math&gt; with discount &lt;math&gt;\gamma&lt;/math&gt;. Also, the expected return from a state &lt;math&gt;s_t&lt;/math&gt; depends on the goals that are sampled. The policy is defined as a distribution over the actions, given the current state &lt;math&gt;s_t&lt;/math&gt; and the goal &lt;math&gt;g_t&lt;/math&gt;: <br /> <br /> \begin{align}<br /> \pi(\alpha|s,g)=Pr(\alpha_t=\alpha|s_t=s, g_t=g)<br /> \end{align}<br /> <br /> Value function is defined as the expected return obtained by sampling actions from policy &lt;math&gt;\pi&lt;/math&gt; from state &lt;math&gt;s_t&lt;/math&gt; with goal &lt;math&gt;g_t&lt;/math&gt;:<br /> <br /> \begin{align}<br /> V^{\pi}(s,g)=E[R_t]=E[Σ_{k=0}^{\infty}\gamma^kr_{t+k}|s_t=s, g_t=g]<br /> \end{align}<br /> <br /> Also, an architecture with multiple pathways is designed to support two types of learning that is required for this problem. First, an agent needs an internal representation which is general and gives an understanding of a scene. Second, to better understand a scene the agent needs to remember unique features of the scene which then help the agent to organize and remember the scenes.<br /> <br /> ===Architectures===<br /> <br /> [[File:figure4-soroush.png|400px|thumb|center|Figure 4. Comparison of architectures. Left: GoalNav is a convolutional encoder plus policy LSTM with goal description input. Middle: CityNav is a single-city navigation architecture with a separate goal LSTM and optional auxiliary heading (θ). Right: MultiCityNav is a multi-city architecture with individual goal LSTM pathways for each city.]]<br /> <br /> The authors use neural networks to parameterize policy and value functions. These neural networks share weights in all layers except the final linear layer. The agent takes image pixels as input. These pixels are passed through a convolutional network. The output of the Convolution network is fed to a Long Short-Term Memory (LSTM) as well as the past reward &lt;math&gt;r_{t-1}&lt;/math&gt; and previous action &lt;math&gt;\alpha_{t-1}&lt;/math&gt;.<br /> <br /> Three different architectures are described below.<br /> <br /> The '''GoalNav''' architecture (Fig. 4a) which consists of a convolutional architecture and policy LSTM. Goal description &lt;math&gt;g_t&lt;/math&gt;, previous action, and reward are the inputs of this LSTM.<br /> <br /> The '''CityNav''' architecture (Fig. 4b) consists of the previous architecture alongside an additional LSTM, called the goal LSTM. Inputs of this LSTM are visual features and the goal description. The CityNav agent also adds an auxiliary heading (θ) prediction task which is defined as an angle between the north direction and the agent’s pose. This auxiliary task can speed up learning and provides relevant information. <br /> <br /> The '''MultiCityNav''' architecture (Fig. 4c) is an extension of CityNav for learning in different cities. This is done using the parallel connection of goal LSTMs for encapsulating locale-specific features, for each city. Moreover, the convolutional architecture and the policy LSTM become general after training on a number of cities. So, new goal LSTMs are required to be trained in new cities.<br /> <br /> In this paper, the authors use IMPALA  to train the agents because IMPALA can get similar performance to A3C . The authors use 256 actors for CityNav and 512 actors for MultiCityNav, with batch sizes of 256 or 512 respectively, and sequences are unrolled to length 50.<br /> <br /> ===Curriculum Learning===<br /> In curriculum learning, the model is trained using simple examples in first steps. As soon as the model learns those examples, more complex and difficult examples would be fed to the model. In this paper, this approach is used to teach agent to navigate to further destinations. This courier task suffers from a common problem of RL tasks which is sparse rewards (similar to Montezuma’s Revenge) . To overcome this problem, a natural curriculum scheme is defined, in which sampling each new goal would be within 500m of the agent’s position. This is called phase 1. In phase 2, the maximum range is gradually increased to cover the full graph (3.5km in the smaller New York areas, or 5km for central London or Downtown Manhattan)<br /> <br /> ==Results==<br /> In this section, the performance of the proposed architectures on the courier task is shown.<br /> <br /> [[File:figure5-2.png|600px|thumb|center|Figure 5. Average per-episode goal rewards (y-axis) are plotted vs. learning steps (x-axis) for the courier task in the NYU (New York City) environment (top), and in central London (bottom). We compare the GoalNav agent, the CityNav agent, and the CityNav agent without skip connection on the NYU environment, and the CityNav agent in London. We also compare the Oracle performance and a Heuristic agent, described below. The London agents were trained with a 2-phase curriculum– we indicate the end of phase 1 (500m only) and the end of phase 2 (500m to 5000m). Results on the Rive Gauche part of Paris (trained in the same way<br /> as in London) are comparable and the agent achieved mean goal reward 426.]]<br /> <br /> It is first shown that the CityNav agent, trained with curriculum learning, succeeds in learning the courier task in New York, London and Paris. Figure 5 compares the following agents:<br /> <br /> 1. Goal Navigation agent.<br /> <br /> 2. City Navigation Agent.<br /> <br /> 3. A City Navigation agent without the skip connection from the vision layers to the policy LSTM. This is needed to regularise the interface between the goal LSTM and the policy LSTM in multi-city transfer scenario.<br /> <br /> Also, a lower bound (Heuristic) and an upper bound(Oracle) on the performance is considered. As it is said in the paper: &quot;Heuristic is a random walk on the street graph, where the agent turns in a random direction if it cannot move forward; if at an intersection it will turn with a probability &lt;math&gt;P=0.95&lt;/math&gt;. Oracle uses the full graph to compute the optimal path using breadth-first search.&quot;. As it is clear in Figure 5, CityNav architecture with the previously mentioned architecture attains a higher performance and is more stable than the simpler GoalNav agent.<br /> <br /> The trajectories of the trained agent over two 1000 step episodes and the value function of the agent during navigation to a destination is shown in Figure 6.<br /> <br /> [[File:figure6-soroush.png|400px|thumb|center|Figure 6. Trained CityNav agent’s performance in two environments: Central London (left panes), and NYU (right panes). Top: examples of the agent’s trajectory during one 1000-step episode, showing successful consecutive goal acquisitions. The arrows show the direction of travel of the agent. Bottom: We visualize the value function of the agent during 100 trajectories with random starting points and the same goal (respectively St Paul’s Cathedral and Washington Square). Thicker and warmer color lines correspond to higher value functions.]]<br /> <br /> Figure 7 shows that navigation policy is learned by agent successfully in St Paul’s Cathedral in London and Washington Square in New York.<br /> [[File:figure7-soroush.png|400px|thumb|center|Figure 7. Number of steps required for the CityNav agent to reach<br /> a goal (Washington Square in New York or St Paul’s Cathedral in<br /> London) from 100 start locations vs. the straight-line distance to<br /> the goal in meters. One agent step corresponds to a forward movement<br /> of about 10m or a left/right turn by 22.5 or 67.5 degrees.]]<br /> <br /> The authors mask 25% of the possible goals and train on the remaining ones in order to investigate the generalisation capability of a trained agent. Figure 8 Showa that the agent is still able to traverse through these areas, it just never samples a goal there. <br /> [[File:fff8.png|600px|center]]<br /> <br /> A critical test for this article is to transfer model to new cities by learning a new set of landmarks, but without re-learning visual representation, behaviors, etc. Therefore, the MultiCityNav agent is trained on a number of cities besides freezing both the policy LSTM and the convolutional encoder. Then a new locale-specific goal LSTM is trained. The performance is compared using three different training regimes, illustrated in Fig. 9: Training on only the target city (single training); training on multiple cities, including the target city, together (joint training); and joint training on all but the target city, followed by training on the target city with the rest of the architecture frozen (pre-train and transfer). Figure 10 shows that transferring to other cities is possible. Also, training the model on more cities would increase its effectiveness. According to the paper: &quot;Remarkably, the agent that is pre-trained on 4 regions and then transferred to Wall Street achieves comparable performance to an agent trained jointly on all the regions, and only slightly worse than single-city training on Wall Street alone&quot;. Training the model in a single city using skip connection is useful. However, it is not useful in multi-city transferring.<br /> [[File:figure9-soroush.png|400px|thumb|center|Figure 9. Illustration of training regimes: (a) training on a single city (equivalent to CityNav); (b) joint training over multiple cities with a dedicated per-city pathway and shared convolutional net and policy LSTM; (c) joint pre-training on a number of cities followed by training on a target city with convolutional net and policy LSTM frozen (only the target city pathway is optimized).]]<br /> [[File:figure10-soroush.png|400px|thumb|center|Figure 10. Joint multi-city training and transfer learning performance of variants of the MultiCityNav agent evaluated only on the target city (Wall Street). We compare single-city training on the target environment alone vs. joint training on multiple cities (3, 4, or 5-way joint training including Wall Street), vs. pre-training on multiple cities and then transferring to Wall Street while freezing the entire agent except for the new pathway (see Fig. 10). One variant has skip connections between the convolutional encoder and the policy LSTM, the other does not (no-skip).]]<br /> <br /> Giving early rewards before agent reaches the goal or adding random rewards (coins) to encourage exploration is investigated in this article. Figure 11a suggests that coins by themselves are ineffective as our task does not benefit from wide explorations. Also, as it is clear from Figure 11b, reducing the density of the landmarks does not seem to reduce the performance. Based on the results, authors chose to start sampling the goal within a radius of 500m from the agent’s location, and then progressively extend it to the maximum distance an agent could travel within the environment. In addition, to asses the importance of the goal-conditioned agents, a Goal-less CityNav agent is trained by removing inputs gt. The poor performance of this agent is clear in Figure 11b. Furthermore, reducing the density of the landmarks by the ratio of 50%, 25%, and 12:5% does not reduce the performance that much. Finally, some alternative for goal representation is investigated:<br /> <br /> a) Latitude and longitude scalar coordinates normalized to be between 0 and 1.<br /> <br /> b) Binned representation. <br /> <br /> The latitude and longitude scalar goal representations perform the best. However, since the all landmarks representation performs well while remaining independent of the coordinate system, we use this representation as the canonical one.<br /> <br /> [[File:figure11-soroush.PNG|300px|thumb|center|Figure 11. Top: Learning curves of the CityNav agent on NYU, comparing reward shaping with different radii of early rewards (ER) vs. ER with random coins vs. curriculum learning with ER 200m and no coins (ER 200m, Curr.). Bottom: Learning curves for CityNav agents with different goal representations: landmark-based, as well as latitude and longitude classification-based and regression-based.]]<br /> <br /> ==Conclusion==<br /> In this paper, a deep reinforcement learning approach that enables navigation in cities is presented through the use of Google StreetView for its photographic content and worldwide coverage. Furthermore, the authors discussed a new courier task and a multi-city neural network agent architecture that is able to be transferred to new cities. A successful navigation architecture is presented which relies on integration of general policies with locale-specific knowledge.<br /> <br /> ==Critique==<br /> 1. It is not clear how this model is applicable in the real world. A real-world navigation problem needs to detect objects, people, and cars. However, it is not clear whether they are modelling them or not. From what I understood, they did not care about the collision, which is against their claim that it is a real-world problem.<br /> <br /> 2. This paper is only using static Google Street View images as its primary source of data. But the authors must at least complement this with other dynamic data like traffic and road blockage information for a realistic model of navigation in the world. Also, this is quite understandable not to use maps but is not clear why have they not used GPS to know their position and maybe even made up with a map. This can be something useful in an emergency or even for investigating places that are not known or there is no access to them. The resulting map could be easily compared with the real one and could also be used in training to achieve higher performance. The availability should not be a serious problem because if they are simulating a real city and the google images are available, why should not GPS be? What is the intuition? At lease a complementary description on this could be helpful.<br /> <br /> 3. The 'Transfer in Multi-City Experiments' results could be strengthened significantly via cross-validation (only Wall Street, which covers the smallest area of the four regions, is used as the test case). Additionally, the results do not show true 'multi-city' transfer learning, since all regions are within New York City. It is stated in the paper that not having to re-learn visual representations when transferring between cities is one of the outcomes, but the tests do not actually check for this. There are likely significant differences in the features that would be learned in NYC vs. Waterloo, for example, and this type of transfer has not been evaluated.<br /> <br /> ==Reference==<br />  Espeholt, Lasse, Soyer, Hubert, Munos, Remi, Simonyan, Karen, Mnih, Volodymir, Ward, Tom, Doron, Yotam, Firoiu, Vlad, Harley, Tim, Dunning, Iain, Legg, Shane, and Kavukcuoglu, Koray. Impala: Scalable distributed deep-rl with importance weighted actor-learner architec- tures. arXiv preprint arXiv:1802.01561, 2018.<br /> <br />  Mnih, Volodymyr, Badia, Adria Puigdomenech, Mirza, Mehdi, Graves, Alex, Lillicrap, Timothy, Harley, Tim, Silver, David, and Kavukcuoglu, Koray. Asynchronous methods for deep reinforcement learning. In Interna- tional Conference on Machine Learning, pp. 1928–1937, 2016.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=Learning_to_Navigate_in_Cities_Without_a_Map&diff=40882 Learning to Navigate in Cities Without a Map 2018-11-22T16:36:41Z <p>Jmmoosa: /* Architectures */</p> <hr /> <div>Paper: <br /> Learning to Navigate in Cities Without a Map[https://arxiv.org/pdf/1804.00168.pdf]<br /> A video of the paper is available here[https://sites.google.com/view/streetlearn].<br /> <br /> == Introduction ==<br /> Navigation is an attractive topic in many research disciplines and technology related domains such as neuroscience and robotics. The majority of algorithms are based on the following steps.<br /> <br /> 1. Building an explicit map<br /> <br /> 2. Planning and acting using that map. <br /> <br /> In this article, based on this fact that human can learn to navigate through cities without using any special tool such as maps or GPS, authors propose new methods to show that a neural network agent can do the same thing by using visual observations. To do so, an interactive environment using Google StreetView Images and a dual pathway agent architecture is designed. As shown in figure 1, some parts of the environment are built using Google StreetView images of New York City (Times Square, Central Park) and London (St. Paul’s Cathedral). The green cone represents the agent’s location and orientation. Although learning to navigate using visual aids is shown to be successful in some domains such as games and simulated environments using deep reinforcement learning (RL), it suffers from data inefficiency and sensitivity to changes in the environment. Thus, it is unclear whether this method could be used for large-scale navigation. That’s why it became the subject of investigation in this paper.<br /> [[File:figure1-soroush.png|600px|thumb|center|Figure 1. Our environment is built of real-world places from StreetView. The figure shows diverse views and corresponding local maps (neither map nor current position have not been used by the agent) in New York City (Times Square, Central Park) and London (St. Paul’s Cathedral). The green cone represents the agent’s location and orientation.]]<br /> <br /> ==Contribution==<br /> This paper has made the following contributions:<br /> <br /> 1. Designing a dual pathway agent architecture. This agent can navigate through a real city and is trained with end-to-end reinforcement learning to handle real-world navigations.<br /> <br /> 2. Using Goal-dependent learning. This means that the policy and value functions must adapt themselves to a sequence of goals that are provided as input.<br /> <br /> 3. Leveraging a recurrent neural architecture. Using that, not only could navigation through a city be possible, but also the model is scalable for navigation in new cities. This architecture supports both locale-specific learnings and general transferable navigations. The authors achieved these by separating a recurrent neural pathway. This pathway receives and interprets the current goal as well as encapsulates and memorizes features of a single region.<br /> <br /> 4. Using a new environment which is built on top of Google StreetView images. This provides real-world images for agent’s observation. Using this environment, the agent can navigate from an arbitrary starting point to a goal and then to another goal etc. Also, London, Paris, and New York City are chosen for navigation.<br /> <br /> ==Related Work==<br /> <br /> 1. Localization from real-world imagery. For example, (Weyand et al., 2016), a CNN was able to achieve excellent results on geolocation task. This paper provides novel work by not including supervised training with ground-truth labels, and by including planning as a goal. Some other works also improve by exploiting spatiotemporal continuity or estimating camera pose or depth estimation from pixels. These methods rely on supervised training with ground truth labels, which is not possible in every environment. <br /> <br /> 2. Deep RL methods for navigation. For instance, (Mirowski et al., 2016; Jaderberg et al., 2016) used self-supervised auxiliary tasks to produce visual navigation in several created mazes. Some other researches used text descriptions to incorporate goal instructions. Researchers developed realistic, higher-fidelity environment simulations to make the experiment more realistic, but that still came with lack of diversities. This paper makes use of real-world data, in contrast to many related papers in this area. It's diverse and visually realistic but still, it does not contain dynamic elements, and the street topology cannot be regenerated or altered.<br /> <br /> 3. Deep RL for path planning and mapping. For example, (Zhang et al., 2017) created an agent that represented a global map via an RL agent with external memory; some other work uses a hierarchical control strategy to propose a structured memory and Memory Augmented Control Maps. Explicit neural mapper and navigation planner with joint training was also used. Among all these works, the target-driven visual navigation with a goal-conditional policy approach was most related to our method.<br /> <br /> ==Environment==<br /> Google StreetView consists of both high-resolution 360-degree imagery and graph connectivity. Also, it provides a public API. These features make it a valuable resource. In this work, large areas of New York, Paris, and London that contain between 7,000 and 65,500 nodes<br /> (and between 7,200 and 128,600 edges, respectively), have a mean node spacing of 10m and cover a range of up to<br /> 5km chosen (Figure 2), without simplifying the underlying connections. This means that there are many areas 'congested' with nodes, occlusions, available footpaths, etc. The agent only sees RGB images that are visible in StreetView images (Figure 1) and is not aware of the underlying graph.<br /> <br /> [[File:figure2-soroush.png|700px|thumb|center|Figure 2. Map of the 5 environments in New York City; our experiments focus on the NYU area as well as on transfer learning from the other areas to Wall Street (see Section 5.3). In the zoomed in area, each green dot corresponds to a unique panorama, the goal is marked in blue, and landmark locations are marked with red pins.]]<br /> <br /> ==Agent Interface and the Courier Task==<br /> In an RL environment, we need to define observations and actions in addition to tasks. The inputs to the agent are the image &lt;math&gt;x_t&lt;/math&gt; and the goal &lt;math&gt;g_t&lt;/math&gt;. Also, a first-person view of the 3D environment is simulated by cropping &lt;math&gt;x_t&lt;/math&gt; to a 60-degree square RGB image that is scaled to 84*84 pixels. Furthermore, the action space consists of 5 movements: “slow” rotate left or right (±22:5), “fast” rotate left or right (±67.5), or move forward (implemented as a ''noop'' in the case where this is not a viable action). The most central edge is chosen if there are multiple edges in the agents viewing cone.<br /> <br /> There are lots of ways to specify the goal to the agent. In this paper, the current goal is chosen to be represented in terms of its proximity to a set L of fixed landmarks &lt;math&gt; L={(Lat_k, Long_k)}&lt;/math&gt; which are specified using Latitude and Longitude coordinate system. For distance to the &lt;math&gt; k_{th}&lt;/math&gt; landmark &lt;math&gt;{(d_{(t,k)}^g})_k&lt;/math&gt; the goal vector contains &lt;math&gt; g_{(t,i)}=\tfrac{exp⁡(-αd_{(t,i)}^g)}{∑_k exp⁡(-αd_{(t,k)}^g)} &lt;/math&gt;for &lt;math&gt;i_{th}&lt;/math&gt; landmark with &lt;math&gt;α=0.002&lt;/math&gt; (Figure 3).<br /> <br /> [[File:figure3-soroush.PNG|400px|thumb|center|Figure 3. We illustrate the goal description by showing a goal and a set of 5 landmarks that are nearby, plus 4 that are more distant. The code &lt;math&gt;g_i&lt;/math&gt; is a vector with a softmax-normalised distance to each landmark.]]<br /> <br /> This form of representation has several advantages: <br /> <br /> 1. It could easily be extended to new environments.<br /> <br /> 2. It is intuitive. Even humans and animals use landmarks to be able to move from one place to another.<br /> <br /> 3. It does not rely on arbitrary map coordinates, and provides an absolute (as opposed to relative) goal.<br /> <br /> In this work, 644 landmarks for New York, Paris, and London are manually defined. The courier task is the problem of navigating to a list of random locations within a city. In each episode, which consists of 1000 steps, the agent starts from a random place with random orientation. when an agent gets within 100 meters of goal, the next goal is randomly chosen. An episode ends after 1000 agent steps. Finally, the reward is proportional to the shortest path between agent and goal when the goal is first assigned (providing more reward for longer journeys). Thus the agent needs to learn the mapping between the images observed at the goal location and the goal vector in order to solve the courier task problem. Furthermore, the agent must learn the association between the images observed at its current location and the policy to reach the goal destination.<br /> <br /> ==Methods==<br /> <br /> ===Goal-dependent Actor-Critic Reinforcement Learning===<br /> In this paper, the learning problem is based on Markov Decision Process, with state space &lt;math&gt;\mathcal{S}&lt;/math&gt;, action space &lt;math&gt;\mathcal{A}&lt;/math&gt;, environment &lt;math&gt;\mathcal{E}&lt;/math&gt;, and a set of possible goals &lt;math&gt;\mathcal{G}&lt;/math&gt;. The reward function depends on the current goal and state: &lt;math&gt;\mathcal{R}: \mathcal{S} \times \mathcal{G} \times \mathcal{A} &amp;rarr; \mathbb{R}&lt;/math&gt;. Typically, in reinforcement learning the main goal is to find the policy which maximizes the expected return. Expected return is defined as the sum of<br /> discounted rewards starting from state &lt;math&gt;s_0&lt;/math&gt; with discount &lt;math&gt;\gamma&lt;/math&gt;. Also, the expected return from a state &lt;math&gt;s_t&lt;/math&gt; depends on the goals that are sampled. The policy is defined as a distribution over the actions, given the current state &lt;math&gt;s_t&lt;/math&gt; and the goal &lt;math&gt;g_t&lt;/math&gt;: <br /> <br /> \begin{align}<br /> \pi(\alpha|s,g)=Pr(\alpha_t=\alpha|s_t=s, g_t=g)<br /> \end{align}<br /> <br /> Value function is defined as the expected return obtained by sampling actions from policy &lt;math&gt;\pi&lt;/math&gt; from state &lt;math&gt;s_t&lt;/math&gt; with goal &lt;math&gt;g_t&lt;/math&gt;:<br /> <br /> \begin{align}<br /> V^{\pi}(s,g)=E[R_t]=E[Σ_{k=0}^{\infty}\gamma^kr_{t+k}|s_t=s, g_t=g]<br /> \end{align}<br /> <br /> Also, an architecture with multiple pathways is designed to support two types of learning that is required for this problem. First, an agent needs an internal representation which is general and gives an understanding of a scene. Second, to better understand a scene the agent needs to remember unique features of the scene which then help the agent to organize and remember the scenes.<br /> <br /> ===Architectures===<br /> <br /> [[File:figure4-soroush.png|400px|thumb|center|Figure 4. Comparison of architectures. Left: GoalNav is a convolutional encoder plus policy LSTM with goal description input. Middle: CityNav is a single-city navigation architecture with a separate goal LSTM and optional auxiliary heading (θ). Right: MultiCityNav is a multi-city architecture with individual goal LSTM pathways for each city.]]<br /> <br /> The authors use neural networks to parameterize policy and value functions. These neural networks share weights in all layers except the final linear layer. The agent takes image pixels as input. These pixels are passed through a convolutional network. The output of the Convolution network is fed to a Long Short-Term Memory (LSTM) as well as the past reward &lt;math&gt;r_{t-1}&lt;/math&gt; and previous action &lt;math&gt;\alpha_{t-1}&lt;/math&gt;.<br /> <br /> Three different architectures are described below.<br /> <br /> The '''GoalNav''' architecture (Fig. 4a) which consists of a convolutional architecture and policy LSTM. Goal description &lt;math&gt;g_t&lt;/math&gt;, previous action, and reward are the inputs of this LSTM.<br /> <br /> The '''CityNav''' architecture (Fig. 4b) consists of the previous architecture alongside an additional LSTM, called the goal LSTM. Inputs of this LSTM are visual features and the goal description. The CityNav agent also adds an auxiliary heading (θ) prediction task which is defined as an angle between the north direction and the agent’s pose. This auxiliary task can speed up learning and provides relevant information. <br /> <br /> The '''MultiCityNav''' architecture (Fig. 4c) is an extension of City-Nav for learning in different cities. This is done using the parallel connection of goal LSTMs for encapsulating locale-specific features, for each city. Moreover, the convolutional architecture and the policy LSTM become general after training on a number of cities. So, new goal LSTMs are required to be trained in new cities.<br /> <br /> In this paper, the authors use IMPALA  to train the agents because IMPALA can get similar performance to A3C . The authors use 256 actors for CityNav and 512 actors for MultiCityNav, with batch sizes of 256 or 512 respectively, and sequences are unrolled to length 50.<br /> <br /> ===Curriculum Learning===<br /> In curriculum learning, the model is trained using simple examples in first steps. As soon as the model learns those examples, more complex and difficult examples would be fed to the model. In this paper, this approach is used to teach agent to navigate to further destinations. This courier task suffers from a common problem of RL tasks which is sparse rewards (similar to Montezuma’s Revenge) . To overcome this problem, a natural curriculum scheme is defined, in which sampling each new goal would be within 500m of the agent’s position. This is called phase 1. In phase 2, the maximum range is gradually increased to cover the full graph (3.5km in the smaller New York areas, or 5km for central London or Downtown Manhattan)<br /> <br /> ==Results==<br /> In this section, the performance of the proposed architectures on the courier task is shown.<br /> <br /> [[File:figure5-2.png|600px|thumb|center|Figure 5. Average per-episode goal rewards (y-axis) are plotted vs. learning steps (x-axis) for the courier task in the NYU (New York City) environment (top), and in central London (bottom). We compare the GoalNav agent, the CityNav agent, and the CityNav agent without skip connection on the NYU environment, and the CityNav agent in London. We also compare the Oracle performance and a Heuristic agent, described below. The London agents were trained with a 2-phase curriculum– we indicate the end of phase 1 (500m only) and the end of phase 2 (500m to 5000m). Results on the Rive Gauche part of Paris (trained in the same way<br /> as in London) are comparable and the agent achieved mean goal reward 426.]]<br /> <br /> It is first shown that the CityNav agent, trained with curriculum learning, succeeds in learning the courier task in New York, London and Paris. Figure 5 compares the following agents:<br /> <br /> 1. Goal Navigation agent.<br /> <br /> 2. City Navigation Agent.<br /> <br /> 3. A City Navigation agent without the skip connection from the vision layers to the policy LSTM. This is needed to regularise the interface between the goal LSTM and the policy LSTM in multi-city transfer scenario.<br /> <br /> Also, a lower bound (Heuristic) and an upper bound(Oracle) on the performance is considered. As it is said in the paper: &quot;Heuristic is a random walk on the street graph, where the agent turns in a random direction if it cannot move forward; if at an intersection it will turn with a probability &lt;math&gt;P=0.95&lt;/math&gt;. Oracle uses the full graph to compute the optimal path using breadth-first search.&quot;. As it is clear in Figure 5, CityNav architecture with the previously mentioned architecture attains a higher performance and is more stable than the simpler GoalNav agent.<br /> <br /> The trajectories of the trained agent over two 1000 step episodes and the value function of the agent during navigation to a destination is shown in Figure 6.<br /> <br /> [[File:figure6-soroush.png|400px|thumb|center|Figure 6. Trained CityNav agent’s performance in two environments: Central London (left panes), and NYU (right panes). Top: examples of the agent’s trajectory during one 1000-step episode, showing successful consecutive goal acquisitions. The arrows show the direction of travel of the agent. Bottom: We visualize the value function of the agent during 100 trajectories with random starting points and the same goal (respectively St Paul’s Cathedral and Washington Square). Thicker and warmer color lines correspond to higher value functions.]]<br /> <br /> Figure 7 shows that navigation policy is learned by agent successfully in St Paul’s Cathedral in London and Washington Square in New York.<br /> [[File:figure7-soroush.png|400px|thumb|center|Figure 7. Number of steps required for the CityNav agent to reach<br /> a goal (Washington Square in New York or St Paul’s Cathedral in<br /> London) from 100 start locations vs. the straight-line distance to<br /> the goal in meters. One agent step corresponds to a forward movement<br /> of about 10m or a left/right turn by 22.5 or 67.5 degrees.]]<br /> <br /> The authors mask 25% of the possible goals and train on the remaining ones in order to investigate the generalisation capability of a trained agent. Figure 8 Showa that the agent is still able to traverse through these areas, it just never samples a goal there. <br /> [[File:fff8.png|600px|center]]<br /> <br /> A critical test for this article is to transfer model to new cities by learning a new set of landmarks, but without re-learning visual representation, behaviors, etc. Therefore, the MultiCityNav agent is trained on a number of cities besides freezing both the policy LSTM and the convolutional encoder. Then a new locale-specific goal LSTM is trained. The performance is compared using three different training regimes, illustrated in Fig. 9: Training on only the target city (single training); training on multiple cities, including the target city, together (joint training); and joint training on all but the target city, followed by training on the target city with the rest of the architecture frozen (pre-train and transfer). Figure 10 shows that transferring to other cities is possible. Also, training the model on more cities would increase its effectiveness. According to the paper: &quot;Remarkably, the agent that is pre-trained on 4 regions and then transferred to Wall Street achieves comparable performance to an agent trained jointly on all the regions, and only slightly worse than single-city training on Wall Street alone&quot;. Training the model in a single city using skip connection is useful. However, it is not useful in multi-city transferring.<br /> [[File:figure9-soroush.png|400px|thumb|center|Figure 9. Illustration of training regimes: (a) training on a single city (equivalent to CityNav); (b) joint training over multiple cities with a dedicated per-city pathway and shared convolutional net and policy LSTM; (c) joint pre-training on a number of cities followed by training on a target city with convolutional net and policy LSTM frozen (only the target city pathway is optimized).]]<br /> [[File:figure10-soroush.png|400px|thumb|center|Figure 10. Joint multi-city training and transfer learning performance of variants of the MultiCityNav agent evaluated only on the target city (Wall Street). We compare single-city training on the target environment alone vs. joint training on multiple cities (3, 4, or 5-way joint training including Wall Street), vs. pre-training on multiple cities and then transferring to Wall Street while freezing the entire agent except for the new pathway (see Fig. 10). One variant has skip connections between the convolutional encoder and the policy LSTM, the other does not (no-skip).]]<br /> <br /> Giving early rewards before agent reaches the goal or adding random rewards (coins) to encourage exploration is investigated in this article. Figure 11a suggests that coins by themselves are ineffective as our task does not benefit from wide explorations. Also, as it is clear from Figure 11b, reducing the density of the landmarks does not seem to reduce the performance. Based on the results, authors chose to start sampling the goal within a radius of 500m from the agent’s location, and then progressively extend it to the maximum distance an agent could travel within the environment. In addition, to asses the importance of the goal-conditioned agents, a Goal-less CityNav agent is trained by removing inputs gt. The poor performance of this agent is clear in Figure 11b. Furthermore, reducing the density of the landmarks by the ratio of 50%, 25%, and 12:5% does not reduce the performance that much. Finally, some alternative for goal representation is investigated:<br /> <br /> a) Latitude and longitude scalar coordinates normalized to be between 0 and 1.<br /> <br /> b) Binned representation. <br /> <br /> The latitude and longitude scalar goal representations perform the best. However, since the all landmarks representation performs well while remaining independent of the coordinate system, we use this representation as the canonical one.<br /> <br /> [[File:figure11-soroush.PNG|300px|thumb|center|Figure 11. Top: Learning curves of the CityNav agent on NYU, comparing reward shaping with different radii of early rewards (ER) vs. ER with random coins vs. curriculum learning with ER 200m and no coins (ER 200m, Curr.). Bottom: Learning curves for CityNav agents with different goal representations: landmark-based, as well as latitude and longitude classification-based and regression-based.]]<br /> <br /> ==Conclusion==<br /> In this paper, a deep reinforcement learning approach that enables navigation in cities is presented through the use of Google StreetView for its photographic content and worldwide coverage. Furthermore, the authors discussed a new courier task and a multi-city neural network agent architecture that is able to be transferred to new cities. A successful navigation architecture is presented which relies on integration of general policies with locale-specific knowledge.<br /> <br /> ==Critique==<br /> 1. It is not clear how this model is applicable in the real world. A real-world navigation problem needs to detect objects, people, and cars. However, it is not clear whether they are modelling them or not. From what I understood, they did not care about the collision, which is against their claim that it is a real-world problem.<br /> <br /> 2. This paper is only using static Google Street View images as its primary source of data. But the authors must at least complement this with other dynamic data like traffic and road blockage information for a realistic model of navigation in the world. Also, this is quite understandable not to use maps but is not clear why have they not used GPS to know their position and maybe even made up with a map. This can be something useful in an emergency or even for investigating places that are not known or there is no access to them. The resulting map could be easily compared with the real one and could also be used in training to achieve higher performance. The availability should not be a serious problem because if they are simulating a real city and the google images are available, why should not GPS be? What is the intuition? At lease a complementary description on this could be helpful.<br /> <br /> 3. The 'Transfer in Multi-City Experiments' results could be strengthened significantly via cross-validation (only Wall Street, which covers the smallest area of the four regions, is used as the test case). Additionally, the results do not show true 'multi-city' transfer learning, since all regions are within New York City. It is stated in the paper that not having to re-learn visual representations when transferring between cities is one of the outcomes, but the tests do not actually check for this. There are likely significant differences in the features that would be learned in NYC vs. Waterloo, for example, and this type of transfer has not been evaluated.<br /> <br /> ==Reference==<br />  Espeholt, Lasse, Soyer, Hubert, Munos, Remi, Simonyan, Karen, Mnih, Volodymir, Ward, Tom, Doron, Yotam, Firoiu, Vlad, Harley, Tim, Dunning, Iain, Legg, Shane, and Kavukcuoglu, Koray. Impala: Scalable distributed deep-rl with importance weighted actor-learner architec- tures. arXiv preprint arXiv:1802.01561, 2018.<br /> <br />  Mnih, Volodymyr, Badia, Adria Puigdomenech, Mirza, Mehdi, Graves, Alex, Lillicrap, Timothy, Harley, Tim, Silver, David, and Kavukcuoglu, Koray. Asynchronous methods for deep reinforcement learning. In Interna- tional Conference on Machine Learning, pp. 1928–1937, 2016.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=Learning_to_Navigate_in_Cities_Without_a_Map&diff=40881 Learning to Navigate in Cities Without a Map 2018-11-22T16:35:21Z <p>Jmmoosa: /* Architectures */</p> <hr /> <div>Paper: <br /> Learning to Navigate in Cities Without a Map[https://arxiv.org/pdf/1804.00168.pdf]<br /> A video of the paper is available here[https://sites.google.com/view/streetlearn].<br /> <br /> == Introduction ==<br /> Navigation is an attractive topic in many research disciplines and technology related domains such as neuroscience and robotics. The majority of algorithms are based on the following steps.<br /> <br /> 1. Building an explicit map<br /> <br /> 2. Planning and acting using that map. <br /> <br /> In this article, based on this fact that human can learn to navigate through cities without using any special tool such as maps or GPS, authors propose new methods to show that a neural network agent can do the same thing by using visual observations. To do so, an interactive environment using Google StreetView Images and a dual pathway agent architecture is designed. As shown in figure 1, some parts of the environment are built using Google StreetView images of New York City (Times Square, Central Park) and London (St. Paul’s Cathedral). The green cone represents the agent’s location and orientation. Although learning to navigate using visual aids is shown to be successful in some domains such as games and simulated environments using deep reinforcement learning (RL), it suffers from data inefficiency and sensitivity to changes in the environment. Thus, it is unclear whether this method could be used for large-scale navigation. That’s why it became the subject of investigation in this paper.<br /> [[File:figure1-soroush.png|600px|thumb|center|Figure 1. Our environment is built of real-world places from StreetView. The figure shows diverse views and corresponding local maps (neither map nor current position have not been used by the agent) in New York City (Times Square, Central Park) and London (St. Paul’s Cathedral). The green cone represents the agent’s location and orientation.]]<br /> <br /> ==Contribution==<br /> This paper has made the following contributions:<br /> <br /> 1. Designing a dual pathway agent architecture. This agent can navigate through a real city and is trained with end-to-end reinforcement learning to handle real-world navigations.<br /> <br /> 2. Using Goal-dependent learning. This means that the policy and value functions must adapt themselves to a sequence of goals that are provided as input.<br /> <br /> 3. Leveraging a recurrent neural architecture. Using that, not only could navigation through a city be possible, but also the model is scalable for navigation in new cities. This architecture supports both locale-specific learnings and general transferable navigations. The authors achieved these by separating a recurrent neural pathway. This pathway receives and interprets the current goal as well as encapsulates and memorizes features of a single region.<br /> <br /> 4. Using a new environment which is built on top of Google StreetView images. This provides real-world images for agent’s observation. Using this environment, the agent can navigate from an arbitrary starting point to a goal and then to another goal etc. Also, London, Paris, and New York City are chosen for navigation.<br /> <br /> ==Related Work==<br /> <br /> 1. Localization from real-world imagery. For example, (Weyand et al., 2016), a CNN was able to achieve excellent results on geolocation task. This paper provides novel work by not including supervised training with ground-truth labels, and by including planning as a goal. Some other works also improve by exploiting spatiotemporal continuity or estimating camera pose or depth estimation from pixels. These methods rely on supervised training with ground truth labels, which is not possible in every environment. <br /> <br /> 2. Deep RL methods for navigation. For instance, (Mirowski et al., 2016; Jaderberg et al., 2016) used self-supervised auxiliary tasks to produce visual navigation in several created mazes. Some other researches used text descriptions to incorporate goal instructions. Researchers developed realistic, higher-fidelity environment simulations to make the experiment more realistic, but that still came with lack of diversities. This paper makes use of real-world data, in contrast to many related papers in this area. It's diverse and visually realistic but still, it does not contain dynamic elements, and the street topology cannot be regenerated or altered.<br /> <br /> 3. Deep RL for path planning and mapping. For example, (Zhang et al., 2017) created an agent that represented a global map via an RL agent with external memory; some other work uses a hierarchical control strategy to propose a structured memory and Memory Augmented Control Maps. Explicit neural mapper and navigation planner with joint training was also used. Among all these works, the target-driven visual navigation with a goal-conditional policy approach was most related to our method.<br /> <br /> ==Environment==<br /> Google StreetView consists of both high-resolution 360-degree imagery and graph connectivity. Also, it provides a public API. These features make it a valuable resource. In this work, large areas of New York, Paris, and London that contain between 7,000 and 65,500 nodes<br /> (and between 7,200 and 128,600 edges, respectively), have a mean node spacing of 10m and cover a range of up to<br /> 5km chosen (Figure 2), without simplifying the underlying connections. This means that there are many areas 'congested' with nodes, occlusions, available footpaths, etc. The agent only sees RGB images that are visible in StreetView images (Figure 1) and is not aware of the underlying graph.<br /> <br /> [[File:figure2-soroush.png|700px|thumb|center|Figure 2. Map of the 5 environments in New York City; our experiments focus on the NYU area as well as on transfer learning from the other areas to Wall Street (see Section 5.3). In the zoomed in area, each green dot corresponds to a unique panorama, the goal is marked in blue, and landmark locations are marked with red pins.]]<br /> <br /> ==Agent Interface and the Courier Task==<br /> In an RL environment, we need to define observations and actions in addition to tasks. The inputs to the agent are the image &lt;math&gt;x_t&lt;/math&gt; and the goal &lt;math&gt;g_t&lt;/math&gt;. Also, a first-person view of the 3D environment is simulated by cropping &lt;math&gt;x_t&lt;/math&gt; to a 60-degree square RGB image that is scaled to 84*84 pixels. Furthermore, the action space consists of 5 movements: “slow” rotate left or right (±22:5), “fast” rotate left or right (±67.5), or move forward (implemented as a ''noop'' in the case where this is not a viable action). The most central edge is chosen if there are multiple edges in the agents viewing cone.<br /> <br /> There are lots of ways to specify the goal to the agent. In this paper, the current goal is chosen to be represented in terms of its proximity to a set L of fixed landmarks &lt;math&gt; L={(Lat_k, Long_k)}&lt;/math&gt; which are specified using Latitude and Longitude coordinate system. For distance to the &lt;math&gt; k_{th}&lt;/math&gt; landmark &lt;math&gt;{(d_{(t,k)}^g})_k&lt;/math&gt; the goal vector contains &lt;math&gt; g_{(t,i)}=\tfrac{exp⁡(-αd_{(t,i)}^g)}{∑_k exp⁡(-αd_{(t,k)}^g)} &lt;/math&gt;for &lt;math&gt;i_{th}&lt;/math&gt; landmark with &lt;math&gt;α=0.002&lt;/math&gt; (Figure 3).<br /> <br /> [[File:figure3-soroush.PNG|400px|thumb|center|Figure 3. We illustrate the goal description by showing a goal and a set of 5 landmarks that are nearby, plus 4 that are more distant. The code &lt;math&gt;g_i&lt;/math&gt; is a vector with a softmax-normalised distance to each landmark.]]<br /> <br /> This form of representation has several advantages: <br /> <br /> 1. It could easily be extended to new environments.<br /> <br /> 2. It is intuitive. Even humans and animals use landmarks to be able to move from one place to another.<br /> <br /> 3. It does not rely on arbitrary map coordinates, and provides an absolute (as opposed to relative) goal.<br /> <br /> In this work, 644 landmarks for New York, Paris, and London are manually defined. The courier task is the problem of navigating to a list of random locations within a city. In each episode, which consists of 1000 steps, the agent starts from a random place with random orientation. when an agent gets within 100 meters of goal, the next goal is randomly chosen. An episode ends after 1000 agent steps. Finally, the reward is proportional to the shortest path between agent and goal when the goal is first assigned (providing more reward for longer journeys). Thus the agent needs to learn the mapping between the images observed at the goal location and the goal vector in order to solve the courier task problem. Furthermore, the agent must learn the association between the images observed at its current location and the policy to reach the goal destination.<br /> <br /> ==Methods==<br /> <br /> ===Goal-dependent Actor-Critic Reinforcement Learning===<br /> In this paper, the learning problem is based on Markov Decision Process, with state space &lt;math&gt;\mathcal{S}&lt;/math&gt;, action space &lt;math&gt;\mathcal{A}&lt;/math&gt;, environment &lt;math&gt;\mathcal{E}&lt;/math&gt;, and a set of possible goals &lt;math&gt;\mathcal{G}&lt;/math&gt;. The reward function depends on the current goal and state: &lt;math&gt;\mathcal{R}: \mathcal{S} \times \mathcal{G} \times \mathcal{A} &amp;rarr; \mathbb{R}&lt;/math&gt;. Typically, in reinforcement learning the main goal is to find the policy which maximizes the expected return. Expected return is defined as the sum of<br /> discounted rewards starting from state &lt;math&gt;s_0&lt;/math&gt; with discount &lt;math&gt;\gamma&lt;/math&gt;. Also, the expected return from a state &lt;math&gt;s_t&lt;/math&gt; depends on the goals that are sampled. The policy is defined as a distribution over the actions, given the current state &lt;math&gt;s_t&lt;/math&gt; and the goal &lt;math&gt;g_t&lt;/math&gt;: <br /> <br /> \begin{align}<br /> \pi(\alpha|s,g)=Pr(\alpha_t=\alpha|s_t=s, g_t=g)<br /> \end{align}<br /> <br /> Value function is defined as the expected return obtained by sampling actions from policy &lt;math&gt;\pi&lt;/math&gt; from state &lt;math&gt;s_t&lt;/math&gt; with goal &lt;math&gt;g_t&lt;/math&gt;:<br /> <br /> \begin{align}<br /> V^{\pi}(s,g)=E[R_t]=E[Σ_{k=0}^{\infty}\gamma^kr_{t+k}|s_t=s, g_t=g]<br /> \end{align}<br /> <br /> Also, an architecture with multiple pathways is designed to support two types of learning that is required for this problem. First, an agent needs an internal representation which is general and gives an understanding of a scene. Second, to better understand a scene the agent needs to remember unique features of the scene which then help the agent to organize and remember the scenes.<br /> <br /> ===Architectures===<br /> <br /> [[File:figure4-soroush.png|400px|thumb|center|Figure 4. Comparison of architectures. Left: GoalNav is a convolutional encoder plus policy LSTM with goal description input. Middle: CityNav is a single-city navigation architecture with a separate goal LSTM and optional auxiliary heading (θ). Right: MultiCityNav is a multi-city architecture with individual goal LSTM pathways for each city.]]<br /> <br /> The authors use neural networks to parameterize policy and value functions. These neural networks share weights in all layers except the final linear layer. The agent takes image pixels as input. These pixels are passed through a convolutional network. The output of the Convolution network is fed to a Long Short-Term Memory (LSTM) as well as the past reward &lt;math&gt;r_{t-1}&lt;/math&gt; and previous action &lt;math&gt;\alpha_{t-1}&lt;/math&gt;.<br /> <br /> Three different architectures are described below.<br /> <br /> The '''GoalNav''' architecture (Fig. 4a) which consists of a convolutional architecture and policy LSTM. Goal description &lt;math&gt;g_t&lt;/math&gt;, previous action, and reward are the inputs of this LSTM.<br /> <br /> The '''CityNav''' architecture (Fig. 4b) consists of the previous architecture alongside an additional LSTM, called the goal LSTM. Inputs of this LSTM are visual features and the goal description. The CityNav agent also adds an auxiliary heading (θ) prediction task which is defined as an angle between the north direction and the agent’s pose. This auxiliary task can speed up learning and provides relevant information. <br /> <br /> The '''MultiCityNav''' architecture (Fig. 4c) is an extension of City-Nav for learning in different cities. This is done using the parallel connection of goal LSTMs for encapsulating locale-specific features, for each city. Moreover, the convolutional architecture and the policy LSTM become general after training on a number of cities. So, new goal LSTMs are required to be trained in new cities.<br /> <br /> In this paper, the authors use IMPALA  to train the agents because IMPALA can get similar performance to A3C. The authors use 256 actors for CityNav and 512 actors for MultiCityNav, with batch sizes of 256 or 512 respectively, and sequences are unrolled to length 50.<br /> <br /> ===Curriculum Learning===<br /> In curriculum learning, the model is trained using simple examples in first steps. As soon as the model learns those examples, more complex and difficult examples would be fed to the model. In this paper, this approach is used to teach agent to navigate to further destinations. This courier task suffers from a common problem of RL tasks which is sparse rewards (similar to Montezuma’s Revenge) . To overcome this problem, a natural curriculum scheme is defined, in which sampling each new goal would be within 500m of the agent’s position. This is called phase 1. In phase 2, the maximum range is gradually increased to cover the full graph (3.5km in the smaller New York areas, or 5km for central London or Downtown Manhattan)<br /> <br /> ==Results==<br /> In this section, the performance of the proposed architectures on the courier task is shown.<br /> <br /> [[File:figure5-2.png|600px|thumb|center|Figure 5. Average per-episode goal rewards (y-axis) are plotted vs. learning steps (x-axis) for the courier task in the NYU (New York City) environment (top), and in central London (bottom). We compare the GoalNav agent, the CityNav agent, and the CityNav agent without skip connection on the NYU environment, and the CityNav agent in London. We also compare the Oracle performance and a Heuristic agent, described below. The London agents were trained with a 2-phase curriculum– we indicate the end of phase 1 (500m only) and the end of phase 2 (500m to 5000m). Results on the Rive Gauche part of Paris (trained in the same way<br /> as in London) are comparable and the agent achieved mean goal reward 426.]]<br /> <br /> It is first shown that the CityNav agent, trained with curriculum learning, succeeds in learning the courier task in New York, London and Paris. Figure 5 compares the following agents:<br /> <br /> 1. Goal Navigation agent.<br /> <br /> 2. City Navigation Agent.<br /> <br /> 3. A City Navigation agent without the skip connection from the vision layers to the policy LSTM. This is needed to regularise the interface between the goal LSTM and the policy LSTM in multi-city transfer scenario.<br /> <br /> Also, a lower bound (Heuristic) and an upper bound(Oracle) on the performance is considered. As it is said in the paper: &quot;Heuristic is a random walk on the street graph, where the agent turns in a random direction if it cannot move forward; if at an intersection it will turn with a probability &lt;math&gt;P=0.95&lt;/math&gt;. Oracle uses the full graph to compute the optimal path using breadth-first search.&quot;. As it is clear in Figure 5, CityNav architecture with the previously mentioned architecture attains a higher performance and is more stable than the simpler GoalNav agent.<br /> <br /> The trajectories of the trained agent over two 1000 step episodes and the value function of the agent during navigation to a destination is shown in Figure 6.<br /> <br /> [[File:figure6-soroush.png|400px|thumb|center|Figure 6. Trained CityNav agent’s performance in two environments: Central London (left panes), and NYU (right panes). Top: examples of the agent’s trajectory during one 1000-step episode, showing successful consecutive goal acquisitions. The arrows show the direction of travel of the agent. Bottom: We visualize the value function of the agent during 100 trajectories with random starting points and the same goal (respectively St Paul’s Cathedral and Washington Square). Thicker and warmer color lines correspond to higher value functions.]]<br /> <br /> Figure 7 shows that navigation policy is learned by agent successfully in St Paul’s Cathedral in London and Washington Square in New York.<br /> [[File:figure7-soroush.png|400px|thumb|center|Figure 7. Number of steps required for the CityNav agent to reach<br /> a goal (Washington Square in New York or St Paul’s Cathedral in<br /> London) from 100 start locations vs. the straight-line distance to<br /> the goal in meters. One agent step corresponds to a forward movement<br /> of about 10m or a left/right turn by 22.5 or 67.5 degrees.]]<br /> <br /> The authors mask 25% of the possible goals and train on the remaining ones in order to investigate the generalisation capability of a trained agent. Figure 8 Showa that the agent is still able to traverse through these areas, it just never samples a goal there. <br /> [[File:fff8.png|600px|center]]<br /> <br /> A critical test for this article is to transfer model to new cities by learning a new set of landmarks, but without re-learning visual representation, behaviors, etc. Therefore, the MultiCityNav agent is trained on a number of cities besides freezing both the policy LSTM and the convolutional encoder. Then a new locale-specific goal LSTM is trained. The performance is compared using three different training regimes, illustrated in Fig. 9: Training on only the target city (single training); training on multiple cities, including the target city, together (joint training); and joint training on all but the target city, followed by training on the target city with the rest of the architecture frozen (pre-train and transfer). Figure 10 shows that transferring to other cities is possible. Also, training the model on more cities would increase its effectiveness. According to the paper: &quot;Remarkably, the agent that is pre-trained on 4 regions and then transferred to Wall Street achieves comparable performance to an agent trained jointly on all the regions, and only slightly worse than single-city training on Wall Street alone&quot;. Training the model in a single city using skip connection is useful. However, it is not useful in multi-city transferring.<br /> [[File:figure9-soroush.png|400px|thumb|center|Figure 9. Illustration of training regimes: (a) training on a single city (equivalent to CityNav); (b) joint training over multiple cities with a dedicated per-city pathway and shared convolutional net and policy LSTM; (c) joint pre-training on a number of cities followed by training on a target city with convolutional net and policy LSTM frozen (only the target city pathway is optimized).]]<br /> [[File:figure10-soroush.png|400px|thumb|center|Figure 10. Joint multi-city training and transfer learning performance of variants of the MultiCityNav agent evaluated only on the target city (Wall Street). We compare single-city training on the target environment alone vs. joint training on multiple cities (3, 4, or 5-way joint training including Wall Street), vs. pre-training on multiple cities and then transferring to Wall Street while freezing the entire agent except for the new pathway (see Fig. 10). One variant has skip connections between the convolutional encoder and the policy LSTM, the other does not (no-skip).]]<br /> <br /> Giving early rewards before agent reaches the goal or adding random rewards (coins) to encourage exploration is investigated in this article. Figure 11a suggests that coins by themselves are ineffective as our task does not benefit from wide explorations. Also, as it is clear from Figure 11b, reducing the density of the landmarks does not seem to reduce the performance. Based on the results, authors chose to start sampling the goal within a radius of 500m from the agent’s location, and then progressively extend it to the maximum distance an agent could travel within the environment. In addition, to asses the importance of the goal-conditioned agents, a Goal-less CityNav agent is trained by removing inputs gt. The poor performance of this agent is clear in Figure 11b. Furthermore, reducing the density of the landmarks by the ratio of 50%, 25%, and 12:5% does not reduce the performance that much. Finally, some alternative for goal representation is investigated:<br /> <br /> a) Latitude and longitude scalar coordinates normalized to be between 0 and 1.<br /> <br /> b) Binned representation. <br /> <br /> The latitude and longitude scalar goal representations perform the best. However, since the all landmarks representation performs well while remaining independent of the coordinate system, we use this representation as the canonical one.<br /> <br /> [[File:figure11-soroush.PNG|300px|thumb|center|Figure 11. Top: Learning curves of the CityNav agent on NYU, comparing reward shaping with different radii of early rewards (ER) vs. ER with random coins vs. curriculum learning with ER 200m and no coins (ER 200m, Curr.). Bottom: Learning curves for CityNav agents with different goal representations: landmark-based, as well as latitude and longitude classification-based and regression-based.]]<br /> <br /> ==Conclusion==<br /> In this paper, a deep reinforcement learning approach that enables navigation in cities is presented through the use of Google StreetView for its photographic content and worldwide coverage. Furthermore, the authors discussed a new courier task and a multi-city neural network agent architecture that is able to be transferred to new cities. A successful navigation architecture is presented which relies on integration of general policies with locale-specific knowledge.<br /> <br /> ==Critique==<br /> 1. It is not clear how this model is applicable in the real world. A real-world navigation problem needs to detect objects, people, and cars. However, it is not clear whether they are modelling them or not. From what I understood, they did not care about the collision, which is against their claim that it is a real-world problem.<br /> <br /> 2. This paper is only using static Google Street View images as its primary source of data. But the authors must at least complement this with other dynamic data like traffic and road blockage information for a realistic model of navigation in the world. Also, this is quite understandable not to use maps but is not clear why have they not used GPS to know their position and maybe even made up with a map. This can be something useful in an emergency or even for investigating places that are not known or there is no access to them. The resulting map could be easily compared with the real one and could also be used in training to achieve higher performance. The availability should not be a serious problem because if they are simulating a real city and the google images are available, why should not GPS be? What is the intuition? At lease a complementary description on this could be helpful.<br /> <br /> 3. The 'Transfer in Multi-City Experiments' results could be strengthened significantly via cross-validation (only Wall Street, which covers the smallest area of the four regions, is used as the test case). Additionally, the results do not show true 'multi-city' transfer learning, since all regions are within New York City. It is stated in the paper that not having to re-learn visual representations when transferring between cities is one of the outcomes, but the tests do not actually check for this. There are likely significant differences in the features that would be learned in NYC vs. Waterloo, for example, and this type of transfer has not been evaluated.<br /> <br /> ==Reference==<br />  Espeholt, Lasse, Soyer, Hubert, Munos, Remi, Simonyan, Karen, Mnih, Volodymir, Ward, Tom, Doron, Yotam, Firoiu, Vlad, Harley, Tim, Dunning, Iain, Legg, Shane, and Kavukcuoglu, Koray. Impala: Scalable distributed deep-rl with importance weighted actor-learner architec- tures. arXiv preprint arXiv:1802.01561, 2018.<br /> <br />  Mnih, Volodymyr, Badia, Adria Puigdomenech, Mirza, Mehdi, Graves, Alex, Lillicrap, Timothy, Harley, Tim, Silver, David, and Kavukcuoglu, Koray. Asynchronous methods for deep reinforcement learning. In Interna- tional Conference on Machine Learning, pp. 1928–1937, 2016.</div> Jmmoosa http://wiki.math.uwaterloo.ca/statwiki/index.php?title=Mapping_Images_to_Scene_Graphs_with_Permutation-Invariant_Structured_Prediction&diff=40880 Mapping Images to Scene Graphs with Permutation-Invariant Structured Prediction 2018-11-22T16:22:19Z <p>Jmmoosa: /* Experimental Results */</p> <hr /> <div>The paper ''Mapping Images to Scene Graphs with Permutation-Invariant Structured Prediction'' was written by Roei Herzig* from Tel Aviv University, Moshiko Raboh* from Tel Aviv University, Gal Chechik from Google Brain, Bar-Ilan University, Jonathan Berant from Tel Aviv University, and Amir Globerson from Tel Aviv University. This paper is part of the NIPS 2018 conference to be hosted in December 2018 at Montréal, Canada. This paper summary is based on version 3 of the pre-print (as of May 2018) obtained from [https://arxiv.org/pdf/1802.05451v3.pdf arXiv] <br /> <br /> (*) Equal contribution<br /> <br /> =Motivation=<br /> In the field of artificial intelligence, a major goal is to enable machines to understand complex images, such as the underlying relationships between objects that exist in each scene. Although there are models today that capture both complex labels and interactions between labels, there is a disconnect for what guidelines should be used when leveraging deep learning. This paper introduces a design principle for such models that stem from the concept of permutation invariance and proves state of the art performance on models that follow this principle.<br /> <br /> The primary contributions that this paper makes include:<br /> # Deriving sufficient and necessary conditions for respecting graph-permutation invariance in deep structured prediction architectures<br /> # Empirically proving the benefit of graph-permutation invariance<br /> # Developing a state-of-the-art model for scene graph predictions over a large set of complex visual scenes<br /> <br /> =Introduction=<br /> In order to make a machine to interpret complex visual scenes, it must recognize and understand both objects and relationships between the objects in the scene. A '''scene graph''' is a representation of the set of objects and relations that exist in the scene, where objects are represented as nodes, relations are represented as edges connecting the different nodes. Hence, the prediction of the scene graph is analogous to inferring the joint set of objects and relations of a visual scene.<br /> <br /> [[File:scene_graph_example.png|600px|center]]<br /> <br /> Given that objects in scenes are interdependent on each other, joint prediction of the objects and relations is necessary. The field of structured prediction, which involves the general problem of inferring multiple inter-dependent labels, is of interest for this problem.<br /> <br /> In structured prediction models, a score function &lt;math&gt;s(x, y)&lt;/math&gt; is defined to evaluate the compatibility between label &lt;math&gt;y&lt;/math&gt; and input &lt;math&gt;x&lt;/math&gt;. For instance, when interpreting the scene of an image, &lt;math&gt;x&lt;/math&gt; refers to the image itself, and &lt;math&gt;y&lt;/math&gt; refers to a complex label, which contains both the objects and the relations between objects. As with most other inference methods, the goal is to find the label &lt;math&gt;y^*&lt;/math&gt; such that &lt;math&gt;s(x,y)&lt;/math&gt; is maximized, &lt;math&gt; y^*=argmax_y s(x,y)&lt;/math&gt;. However, the major concern is that the space for possible label assignments grows exponentially with respect to input size. For example, although an image may seem very simple, the corpus containing possible labels for objects may be very large, rendering it difficult to optimize the scoring function. <br /> <br /> The paper presents an alternative approach, for which input &lt;math&gt;x&lt;/math&gt; is mapped to structured output &lt;math&gt;y&lt;/math&gt; using a &quot;black box&quot; neural network, omitting the definition of a score function. The main concern for this approach is the determination of the network architecture.<br /> <br /> The model is evaluated by firstly demonstrating the importance of permutation invariance on a synthetic data set. The approach laid out by the authors is then shown to respect permutation invariance, and results are compared to a competitive benchmark. This method achieves state-of-the-art results.<br /> <br /> =Structured prediction=<br /> This paper further considers structured predictions using score-based methods. For structured predictions that follow a score-based approach, a score function &lt;math&gt;s(x, y)&lt;/math&gt; is used to measure how compatible label &lt;math&gt;y&lt;/math&gt; is for input &lt;math&gt;x&lt;/math&gt; and is also used to infer a label by maximizing &lt;math&gt;s(x, y)&lt;/math&gt;. To optimize the score function, previous works have decomposed &lt;math&gt;s(x,y) = \sum_i f_i(x,y)&lt;/math&gt; in order to facilitate efficient optimization which is done by optimizing the local score function, &lt;math&gt;\max_y f_i(x,y)&lt;/math&gt;, with a small subset of the &lt;math&gt;y&lt;/math&gt; variables.<br /> <br /> Recently, modeling the &lt;math&gt;f_i &lt;/math&gt; functions as deep networks is a new interest. In such area of structured predictions, the most commonly-used score functions include the singleton score function &lt;math&gt;f_i(y_i, x)&lt;/math&gt; and pairwise score function &lt;math&gt;f_{ij} (y_i, y_j, x)&lt;/math&gt;. Previous works explored a two-stage architectures (learn local scores independently of the structured prediction goal), end-to-end architectures (to include the inference algorithm within the computation graph), and modelling global factors. <br /> <br /> ==Advantages of using score-based methods==<br /> # Allow for intuitive specification of local dependencies between labels, and how they map to global dependencies<br /> # Linear score functions offer natural convex surrogates<br /> # Inference in large label space is sometimes possible via exact algorithms or empirically accurate approximations<br /> <br /> The concern for modelling score functions using deep networks is that learning may no longer be convex. Hence, the paper presents properties for how deep networks can be used for structured predictions by considering architectures that do not require explicit maximization of a score function.<br /> <br /> =Background, Notations, and Definitions=<br /> We denote &lt;math&gt;y&lt;/math&gt; as a structured label where &lt;math&gt;y = [y_1, \dots, y_n]&lt;/math&gt;<br /> <br /> '''Score functions:''' for score-based methods, the score is defined as either the sum of a set of singleton scores &lt;math&gt;f_i = f_i(y_i, x)&lt;/math&gt; or the sum of pairwise scores &lt;math&gt;f_{ij} = f_{ij}(y_i, y_j, x)&lt;/math&gt;.<br /> <br /> Let &lt;math&gt;s(x,y)&lt;/math&gt; be the score of a score-based method. Then:<br /> <br /> &lt;div align=&quot;center&quot;&gt;<br /> &lt;math&gt;s(x,y) = \begin{cases}<br /> \sum_i f_i ~ \text{if we have a set of singleton scores}\\<br /> \sum_{ij} f_{ij} ~ \text{if we have a set of pairwise scores } \\<br /> \end{cases}&lt;/math&gt;<br /> &lt;/div&gt;<br /> <br /> '''Inference algorithm:''' an inference algorithm takes input set of local scores (either &lt;math&gt;f_i&lt;/math&gt; or &lt;math&gt;f_{ij}&lt;/math&gt;) and outputs an assignment of labels &lt;math&gt;y_1, \dots, y_n&lt;/math&gt; that maximizes score function &lt;math&gt;s(x,y)&lt;/math&gt;<br /> <br /> '''Graph labeling function:''' a graph labeling function &lt;math&gt;\mathcal{F} : (V,E) \rightarrow Y&lt;/math&gt; is a function that takes input of: an ordered set of node features &lt;math&gt;V = [z_1, \dots, z_n]&lt;/math&gt; and an ordered set of edge features &lt;math&gt;E = [z_{1,2},\dots,z_{i,j},\dots,z_{n,n-1}]&lt;/math&gt; to output set of node labels &lt;math&gt;\mathbf{y} = [y_1, \dots, y_n]&lt;/math&gt;. For instance, &lt;math&gt;z_i&lt;/math&gt; can be set equal to &lt;math&gt;f_i&lt;/math&gt; and &lt;math&gt;z_{ij}&lt;/math&gt; can be set equal to &lt;math&gt;f_{ij}&lt;/math&gt;.<br /> <br /> For convenience, the joint set of nodes and edges will be denoted as &lt;math&gt;\mathbf{z}&lt;/math&gt; to be a size &lt;math&gt;n^2&lt;/math&gt; vector (&lt;math&gt;n&lt;/math&gt; nodes and &lt;math&gt;n(n-1)&lt;/math&gt; edges).<br /> <br /> '''Permutation:''' Let &lt;math&gt;z&lt;/math&gt; be a set of node and edge features. Given a permutation &lt;math&gt;\sigma&lt;/math&gt; of &lt;math&gt;\{1,\dots,n\}&lt;/math&gt;, let &lt;math&gt;\sigma(z)&lt;/math&gt; be a new set of node and edge features given by [&lt;math&gt;\sigma(z)]_i = z_{\sigma(i)}&lt;/math&gt; and &lt;math&gt;[\sigma(z)]_{i,j} = z_{\sigma(i), \sigma(j)}&lt;/math&gt;<br /> <br /> '''One-hot representation:''' &lt;math&gt;\mathbf{1}[j]&lt;/math&gt; be a one-hot vector with 1 in the &lt;math&gt;j^{th}&lt;/math&gt; coordinate<br /> <br /> =Permutation-Invariant Structured prediction=<br /> <br /> With permutation-invariant structured prediction, we would expect the algorithm to produce the same result given the same score function. For instance, consider the case where we have label space for 3 variables &lt;math&gt;y_1, y_2, y_3&lt;/math&gt; with input &lt;math&gt;\mathbf{z} = (f_1, f_2, f_3, f_{12}, f_{13}, f_{23})&lt;/math&gt; that outputs label &lt;math&gt;\mathbf{y} = (y_1^*, y_2^*, y_3^*)&lt;/math&gt;. Then if the algorithm is run on a permuted version input &lt;math&gt;z' = (f_2, f_1, f_3, f_{21}, f_{23}, f_{13})&lt;/math&gt;, we would expect &lt;math&gt;\mathbf{y} = (y_2^*, y_1^*, y_3^*)&lt;/math&gt; given the same score function.<br /> <br /> '''Graph permutation invariance (GPI):''' a graph labeling function &lt;math&gt;\mathcal{F}&lt;/math&gt; is graph-permutation invariant, if for all permutations &lt;math&gt;\sigma&lt;/math&gt; of &lt;math&gt;\{1, \dots, n\}&lt;/math&gt; and for all nodes &lt;math&gt;z&lt;/math&gt;, &lt;math&gt;\mathcal{F}(\sigma(\mathbf{z})) = \sigma(\mathcal{F}(\mathbf{z}))&lt;/math&gt;<br /> <br /> The paper presents a theorem on the necessary and sufficient conditions for a function &lt;math&gt;\mathcal{F}&lt;/math&gt; to be graph permutation invariant. Intuitively, because &lt;math&gt;\mathcal{F}&lt;/math&gt; is a function that takes an ordered set &lt;math&gt;z&lt;/math&gt; as input, the output on &lt;math&gt;\mathbf{z}&lt;/math&gt; could very well be different from &lt;math&gt;\sigma(\mathbf{z})&lt;/math&gt;, which means &lt;math&gt;\mathcal{F}&lt;/math&gt; needs to have some sort of symmetry in order to sustain &lt;math&gt;[\mathcal{F}(\sigma(\mathbf{z}))]]_k = [\mathcal{F}(\mathbf{z})]_{\sigma(k)}&lt;/math&gt;.<br /> <br /> [[File:graph_permutation_invariance.jpg|400px|center]]<br /> <br /> ==Theorem 1==<br /> Let &lt;math&gt;\mathcal{F}&lt;/math&gt; be a graph labeling function. Then &lt;math&gt;\mathcal{F}&lt;/math&gt; is graph-permutation invariant if and only if there exist functions &lt;math&gt;\alpha, \rho, \phi&lt;/math&gt; such that for all &lt;math&gt;k=1, .., n&lt;/math&gt;:<br /> \begin{align}<br /> [\mathcal{F}(\mathbf{z})]_k = \rho(\mathbf{z}_k, \sum_{i=1}^n \alpha(\mathbf{z}_i, \sum_{i\neq j} \phi(\mathbf{z}_i, \mathbf{z}_{i,j}, \mathbf{z}_j)))<br /> \end{align}<br /> where &lt;math&gt;\phi: \mathbb{R}^{2d+e} \rightarrow \mathbb{R}^L, \alpha: \mathbb{R}^{d + L} \rightarrow \mathbb{R}^{W}, p: \mathbb{R}^{W+d} \rightarrow \mathbb{R}&lt;/math&gt;.<br /> <br /> Notice that for the dimensions of inputs and outputs, &lt;math&gt;d&lt;/math&gt; refers to the number of singleton features in &lt;math&gt;z&lt;/math&gt; and &lt;math&gt;e&lt;/math&gt; refers to the number of edges. <br /> <br /> [[File:GPI_architecture.jpg|thumb|A schematic representation of the GPI architecture. Singleton features &lt;math&gt;z_i&lt;/math&gt; are omitted for simplicity. First, the features &lt;math&gt;z_{i,j}&lt;/math&gt; are processed element-wise by &lt;math&gt;\phi&lt;/math&gt;. Next, they are summed to create a vector &lt;math&gt;s_i&lt;/math&gt;, which is concatenated with &lt;math&gt;z_i&lt;/math&gt;. Third, a representation of the entire graph is created by applying &lt;math&gt;\alpha\ n&lt;/math&gt; times and summing the created vector. The graph representation is then finally processed by &lt;math&gt;\rho&lt;/math&gt; together with &lt;math&gt;z_k&lt;/math&gt;.|600px|center]]<br /> <br /> ==Proof Sketch for Theorem 1==<br /> The proof of this theorem can be found in the paper. A proof sketch is provided below:<br /> <br /> '''For the forward direction''' (function that follows the form set out in equation (1) is GPI):<br /> # Using definition of permutation &lt;math&gt;\sigma&lt;/math&gt;, and rewriting &lt;math&gt;[F(z)]_{\sigma(k)}&lt;/math&gt; in the form from equation (1)<br /> # Second argument of &lt;math&gt;\rho&lt;/math&gt; is invariant under &lt;math&gt;\sigma&lt;/math&gt;, since it takes the sum of all indices &lt;math&gt;i&lt;/math&gt; and all other indices &lt;math&gt;j \neq i &lt;/math&gt;.<br /> <br /> '''For the backward direction''' (any black-box GPI function can be expressed in the form of equation 1):<br /> # Construct &lt;math&gt;\phi, \alpha&lt;/math&gt; such that second argument of &lt;math&gt;\rho&lt;/math&gt; contains all information about graph features of &lt;math&gt;z&lt;/math&gt;, including edges that the features originate from<br /> # Assume each &lt;math&gt;z_k&lt;/math&gt; uniquely identifies the node and &lt;math&gt;\mathcal{F}&lt;/math&gt; is a function only of pairwise features &lt;math&gt;z_{i,j}&lt;/math&gt;<br /> # Construct &lt;math&gt;H&lt;/math&gt; be a perfect hash function with &lt;math&gt;L&lt;/math&gt; buckets, and &lt;math&gt;\phi&lt;/math&gt; which maps '''pairwise features''' to a vector of size &lt;math&gt;L&lt;/math&gt;<br /> # &lt;math&gt;*&lt;/math&gt;Construct &lt;math&gt;\phi(z_i, z_{i,j}, z_j) = \mathbf{1}[H(z_j)] z_{i,j}&lt;/math&gt;, which intuitively means that &lt;math&gt;\phi&lt;/math&gt; stores &lt;math&gt;z_{i,j}&lt;/math&gt; in the unique bucket for node &lt;math&gt;j&lt;/math&gt;<br /> # Construct function &lt;math&gt;\alpha&lt;/math&gt; to output a matrix &lt;math&gt;\mathbb{R}^{L \times L}&lt;/math&gt; that maps each pairwise feature into unique positions (&lt;math&gt;\alpha(z_i, s_i) = \mathbf{1}[H(z_i)]s_i^T&lt;/math&gt;)<br /> # Construct matrix &lt;math&gt;M = \sum_i \alpha(z_i,s_i)&lt;/math&gt; by discarding rows/columns in &lt;math&gt;M&lt;/math&gt; that do not correspond to original nodes (which reduces dimension to &lt;math&gt;n\times n&lt;/math&gt;; set &lt;math&gt;\rho&lt;/math&gt; to have same outcome as &lt;math&gt;\mathcal{F}&lt;/math&gt;, and set the output of &lt;math&gt;\mathcal{F}&lt;/math&gt; on &lt;math&gt;M&lt;/math&gt; to be the labels &lt;math&gt;\mathbf{y} = y_1, \dots, y_n&lt;/math&gt;<br /> <br /> &lt;math&gt;*&lt;/math&gt;The paper presents the proof for the edge features &lt;math&gt;z_{ij}&lt;/math&gt; being scalar (&lt;math&gt;e = 1&lt;/math&gt;) for simplicity, which can be extended easily to vectors with additional indexing.<br /> <br /> Although the results discussed previously apply to complete graphs (edges apply to all feature pairs), it can be easily extended to incomplete graphs. For incomplete graphs, the input to F only contains the features corresponding to valid edges of the graph. The authors are only interested in invariances that preserve the graph structure. Thus, in place of permutation-invariance, it is now an automorphism-invariance.<br /> <br /> ==Implications and Applications of Theorem 1==<br /> ===Key Implications of Theorem 1===<br /> # Architecture &quot;collects&quot; information from the different edges of the graph, and does so in an invariant fashion using &lt;math&gt;\alpha&lt;/math&gt; and &lt;math&gt;\phi&lt;/math&gt;<br /> # Architecture is parallelizable, since all &lt;math&gt;\phi&lt;/math&gt; functions can be applied simultaneously<br /> <br /> ===Some applications of Theorem 1===<br /> # '''Attention:''' the concept of attention can be implemented in the GPI characterization, with slight alterations to the functions &lt;math&gt;\alpha&lt;/math&gt; and &lt;math&gt;\phi&lt;/math&gt;. In attention each node aggregates features of neighbours through a function of neighbour's relevance. Which means the lable of an entity could depend strongly on its close entity. The complete details can be found in the supplementary materials of the paper.<br /> <br /> # '''RNN:''' recurrent architectures can maintain GPI property, since all GPI function &lt;math&gt;\mathcal{F}&lt;/math&gt; are closed under composition. The output of one step after running &lt;math&gt;\mathcal{F}&lt;/math&gt; will act as input for the next step, but maintain the GPI property throughout.<br /> <br /> =Related Work=<br /> # '''Architectural invariance:''' suggested recently in a 2017 paper called Deep Sets by Zaheer et al., which considers the case of invariance that is more restrictive.<br /> # '''Deep structured prediction:''' previous work applied deep learning to structured prediction, for instance, semantic segmentation. Some algorithms include message passing algorithms, gradient descent for maximizing score functions, greedy decoding (inference of labels based on time of previous labels). For example, Xu et al. 2017 proposes a novel end-to-end model that generates structured scene representation, and their model solves the scene graph inference problem using standard RNNs and learns to iteratively improves its predictions via message passing. Apart from those algorithms, deep learning has been applied to other graph-based problems such as the Travelling Salesman Problem (Bello et al., 2016; Gilmer et al., 2017; Khalil et al., 2017). However, none of the previous work specifically address the notion of invariance in the general architecture, but rather focus on message passing architectures that can be generalized by this paper.<br /> # '''Scene graph prediction:''' scene graph extraction allows for reasoning, question answering, and image retrieval (Johnson et al., 2015; Lu et al., 2016; Raposo et al., 2017). Some other works in this area include object detection, action recognition, and even detection of human-object interactions (Liao et al., 2016; Plummer et al., 2017). Additional work has been done with the use of message passing algorithms (Xu et al., 2017), word embeddings (Lu et al., 2016), and end-to-end prediction directly from pixels (Newell &amp; Deng, 2017). A notable mention is NeuralMotif (Zellers et al., 2017), which the authors describe as the current state-of-the-art model for scene graph predictions on Visual Genome dataset.<br /> # '''Burst Image Deblurring Using Permutation Invariant Convolutional Neural Networks:''' similar ideas were applied, where Permutation Invariant CNN, are used to restore sharp and noise-free images from bursts of photographs affected by hand tremor and noise. This presented good quality images with lots of details for challenging datasets.<br /> <br /> =Experimental Results=<br /> <br /> The authors evaluated the advantage of GPI architectures empirically. They first utilized synthetic graph labeling and then used scene-graph classification for mapping images.<br /> <br /> ==Synthetic Graph Labeling==<br /> The authors created a synthetic problem to study GPI. This involved using an input graph &lt;math&gt;G = (V,E)&lt;/math&gt; where each node &lt;math&gt;i&lt;/math&gt; belongs to the set &lt;math&gt;\Gamma(i) \in \{1, \dots, K\}&lt;/math&gt; where &lt;math&gt;K&lt;/math&gt; is the number of samples. The task is to compute for each node, the number of neighbours that belong to the same set (i.e. finding the label of the node &lt;math&gt;i&lt;/math&gt; if &lt;math&gt;y_i = \sum_{j \in N(i)} \mathbf{1}[\Gamma(i) = \Gamma(j)]&lt;/math&gt;) . Then, random graphs (each with 10 nodes) were generated by sampling edges, and the set &lt;math&gt;\Gamma(i) \in \{1, \dots, K\}&lt;/math&gt;for each node independently and uniformly.<br /> The node features of the graph &lt;math&gt;z_i \in \{0,1\}^K&lt;/math&gt; are one-hot vectors of &lt;math&gt;\Gamma(i)&lt;/math&gt;, and each pairwise edge feature &lt;math&gt;z_{ij} \in \{0, 1\}&lt;/math&gt; denote whether the edge &lt;math&gt;ij&lt;/math&gt; is in the edge set &lt;math&gt;E&lt;/math&gt;. <br /> 3 architectures were studied in this paper:<br /> # '''GPI-architecture for graph prediction''' (without attention and RNN)<br /> # '''LSTM''': replacing &lt;math&gt;\sum \phi(\cdot)&lt;/math&gt; and &lt;math&gt;\sum \alpha(\cdot)&lt;/math&gt; in the form of Theorem 1 using two LSTMs with state size 200, reading their input in random order<br /> # '''Fully connected feed-forward network''': with 2 hidden layers, each layer containing 1,000 nodes; the input is a concatenation of all nodes and pairwise features, and the output is all node predictions<br /> <br /> The results show that the GPI architecture requires far fewer samples to converge to the correct solution.<br /> [[File:GPI_synthetic_example.jpg|450px|center]]<br /> <br /> ==Scene-Graph Classification==<br /> Applying the concept of GPI to Scene-Graph Prediction (SGP) is the main task of this paper. The input to this problem is an image, along with a set of annotated bounding boxes for the entities in the image. The goal is to correctly label each entity within the bounding boxes and the relationship between every pair of entities, resulting in a coherent scene graph.<br /> <br /> The authors describe two different types of variables to predict. The first type is entity variables &lt;math&gt;[y_1, \dots, y_n]&lt;/math&gt; for all bounding boxes, where each &lt;math&gt;y_i&lt;/math&gt; can take one of L values and refers to objects such as &quot;dog&quot; or &quot;man&quot;. The second type is relation variables &lt;math&gt;[y_{n+1}, \cdots, y_{n^2}]&lt;/math&gt;, where each &lt;math&gt;y_i&lt;/math&gt; represents the relation (e.g. &quot;on&quot;, &quot;below&quot;) between a pair of bounding boxes (entities).<br /> <br /> The scene graph and contain two types of edges:<br /> # '''Entity-entity edge''': connecting two entities &lt;math&gt;y_i&lt;/math&gt; and &lt;math&gt;y_j&lt;/math&gt; for &lt;math&gt;1 \leq i \neq j \leq n&lt;/math&gt;<br /> # '''Entity-relation edges''': connecting every relation variable &lt;math&gt;y_k&lt;/math&gt; for &lt;math&gt;k &gt; n&lt;/math&gt; to two entities<br /> <br /> The feature set &lt;math&gt;\mathbf{z}&lt;/math&gt; is based on the baseline model from Zellers et al. (2017). For entity variables &lt;math&gt;y_i&lt;/math&gt;, the vector &lt;math&gt;\mathbf{z}_i \in \mathbb{R}^L&lt;/math&gt; models the probability of the entity appearing in &lt;math&gt;y_i&lt;/math&gt;. &lt;math&gt;\mathbf{z}_i&lt;/math&gt; is augmented by the coordinates of the bounding box. Similarly for relation variables &lt;math&gt;y_j&lt;/math&gt;, the vector &lt;math&gt;\mathbf{z}_j \in \mathbb{R}^R&lt;/math&gt;, models the probability of the relations between the two entities in &lt;math&gt;j&lt;/math&gt;. For entity-entity pairwise features &lt;math&gt;\mathbf{z}_{i,j}&lt;/math&gt;, there is a similar representation of the probabilities for the pair. The SGP outputs probability distributions over all entities and relations, which will then be used as input recurrently to maintain GPI. Finally, word embeddings are used and concatenated for the most probable entity-relation labels.<br /> <br /> '''Components of the GPI architecture''' (ent for entity, rel for relation)<br /> # &lt;math&gt;\phi_{ent}&lt;/math&gt;: network that integrates two entity variables &lt;math&gt;y_i&lt;/math&gt; and &lt;math&gt;y_j&lt;/math&gt;, with input &lt;math&gt;z_i, z_j, z_{i,j}&lt;/math&gt; and output vector of &lt;math&gt;\mathbb{R}^{n_1}&lt;/math&gt; <br /> # &lt;math&gt;\alpha_{ent}&lt;/math&gt;: network with inputs from &lt;math&gt;\phi_{ent}&lt;/math&gt; for all neighbours of an entity, and uses attention mechanism to output vector &lt;math&gt;\mathbb{R}^{n_2}&lt;/math&gt; <br /> # &lt;math&gt;\rho_{ent}&lt;/math&gt;: network with inputs from the various &lt;math&gt;\mathbb{R}^{n_2}&lt;/math&gt; vectors, and outputs &lt;math&gt;L&lt;/math&gt; logits to predict entity value<br /> # &lt;math&gt;\rho_{rel}&lt;/math&gt;: network with inputs &lt;math&gt;\alpha_{ent}&lt;/math&gt; of two entities and &lt;math&gt;z_{i,j}&lt;/math&gt;, and output into &lt;math&gt;R&lt;/math&gt; logits<br /> <br /> ==Set-up and Results==<br /> '''Dataset''': based on Visual Genome (VG) by (Krishna et al., 2017), which contains a total of 108,077 images annotated with bounding boxes, entities, and relations. An average of 12 entities and 7 relations exist per image. For a fair compar