Probabilistic Movement Primitives Part 3: Supervised Learning
In this post, we describe how a Probabilistic Movement Primitive can be learnt from demonstrations using supervised learning.
Learning from Demonstrations
To simplify the learning of the parameters
It can be observed from the above equation, that the learnt ProMP distribution is Gaussian with,
Learning Stroke-based Movements
For stroke-based movements, the parameter
where
The mean
where
Let's code
W = [] # list that stores all the weights
mean_W = None
sigma_W = None
mid_term = np.dot(Phi, Phi.T) + np.dot(Phi_dot, Phi_dot.T)
for demo_traj in pos_list:
interpolate = interp1d(z, demo_traj, kind='cubic')
stretched_demo = interpolate(z)[None,:] # strech the trajectory to fit 0 to 1
w_d = np.dot(np.linalg.inv(mid_term + 1e-12*np.eye(n_bfs)),
np.dot(Phi, stretched_demo.T)).T # weights for each trajectory
W.append(w_d.copy()) # append the weights to the list
W = np.asarray(W).squeeze()
mean_W = np.mean(W, axis=0)
sigma_W = np.cov(W.T)
# Computing the mean and sigma of the sampled trajectory
mean_of_sample_traj = np.dot(Phi.T, mean_W)
sigma_of_sample_traj = np.dot(np.dot(Phi.T, sigma_W), Phi) + 1e-10 # Sigma_y
The learnt stroke-based ProMP distribution is shown in blue over the demonstration distribution in red.
References:
Comments
Post a Comment