{'fraction_non_alphanumeric': 0.03277169822245382, 'fraction_numerical': 0.003995136355740838, 'mean_word_length': 4.7286898839137645, 'pattern_counts': {'":': 1, '<': 1, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Improved Memories Learning

We propose Improved Memories Learning (IMeL), a novel algorithm that turns reinforcement learning (RL) into a supervised learning (SL) problem and delimits the role of neural networks (NN) to interpolation. IMeL consists of two components. The first is a reservoir of experiences. Each experience is updated based on a non-parametric procedural improvement of the policy, computed as a bounded one-sample Monte Carlo estimate. The second is a NN regressor, which receives as input improved experiences from the reservoir (context points) and computes the policy by interpolation. The NN learns to measure the similarity between states in order to compute long-term forecasts by averaging experiences, rather than by encoding the problem structure in the NN parameters. We present preliminary results and propose IMeL as a baseline method for assessing the merits of more complex models and inductive biases.


Introduction
Deep reinforcement learning (RL) algorithms have produced many of the seminal results of machine learning, achieving success in classic games [15], videogames [9,20], and robotic control [1]. These results required extraordinary feats in terms of algorithmic and modeling advances, as well as high-performance computing to produce the large amounts of data required for training. Along with these advances, the research credit assignment problem (that of isolating the causes of the performance gains) grows in complexity. Indeed, recent works have shown that the results obtained by deep RL rely, in unintuitive ways, on code-level optimizations [2], hyper-parameter tuning [4], and unreliable gradient estimates [5]. Here we focus on the question "are deep neural networks (NNs) beneficial to RL because they are able to encode a model of the problem?" and attempt the investigation by contradiction.
RL algorithms can be broadly classified as either model-based or model-free. Model-based methods explicitly learn a model of the environment to predict and plan future steps, while the model-free ones define objective functions that can be computed directly from environment-interaction data. In the case of deep RL, many model-free methods learn value functions which implicitly learn the structure of the environment by constructing an utilitarian model to predict future outcomes. For the purpose of efficiently adapting to specific tasks, inductive biases may be presumed to benefit both model-based and model-free methods, as they allow encoding prior knowledge about the RL problem in the parametric architecture. A common pitfall encountered by RL methods is that of modeling "delusions": structural mis-representations of the task encoded in the NN models. For example, one such delusion was faulted for the loss of AlphaGo on the fourth game against Lee Sedol, while [8] show that incorrect inductive biases (such as linear approximation for Q-learning) are a cause for delusional bias. Structural errors in model-based RL have been shown to decrease stability [19] and generalization [21] compared to methods that rely purely on experience replay. Despite the fact that incorrect inductive biases are detrimental for RL, NN architectures commonly employed for RL are those employed also for supervised learning rather than specifically optimized for RL. Moreover, linear approximation provides a strong baseline for policy optimization in continuous control benchmarks [11].
In order to asses whether (implicit or explicit) RL models can surpass methods that rely exclusively on experiences in a replay memory (RM), we propose a novel baseline algorithm, Improved Memories Learning (IMeL). IMeL does not rely on a NN to predict value functions or compute optimal actions. Instead, the NN is employed to interpolate between experiences and is trained with a supervised learning loss. The IMeL agent, similarly to many off-policy RL methods, fills and maintains a reservoir of experiences. IMeL performs policy optimization by annotating each experience with an estimate improved policy, computed as an incremental Monte Carlo update of the behavior policy, as described in Sec. 4.1. Therefore, by construction the IMeL algorithm is less reliant on the ability of NN to learn the structure of the task and generalize to unseen states, rather the NN serves only for regression. We claim that a properly tuned implementation of IMeL may serve as a simple baseline against which the benefits of models and inductive biases can be fairly measured.

Background and Related Work
The IMeL algorithm takes inspiration from several well-known practices in RL. The policy gradient theorem [18], trust region updates [13] and Experience Replay [7] are the building blocks constituting IMeL. Here we summarize these concepts to provide the framework in which the algorithm is developed.

Constrained Policy Optimization
Policy gradient methods directly optimize the policy by searching the class of functions π θ (a|s) parametrized by θ. The search is performed by gradient ascent, maximizing the performance measure J(θ) = E s,a T t=0 γ t r t by following the policy gradient: Estimations of this gradient are known to have high variance and depend on the choice of estimator for the on-policy state-action value Q π θ (s, a) [17]. The state-action value is usually approximated by a parametric model, computed with one-sample Monte Carlo (MC) estimates, or combinations thereof. These sources of inaccuracy about the gradient's direction are compounded with the uncertainty about the correct step size [6]. The most prominent way to stabilize policy gradient-based algorithms is that of limiting each step's optimization search space by employing constrains, as in Trust Region Policy Optimization (TRPO) [13], or penalization, as in Proximal Policy Optimization (PPO) [14]. Here we both use as baseline and adapt the techniques of TRPO. On each step, TRPO solves an optimization problem for θ constrained on the average Kullback-Leibler (KL) divergence D KL (π θ old π θ ). Here π θ old is the policy after the previous step which is used to sample the environment and to compute the MC estimates of the Q function for the current step, i.e. q π θ old (s, a). The optimization problem can be written as: Here ρ θ old is the state visitation frequency induced by the policy π θ old . TRPO efficiently iterates this optimization problem by linear approximation of the objective and quadratic approximation of the constraint equation. TRPO is a simple and stable algorithm and has become a benchmark for several continuous problems.

Experience Replay
Experience Replay (ER) has been widely employed for developing sample efficient off-policy RL algorithms. ER allows the algorithm to reuse experiences over multiple updates, boosting its sample efficiency [7]. For each environment time-step t, experiences can be stored in a replay memory (RM) as tuples {s t , r t , a t , β t }, where s t is the state, r t is the reward, and β t represents the policy statistics (mean and covariance for continuous actions, categorical probabilities for discrete actions) used to sample the action a t . However, as the policy is trained it becomes increasingly different from past behaviours. Even with off-policy RL methods, updates computed using distant experiences become inaccurate and may lead to instabilities [10].

Supervised Reinforcement Learning
RL approaches typically attempt to infer actions that correspond to maximal rewards or train function approximators to satisfy the Bellman equation. Until recently, the use of Supervised Learning (SL) methods in RL were limited to, for example, learning models of the environment's dynamics or of the reward function. A Recently proposed alternative, termed Upside-Down Reinforcement Learning (UDRL) [12,16], is to train a function approximator to predict actions that correspond to a desired reward and time horizon (behaviour function). Because the NN takes the returns as input, rather than having to predict them, and outputs the corresponding action, it can be trained with a SL loss by experience replay. UDRL obtained competitive results in several RL problems.

Supervised learning methods
The proposed IMeL algorithm requires NNs only as interpolators among past experiences. Therefore, we employ NN architectures designed with inductive biases of interpolation which are trained by SL. In this section we present the methods used for this task.

Neural Processes
Neural Processes (NP) [3] are generative models able to model a distribution over functions, combining the benefits of NNs and Gaussian Processes. NPs model a random process and learn this distribution in a data-driven manner. This is achieved by introducing a global latent variable z, assumed to be modeling the randomness of the process, and a nonlinear regression function g(z, x). NPs learns the distribution of z by an encoder network h w (C) mapping the set of available observations C = {(x, y) i } m i=1 to the parameters µ z , σ z defining the conditional distribution p(z|C) = N (µ z , σ z |C). A decoder network g w (z, x) is mapping the latent variable realization z ∼ p(z|C) and the target set x 1:n to the mean and standard deviation of the posterior distribution y 1:n ∼ N (µ y , σ y |x 1:n , C). To learn such mappings, NPs employ amortised variational inference, minimizing the cost L derived by the evidence lower-bound (ELBO), i.e.
where the distributions q(z|x 1:n , y 1:n ) and q(z|x 1:m , y 1:m ) are the variational posteriors computed with the available context set. The first term in Equation 4 maximizes the log-likelihood of the samples given z and is thus used to learn g w (x, z). The second term is the Kullback-Leibler divergence between the prior z distribution, conditioned on the context set alone, and the posterior one which considers the target set as well. Minimizing the kl divergence, the algorithm learns how to approximate the distribution of the latent variable from the context set. The posterior distribution y 1:n ∼ N (µ y , σ y |x 1:n , C) gives an estimate of the uncertainty in the prediction, which largely depends on the amount of the nearby context points. Eventually, NPs manage to learn a distribution over functions induced by the realizations z of z. The trained model is employed for probabilistic inference.

Mean Kernel Interpolation
Mean Kernel Interpolation (MKI) is a simple architecture explicitly designed to perform weighted interpolation of a set of experiences. The model is constituted by two parts. A NN z = f w (x) projecting the input x to a feature space z, and an exponential kernel function parametrized by W used to represent the geometric mapping between the latent space z and the output space y. Interpolation on the y space is performed by interpolating the kernel in the latent space, based on the context set points.
By training the architecture (learning the weights w and W) on a dataset of functions, the NN learns to extract the common features to capture the global structure of the function space. To perform inference on a target point x n ∈ R dx given the context set C = {(x, y) i } m i=1 , we first project the x-values onto the feature space z ∈ R dz , d z < d x . Then the y-values of the context points are interpolated using the learned exponential kernel, parametrized by the weight matrix W ∈ R dz×dz , i.e.
where z n is the projection of the target point, while {z i } m i=1 the projection of the context set. This procedure results in a method able to efficiently interpolate the context points and accurately regress the function. As opposed to NPs, MKI is not a generative model.

IMeL algorithm
As in standard policy gradient methods, we optimize a parametrized policy with respect to its expected discounted reward. However, instead of directly updating its parameters, we (1) update previously sampled policy realizations, (2) utilize a supervised learning method to interpolate on the space of policies to (3) obtain the new policy function. To ensure robustness, taking inspiration from TRPO, we constrain the change between the sampled mean-distribution and the improved one to be within a trust region. All the improved policy realizations, are stored in a replay memory, so that the SL method can keep on learning from them at later iterations. Learning from this distribution of improved policies, instead of directly updating the parameters, allows to best exploit the local information contained in the dataset and use the information of each experience where most needed. An update step of IMeL is illustrated in Figure 1.

The structure
For this pilot version of the algorithm we consider only continuous-control problems and Gaussian policies π(a|s). We augment every experience φ t = (s t , µ t , σ t , a t , r t ) gathered during the interaction with the environment with an improved mean of the policy µ * t , which can be thought of as a free parameter. The gradient of the Monte Carlo return with respect to µ t is estimated by the policy gradient: ∇ µt J = ∇ µt log(π(a t |s t )) q π (s t , a t ) Here, q π (s t , a t ) is the Monte Carlo return. This result is used to generate the improved policy µ * t , i.e.
The step size η is a crucial parameter, since it determines how far the improved means will be moved away from the sampled ones, tuning the trade-off between accuracy and learning speed. Taking inspiration from TRPO, we take η such that the expected KL divergence between the behavior policy and the improved policies is bounded by a hyper-parameter . Assuming a constant standard deviation over the iterations σ and using MC sampling to estimate the mean D KL over the state space, we obtain the following analytical relations: Substituting the update step relation µ * t = µ t + η q π t at−µt σ 2 we obtain: Therefore, the RL process of estimating optimal policies given states is delegated to an analytical procedure, rather than relying on function approximation. Yet, these estimates are noisy and imprecise due to the Monte Carlo estimate of the expected returns. A similar procedure may be employed to update the standard deviation, which we kept constant in this study, or could be derived for discrete policies.
By moving all experiences in the Replay Memory towards the direction of higher returns, IMeL generates a dataset of improved policies C = {(s, µ * ) i } m i=1 . For an unseen state s, the policy π(a|s) is computed by interpolation given a learned kernel (via NPs and MKI) which determines the similarity of s to the set of states in C and all prior improved policies. The NN regressor is trained with a SL loss to predict µ * for a state excluded from the set C by interpolating between the noisily improved experiences in the RM. The pseudocode for the IMeL algorithm is reported in the Supplementary Material.
(a) s ∈ R 2 , a ∈ R (b) s ∈ R 17 , a ∈ R 6 Figure 2: Comparison of IMeL with NPs, IMeL with MKI and TRPO in two benchmark problems. IMeL shows superior performance in the low dimensional problem, while being competitive in the high dimensional one.

Discussion
The proposed IMeL is a baseline RL algorithm based on interpolation of first order improvements of experiences in a RM. IMeL is designed with the objective of delimiting the role of NN in the RL process. This objective is motivated by recent results which suggest that, as stated in [5], "the theoretical framework for deep RL algorithms is often unpredictive of phenomena arising in practice." IMeL uses NNs as interpolators between procedurally updated policies in a reservoir, in a manner that could be extended to modeling environment dynamics and value learning. Therefore, we train a NN to measure the similarity between states in order to compute long-term forecasts by averaging experiences, rather than by encoding the problem structure in the NN parameters. We argue that this approach is more transparent to inspect whether the theoretical justifications of RL algorithms are met in practice. Moreover, RL tasks may call for specific inductive biases (e.g. partial-observability and/or states-from-pixels), in such cases the ability of NN to meet their requirements could be assessed separately from their performance in terms of returns.
In promising preliminary results, obtained for benchmark environments with a low-dimensional continuous-action space, we show that IMeL has comparable performance as TRPO (Fig. 2), both when employing NPs and MKI as interpolation method. A properly tuned version of IMeL could be employed to evaluate the performance gains of more complex RL methods, such as the benefits of algorithmic advances and inductive biases. These results are supported by additional tests reported in the Supplementary Material. The shaded area around the mean reports the 20 th and 80 th percentiles of the reward. We observe that IMeL is slightly superior compared to TRPO in both the Humanoid and the Inverted Double Pendulum environments. In environments that are characterized by local optima, IMeL fails to recover from them and shows inferior performance compared to TRPO, demonstrating that the increased complexity in TRPO is necessary. In other environments, IMeL can be a faster, less sophisticated, computationally cheaper alternative.