Artificial Neural Networks working with Hal

  • Grotius
  • Grotius's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
23 Jul 2021 20:21 #215712 by Grotius
Hi,

I was curious how to use Artificial Networks. I found a nice blog how to do it.
This blog explain's a basic Xor logic example. ( 2 inputs, 1 output )
In linuxcnc the component xor2.comp is more or less the same.

I compiled the c++ example and it worked. Output is oke.
Now i am planning to test this Artificial Network working within a hal component.

If the program is trained, it can predict a solution.

What should be a nice thing to predict in linuxcnc hal?










 

Please Log in or Create an account to join the conversation.

More
24 Jul 2021 03:45 #215735 by cmorley
Replied by cmorley on topic Artificial Neural Networks working with Hal
backlash compensation.
actually any compensation.

PID control?
The following user(s) said Thank You: Grotius

Please Log in or Create an account to join the conversation.

More
24 Jul 2021 07:44 #215747 by robertspark
Replied by robertspark on topic Artificial Neural Networks working with Hal
torch height (voltage)
torch void detection (voltage spike outside of standard deviation)
The following user(s) said Thank You: Grotius

Please Log in or Create an account to join the conversation.

  • Grotius
  • Grotius's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
24 Jul 2021 11:00 #215760 by Grotius
Replied by Grotius on topic Artificial Neural Networks working with Hal
Hi,

I just finished the hal implementation of the arteficial neural network performing a xor2 function.
The code is at github, you can look at it. It works ok with linuxcnc on the servo-thread.

First i train the ai providing the training_data file. # setp train 1
Then i run the ai with # setp run 1
Once the ai is trained. You don't have to train it again next time linuxcnc starts.



I think when to make any implementation request's succesful we have to consider the following:
- the ai has to be trained. User has to provide a training set.

The training set can be for example this file , where line 2,3 are a set. line 4,5 are a set, etc.
Line 2 = input 0,1 (xor2 input)
Line 3 = result input 0,1 (xor2 output)
and so on.

I see the request's are manly for position control purposes.
 

Please Log in or Create an account to join the conversation.

  • tommylight
  • tommylight's Avatar
  • Away
  • Moderator
  • Moderator
More
24 Jul 2021 13:55 #215778 by tommylight
Replied by tommylight on topic Artificial Neural Networks working with Hal
Sorting recycling with an efector and camera,
Sorting clothes for big retailers,
Quality control,
....
The following user(s) said Thank You: Grotius

Please Log in or Create an account to join the conversation.

More
24 Jul 2021 23:19 #215815 by robertspark
Replied by robertspark on topic Artificial Neural Networks working with Hal
??
I am confused.... I've read... I don't understand how it works (yet!)... off to read again....
The following user(s) said Thank You: Grotius

Please Log in or Create an account to join the conversation.

  • Grotius
  • Grotius's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
25 Jul 2021 09:37 - 25 Jul 2021 09:45 #215845 by Grotius
Replied by Grotius on topic Artificial Neural Networks working with Hal
Hi,

The library that is used.
The library set's up the neural network, input's, output's, layers between etc.

In the example there are 2 input's and 1 output.
The ai is trained from a data sheet how the result on the output should be, when the 2 input's are at different states.

Normally we should code this in c or c++ by :
if(input0==0 && input1==0){output=1;}
if(input0==1 && input1==1){output=1;}
if(input0==0 && input1==1){output=0;}
if(input0==1 && input1==0){output=0;}

In the "ai network" we can train above situation by giving the desired output like :
input0=0 input1=0
-> ouput=1
input0=1 input1=1
-> ouput=1
input0=0 input1=1
-> ouput=0
input0=0 input1=1
-> ouput=0

Behind the screen the ai is trained. This example is trained within 1 second. But i have already experienced a training period
of around 1 minute for a more complex situation.

You can in fact cheet the output with an ai quite easy by giving wrong results in the training sheet. For example we now
have cheeted the ouput to a inverted xor2 output.
input0=0 input1=0
-> ouput=0
input0=1 input1=1
-> ouput=0
input0=0 input1=1
-> ouput=1
input0=1 input1=0
-> ouput=1

I hope this tiny example helps a bit.
Last edit: 25 Jul 2021 09:45 by Grotius.
The following user(s) said Thank You: robertspark

Please Log in or Create an account to join the conversation.

Time to create page: 0.060 seconds
Powered by Kunena Forum