Title: LEARNING BY SHAKING: COMPUTING POLICY GRADI-ENTS BY PHYSICAL FORWARD-PROPAGATION

Abstract: Model-free and model-based reinforcement learning are two ends of a spectrum. Learning a good policy without a dynamic model can be prohibitively expensive. Learning the dynamic model of a system can reduce the cost of learning the policy, but it can also introduce bias if it is not accurate. We propose a middle ground where instead of the transition model, the sensitivity of the trajectories with respect to the perturbation (shaking) of the parameters is learned. This allows us to predict the local behavior of the physical system around a set of nominal policies without knowing the actual model. We assay our method on a custom-built physical robot in extensive experiments and show the feasibility of the approach in practice. We investigate potential challenges when applying our method to physical systems and propose solutions to each of them.

1. INTRODUCTION:

Traditional reinforcement learning crucially relies on reward (Sutton & Barto, 2018) . However, reward binds the agent to a certain task for which the reward represents success. Aligned with the recent surge of interest in unsupervised methods in reinforcement learning (Baranes & Oudeyer, 2013; Bellemare et al., 2016; Gregor et al., 2016; Hausman et al., 2018; Houthooft et al., 2016) and previously proposed ideas (Schmidhuber, 1991a; 2010) , we argue that there exist properties of a dynamical system which are not tied to any particular task, yet highly useful, and their knowledge can help solve other tasks more efficiently. This work focuses on the sensitivity of the produced trajectories of the system with respect to the policy so called Physical Derivatives. The term physical comes from the fact that it uses the physics of the system rather than any idealized model. We learn a map from the directions in which policy parameters change to the directions in which every state of the trajectory changes. In general, our algorithm learns the Jacobian matrix of the system at every time step through the trajectory. The training phase consists of physically calculating directional derivatives by the finite difference after applying perturbed versions of a nominal policy (a.k.a. controller).

Perturbing the parameters of the controller is the reason for naming our method shaking. The test phase uses these directional derivatives to compute derivatives along unseen directions. Due to the difficulty of computing the Jacobian matrix by the finite difference in higher dimensions, we use random controllers joint with probabilistic learning methods to obtain a robust estimate of the Jacobian matrix at each instant of time along a trajectory. We are capable of this generalization to unseen perturbations because the trajectories of physical systems live on an intrinsic low-dimensional manifold and change slowly with the small changes in the parameters of the system (Koopman, 1931) .

This assumption holds as long as the system is not chaotic or close to a bifurcation condition (Khalil, 2002) .

1.1. PRELIMINARIES:

A reward function describes how close the agent is to the solution of the target task. In the absence of the reward, the agent will be given no means to find its way towards the solution. Let x ∈ X ⊆ R d be a d-dimensional state vector that fully describes the environment with which the agent interacts. At each state, the agent is allowed to take action u ∈ U ⊆ R q from a q-dimensional action space via a parameterised policy function u = π(x; θ). The agent will be rewarded r(x, u) by the function r : X × U → R when it takes action u at state x. The goal of learning is to update θ such that some desired target is achieved. The target can be anything as long as a concrete reward function is associated with it. In stochastic cases, return R : Π(Θ) → R is defined as a cumulative future discounted reward whose expectation is often of main interest. For parametric policies, the space of feasible parameters Θ has a one-to-one correspondence to the policy space Π. The agent who takes on the policy π from state x 0 produces the trajectory T ∈ T where T is the space of possible trajectories. For a return function R : T → R, the expected return becomes a function of the policy as J(π θ ) = E T {R(T )} where the expectation is taken with respect to the probability distribution P (T |π θ ). There exist two major classes of approaches in reinforcement learning: value-based methods and value-free methods. In the first class, a surrogate function is defined to approximate the value of either a state V (x) or a state-action pair Q(x, u). The policy is updated such that the agent tends towards states with higher values. The value-free methods update the policy directly without any need for an auxiliary function such as V or Q. This paper mainly concerns the second class. The policy parameters are updated as

θ t+1 = θ t + α ∂J(π θ ) ∂θ θ=θt (1)

and the gradient ∂J(π θ )/∂θ is written as

EQUATION

which is normally difficult to compute in practice. As can be seen in eq. ( 2), the integrand of the r.h.s. consists of two terms. The second term R(T ) is the return which is defined according to the target task. Hence, this term is task-dependent. The first term ∂p(T |π θ )/∂θ though shows how the trajectories change with respect to a change in the policy. Notice that there is no notion of reward or any task-dependent quantities in this term. For an empirical distribution p e (T |π) =

1 M M i=1 δ(T -T (i) ), the dependence of partial derivative of the distribtion of T on the partial derivative of T can be explicitely derived as

EQUATION

where u 1 is the unit doublet function (derivative of the Dirac delta function). This examplary distribution makes it clear that the change in the distribution of trajetories relates to the change of the trajectories themselves. As an unsupervised object, ∂T /∂θ is of main interest in this paper.

1.2. PHYSICAL DERIVATIVE:

In this paper, we investigate the feasibility of learning a less explored unsupervised quantity, the so called Physical Derivative which is computed directly from the physical system. In abstract terms, we perturb the policy and learn the effect of its perturbation on the resulting trajectory. The difference from traditional RL whose algorithms are based on eq. ( 1) is the absence of a specified reward function. Instead, we generate samples from ∂p(T |π θ )/∂θ of eq. ( 2) that makes it possible to compute ∂J(π θ )/∂θ for an arbitrary return function R. If the exact model of the system is known, control theory has a full set of tools to intervene in the system with stability and performance guarantees. When the system is unknown, one could identify the system as a preliminary step followed by a normal control synthesis process from control theory (Ljung, 2001) . Otherwise, the model and the policy can be learned together in a model-based RL (Sutton, 1996) or in some cases adaptive control (Sastry & Bodson, 2011) . We argue that learning physical derivatives is a middle ground. It is not model-based in the sense that it does not assume knowing the exact model of the system. Rather, it knows how the trajectories of the system change as a result of perturbing the policy parameters. This differential information of the system has applications in many downstream tasks. This work focuses on the concept and introduction of physical derivatives and direct applications would go significantly beyond the scope of this work. Few potential applications are discussed with more details in appendix C.

Our contributions-In summary, the key contributions of the current paper are as follows:

• A method to generate training pairs to learn the map from the policy perturbations to the resulting changes in the trajectories. • Learning the above map as a probabilistic function and showing that it generalizes to unseen perturbations in the policy. • Use the inverse of the above map to perturb the policy in the desired direction to achieve certain goals without conventional RL methods. • Use a physical custom-built robotic platform to test the method and propose solutions to deal with the inherent issues of the physical system to ensure the practicality of the method (see fig. 1 for images of the platform and and appendix A for technical details). • The supplementary materials for the paper, including code and the videos of the robot in action can be found in https://sites.google.com/view/ physicalderivatives/

2. METHOD:

In this section, we describe our pipeline to estimate the physical derivatives and our proposed solutions to the inevitable challenges that are likely to occur while working with a real physical robot. We are interested in ∂T /∂θ which denotes how a small change in the parameters θ of the controller results in a different trajectory produced by the system. We normally consider a finite period of time [0, T ] and the trajectory is an ordered list of states T = [x 0 , x 1 , . . . , x T ] where the subscript shows the time step. Therefore, having ∂T /∂θ is equivalent with having ∂x t /∂θ for every t ∈ {1, . . . , T }. Notice that the initial state x 0 is chosen by us. Hence we can see it either as a constant or as a changeable parameter in θ. We kept it fixed in our experiments.

Assume x t ∈ R d and θ ∈ R m . Hence, ∇ θ x t = ∂x t /∂θ ∈ R d×m where the t th row of this matrix is ∇ θ x it = (∂x it /∂θ) T ∈ R m showing how the i th dimension of the state vector changes in response to a perturbation in θ. The directional derivative of x it in the direction δθ is defined as

EQUATION

If ( 4) is available for m linearly independent and orthonormal directions, {δθ (1) , δθ (2) , . . . , δθ (m) }, the directional derivative along an arbitrary δθ can be approximated by

EQUATION

where c j = δθ, δθ (j) is the coordinates of the desired direction in the coordinate system formed by the orthonormal bases.

In practice, m directions δθ (j) can be randomly chosen or can be along some pre-defined axes of the coordinate system. To compute ∇ θ x it , δθ (j) , the nominal policy parameters θ are perturbed by δθ (j) as θ (j) ← θ + δθ (j) and the derivative is computed as

EQUATION

)

This quantity is often approximated by finite difference where h takes a small nonzero value. By perturbing the parameters θ along m orthonormal directions δθ (j) and computing the approximate directional derivative by ( 6), ∇ δθ θ x it can be computed along every arbitrary direction δθ, meaning that, we can compute ∇ θ x it by evaluating it along any direction which is the aim of this paper. 

F f / o U F J w 0 e z n x X S 1 R y g R K 2 b Z k = " > A A A B 7 3 i c b V B N S 8 N A E J 3 U r 1 q / q h 6 9 L B b B U 0 m q o M e i F 4 8 V 7 A e 0 o W y 2 m 3 b p Z h N 3 J 0 I J / R N e P C j i 1 b / j z X / j t s 1 B W x 8 M P N 6 b Y W Z e k E h h 0 H W / n c L a + s b m V n G 7 t L O 7 t 3 9 Q P j x q m T j V j D d Z L G P d C a j h U i j e R I G S d x L N a R R I 3 g 7 G t z O / / c S 1 E b F 6 w E n C / Y g O l Q g F o 2 i l T g 9 H H G n f 6 5 c r b t W d g 6 w S L y c V y N H o l 7 9 6 g 5 i l E V f I J D W m 6 7 k J + h n V K J j k 0 1 I v N T y h b E y H v G u p o h E 3 f j a / d 0 r O r D I g Y a x t K S R z 9 f d E R i N j J l F g O y O K I 7 P s z c T / v G 6 K 4 b W f C Z W k y B V b L A p T S T A m s + f J Q G j O U E 4 s o U w L e y t h I 6 o p Q x t R y Y b g L b + 8 S l q 1 q n d R r d 1 f V u o 3 e R x F O I F T O A c P r q A O d 9 C A J j C Q 8 A y v 8 O Y 8 O i / O u / O x a C 0 4 + c w x / I H z + Q P O t Y / Q < / l a t e x i t > ✓2 < l a t e x i t s h a _ b a s e = " o e D a g N b C s b j j y b L f Z H d S Y = " > A A A B i c b V B N S N A E J U r q / q h L B b B U m q o M e i F V A e o W y m b p Z h N J I J / R N e P C j i b / j z X / j t s B W x M P N b Y W Z e k E h h H W / n c L a + s b m V n G t L O t Q P j x q m T j V j D d Z L G P d C a j h U i j e R I G S d x L N a R R I g G t z O / / c S E b F w E n C / Y g O l Q g F o i l T g H H G m / i X K o B k l X k q k K P R L / B j F L I Q S W p M M T D O q U T D J p V e a n h C Z g O e d d S R S N u / G x + S c W W V A w l j b U k j m u + J j E b G T K L A d k Y U R b Z m n / e d U w s / E y p J k S u W B S m k m B M Z s + T g d C c o Z x Y Q p k W l b C R l R T h j a i k g B W l b R q V e + i W r u / r N R v j i K c A K n c A e X E E d q A B T W A g R l e c d F c d + d j V p w p l j + A P n w f Q O Y / R < / l a t e x i t >

✓1:

< l a t e x i t s h a 1 _ b a s e 6 4 = " b 2 F f / o U F J w 0 e z n x X S 1 R y g R K 2 b Z k = " > A A A B 7 3 i c b V B N S 8 N A E J 3 U r 1 q / q h 6 9 L B b B U 0 m q o M e i F 4 8 V 7 A e 0 o W y 2 m 3 b p Z h N 3 J 0 I J / R N e P C j i 1 b / j z X / j t s 1 B W x 8 M P N 6 b Y W Z e k E h h 0 H W / n c L a + s b m V n G 7 t L O 7 t 3 9 Q P j x q m T j

V j D d Z L G P d C a j h U i j e R I G S d x L N a R R I 3 g 7 G t z O / / c S 1 E b F 6 w E n C / Y g O l Q g F o 2 i l T g 9 H H G n f 6 5 c r b t W d g 6 w S L y c V y N H o l 7 9 6 g 5 i l E V f I J D W m 6 7 k J + h n V K J j k 0 1 I v N T y h b E y H v G u p o h E 3 f j a / d 0 r O r D I g Y a x t K S R z 9 f d E R i N j J l F g O y O K I 7 P s z c T / v G 6 K 4 b W f C Z W k y B V b L A p T S T A m s + f J Q G j O U E 4 s o U w L e y t h I 6 o p Q x t R y Y b g L b + 8 S l q 1 q n d R r d 1 f V u o 3 e R x F O I F T O A c P r q A O d 9 C A J j C Q 8 A y v 8 O Y 8 O i / O u / O x a C 0 4 + c w x / I H z + Q P O t Y / Q < / l a t e x i t >

✓2:

< l a t e x i t s h a 1 _ b a s e 6 4 = " o e 3 D a g N b C s 6 b j j 1 0 y b L f Z H 9 d 5 S Y = " > A A A B 7 3 i c b V B N S 8 N A E J 3 U r 1 q / q h 6 9 L B b B U 0 m q o M e i F 4 8 V 7 A e 0 o W y 2 m 3 b p Z h N 3 J 0 I J / R N e P C j i 1 b / j z X / j t s 1 B W x 8

M P N 6 b Y W Z e k E h h 0 H W / n c L a + s b m V n G 7 t L O 7 t 3 9 Q P j x q m T j V j D d Z L G P d C a j h U i j e R I G S d x L N a R R I 3 g 7 G t z O / / c S 1 E b F 6 w E n C / Y g O l Q g F o 2 i l T g 9 H H G m / 1 i 9 X 3 K o 7 B 1 k l X k 4 q k K P R L 3 / 1 B j F L I 6 6 Q S W p M 1 3 M T 9 D O q U T D J p 6 V e a n h C 2 Z g O e d d S R S N u / G x + 7 5 S c W W V A w l j b U k j m 6 u + J j E b G T K L A d k Y U R 2 b Z m 4 n / e d 0 U w 2 s / E y p J k S u 2 W B S m k m B M Z s + T g d C c o Z x Y Q p k W 9 l b C R l R T h j a i k g 3 B W 3 5 5 l b R q V e + i W r u / r N R v 8 j i K c A K n c

A 4 e X E E d 7 q A B T W A g 4 R l e 4 c 1 5 d F 6 c d + d j 0 V p w 8 p l j + A P n 8 w f Q O Y / R < / l a t e x i t > In the matrix form for x ∈ R d , we can compute

∇ δθ (j) θ x = [∇ δθ (j) θ x 1 , ∇ δθ (j) θ x 1 , . . . , ∇ δθ (j) θ

x d ] T in a single run by computing (6) for all d dimensions of the states. Let's define

∆ θ x [∇ δθ (1) θ x, ∇ δθ (2) θ x, . . . , ∇ δθ (m) θ x] (7)

where ∆ θ x ∈ R d×m and let Λ = [δθ (1) , δθ (2) , . . . , δθ (m) ].

Therefore, if ∆ δθ θ x shows the directional derivative of x along δθ, we can write it as:

∇ δθ θ x = ∆ θ x(Λ T δθ) (8)

which is only a vectoral representation of eq. ( 4). Even though the linear formula of eq. ( 8) requires only m directional derivatives, it has two major downsides. First, it does not give a clear way to incorporate more than m training directional physical derivatives. Second, the linear approximation remains valid only for very small δθ. We propose Gaussian Process (GP) as a nonlinear probabilistic function approximator (Rasmussen, 2003) to capture the maps ĝt defined as

ĝt : Θ → X (9) ĝt (δθ) = δx (10)

where subscript t shows the function that maps δθ to the change of the states δx t at time step t. We considered distinct functions for every time step. Taking into account the commonality among the function approximators corresponding to different time steps is deferred to future research. Learning this map requires training data that comes from an initial data collection phase called shaking. Shaking refers to perturbing parameters of the controller to obtain the set of trajectories produced by the perturbed controllers.

The perturbation can be either regular or stochastic. Stochastic perturbations have the advantage over regular perturbations that the agent does not need to be worried about perturbing the parameters in a particular direction. Besides, in some cases, perturbing the parameters of the policy in certain directions is infeasible. We propose two methods of shaking called Gaussian and Uniform shaking.

Gaussian shaking-Likely values of θ create nominal policies encoded by {θ (1) , θ (2) , . . . , θ (m) }.

We put Gaussian distributions centered at each of the nominal values resulting in a mixture of Gaussians. To reduce the hyper-parameters, we assume the variances of the Gaussians are themselves sampled from an exponential distribution making sure they all take positive values (See fig. 2 left ).

Here, we manually choose a reasonable value for the rate parameter of the exponential distribution. Doing inference on the hyper-parameters of the sampling distributions can be a topic for future research especially in active learning for a more clever less costly sampling stratgey.

Uniform shaking-In this setting, the state space of the changeable parameters of the policy is discretized and a uniform distribution is assumed around each value of this grid with some overlapping with the neighboring cells (See fig. 2 right ).

We show the effect of each of these sampling methods later in section 4. We observed that the results are less sensitive to the hyper-parameters of the uniform sampling than Gaussian sampling. A carelessly chosen rate for the exponential distribution that generates the variances of the Gaussians in Gaussian sampling can result in too local or global sampling that gives rise to a large variance or bias in the estimated gradients.

REAL WORLD CHALLENGES:

In this section, we present two major low-level challenges that are common when dealing with physical systems. There exist inherent noise and imperfection in the system that results in a change in the produced trajectories while the policy parameters are kept fixed. In our finger platform, we observed two different major sources of noise which are likely to occur in other physical systems too. We call them temporal and spatial noise for the reasons that come in the following.

Temporal noise. The temporal noise represented by n affects trajectories by shifting them in time

EQUATION

Notice that the absence of subscript t in n shows that this noise is not time-dependent, i.e., the time shift does not change along the trajectory as time proceeds.

Spatial noise. The trajectories affected by spatial noise cannot be aligned with each other by shifting forward or backward in time. We can model this noise as a state-dependent influence on the state of the system at every time step.

EQUATION

The following definition makes the distinction more concrete. Definition 1. Consider two trajectories T (1) (t) and T (2) (t) as two temporal signals. Assume S t• is the shift-in-time operator defined as

S t• T (t) = T (t + t • ) (13)

for an arbitrary function of time T (t). We say

T (2) (t) is temporally noisy version of T (1) (t) if ∃t • ∈ R s.t. T (2) -S t• T (1) 1 ≤ (14)

where is a hyper-parameter threshold that reflects our prior confidence about the accuracy of the motors, joints, physical and electrical elements (in general construction process) of the robot. On the other hand,

T (2) is called a spatially noisy version of T (1) if t • ∈ R s.t. T (2) -S t• T (1) 1 ≤ (15) 3.0.1 SOLUTION TO TEMPORAL NOISE

Fortunately, this type of noise is not state-dependent by definition. If we find out how much a trajectory is shifted in time with respect to another trajectory, we can simply shift the trajectory for those many time steps and compensate for the delay. Hence, the problem becomes detecting the lagged trajectories with respect to a reference trajectory and also estimate the amount of the required time shift to compensate for the delay. We can either use physical landmarks in the trajectories to align them or use the correlation between them as a measure of alignment. The later gave better results, hence, we postpone the description of the former to the appendix D.1.

Correlation-based delay estimation:

In this method, we use the correlation between zero-meaned trajectories T (i) and T (j) to check if one is the lagged version of the other one. The delay τ is found by

τ * = argmax τ T -τ t=0 S τ x (i) t , x (j) t (16)

where S τ is a shift-operator by τ ∈ Z time steps. In practice, we take one trajectory of {T (1) , T (2) , . . . , T (M ) }, e.g. T (r) as the reference and synchronize other trajectories with respect to it using eq. ( 16). The trajectories must be initially normalized to avoid trivial solutions where every trajectory is pushed towards the larger parts of the reference trajectory. For illustrative purposes, the plots of fig. 14 show a sample of the lagged trajectory from the finger platform and its correction by the above method.

3.1. SOLUTION TO SPATIAL NOISE:

The spatial noise can be a stochastic function of the actuator, environmental change, and electronic drivers. In a perfect model of the transition dynamics x t+1 = f (x t , u t ), applying the same control sequence {u 0 , u 1 , . . . , u T -1 } always results in the same sequence of states {x 1 , x 2 , . . . , x T } when it starts from the same initial state x 0 . This assumption is often violated in physical systems as different runs of the same policy may result in different trajectories as can be seen in fig. 10 in the Appendix. The noise in the dynamics can be any function of states, input, and time. Therefore, it is difficult to model this noise since it requires a prohibitively large number of random experiments.

The good news is that if the physical system is built properly, the effect of this noise is expectedly low. Based on our observations from the finger platform, we can assume the following. Assumption 2. Limit on the physical noise: Let's the control sequence U = {u 0 , u 1 , . . . , u T -1 } be applied to the system M times resulting in multiple sequence of states T (1) , T (2) , . . . , T (M ) . There exists a relatively small ζ such that

EQUATION

The word relatively here means that the change of the trajectory due to the inherent physical noise of the system must be small compared to the change of the trajectories when the parameters of the policy are perturbed.

To reduce the sensitivity of the estimated gradient to this unwanted spatial noise, we divide the state space of the physical system into regularly located adjacent cells called voxels. Each voxel vox(c) is represented by its center c and is defined as

EQUATION

)

where γ is the parameter of the voxelization. The concept of the voxel is roughly used as a superstate. Every state that ends up within vox(c) gives rise to the same superstate. After recording the trajectories form the robot, every state is mapped to the center of the voxel it belongs to as

EQUATION

After voxelization, we work with c instead of x. For example, all the gradients of ( 7) are computed as ∇ θ c rather than ∇ θ x. To illustrate the positive effect of voxelization of the state space, it can be seen in fig. 3 that increasing the voxel size improves the overlapping between two trajectories that deviate from each other due to the inherent spatial noise of the system not because of perturbing the parameters of the policy, but because of the inherent imperfection of the mechanical and electrical components of the system. This benefit comes with a cost which is the error introduced by voxelization. Fortunately, this error is bounded due to the following lemma Lemma 3. The error caused by voxelization is bounded and inversely proportional to the size of each voxel (see appendix F.1 for a brief proof).

After dealing with the challenge of inherent noise, we pursue the main goal of this paper which is estimating ∂T /∂θ directly from the physical system. In the following, we investigate the use of the different type of controllers to emphasize the extent of applicability of the proposed method.

4. EXPERIMENTS:

In this section, we show how physical derivatives can be estimated in practice through several experiments. Notice that our work is different from computing gradients around the working point of a system by finite-difference. We aim to collect samples from such gradients by perturbing a grid of nominal values of the policy parameters and then generalize to unseen perturbations by Gaussian process as a probabilistic regression method. The experiments are designed to show each challenge separately and the efficacy of our proposed solution to it. Due to space constraints, details to the physical platform can be found in section A in the Appendix. See 1 for videos of the robot while collecting data for different experiments and more backup materials. 

4.1. LINEAR OPEN-LOOP CONTROLLER:

As a simple yet general policy, in this section, we consider an open-loop controller which is a linear function of time. The policy u t = [u 1t , u 2t , u 3t ] constitutes the applied torques to the three motors {m 1 , m 2 , m 3 } of the system and is assigned as

EQUATION

Notice that the torque consists of two terms. The first term w i t grows with time and the second term remains constant. The controller has 6 parameters in total denoted by θ. The task is to predict ∇ θ x t for every t along the trajectory. In the training phase, the training data is obtained via shaking as described in section 2. 

4.2. NONLINEAR OPEN-LOOP CONTROLLER:

Physical derivatives can naturally be computed for either linear or nonlinear controllers which makes it different from taking the gradient of models through time. In model-based methods, if the model's transition dynamics is not differentiable, taking the derivative is theoretically challenging. However, our method is taking advantage of the real physics of the system to compute the gradients regardless of whether the approximating model is differentiable or not. To elaborate more on this, we test our method for a simple but nonlinear policy, i.e., u t = A sin(ωt). The sinusoidal torque is applied to either one or two motors of the system to investigate the performance of our method. We tested Gaussian and uniform shaking for θ = {A, ω} as parameters of this controller. The GP interpolation for the partial derivatives at some time instances along the trajectory can be seen in fig. 6 and more extensively in figs. 16 to 18 in the Appendix. One might be interested in the direction of the predicted derivative instead of its exact size. To this end, we take several test perturbations for every time step and use cos(α) as a measure of alignment between the predicted and ground-truth derivative vectors.

The time evolution of the histogram of this measure along the trajectory shows a better alignment as time proceeds. This effect can be seen in figs. 27 and 28. This confirms our observation of initial transient noise in the system that dies out gradually by the progression of time. The overall performance of our method in predicting physical derivatices in unseen directions for two different shaking methods is shown in appendix E.

4.3. FEEDBACK CONTROLLER:

Often in practice, the policy incorporates some function of the states of the system. Some wellknown examples which have been extensively used in control applications are P, PD, PI and PID controllers. Here, we consider two member of this family, i.e., P and PD controllers. The policy becomes u = K p e for P controllers and u = K p e + K d ė for PD controllers. The error e shows the difference between the current state x and the desired state x * . The parameters of the controller {K p , K d } are scalar values that are multiplied by the error vector element wise. This implies that the controller parameters are the same for three motors leaving the controller of the whole platform with two parameters that weights the value and the rate of the error. We applied the uniform and Gaussian shaking for the set of parameters θ = {K p , K d } with different scenarios. The GP interpolation for the physical derivatives at some time instances along the trajectory can be seen in fig. 6 Our previous experiments in sections 4.1,4.2 and 4.3 showed that learning the physical derivative map is feasible for various types of controllers. In this section, we demonstrate an example of a constrain satisfaction task by means of the physical derivative map. In this experiment, the superscript (s) corresponds to the nominal trajectory which is called source. Assuem the system is controlled by a PD controller to reach a target state x * , i.e., the control torques are designed as

u = k (s) p (x -x * ) + k (s) d ẋ.

The controller does a decent job to reach the target state given reasonable values for k p and k d . However, such controller does not give us a clear way to shape the trajectory that starts from x • and ends at x * . Assume it is desired that the nominal controlled trajectory T (s) passes through an intermediate state x * t at time t on its way towards the target state x * (we can equally assume that the system must avoid some regions of the state space because of safety reasons). The solution with physical derivatives is as follows . Assume k 

p ) = (x * t -x (s) t )/(k * p -k (s) p )

. By simple algebraic rearrangement, we have

EQUATION

The new parameter of the policy is supposed to push the source trajectory T (s) towards a target trajectory T * that passes through the desired state x * t at time t. The result of this experiment on our physical finger platform can be seen in fig. 8 .

4.5. RELATED WORKS:

A truly intelligent agent must develop some sort of general competence that allows it to combine primitive skills to master a range of tasks not only a single task associated with a specified reward function. The major part of such competence come from unsupervised experiences. Animals use a similar competence to quickly adapt to new environments (Weng et al., 2001) . and function efficiently soon after birth before being exposed to massive supervised experience (Zador, 2019) . Due to its generality, such basic skills can be inherited over generations rather than being learned from scratch (Gaier & Ha, 2019) . Despite traditional RL that the learning is driven by an extrinsic reward signal, intrinsically motivated RL concerns task-agnostic learning. Similar to animals' babies (Touwen et al., 1992) , the agent may undergo a developmental period in which it acquires reusable modular skills (Kaplan & Oudeyer, 2003; Weng et al., 2001) such as curiosity and confidence (Schmidhuber, 1991a; Kompella et al., 2017) . Another aspect of such general competence is the ability of the agent to remain safe during its learning and deployment period (Garcıa & Fernández, 2015) . In physical systems especially continuous control, stability is a major aspect of safety that implies states of the system converge to some invariant sets or remain within a certain bound (Lyapunov, 1992) . Control theory often assumes the model of the system known to guarantee stability (Khalil, 2002) . In the absence of the model, model-based RL learns the model along with the policy. Hence, learning the transition model to predict the states in the future can be another intrinsic reward.

From a technical point of view, our work is relevant to sensitivity analysis and how it is used to train the parameters of models such as in Chen et al.'s NeuralODE. The method seemed to be effective in many tasks including learning dynamics (Rudy et al., 2019) , optimal control (Han et al., 2018) , and generative models (Grathwohl et al., 2018) . Our method can be seen as a mode-free sensitivity analysis in real-world systems. In NeuralODE, the gradient with respect to the parameters requires solving ODEs for both states and adjoint states that require a transition model. Since we are working directly on the physical system, we don't need to calculate the integrals forward in time. The systems itself acts as a physical ODE solver. We refer to appendix F for a more detailed review of the related works.

5. CONCLUSION:

In this paper, we present a method to learn the way that the trajectories of a physical real world dynamical system changes with respect to a change in the policy parameters. We tested our method on a custom-built platform called finger robot that allows testing a couple of controllers with various settings to show the applicability of our method for linear, nonlinear, open-loop, and feedback controllers. By estimating the physical derivative function, we showed that our method is able to push a controlled trajectory towards a target intermediate state. We investigate the real-world challenges when doing a fine sensitive task such as estimating physical derivatives on a real robot and proposed solutions to make our algorithm robust to inherent imperfection and noise in physical systems. We focused mainly on low-level issues of physical derivative and showing the feasibility of estimating it robustly. We expect that physical derivatives will contribute to research areas such as safety, control with constrain satisfaction and trajectory planning, robust or safe control.

A PHYSICAL PLATFORM:

In this section, we introduce the physical robot on which we tested our method. The robot is called finger platform or simply finger throughout this paper. The range of movement for the motors are [0, π], [0, π], [0, 2π] respectively. The axes of the plots throughout the paper are in radian. It consists of three articulated arms with three degrees of freedom in total (see fig. 9d ). The motors {m 1 , m 2 , m } are depicted in the figure. This naming remains consistent throughout this paper. Each arm is moved by a separate brushless DC motor and has one degree of freedom to swing in its own plane (see fig. 9a ). Each arm is equipped with an encoder that measures its angle (see fig. 9b ). The brushless motors are controlled by an electronic driver that receives torque values applied to each motor from a computer terminal via a CAN bus and applies the torques to the motors(see fig. 9c ). Due to the imperfections of the arms, motors, and drivers, we did not use any model for the system including the inertial matrix of the robot or the current-torque characteristic function of the motors. The low-cost and safe nature of this robot makes it a suitable platform to test the idea of physical derivatives that requires applying many different controllers in the training phase. 

C APPLICATIONS OF PHYSICAL DERIVATIVES:

If we know how the states of a trajectory change as a result of a change in the policy parameters, the policy can be easily updated to push the trajectory towards a desired one. For example, assume we are interested in going from the current trajectory T (θ) to the target trajectory T * . The distance between these trajectories can get minimized by perturbing the policy parameters in the direction -∂ T (θ) -T * /∂θ. This direction is already available since we have estimated ∂T (θ)/∂θ as a physical derivative. As an exemplary case, we show this application of our method in practice in section 4. Other applications of physical derivatives are in robust control and safety. In both cases, the physical derivative allows us to predict the behaviour of the system if the policy changes in a neighbourhood around a nominal policy. Then, it is possible to make sure that some performance or safety criteria will not be violated for the local perturbation in the policy. As a concrete example, for an autonomous driving system, there can be a calibration phase during which physical derivatives of the car is estimated by perturbing the controller parameters around different nominal policies which are likely to occur in real roads. The calibration must be done in a safe condition and before deploying the system. When deployed, the estimated physical derivatives can be used to predict the effect of a change of the policy on the behaviour of the system and neutralize the change if it would move the car towards unsafe regions of its state space. The command that changes the policy can be issued by a high-level controller (e.g. guidance system), and the safety is confirmed by a low-level mechanisms through physical derivatives. This work focuses on the concept and introduction of physical derivatives and direct applications would go significantly beyond the scope of this work. In the following more detailed description of the use of physical derivatives in robust and safe control.

Robust control In control theory, robust control relates to the design of a controller whose performance is guaranteed for a range of systems and controllers belonging to a certain neighborhood around the nominal system (Zhou & Doyle, 1998) . It is desired to have a controller that keeps the performance of the system at a certain good level even if the parameters of the controller are not fixed to the theoretical values. Assume the performance of the system is associated with some function of a trajectory E(T ). Changing the parameters of the controller θ results in a change in the trajectories. This allows us to compute ∂T /∂θ that consequently gives us ∂E(T )/∂θ by the chain rule. Roughly speaking, between two sets of parameters θ 1 and θ 2 , the set of parameters that gives the least ∂E/∂θ is preferred. This means that by shaking the parameters of the controller and assessing the performance of the system, an estimate of the curvature of the landscape of E(T (θ)) is obtained. We prefer flatter regions of this space where a small change in θ does not cause a drastic change in the performance metric E.

Safety Safety refers to the situations in which the agent may hurt itself or the environment and causes irreversible damages if it freely takes arbitrary actions (Garcıa & Fernández, 2015) . For a safety-critical system whose full physical models are hard to obtain, the physical gradients can assist in avoiding restricting the parameters of the robot to avoid unsafe behavior. The physical derivatives are learned in the Lab environment before the robot is deployed into the wild. For example, a rover whose mission is to safely explore an unknown environment often enjoys a learning loop that allows it to adapt to the new environment. Even though the learning in the new environment requires sufficient exploration, the physical derivatives can be used to give a rough simulation of the robots next few states under a given update to its parameters. The potential harmful updates might be detected by such simulation and be avoided.

D EXTENDED SET OF SOLUTIONS TO THE REAL WORLD CHALLENGES D.1 DETECTING ZERO CROSSING:

In this method, we take advantage of special landmarks in the trajectories. The landmarks are typically caused by physical constraints of the system. For example, when a robot's leg touches the ground, the velocity of the leg becomes zero. Likewise, when a joint reaches its physical limit, the velocity of the connected arm to the joint becomes zero or changes sign. In both cases, a zero crossing occurs that can be used as a landmark to synchronize lagged trajectories with a reference trajectory. Even though this method will eliminate the temporal noise, it requires the presence of such landmarks along the trajectories. Notice that from a mathematical point of view, there is nothing special about zero. We can pick any value of states along a reference trajectory and synchronize all other trajectories with respect to it. However, in practice, physical landmarks are easier to detect and have less ambiguity that consequently gives a more accurate synchronization.

E EXPERIMENTAL DETAILS:

Starting position in all the experiments is ( π 2 , π 2 , π). Task's overall details are as following: In normal sampling cases, we ran 10 simulations for each set of λ parameters which indicates noise level.

E.1 LINEAR:

EQUATION

E.1.1 GAUSSIAN SAMPLING

w i = W i + w,i for i = 1, 2, 3

w,i ∼ N (0, e w × W i 2 ) e w ∼ exp(λ w ) for λ w = 1, 5, 10, 50, 100, 500, 1000, 5000 5, 10, 50, 100, 500, 1000, 5000 W = [0.00001, 0.0001, -0.00001], B = [-0.28, -0.15, -0.08]

b i = B i + b,i for i = 1, 2, 3 b,i ∼ N (0, e b × B i 2 ) e b ∼ exp(λ b ) for λ b = 1,

E.2 PD CONTROLLER Final destination is ( π 10 , 3 π 4 , 7 π 12 ) E.2.1 GAUSSIAN SAMPLING kp = KP +

kp ∼ N (0, e kp × KP ) e kp ∼ exp(λ kp ) for λ kp = 1, 5, 10, 50, 100, 500, 1000, 5000 kd = KD + kd ∼ N (0, e kd × KD ) e kd ∼ exp(λ kd ) for λ kd = 1, 5, 10, 50, 100, 500, 1000, 5000

E.2.2 UNIFORM SAMPLING kp ∼ U (-0.5, 1.5), KP = 1 kd = KD = 0.01 E.3 SINE 1 JOINT E.3.1 GAUSSIAN SAMPLING w = W + w ∼ N (0, e w × W )

e w ∼ exp(λ w ) for λ w = 1, 5, 10, 50, 100, 500, 1000, 5000 a = A + a ∼ N (0, e a × A ) e a ∼ exp(λ a ) for λ a = 1, 5, 10, 50, 100, 500, 1000, 5000

W = 0.01, B = 0.5 E.3.2 UNIFORM SAMPLING w ∼ U (0.005, 0.015), a = A = 0.5 E.3.3 SINE 2 JOINTS E.3.4 GAUSSIAN SAMPLING w i = W i + for i = 1, 2 w,i ∼ N (0, e w × W 2 )

e w ∼ exp(λ w ) for λ w = 1, 5, 10, 50, 100, 500, 1000, 5000

a i = A i + for i = 1, 2 a,i ∼ N (0, e a × A 2 )

e a ∼ exp(λ a ) for λ a = 1, 5, 10, 50, 100, 500, 1000, 5000

W = [0.01, 0.01], A = [-0.4, 0.5] E.3.5 UNIFORM SAMPLING w i ∼ U (0.005, 0.015) for i = 1, 2, a = A = 0.5 E.4 GP SCORE:

Definition of the GP score: The score is defined as (1u/v), where u is the residual sum of squares Σ(y true -y pred ) 2 and v is the total sum of squares Σ(y true -mean(y true )) 2 . The best possible score is 1.0. 

F DETAILED LITERATURE REVIEW:

There has been a recent surge of interest in unsupervised methods in reinforcement learning when a task-specific reward function is not the only driving force to train the agent (Baranes & Oudeyer, 2013; Bellemare et al., 2016; Gregor et al., 2016; Hausman et al., 2018; Houthooft et al., 2016) . A truly intelligent agent must behave intelligently in a range of tasks not only in a single task associated with its reward function. This requires the agent to develop some sort of general competence that allows it to come up with solutions to new problems by combining some low-level primitive skills. This general competence is a key factor in animals to quickly and efficiently adapt to a new problem (Weng et al., 2001) . By calling the traditional RL, extrinsicially motivated RL, the new framework is called intrinsically motivated RL. There have been many ideas in this line with various definitions for the terms motivation and intrinsic. Some researchers assume a developmental period in which the agent acquires some reusable modular skills that can be easily combined to tackle more sophisticated tasks (Kaplan & Oudeyer, 2003; Weng et al., 2001) . Curiosity and confidence are other unsupervised factors that can be used to drive the agent towards unexplored spaces to achieve new skills (Schmidhuber, 1991b; Kompella et al., 2017) . Interestingly, there are observations in neuroscience that dopamine, a known substance that controls one's motivation for extrinsic rewards, is also associated with intrinsic properties of the agent such as novelty and curiosity. A novel sensory stimulus activates the dopamine cells the same way they are activated by extrinsic reward. Children build a collection of skills accumulatively while they engage in activities without a specific goal, e.g., hitting a ball repeatedly without a long-term target such as scoring a goal. The achieved skills contribute to their stability while handling objects (Touwen et al., 1992) .

x (i) < l a t e x i t s h a 1 _ b a s e 6 4 = " j f z e b 6 s y S g 5 m R H L W 8 P 8 7 T B o n

I 5 Q = " > A A A B + X i c b V D L S s N A F L 2 p r 1 p f U Z d u B o t Q N y W p g i 6 L b l x W s A 9 o a 5 l M J + 3 Q y S T M T I o l 5 E / c u F D E r X / i z r 9 x 0 m a h r Q c G D u f c y z 1 z v I g z p R 3 n 2 y q s r W 9 s b h W 3 S z u 7 e / s H 9 u F R S 4 W x J L R J Q h 7 K j o c V 5 U z Q p m a a 0 0 4 k K Q 4 8 T t v e 5 D b z 2 1 M q F Q v F g 5 5 F t B / g k W A + I 1 g b a W D b v Q D r s e c n T + l j U m H n 6 c A u O 1 V n D r R K 3 J y U I U d j Y H / 1 h i G J A y o 0 4 V i p r u t E u p 9 g q R n h N C 3 1 Y k U j T C Z 4 R L u G C h x Q 1 U / m y V N 0 Z p Q h 8 k N p n t B o r v 7 e S H C g 1 C z w z G S W U y 1 7 m f i f 1 4 2 1 f 9 1 P m I h i T Q V Z H P J j j n S I s h r Q k E l K N J 8 Z g o l k J i s i Y y w x 0 a a s k i n B X f 7 y K m n V q u 5 F t X Z / W a 7 f 5 H U U 4 Q R O o Q I u X E E d 7 q A B T S A w h W d 4 h T c

r s V 6 s d + t j M V q w 8 p 1 j + A P r 8 w e T c Z O d < / l a t e x i t >

x (j) < l a t e x i t s h a 1 _ b a s e 6 4 = " E s a z S a y D

m Z Z k 1 W / b V B V p D o O i j d g = " > A A A B + X i c b V D L S s N A F L 2 p r 1 p f U Z d u B o t Q N y V R Q Z d F N

y 4 r 2 A e 0 s U y m k 3 b s Z B J m J s U S 8 i d u X C j i 1 j 9 x 5 9 8 4 b b P Q 1 g M D h 3 P u 5 Z 4 5 f s y Z 0 o 7 z b R V W V t f W N 4 q b p a 3 t n d 0 9 e / + g q a J E

E t o g E Y 9 k 2 8 e K c i Z o Q z P N a T u W F I c + p y 1 / d D P 1 W 2 M q F Y v E v Z 7 E 1 A v x Q L C A E a y N 1 L P t b o j 1 0 A / S p + w h r T y e Z j 2 7 7 F S d G d A y c X N S h h z 1 n v 3 V 7 U c k C a n Q h G O l O q 4 T a y / F U j P C a V b q J o r G m I z w g H Y M F T i k y k t n y T N 0 Y p Q + C i J p n t B o p v 7 e S H G o 1 C T 0 z e Q 0 p 1 r 0 p u J / X i f R w Z W X M h E n m g o y P x Q k H O k I T W t A f S Y p 0 X x i C C a S m a y I D L H E R J u y S q Y E d / H L y 6 R 5 V n X P q 2 d 3 F + X a d V 5 H E Y 7 g G C r g w i X U 4 B b q 0 A A C Y 3 i G V 3 i z U u v

F e r c + 5 q M F K 9 8 5 h D + w P n 8 A l P e T n g = = < / l a t e x i t >

x (i) < l a t e x i t s h a 1 _ b a s e 6 4 = " j f z e b 6 s y S g 5 m R H L W 8 P 8 7 T B o n I 5 Q = " > A A A B + X i c b V D L S s N A F L 2 p r 1 p f U Z d u B o t Q N y W p g i 6 L b l x W s A 9 o a 5 l M J + 3 Q y S T M T I o l 5 E / c u F D E r X / i z r 9 x 0 m a h r Q c G D u f c y z 1 z v I g z p R 3 n 2 y q s r W 9 s b h W 3 S z u 7 e / s H 9 u F R S 4 W

x J L R J Q h 7 K j o c V 5 U z Q p m a a 0 0 4 k K Q 4 8 T t v e 5 D b z 2 1 M q F Q v F g 5 5 F t B / g k W A + I 1 g b a W D b v Q D r s e c n T + l j U m H n 6 c A u O 1 V n D r R K 3 J y U I U d j Y H / 1 h i G J A y o 0 4 V i p r u t E u p 9 g q R n h N C 3 1 Y k U j T C Z 4 R L u G C h x Q 1 U / m y V N 0 Z p Q h 8 k N p n t B o r v 7 e S H C g 1 C z w z G S W U y 1 7 m f i f 1 4 2 1 f 9 1 P m I h i T Q V Z H P J j j n S I s h r Q k E l K N J 8 Z g o l k J i s i Y y w x 0 a a s k i n B X f 7 y K m n V q u 5 F t X Z / W a 7 f 5 H U U 4 Q R O o Q I u X E E d 7 q A B

T S A w h W d 4 h T c r s V 6 s d + t j M V q w 8 p 1 j + A P r 8 w e T c Z O d < / l a t e x i t >

x (j) < l a t e x i t s h a 1 _ b a s e 6 4 = " E s a z S a y D

m Z Z k 1 W / b V B V p D o O i j d g = " > A A A B + X i c b V D L S s N A F L 2 p r 1 p f U Z d u B o t Q N y V R Q Z d F N

y 4 r 2 A e 0 s U y m k 3 b s Z B J m J s U S 8 i d u X C j i 1 j 9 x 5 9 8 4 b b P Q 1 g M D h 3 P u 5 Z 4 5 f s y Z 0 o 7 z b R V W V t f W N 4 q b p a 3 t n d 0 9 e / + g q a J E

E t o g E Y 9 k 2 8 e K c i Z o Q z P N a T u W F I c + p y 1 / d D P 1 W 2 M q F Y v E v Z 7 E 1 A v x Q L C A E a y N 1 L P t b o j 1 0 A / S p + w h r T y e Z j 2 7 7 F S d G d A y c X N S h h z 1 n v 3 V 7 U c k C a n Q h G O l O q 4 T a y / F U j P C a V b q J o r G m I z w g H Y M F T i k y k t n y T N 0 Y p Q + C i J p n t B o p v 7 e S H G o 1 C T 0 z e Q 0 p 1 r 0 p u J / X i f R w Z W X M h E n m g o y P x Q k H O k I T W t A f S Y p 0 X x i C C a S m a y I D L H E R J u y S q Y E d / H L y 6 R 5 V n X P q 2 d 3 F + X a d V 5 H E Y 7 g G C r g w i X U 4 B b q 0 A A C Y 3 i G V 3 i z U u v

F e r c + 5 q M F K 9 8 5 h D + w P n 8 A l P e T n g = = < / l a t e x i t >

x (i) < l a t e x i t s h a 1 _ b a s e 6 4 = " j f z e b 6 s y S g 5 m R H L W 8 P 8 7 T B o n

I 5 Q = " > A A A B + X i c b V D L S s N A F L 2 p r 1 p f U Z d u B o t Q N y W p g i 6 L b l x W s A 9 o a 5 l M J + 3 Q y S T M T I o l 5 E / c u F D E r X / i z r 9 x 0 m a h r Q c G D u f c y z 1 z v I g z p R 3 n 2 y q s r W 9 s b h W 3 S z u 7 e / s H 9 u F R S 4 W x J L R J Q h 7 K j o c V 5 U z Q p m a a 0 0 4 k K Q 4 8 T t v e 5 D b z 2 1 M q F Q v F g 5 5 F t B / g k W A + I 1 g b a W D b v Q D r s e c n T + l j U m H n 6 c A u O 1 V n D r R K 3 J y U I U d j Y H / 1 h i G J A y o 0 4 V i p r u t E u p 9 g q R n h N C 3 1 Y k U j T C Z 4 R L u G C h x Q 1 U / m y V N 0 Z p Q h 8 k N p n t B o r v 7 e S H C g 1 C z w z G S W U y 1 7 m f i f 1 4 2 1 f 9 1 P m I h i T Q V Z H P J j j n S I s h r Q k E l K N J 8 Z g o l k J i s i Y y w x 0 a a s k i n B X f 7 y K m n V q u 5 F t X Z / W a 7 f 5 H U U 4 Q R O o Q I u X E E d 7 q A B T S A w h W d 4 h T c

r s V 6 s d + t j M V q w 8 p 1 j + A P r 8 w e T c Z O d < / l a t e x i t >

x (j) < l a t e x i t s h a 1 _ b a s e 6 4 = " E s a z S a y D

m Z Z k 1 W / b V B V p D o O i j d g = " > A A A B + X i c b V D L S s N A F L 2 p r 1 p f U Z d u B o t Q N y V R Q Z d F N

y 4 r 2 A e 0 s U y m k 3 b s Z B J m J s U S 8 i d u X C j i 1 j 9 x 5 9 8 4 b b P Q 1 g M D h 3 P u 5 Z 4 5 f s y Z 0 o 7 z b R V W V t f W N 4 q b p a 3 t n d 0 9 e / + g q a J E

E t o g E Y 9 k 2 8 e K c i Z o Q z P N a T u W F I c + p y 1 / d D P 1 W 2 M q F Y v E v Z 7 E 1 A v x Q L C A E a y N 1 L P t b o j 1 0 A / S p + w h r T y e Z j 2 7 7 F S d G d A y c X N S h h z 1 n v 3 V 7 U c k C a n Q h G O l O q 4 T a y / F U j P C a V b q J o r G m I z w g H Y M F T i k y k t n y T N 0 Y p Q + C i J p n t B o p v 7 e S H G o 1 C T 0 z e Q 0 p 1 r 0 p u J / X i f R w Z W X M h E n m g o y P x Q k H O k I T W t A f S Y p 0 X x i C C a S m a y I D L H E R J u y S q Y E d / H L y 6 R 5 V n X P q 2 d 3 F + X a d V 5 H E Y 7 g G C r g w i X U 4 B b q 0 A A C Y 3 i G V 3 i z U u v F e

r c + 5 q M F K 9 8 5 h D + w P n 8 A l P e T n g = = < / l a t e x i t > d < l a t e x i t s h a 1 _ b a s e 6 4 = " i 4

T 7 b f C H i b Y N J N n g w p / p 1 + T X A D k = " > A A A B 6 H i c b V B N S 8 N A E J 3 U r 1 q / q h 6 9 L B b B U 0 m q o M e i F 4 8 t 2 F p o Q 9 l s J u 3 a z S b s b o R S + g u 8 e F D E q z / J m / / G b Z u D t j 4 Y e L w 3 w 8 y 8 I B V c G 9 f 9 d g p r 6 x u b W 8 X t 0 s 7 u 3 v 5 B + f C o r Z N M M W y x R C S q E 1 C N g k t s G W 4 E d l K F N A 4 E P g S j 2 5 n / 8 I R K 8 0 T e m 3 G K f k w H k k e c U W O l Z t g v V 9 y q O w d Z J V 5 O K p C j 0 S 9 / 9 c K E Z T F K w w T V u u u 5 q f E n V B n O B E 5 L v U x j S t m I D r B r q a Q x a n 8 y P 3 R K z q w S k i h R t q Q h c / X 3 x I T G W o / j w H b G 1 A z 1 s j c T / / O 6 m Y m u / Q m X a W Z Q s s W i K B P E J G T 2 N Q m 5 Q m b E 2 B L K F L e 3 E j a k i j J j s y n Z E L z l l 1 d J u 1 b 1 L q q 1 5 m W l f p P H U Y Q T O I V z 8 O A K 6 n A H D W g B A 4 R n e I U 3 5 9 F 5 c d 6 d j 0 V r w c l n j u E P n M 8 f y T e M 7 A = = < / l a t e x i t > ⌫ = d( p 6 1) w < l a t e x i t s h a 1 _ b a s e 6 4 = " o q S q G k 3 G m r V P p o o I c 5 I 1 Y G p G F j A = " > A A A C D 3 i c b V B N S 8 N A E N 3 4 W e t X 1 a O X x a L o w Z J U U S 9 C U Q 8 e K 1 h b a E L Z b D e 6 d L O J u x O l h P w D L / 4 V L x 4 U 8 e r V m / / G b Z u D V h 8 M P N 6 b Y W a e H w u u w b a / r I n J q e m Z 2 c J c c X 5 h c W m 5 t L J 6 p a N E U d a g k Y h U y y e a C S 5 Z A z g I 1 o o V I 6 E v W N P v n Q 7 8 5 h 1 T m k f y E v o x 8 0 J y L X n A K Q E j d U p b r k z w M X Y D R W j a 3 X b 1 r Y L 0 I M O 7 2 N n J U v e M C S D 4 P u u U y n b F H g L / J U 5 O y i h H v V P 6 d L s R T U I m g Q q i d d u x Y / B S o o B T w b K i m 2 g W E 9 o j 1 6 x t q C Q h 0 1 4 6 / C f D m 0 b p 4 i B S p i T g o f p z I i W h 1 v 3 Q N 5 0 h g R s 9 7 g 3 E / 7 x 2 A s G R l 3 I Z J 8 A k H S 0 K E o E h w o N w c J c r R k H 0 D S F U c X M r p j f E R A M m w q I J w R l / + S + 5 q l a c v U r 1 Y r 9 c O 8 n j K K B 1 t I G 2 k Y M O U Q 2 d o z p q I I o e 0 B N 6 Q a / W o / V s v V n v o 9 Y J K 5 9 Z Q 7 9 g f X w D 6 X m b U w = = < / l a t e x i t > ⌫ = d p 3 w < l a t e x i t s h a 1 _ b a s e 6 4 = " V 9 Y F j E l V Z W M s L y 6 i C S I B x n u H m z E = " > A A A C C n i c b V D L S s N A F J 3 4 r P U V d e l m t A i u S t I K u h G K u n B Z w T 6 g K W U y n b R D J 5 M 4 c 6 O U k L U b f 8 W N C 0 X c + g X u / B u n j 4 W 2 H r h w O O d e 7 r 3 H j w X X 4 D j f 1 s L i 0 v L K a m 4 t v 7 6 x u b V t 7 + z W d Z Q o y m o 0 E p F q + k Q z w S W r A Q f B m r F i J P Q F a / i D y 5 H f u G d K 8 0 j e w j B m 7 Z D 0 J A 8 4 J W C k j n 3 g y Q S f Y y 9 Q h K Z d 7 O k 7 B W k 5 y 1 L v i g k g + C H r 2 A W n 6 I y B 5 4 k 7 J Q U 0 R b V j f 3 n d i C Y h k 0 A F 0 b r l O j G 0 U 6 K A U 8 G y v J d o F h M 6 I D 3 W M l S S k O l 2 O n 4 l w 0 d G 6 e I g U q Y k 4 L H 6 e y I l o d b D 0 D e d I Y G + n v V G 4 n 9 e K 4 H g r J 1 y G S f A J J 0 s C h K B I c K j X H C X K 0 Z B D A 0 h V H F z K 6 Z 9 Y l I B k 1 7 e h O D O v j x P 6 q W i W y 6 W b k 4 K l Y t p H D m 0 j w 7 R M X L R K a q g a 1 R F N U T R I 3 p G r + j N e r J e r H f r Y 9 K 6 Y E 1 n 9 t A f W J 8 / v a S a T w = = < / l a t e x i t > ⌫ = d( p 11 2) w < l a t e x i t s h a 1 _ b a s e 6 4 = " b C Z F E U W s Q l A 6 j P W 7 l S p T B j L M v v o = " > A A A C E H i c b V C 7 S g N B F J 2 N r x h f U U u b w S D G w r A b B W 2 E o B a W E c w D s i H M T m a T I b O z 6 8 x d J S z 7 C T b + i o 2 F I r a W d v 6 N k 0 e h 0 Q M X D u f c y 7 3 3 e J H g G m z 7 y 8 r M z S 8 s L m W X c y u r a + s b + c 2 t u g 5 j R V m N h i J U T Y 9 o J r h k N e A g W D N S j A S e Y A 1 v c D H y G 3 d M a R 7 K G x h G r B 2 Q n u Q + p w S M 1 M n v u z L G Z 9 j 1 F a F J t + j q W w W J 4 6 T 4 E J c P 0 s S 9 Z A I I v k 8 7 + Y J d s s f A f 4 k z J Q U 0 R b W T / 3 S 7 I Y 0 D J o E K o n X L s S N o J 0 Q B p 4 K l O T f W L C J 0 Q H q s Z a g k A d P t Z P x Q i v e M 0 s V + q E x J w G P 1 5 0 R C A q 2 H g W c 6 A w J 9 P e u N x P + 8 V g z + a T v h M o q B S T p Z 5 M c C Q 4 h H 6 e A u V 4 y C G B p C q O L m V k z 7 x G Q D J s O c C c G Z f f k v q Z d L z l G p f H 1 c q J x P 4 8 i i H b S L i s h B J 6 i C r l A V 1 R B F D + g J v a B X 6 9 F 6 t t 6 s 9 0 l r x p r O b K N f s D 6 + A V 2 O m 4 o = < / l a t e x i t >

Figure 15 : The maximum potential error in the estimated gradients when the space is voxelized. As can be seen, the error is vanishing when the corresponding voxels to x (i) and x (j) are far from each other.

Another line of work concerns the fundamental constraints of the agent/environment and ensures those constraints are met while learning. For example, in many practical systems, learning episodes must halt if the system is likely to undergo an irreversible change. For example, the training episodes of a fragile robot must ensure the robot does not fall or will not be broken in any circumstance while acting under a certain policy. The general name safe RL embodies ideas to tackle such issues in current interactive learning algorithms (Garcıa & Fernández, 2015) . One major aspect of safety is stability that loosely means that states of the system converge to some invariant sets or remain within a certain bound (Lyapunov, 1992) . Control theory enjoys a physical model of the system to guarantee stability (Khalil, 2002) . When the physical model is not known in advance, the model is either learned along with the policy (model-based RL) or will be implicitly distilled in the value function (model-free RL) (Sutton & Barto, 2018) . Stability can be categorized as an intrinsic motivation for the agent. No matter what task the agent aims to solve, it must remain stable all the time. Learning the transition model which is the major concern of model-based RL can also be seen as intrinsic motivation. The agent learns to predict the future step given the current state. The advantage of learning a model-even inaccurately-is twofold: the agent would know where to go and where not to go. It knows which regions of the state space is unsafe to explore and must be avoided. It also knows which regions are unexplored and might be informative to improve the model. This brings us to another view to intrinsic reward that encourages diversity.

Our work is also relevant to sensitivity analysis and its use in trainig the parameters of dynamical models. After Chen et al.'s NeuralODE on training neural networks by sensitivity analysis of the network parameters, the method was successfully applied to various tasks such as learning dynamics (Rudy et al., 2019) , optimal control (Han et al., 2018) , and generative models (Grathwohl et al., 2018) . Our method can be seen as a mode-free sensitivity analysis in real-world systems. In NeuralODE, the gradient with respect to the parameters requries solving ODEs for both states and adjoint states that require a transition model. Since we are working directly on the physical system, we don't need to calculate the integrals forward in time. The systems itself acts as a physical ODE solver.

The importance of learning from unlabelled experiences is a known fact in animals. Many animals function efficiently soon after birth before being exposed to a massive labeled experience. Part of it might be due to unsupervised learning but the major part of the story can be a genetic heritage after years of evolution that Zador called genomic bottleneck. The same idea turned out to be valid in statistical learning where an automatically discovered neural network architecture peforms surpsingly well with a shared random weight (Gaier & Ha, 2019) . The embedded inductive bias in the neural network architectures could be analogous to the wiring of the brain of animal babies which transfers from generation to generation by genes.

F.1 PROOFS Proof to the lemma on voxelization error.

Proof. The voxels become boxes in 3D as in fig. 15 . The gradient is estimated as the distance between two points in 3D coordinates. Hence the source of voxelization error is approximating the distance between two points in 3D with the distance between the centers of the corresponding boxes to which those points belong. This error is written next to the boxes in fig. 15 . The maximmum error is inversely proportional to the distance between voxels. Meaning that the voxels which are located far away will induce less voxelization error. This is intuitively clear. When two points are too distant from each other, a slight change in their position would not change the distance between them considerably. The upper bound on the error, however, occurs for a single voxel where the error is bounded by the size of the voxel. 

:

https://sites.google.com/view/physicalderivatives/

Figures and Tables:

Figure 1: Physical finger platform in action with different policies.

l a t e x i t s h a 1 _ b a s e 6 4 = " b 2

Figure 2: Gaussian (left) and uniform (right) shaking examples.

Figure 3: The effect of voxels on supressing spatial noise of the physical system. The trajectories are produced by linear open-loop controllers as those in section 4.1 for the purpose of illustrating the effect of voxelization.

Figure 4: PD controller with various noise intensities on K p parameter.

fig. 7 shows examples of nominal trajectories + trajectories produced by the perturbed controller and the computed derivatives. The arrows are plotted as they originate from the perturbed trajectories only for easier distinction. Each arrow corresponds to the change of the states at a certain time step on the source trajectory as a result of perturbing the policy. Each figure corresponds to a pair of nominal values of {w, b} for the linear open-loop controller. See fig. 29 for examples.

Figure 7: Pysical gradients computed for various time steps along a source trajetcory using two perturbed trajectories of linear open-loop controller.

Figure 8: Zero-shot planning with constraint satisfaction. The orange trajectory is the source produced by the nominal controller. The green and blue are two sampled trajectoreis that are produced by perturbing k p to k * p by eq. (21)

is changeable. If the physical derivatives map is available, we have access to ĝt (k * pk (s)

Figure 9: Components of the physical finger platform

Figure 10: Same controller applied for multiple runs. The trajectories are produced by the linear open-loop controller similar to those used in section 4.1. See the plot for a different set of nominal parameters of the controller in fig. 13 in the Appendix (Zooming is recommended)

Figure 11: The same as fig. 10 but for a different setting.

Figure 12: Noisy linear open-loop controller

Figure 13: The same as fig. 12 but for a different nominal parameters of the policy.

Figure 14: The effect of temporal noise in delaying one trajectory versus the other one and its correction. The trajectories are produced by the linear open-loop controller similar to those used in section 4.1(Zooming is recommended)

ZERO-SHOT PLANNING TASK: For the task of section 4.4: Number of training trajectories: 100 each with 1500 time steps Kd = 0.01 Kp = Uniformly sampled from [0.2, 0.6] Initial point: X • = [π/2, π/2, π]) desired position = [π/10, 3 * π/4, 7 * π/12]

Figure 17: The time evolution of the learned GP models from directional derivatives for ∂x 3 /∂k p by uniform sampling

Figure 29: Examples of trajectories produced by the perturbed controller and the computed derivatives along the trajectory. The arrows are plotted as they originate from the perturbed trajectories only for easier distinction. Each arrow corresponds to the change of the states at a certain time step on the source trajectory as a result of perturbing the policy. Each figure corresponds to a pair of nominal values of {w, b} for the linear open-loop controller of section 4.1 and the perturbed trajectories are produced by Gaussian sampling.

The aggregate performance of our method to predict physical derivatives in unseen directions of perturbations to the parameters. • shows time average. The first column is the normalized time averaged MSE. The second column is the time averaged GP score (closer to 1 is better. See appendix E.4 for definition). The third column is the time averaged misalignment between derivatives. Every experiment is repeated for 10 voxel sizes and the values are chosen for the best voxel size. N: Gaussian sampling, U: uniform sampling.

Table content: <table><tr><td>Task</td><td/><td>MSE</td><td>Score</td><td>cos α</td></tr><tr><td colspan="5">PD controller (N) 0.00871 0.8991 0.9492</td></tr><tr><td colspan="3">PD controller (U) 0.0018</td><td colspan="2">0.9841 0.9723</td></tr><tr><td colspan="2">Sine 2 joints (U)</td><td>0.0368</td><td colspan="2">0.7992 0.9513</td></tr><tr><td colspan="2">Sine 2 joints (N)</td><td>0.0796</td><td colspan="2">0,6696 0,9553</td></tr><tr><td>(a)</td><td>(b)</td><td/><td>(c)</td><td>(d)</td></tr></table>

Peer review (iclr2020):
*Summary of paper* This paper investigates the use of random perturbations applied to a robotic policy to learn a local gradient useful for policy optimization. The method aims to learn a policy directly on a real physical robotic system, bypassing both simulation models and model-free RL. Training pairs are gathered by perturbations of a starting policy, and the *gradient* is captured in a probabilistic model learned from the training data. The paper includes experiments on a custom 3-DOF robotic platform. *Decision* I vote for rejecting this paper. While the idea is interesting, the paper lacks precision in key areas and the method is not placed in context among related work. Further, it fails to communicate key ideas (particularly in the experiments) to a non-robotics reader. Without sufficient clarity and background, it is not suited to a general machine learning conference. - Lemma 3, which attempts to justify the use of voxelization, and its proof are both imprecise and inadequate. To improve precision, please define *error causes by voxelization* in mathematical terms, e.g. ||c_i - x_i||. Also, while the statement of the lemma un-intuitively implies that larger voxels introduce smaller errors, the proof seems to say that larger errors will result for smaller gradients if larger voxels are used. - Related work: How does this work relate to random search/evolutionary computation? How does it compare to performing those methods or a model-free RL method directly on the robot? How does it compare to learning using an inaccurate model for robot dynamics? Presumably there are numerous methods that have been tried in this area, so further context is needed. - The evaluation is unclear, at least to a non-expert in robotics. A lack of quantitative evaluation further exacerbates this issue: nearly all experiments, even those with associated plots, are characterized qualitatively and without reference the performance of related methods. - In addition to addressing the limitations above, I would encourage the authors to consider the use of experiments in simulation to thoroughly and quantitatively investigate the convergence/bias/variance of the gradient model w.r.t. #DoF of the robot, length of the trajectory, voxelization, # sampled trajectories, perturbation sampling method, and robot reliability/reproducibility *Additional feedback* - spelling errors throughout; please check thoroughly - the captions/labels/etc. in most figures is far too small to read in a printed copy of the paper - What is the intuition for the *empirical distribution p_e(T|pi) = ...* on page 2? Is it counting the exact matches between the trajectory T and the M observed trajectories? (This may be more clear in the context of voxelization introduced later.) - Figure 3: what are the units for gamma? what is the time step? - many of the figures are out of order w.r.t. their introduction in the text