ot -- Observation resulting from the state. Not necessarily the true state (e.g. cheetah and gazelle and car)
at -- Action (often a distribution)l
πθ(at∣ot) -- Policy based on ot (or st) which outputs a distribution over at given ot (at∣ot)
θ -- Policy parameters e.g. in a NN, θ = weights
Markov Property -- Given a state, one can figure out the distribution over the next state without knowing the previous state.
Given st we can find p(st+1∣st,at) without st−1. It is worth noting that observations do not necessarily have the Markov Property.
Behavior Cloning
pdata(ot) -- The distribution of observations seen in the training data
Often doesn't work because small errors in the learned model compound and it doesn't know how to recover (e.g. NVIDIA car).
The mathematical explanation is that when running the expected trajectory we're sampling from the distribution πθ(at∣ot), which was trained on the data distribution pdata(ot). When errors compound pdata(ot)=pπθ(ot).
Data Aggregation (DAgger)
We need pπθ(ot)=pdata(ot) to minimize the errors seen in behavior cloning. What if, instead of optimizing pπθ(ot), we optimized pdata(ot)? We want to collect training date from pπθ(ot) instead of pdata(ot), which we can do by running πθ(at∣ot) once we have at.
Train πθ(at∣ot) on data from a human D={o1,a1,…,oN,aN}
Run πθ(at∣ot) to get dataset Dπ={o1,…,oM}
Get human to label Dπ with optimal actions at
Merge the two datasets D←D∪Dπ
Start again from 1. with new D
The problematic step here is 3.
It's possible to make a model without the distributional drift problem, but first: why might we fail to fit the expert?
Even if ot is Markovian (πθ(at∣ot)), the expert (the human) might exhibit non-Markovian behavior (πθ(at∣o1,…,ot)). This can be solved by using a recurrent neural network (RNN) with Long Short-Term Memory (LSTM).
The demonstrator might inconsistently choose between different modes in the distribution, which is hard to imitate. The average of two good actions could be a bad action! This can be solved with three techniques:
We could represent the distribution as a mixture of Gaussians π(a∣0)=∑iwiN(μi,Σi). This can get complicated quickly as you add more mixture elements.
We could input a latent variable ξ≃N(0,I) into the model alongside our images, essentially injecting random noise. Can theoretically represent any distribution, but can be hard to train.
Autoregressive discretization is a happy medium between the two options listed above. It takes advantage of the fact that discrete actions are easily representable by a softmax distribution, sidestepping the multi-modality problem.
Cost Functions
How can we "score" actions mathematically? Cost/reward functions! If we wanted to minimize cost (note that the cost is the negative of the reward) (we do), we would minimize the expectation under a distribution over sequences of states and actions of the sum of the cost function.
minθ(Es1:T,a1:T[t∑c(st,at)])
A reasonable reward function could be the log probability of an expert's action:
r(s,a)=logp(a=π∗(s)∣s)
π∗ is the unknown expert policy. Another cost function could be a 0-1 loss function, which assigns a 0 if we perfectly match the expert's actions and a 1 in every other case (harsh!):
c(s,a)={0ifa=π∗(s)1otherwise
If we assume that πθ(a=π∗(s)∣s)≤ϵ for all s∈Dtrain (remember the tightrope walker scenario) then the probability function is:
Note that this is naively assuming that for all states in the training set, the probability of making a mistake at those steps is ≤ϵ, where ϵ is a small number. Using the identity (1−ϵ)t≥1−ϵt for ϵ∈[0,1] we can simplify: