Neural Network function approximator for robotics

username: desmond13
cooked: <p>Hi, I am new to Pytorch and I am trying to get its basics. The first project I will need it for is one involving a function approximation. My problem is the following: I have a robot that can radically change its morphology and the respective simple PID controller with the (P, I, D) gains.<br>
Therefore, I would like to use a Neural Network (NN) that is able to approximate a function that goes from (size, inertia, … ) to (P, I, D).<br>
I will create the dataset on which to train all in simulation, for now, therefore I can generate quite a lot of data.<br>
I still do not have a clean dataset which has really the correspondence (size, inertia, … ) —&gt; (P, I, D) but I am working on it.</p>
<p>I know that this problem might be a better fit for a reinforcement learning implementation or even just a simple regression. However, to get my hands dirty with Pytorch, I thought that it is a nice problem to start with (and I will need it for my research).</p>
<p>So far I followed the main Pytorch tutorials (<a href="https://pytorch.org/tutorials/" rel="nofollow noopener">here</a>) and <a href="https://medium.com/@benjamin.phillips22/simple-regression-with-neural-networks-in-pytorch-313f06910379" rel="nofollow noopener">this one too</a>. I would like to do some more oriented to the problem described. Could you please suggest me a path to follow?</p>
<p>Thanks in advance!</p>

username: ptrblck
cooked: <p>The use case sounds interesting!<br>
What kind of format does your data have or are you a bit flexible?<br>
The format (e.g. a fixed number of input features, temporal data, spatial data etc.) would determine the first path and model architecture you could try.</p>

username: desmond13
cooked: <p>Hi, thanks a lot on your answer!</p>
<p>I am indeed flexible since I am working in simulation and able to generate data. The input features, for now, are mass, inertia, size, and some others I am thinking about related to the motors of the robot.</p>
<p>Regarding temporal/spatial data, if I understand what that means, I am not looking at the evolution of the robot in time and neither depending on its position in space. The robot simulation is starting again and again and the robot is always in the same initial state. I plan to change that in the future. However, for what I need now I think it is enough. Is it what you meant or should I tell you something else?</p>

username: ptrblck
cooked: <p>I think you clarified your approach.<br>
For this static data, I would recommend to start with a vanilla fully-connected model (using linear layers).<br>
I assume the features have different ranges, so I would recommend to normalize them such that each feature has a zero mean and unit variance.<br>
While <code>mass</code> and <code>inertia</code> seem to be floating point features, it seems <code>size</code> might be a discrete feature.<br>
If that’s the case, you could think about using an <code>nn.Embedding</code> layer to transform this particular feature to a dense representation and concatenate it with the output activation for the other features.</p>
<p>Also, since you are working on a new architecture, I would recommend to start simple regarding the model architecture as well as the dataset. E.g. you could use with two linear layers only and use a small dataset of just 10 samples to make sure your model overfits this sample. Once this is done, you should scale the problem up.<br>
It can get quite tricky if you start with a very deep model and the complete dataset, as you have a lot of variables to play around with.</p>

username: desmond13
cooked: <p>Thanks for the really detailed answer.</p>
<p>I want to add one thing: the feature <code>size</code> is also a floating point. Therefore, from what you said it seems that it will be even easier since it is not different from the other features.</p>
<p>I will try to implement what you said and write here some advancements.</p>