## 2 Methods and Techniques
### Neural Network Design  
FFNNs (Feed Forward Neural Networks) were trained by the Levenberg-Marquardt algorithm [38], which is a quasi-Newton optimization algorithm designed for nonlinear least squares problems. It is probably the most efficient training algorithm for small and medium-sized NNs [39]. In this work, NNs are used in two critical steps:  
1. Calculation of the relative rotational angle between the frame of the bicycle and the thigh, \(\theta\)s;
2. Estimation of muscle forces. In the first step, considering the coordinates of the points (A, B, C, D) respect to the reference system centered in O, as reported in Figure 2, the neural network is necessary since the angle \(\theta\)s is defined in an implicit transcendental equation:  
\[\frac{X^{2}+Y^{2}+t^{2}-s^{2}}{2t}=Xcos(\theta_{s})+Ysin(\theta_{s}) \tag{4}\]  
where X = X\({}_{\rm B}\) + X\({}_{\rm D}\) and Y = Y\({}_{\rm B}\) - Y\({}_{\rm D}\), assuming that:  
\[ \begin{cases}X_{B}=X_{A}-fsin(\theta_{c}-\theta_{p})\\ Y_{B}=Y_{A}+fsin(\theta_{c}-\theta_{p})\end{cases}  \tag{5}\]  
Both the segments \(t\) and \(s\) are constants, whereas the terms X and Y are the time-varying unknowns. The equation can be solved for \(\theta\)s using numerical methods (e.g. optimization algorithms implemented in Matlab, MathWorks, Natick, MA, USA), but even if this is an assessed solution that gives accurate results [15], it is iterative and consequently slow. To solve this problem, for the calculation of the angle \(\theta\)s, a Multiple Input Single Output (MISO) NN with two inputs, four hidden neurons and a single output, has been used. The inputs were the angle between the frame of the bicycle and the crank (\(\theta\)c) and the angle between the frame of the bicycle and the pedal (\(\theta\)p), which can be expressed as a function of X and Y. Indeed, even if the X and Y displacements could be used as direct inputs to the Neural Network, this would require an additional computational step, since the direct outputs of the measurement system are \(\theta_{\rm C}\) and \(\theta_{\rm P}\). To reduce the computational cost of the algorithm, the calculation of X and Y was included in the neural network tasks, using as input the raw data from the crank and pedal angle sensors. For this first step, training data set was composed of 7050 samples from three different subjects, and 118,000 samples from a different new subject composed the testing dataset. It is important to highlight that since the problem is analytical it is not necessary to use measured input data to train the NN, as long as it belongs to a sensible function domain [40]. In this work being the measured data set oversampled with respect to its frequency content and covering the whole angular domain, it was more practical to use it instead of synthetic data. The comparison between the old method and the new one was done through direct error estimation. This is justified considering in this first phase the NN approach as an approximation of the quasi-analytical solution. The second step, relative to the estimation of muscle forces, can be approached by numerically solving the implicit non-linear system described by the equation (1), while minimizing (2) considering the boundaries in (3). This is done by solving an inverse problem of bounded function minimization, which can be approached by numerical optimization techniques. Each time the problem must be solved, it has three known parameters (the muscular moments) and nine unknowns (the muscle forces). The problem was generalized using nine different MISO NNs, one for each unknown. The inputs were the threeparameters (muscular moments of ankle, knee and hip), while the output was a specific unknown (a muscular force). In this case, the training set was composed by 2360 samples from a single subject. Test data was composed by 118,000 samples from a different new subject. The choice of splitting a MIMO problem into multiple MISO problems lies in common good practice for NN.