Jump to content

Artificial Neural Network UDF


Recommended Posts

You need to train a neural net on data, using this code:

#include "_Fann.au3"

Global $InputsArray[4][2] = [[-1, -1],[-1, 1],[1, -1],[1, 1]]
Global $OutputsArray[4][1] = [[-1],[1],[1],[-1]]
Local $ANNLayers[3] = [2, 3, 1]
_InitializeANN()
$Ann = _CreateAnn(3, $ANNLayers)
_ANNSetActivationFunctionHidden($Ann, $FANN_SIGMOID_SYMMETRIC)
_ANNSetActivationFunctionOutput($Ann, $FANN_SIGMOID_SYMMETRIC)
_ANNTrainOnData($Ann, $InputsArray, $OutputsArray, 5000, 10, 0.001)
_ANNSaveToFile($Ann, "xor_float.net")
_DestroyANN($Ann)
_CloseANN()

The ANN being created has 3 layers, 2 input, 3 hidden, and 1 output neuron.

For my example, you need to create a neural network with 3 layers, 24 inputs in the first one, 12 hidden neurons, and 11 outputs. The training data is saved into .data files, the networks into .net. It looks like you tried to load the training data as a network.

I've got it .I mixed between mousepatterns.net and mousepatterns.data

Thanks!

Edited by lsakizada

Be Green Now or Never (BGNN)!

Link to post
Share on other sites

I tried to make an example that learn division but is not working, anyone a little help?

#include <_Fann.au3>

Dim $INPUT[5][2] = [[2,1],[8,4],[12,3],[5,2],[9,1.5]]
Dim $OUTPUT[5][1] = [[2],[2],[4],[2.5],[6]]
Local $LAYER[3] = [2, 3, 1]

_InitializeANN()
$ANN = _CreateAnn(3,$LAYER)
_ANNSetActivationFunctionHidden($ANN, $FANN_SIGMOID_SYMMETRIC)
_ANNSetActivationFunctionOutput($ANN, $FANN_SIGMOID_SYMMETRIC)
_ANNTrainOnData($ANN,$INPUT,$OUTPUT, 15000, 1000,0.001)
_ANNSaveToFile($ANN, "num_div.net")
_DestroyANN($ANN)
_CloseANN()

Dim $CALC[2] = [4,1]
_InitializeANN()
$ANN = _ANNCreateFromFile("num_div.net")
$RESULT = _ANNRun($ANN,$CALC)
MsgBox(0,"Division", $CALC[0] & " / " & $CALC[1] & " = " & $RESULT[0])
_DestroyANN($ANN)
_CloseANN()
Edited by Andreik
When the words fail... music speaks
Link to post
Share on other sites

@Andreik, try different numbers of neurons and hidden layers between your inputs and outputs, it could be that the relation you're trying to model is more complex than can be represented with just 3 neurons. It will take some trial and error, but I think it can be done. Maybe try 2 hidden layers with 4 neurons each?

Local $LAYER[3] = [2, 4, 4, 1]

@Jjo, the include folder isn't for scripts that you download, that's used for core AutoIt includes. Put _Fann.au3 in the same directory as the script you're trying to use, and do #include "_Fann.au3".

The error is meaningless without knowing what script you're running, what directory the dll is in, and so on. So, let me know more information. :)

Link to post
Share on other sites

@Jjo, the include folder isn't for scripts that you download, that's used for core AutoIt includes. Put _Fann.au3 in the same directory as the script you're trying to use, and do #include "_Fann.au3".

The error is meaningless without knowing what script you're running, what directory the dll is in, and so on. So, let me know more information. :)

Ok that worked, thanks. :)
Link to post
Share on other sites
  • 1 year later...

Its stilll not working for me...I am also getting the same error as that of jijo. The udf, the dll file and the example file is in the same directory still it is not working. plz help..!! :graduated:

[font="Comic Sans MS"][size="7"]Piyush.....[/size][/font][font="Palatino Linotype"][size="2"]Some Of My Scripts...Cool Font Generator Train Searcher and Tracer[/size][/font]

Link to post
Share on other sites
  • 3 weeks later...

Wow, This is spectacular. I've always seen in AutoIt's AI department great potential, but this exceeds all expectations.

Been working on AI's for a while now and i can say just by looking a this, that it will speed up my work exponentially.

I give my thanks.

Zibit

Link to post
Share on other sites
  • 4 weeks later...
  • 1 year later...
  • 5 years later...

First my appology for resurecting this thread. But I'm curious, and someone monitoring this thread from way back might have good answers.

1: Does anyone use FANN (with autoit) these days?

2: Does anyone use it on win64? To me it looks like a wraper to handle pointers to structs are needed between the library and AutoIt?

3: Is there any other Neural Network Library in use with AutoIt?

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...