Constructing skill trees
Constructing skill trees (CST) is a hierarchical reinforcement learning algorithm which can build skill trees from a set of sample solution trajectories obtained from demonstration. CST uses an incremental MAP (maximum a posteriori) change point detection algorithm to segment each demonstration trajectory into skills and integrate the results into a skill tree. CST was introduced by George Konidaris, Scott Kuindersma, Andrew Barto and Roderic Grupen in 2010.[1]
Algorithm
CST consists of mainly three parts;change point detection, alignment and merging. The main focus of CST is online change-point detection. The change-point detection algorithm is used to segment data into skills and uses the sum of discounted reward [math]\displaystyle{ R_t }[/math] as the target regression variable. Each skill is assigned an appropriate abstraction. A particle filter is used to control the computational complexity of CST.
The change point detection algorithm is implemented as follows. The data for times [math]\displaystyle{ t\in T }[/math] and models Q with prior [math]\displaystyle{ p(q\in Q) }[/math] are given. The algorithm is assumed to be able to fit a segment from time [math]\displaystyle{ j+1 }[/math] to t using model q with the fit probability [math]\displaystyle{ P(j,t,q)^{}_{} }[/math]. A linear regression model with Gaussian noise is used to compute [math]\displaystyle{ P(j,t,q) }[/math]. The Gaussian noise prior has mean zero, and variance which follows [math]\displaystyle{ \mathrm{InverseGamma}\left(\frac{v}{2}, \frac{u}{2}\right) }[/math]. The prior for each weight follows [math]\displaystyle{ \mathrm{Normal}(0, \sigma^{2} \delta) }[/math].
The fit probability [math]\displaystyle{ P(j,t,q) }[/math] is computed by the following equation.
- [math]\displaystyle{ P(j,t,q)=\frac{\pi^{-\frac{n}{2}}}{\delta^m}\left|(A+D)^{-1}\right|^{\frac{1}{2}}\frac{u^{\frac{v}{2}}}{(y+u)^{\frac{u+v}{2}}}\frac{\Gamma(\frac{n+v}{2})}{\Gamma({\frac{v}{2}})} }[/math]
Then, CST compute the probability of the changepoint at time j with model q, [math]\displaystyle{ P_t(j,q) }[/math] and [math]\displaystyle{ P^\text{MAP}_j }[/math] using a Viterbi algorithm.
- [math]\displaystyle{ P_t(j,q)=(1-G(t-j-1))P(j,t,q)p(q)P^\text{MAP}_j }[/math]
- [math]\displaystyle{ P^\text{MAP}_{j}=\max_{i,q}\frac{P_j(i,q)g(j-i)}{1-G(j-i-1)}, \forall j\lt t }[/math]
The descriptions of the parameters and variables are as follows;
- [math]\displaystyle{ A=\sum^t_{i=j}\Phi(x_i)\Phi(x_i)^T }[/math]
- [math]\displaystyle{ \Phi(x_i) }[/math]: a vector of m basis functions evaluated at state [math]\displaystyle{ x_i }[/math]
- [math]\displaystyle{ y=(\sum^t_{i=j}R^2_{i})-b^T(A+D)^{-1}b }[/math]
- [math]\displaystyle{ b=\sum^t_{i=j}R_i\Phi(x_i) }[/math]
- [math]\displaystyle{ R_i=\sum^T_{j=i}\gamma^{j-i}r_{j} }[/math]
- Template:Gamma: Gamma function
- [math]\displaystyle{ n=t-j }[/math]
- m: The number of basis functions q has.
- D: an m by m matrix with [math]\displaystyle{ \delta^{-1} }[/math] on the diagonal and zeros elsewhere
The skill length l is assumed to follow a Geometric distribution with parameter p
- [math]\displaystyle{ g^{}_{}(l)=(1-p)^{l-1}p }[/math]
- [math]\displaystyle{ G^{}_{}(l)=(1-(1-p)^l) }[/math]
- [math]\displaystyle{ p^{}_{}=\frac{1}{k} }[/math]
- k: Expected skill length
Using the method above, CST can segment data into a skill chain. The time complexity of the change point detection is [math]\displaystyle{ O(NL) }[/math] and storage size is [math]\displaystyle{ O(Nc) }[/math], where N is the number of particles, L is the time of computing [math]\displaystyle{ P(j,t,q) }[/math], and there are [math]\displaystyle{ O(c) }[/math] change points.
Next step is alignment. CST needs to align the component skills because the change-point does not occur in the exactly same places. Thus, when segmenting second trajectory after segmenting the first trajectory, it has a bias on the location of change point in the second trajectory. This bias follows a mixture of gaussians.
The last step is merging. CST merges skill chains into a skill tree. CST merges a pair of trajectory segments by allocating the same skill. All trajectories have the same goal and it merges two chains by starting at their final segments. If two segments are statistically similar, it merges them. This procedure is repeated until it fails to merge a pair of skill segments. [math]\displaystyle{ P(j,t,q) }[/math] are used to determine whether a pair of trajectories are modeled better as one skill or as two different skills.
Pseudocode
The following pseudocode describes the change point detection algorithm:
particles := [];
Process each incoming data point
for t = 1:T do
//Compute fit probabilities for all particles
for p ∈ particles do
p_tjq := (1 − G(t − p.pos − 1)) × p.fit_prob × model_prior(p.model) × p.prev_MAP
p.MAP := p_tjq × g(t−p.pos) / (1 − G(t − p.pos − 1))
end
// Filter if necessary
if the number of particles ≥ N then
particles := particle_filter(p.MAP, M)
end
// Determine the Viterbi path
for t = 1 do
max_path := []
max_MAP := 1/|Q|
else
max_particle := p.MAP
max_path := max_particle.path ∪ max_particle
max_MAP := max_particle.MAP
end
// Create new particles for a changepoint at time t
for q ∈ Q do
new_p := create_particle(model=q, pos=t, prev_MAP=max_MAP, path=max_path)
p := p ∪ new_p
end
// Update all particles
for p ∈ P do
particles := update_particle(current_state, current_reward, p)
end
end
// Return the most likely path to the final point
return max_path
function update_particle(current_state, current_reward, particle) is p := particle r_t := current_reward // Initialization if t = 0 then p.A := zero matrix(p.m, p.m) p.b := zero vector(p.m) p.z := zero vector(p.m) p.sum r := 0 p.tr1 := 0 p.tr2 := 0 end if // Compute the basis function vector for the current state Φt := p.Φ (current state) // Update sufficient statistics p.A := p.A + ΦtΦTt p.z := Template:Gammap.z + Φt p.b := p.b + rt p.z p.tr1 := 1 + Template:Gamma2 p.tr1 p.sum r := sum p.r + r2t p.tr1 + 2Template:Gammart p.tr2 p.tr2 := Template:Gammap.tr2 + rt p.tr1 p.fit_prob := compute_fit_prob(p, v, u, delta, Template:Gamma)
Assumptions
CTS assume that the demonstrated skills form a tree, the domain reward function is known and the best model for merging a pair of skills is the model selected for representing both individually.
Advantages
CST is much faster learning algorithm than skill chaining. CST can be applied to learning higher dimensional policies. Even unsuccessful episode can improve skills. Skills acquired using agent-centric features can be used for other problems.
Uses
CST has been used to acquire skills from human demonstration in the PinBall domain. It has been also used to acquire skills from human demonstration on a mobile manipulator.
See also
References
- ↑ Jeevanandam, Nivash (2021-09-13). "Underrated But Fascinating ML Concepts #5 – CST, PBWM, SARSA, & Sammon Mapping" (in en). https://analyticsindiamag.com/underrated-but-fascinating-ml-concepts-5-cst-pbwm-sarsa-sammon-mapping/.
- Konidaris, George; Scott Kuindersma; Andrew Barto; Roderic Grupen (2010). "Constructing Skill Trees for Reinforcement Learning Agents from Demonstration Trajectories".
- Konidaris, George; Andrew Barto (2009). "Skill discovery in continuous reinforcement learning domains using skill chaining".
- Fearnhead, Paul; Zhen Liu (2007). "On-line Inference for Multiple Change Points".
Original source: https://en.wikipedia.org/wiki/Constructing skill trees.
Read more |