简体   繁体   English

神经网络用于控制应用

[英]Neural network for control application

I am trying to use brain.js or synapse.js (or any other JS NN library) to accomplish the following: 我试图使用brain.jssynapse.js (或任何其他JS NN库),以实现以下目标:

  • I have an 3-axis accelerometer 我有一个三轴加速度计
  • I have 4 motors 我有4个马达

My input looks like: 我的输入如下所示:

{
  accelX: 0.12,
  accelY: 0.25,
  accelZ: 0.91,
  powerA: 1,
  powerB: 0.75,
  powerC: 0.44,
  powerD: 0.92
}

I want the output to be the motor powers: 我希望输出为电动机功率:

{
  powerA: 1,
  powerB: 0.75,
  powerC: 0.44,
  powerD: 0.92
}

such that the accel 's are approaching 0. I imagine I can train it by adjusting the power of each motor randomly and then checking if the accel's are closer to 0. If they are, include it in the training set. 使得accel接近0。我想我可以通过随机调整每个电动机的功率然后对加速度是否接近0进行训练来进行训练。如果接近,则将其包括在训练集中。 If not, then do not include in the training set. 如果不是,则不包括在训练集中。

This way, over time, I will have a training set of various states of my 7 inputs and what the appropriate output should be to achieve my desired objective of 0 across the accel's. 这样,随着时间的流逝,我将获得一个包含我的7个输入的各种状态的训练集,以及为实现加速目标中我期望的0目标而应该采用的适当输出。 My question is: how do I structure this? 我的问题是:我该如何构造? I am still relatively new to ANN. 我对ANN还是比较陌生。 I am not looking for someone to write code for me or solve this for me, but perhaps general pointers in the right direction. 我不是在寻找为我编写代码或为我解决代码的人,而是寻找正确方向的一般指针。

If anything is unclear, please add a comment and I will update the question to clarify. 如果有任何不清楚的地方,请添加评论,我将更新问题进行澄清。

Thanks 谢谢

First of all, I see that you have the motor power both in the input and the output. 首先,我看到输入和输出中都有电动机功率。 By this I assume you mean that you are passing the current power of the motors, along with the current accel values to determine the next power settings for the motors. 通过这种方式,我假设您的意思是要传递电动机的当前功率以及当前的加速度值,以确定电动机的下一个功率设置。 I also assume that you have some sort of a "physics function" that takes the output from the neural network (the motor powers) and causes the accel values to change appropriately, based on the motors causing movement. 我还假设您具有某种“物理功能”,该功能可以吸收神经网络的输出(电动机功率),并根据引起运动的电动机来使加速度值适当地变化。 The ultimate goal is to come to rest with a 0 value of each accel. 最终目标是使每个加速度的值都为0。

I do not suggest using a training set. 我不建议使用训练集。 What you need to do is to create a scoring function that evaluates the effectiveness of a neural network. 您需要做的是创建一个评估神经网络有效性的评分函数。 A really easy one might be to run the neural network through 100 cycles and then take the mean accel for that neural network as the score. 一个非常简单的方法可能是将神经网络运行100个周期,然后以该神经网络的平均加速度作为得分。 The goal now becomes to minimize the score. 现在的目标是使分数最小化。

Set the neural network weights to random values. 将神经网络权重设置为随机值。 And apply an optimization algorithms to the weights of the neural network. 并将优化算法应用于神经网络的权重。 Optimization algorithms adjust the parameters (weights) to lower the score function. 优化算法会调整参数(权重)以降低得分函数。 No training data is needed. 无需培训数据。

There are many different optimization functions. 有许多不同的优化功能。 Simulated annealing is probably the easiest to implement, yet quite effective optimization algorithm I can think of. 模拟退火可能是最容易实现的,但我能想到的却是非常有效的优化算法。 Other possibilities include Nelder Mead, Genetic Algorithms, or Hill Climbing. 其他可能性包括Nelder Mead,遗传算法或爬坡。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM