-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update pytorch interface #65
Conversation
I did a 10-minute test to verify that the pytorch interface can be used in a neural network. I created a small NN that takes in input a constant value, it has some intermediate layers, with the last one a forward kinematics function. The network outputs 2 homogenous transforms ( This is the script:
The output of the network, i.e. the predicted homogeneous transforms of target lsole: tensor([[-0.4314, 0.7503, -0.5010, 1.1846],
[ 0.7966, 0.5775, 0.1789, 1.1001],
[ 0.4235, -0.3219, -0.8468, -0.6390],
[ 0.0000, 0.0000, 0.0000, 1.0000]], dtype=torch.float64)
output lsole: tensor([[-0.4314, 0.7503, -0.5010, 1.1846],
[ 0.7966, 0.5775, 0.1789, 1.1001],
[ 0.4235, -0.3219, -0.8468, -0.6390],
[ 0.0000, 0.0000, 0.0000, 1.0000]], dtype=torch.float64,
grad_fn=<MmBackward0>)
target llower leg: tensor([[-0.4487, 0.8847, 0.1266, 1.1776],
[ 0.7305, 0.2815, 0.6222, 1.2364],
[ 0.5148, 0.3716, -0.7726, -0.8485],
[ 0.0000, 0.0000, 0.0000, 1.0000]], dtype=torch.float64)
output llower leg: tensor([[-0.4487, 0.8847, 0.1266, 1.1776],
[ 0.7305, 0.2815, 0.6222, 1.2364],
[ 0.5148, 0.3716, -0.7726, -0.8485],
[ 0.0000, 0.0000, 0.0000, 1.0000]], dtype=torch.float64,
grad_fn=<MmBackward0>) The output of the intermediate layers, i.e, the joints that we insert in the forward kinematics function converge to the joints values used to compute the target values (for the left leg joints, the 6 values before the 6 last values) original joints: tensor([ 1.8165, -0.4723, 0.5580, -1.3924, 0.2683, -0.2554, 1.2683, -0.8576,
-0.0050, -1.4101, -0.6394, 0.5347, -0.5572, 0.8706, 2.6310, -0.1141,
0.7860, 0.1291, -0.4271, 0.0490, -1.9311, -0.9298, 0.2214],
requires_grad=True)
nn joints: tensor([-0.0812, -0.1694, 0.3457, -0.3293, -0.7453, 0.0631, 0.4840, -0.2661,
-0.3233, 0.0550, 0.3637, 0.5347, -0.5572, 0.8706, 2.6310, -0.1141,
0.7860, 0.1906, 0.6204, 0.4075, 0.0221, 0.3031, -0.3142], cc. @Zweisteine96 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some typos
Co-authored-by: Silvio Traversaro <silvio@traversaro.it>
Co-authored-by: Silvio Traversaro <silvio@traversaro.it>
Thanks @traversaro! Fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Giuse! I'll try in my network soon!
Thanks! :) |
The aim of this PR is to update the Pytorch interface and habilitate its use in deep learning context (i.e. use differentiability). Uniforming to
float64
.