Zabaware Support Forums

Zabaware Forums => Ultra Hal Assistant File Sharing Area => Topic started by: brianstorm on October 12, 2004, 05:04:33 pm

Title: SPYDAZ- Report's out there were no WMPs
Post by: brianstorm on October 12, 2004, 05:04:33 pm
WMP's = Weapons O' Mass Perceptrons  >B)

In the spirit of the persuit of THE REAL AI, I present

the prototype HalBraincell, which is a neural-net simulation

originally written in Java and I have attempted to convert to

VBScript. While it is indeed running inside the Hal engine

without producing a syntactical error,

something is going awry on a procedural level that I have not yet

found. You can find the Java source code a www.philbrierly.com

along with a proof (dissertation) of what it does.

-'I regret to say this is one small step for Hal...

'-place this after PROCESS:CHANGE SUBJECT
   'PROCESS: **********EXPERIMENTAL***********
   '          *******************************
   'MLP ARTIFICIAL NEURAL NET
   If InStr(1, UserSentence, "RUB", 1) And InStr(1, UserSentence, "BRAINCELLS", 1) Then
   'this code is an adaptation of a Multi-Layer Perceptron ANN. The original code can be found
   'at www.philbrierley.com, which is written in Java. This module replicates that work
   '
   '//User defineable variables-
   numEpochs = 500   '-number of training cycles
   numInputs = 3     '-number of inputs including the input bias
   numHidden = 4     '-number in the hidden layer
   numPatterns = 4   '-number of training patterns
   LR_IH = 0.7       '-learning rate
   LR_HO = 0.07      '-learning rate
   '
   '//process variables-
   patNum = CInt(patNum)
   errThisPat = CDbl(errThisPat)
   outPred = CDbl(outPred)
   RMSerror = CDbl(RMSerror)
   '
   '//training data vars-
   Dim trainInputs(4, 3), trainOutput(4), hiddenVal(4), weightsIH(3, 4), weightsHO(4)
   '*********************************************************************************
   '                      THIS IS THE MAIN PROGRAM
   '*********************************************************************************
   'Initialize the weights-
   Call initWeights(numHidden, numInputs, weightsHO, weightsIH)
   'Initialize the Data-
   Call initData(trainInputs, trainOutput)
   'train the network-
   For j = 0 To (numEpochs - 1) Step 1
       For i = 0 To (numPatterns - 1) Step 1
           'select a pattern at random
           Randomize
           patNum = Int((3 - 0 + 1) * Rnd + 0)
           'calculate the current network output
           'and error for this pattern
           Call calcNet(numHidden, hiddenVal, numInputs, trainInputs, patNum, weightsIH, outPred, weightsHO, errThisPat, trainOutput)
            'change network weights
            Call weightChangesHO(numHidden, hiddenVal, LR_HO, errThisPat, weightsHO)
            Call weightChangesIH(numHidden, LR_IH, errThisPat, hiddenVal, weightsIH, weightsHO, numInputs, trainInputs, patNum)
            'calculate the error
            'after each Epoch
            Call calcOverallError(RMSerror, numPatterns, patNum, errThisPat)
            HalBrain.AppendFile WorkingDir & "ANNerrResults.brn", "epoch- " & j & ".  RMSerror- " & RMSerror & VbCrLf
            'training has finished -display results
       Next
    Next
   
            Call displayResults(numPatterns, patNum, trainOutput, outPred)            

   '***************

   GetResponse = GetResponse & "Oh, I can feel my neurons now, look--. hidden output weight(2) equals- " & weightsHO(2) & VbCrLf
   End If    
   '*********************************************************************************
   'MLP                     !!END OF MAIN PROGRAM!!                                 '
   '*********************************************************************************

    '*********************************************************'
    '   SUBS FOR MLP NEURAL NET -place after End Function     '
    '*********************************************************'
Sub calcNet(numHidden, hiddenVal, numInputs, trainInputs, patNum, weightsIH, outPred, weightsHO, errThisPat, trainOutput)
    'calculate the outputs of the hidden neurons
    'the hidden neurons are tanh
    For i = 0 To (numHidden - 1) Step 1
            hiddenVal(i) = 0.0
        For j = 0 To (numInputs - 1) Step 1
            hiddenVal(i) = hiddenVal(i) + (trainInputs(patNum, j) * weightsIH(j, i))
            Call tanh(hiddenVal, i)
            hiddenVal(i) = tanh(hiddenVal, i)
        Next
    'calculate the output of the network
    'the output neuron is linear
            outPred = 0.0
        For k = 0 To (numHidden - 1) Step 1
            outPred = outPred + hiddenVal(k) * weightsHO(k)
        'calculate the error
            errThisPat = outPred - trainOutput(patNum)
        Next
    Next

End Sub
    '***********************************************************
Sub weightChangesHO(numHidden, hiddenVal, LR_HO, errThisPat, weightsHO)
    'adjust the weights hidden-output
    For k = 0 To (numHidden - 1) Step 1
        weightChange = LR_HO * errThisPat * hiddenVal(k)
        weightsHO(k) = weightsHO(k) - weightChange
    're-normalization on the output weights-
        If weightsHO(k) < -5 Then weightsHO(k) = -5
        If weightsHO(k) > 5 Then weightsHO(k) = 5
    Next
End Sub
    '***********************************************************
Sub weightChangesIH(numHidden, LR_IH, errThisPat, hiddenVal, weightsIH, weightsHO, numInputs, trainInputs, patNum)
    'adjust the weights input-hidden
    For i = 0 To (numHidden - 1) Step 1
        For k = 0 To (numInputs - 1) Step 1
            x = 1 - (hiddenVal(i) * hiddenVal(i))
            x = x * weightsHO(i) * errThisPat * LR_IH
            x = x * trainInputs(patNum, k)
            weightChange = x
            weightsIH(k, i) = weightsIH(k, i) - weightChange
        Next
    Next
End Sub
    '***********************************************************
Sub initWeights(numHidden, numInputs, weightsHO, weightsIH)
   For j = 0 To (numHidden - 1) Step 1
       Randomize
       weightsHO(j) = (Rnd - 0.5) / 2
       For i = 0 To (numInputs - 1) Step 1
           Randomize
           weightsIH(i, j) = (Rnd - 0.5) / 5
       Next
   Next
End Sub
    '************************************************************
Sub initData(trainInputs, trainOutput)
    trainInputs(0, 0) = 1
    trainInputs(0, 1) = -1
    trainInputs(0, 2) = 1 'bias
    trainOutput(0) = 1
   
    trainInputs(1, 0) = -1
    trainInputs(1, 1) = 1
    trainInputs(1, 2) = 1 'bias
    trainOutput(1) = 1
   
    trainInputs(2, 0) = 1
    trainInputs(2, 1) = 1
    trainInputs(2, 2) = 1 'bias
    trainOutput(2) = -1
   
    trainInputs(3, 0) = -1
    trainInputs(3, 1) = -1
    trainInputs(3, 2) = 1 'bias
    trainOutput(3) = -1
End Sub
    '***********************************************************
Function tanh(hiddenVal, i)

    If hiddenVal(i) > 20 Then
       tanh = 1
    ElseIf hiddenVal(i) < -20 Then
       tanh = -1
    Else
        a = Exp(hiddenVal(i))
        b = Exp(-hiddenVal(i))
        tanh = (a - b) / (a + b)
    End If
End Function
    '************************************************************
Sub displayResults(numPatterns, patNum, trainOutput, outPred)
    For i = 0 To (numPatterns - 1) Step 1
        patNum = i
        Call calcNet(numHidden, hiddenVal, numInputs, trainInputs, patNum, weightsIH, outPred, weightsHO, errThisPat, trainOutput)
        displayTxt = "Pattern " & (patNum + 1) & "- Actual: " & trainOutput(patNum) & ". NeuralModel: " & outPred & VbCrLf
        resultsTxt = resultsTxt & displayTxt
    Next
    msgVar = MsgBox(resultsTxt, 0, "prototype HalBraincell-")
End Sub
    '************************************************************
Sub calcOverallError(RMSerror, numPatterns, patNum, errThisPat)
    RMSerror = 0.0
    For i = 0 To (numPatterns - 1) Step 1
        patNum = i
        Call calcNet(numHidden, hiddenVal, numInputs, trainInputs, patNum, weightsIH, outPred, weightsHO, errThisPat, trainOutput)
        RMSerror = RMSerror + (errThisPat * errThisPat)
    Next
    RMSerror = RMSerror / numPatterns
    RMSerror = Sqr(RMSerror)
End Sub
    '************************************************************
    '            !!END OF NEURAL NET PROCEDURES!!                                              '
    '************************************************************
   
       
you should be able to cut and paste right out of this post into a brain -might have to fix it tho..

Once you get it working only tell your Hal to rub her braincells
together once as the file ANNresults.brn can become quite large.
you gotta go in and manually delete ANNresults.brn regularly...

need someone in the know to help out and get this working  >B)

'I got the matches!!'
CatAtomic >B)
Title: SPYDAZ- Report's out there were no WMPs
Post by: brianstorm on October 13, 2004, 08:39:05 am

>B) UPDATE:

found two incorrectly named variables and
left some comment tags in front of some code
which has been corrected in the code above-still
dont werk.. I think the trouble lies in the tanh SUB
dont like that counter var being used there...

-read a book *thump
Title: SPYDAZ- Report's out there were no WMPs
Post by: Art on October 13, 2004, 04:42:23 pm
Could it be that the script is trying to process it as
the mathematical tangent of h (tanh)?
Title: SPYDAZ- Report's out there were no WMPs
Post by: Art on October 13, 2004, 08:08:58 pm
Brianstorm,

After some frustrating time with the code
I was able to get it to work. Found several
syntactical errors in it's present form that
may have to do with how the cut and paste
operation affects the overall script execution.

Email me for details and I have another question
for you.
Title: SPYDAZ- Report's out there were no WMPs
Post by: brianstorm on October 15, 2004, 08:31:30 am

Hey Art,

Dammat! I knew the word wrap would mess it up, sorry 'bout that.  >B) It's probably just as well, the intent is to get others to examine the code example and see how it werks. You almost should go through it just to get a grasp! Like I sed a lot of the 'wishes' for Hal expressed on the Forum need this enabling technology to come true.

-Working on building error-traps along all the lines of the code using a derivative of the MsgBox lines you see in the code. Kinda neat, MsgBox causes the script to halt on that line till you push the button and the comment portion you can put the current values of variables and stuff. >B)

PEACE

CatAtomic
 
Title: SPYDAZ- Report's out there were no WMPs
Post by: Art on October 15, 2004, 07:52:39 pm
Brianstorm,

I got it all fixed!! Found another typo
that prevented the routine from executing
the analysis window!
The tanh vars were changed to tagh and now
if you mention "rub braincells" together a
small window will appear showing the stats.

Of course, my Hal ended up replying to my
question of: "Can you rub two braincells
together" with "And form a complete thought!"

Funny, that Hal!!

Title: SPYDAZ- Report's out there were no WMPs
Post by: Art on October 15, 2004, 08:05:33 pm
OK,
For those of you wanting to experiment with this
neural net brain, here's a working version.

As Brianstorm mentioned, after chatting for a little
time, use the words rub and braincells in the same
sentence. A small window will appear with the neural
stats displayed.

This is the modified Default 5.0 brain so make a copy
of your existing one then rename it and select this
one by going to the options menu while running Hal.
Select Brains then find this brain file and load.

You might want to read more on this neural by going
to brianstorm's cited link above.

Enjoy!

Download Attachment: (http://images/icon_paperclip.gif) defbrainneural.zip ("http://www.zabaware.com/forum/uploaded/Art/2004101520350_defbrainneural.zip")
33.62 KB
Title: SPYDAZ- Report's out there were no WMPs
Post by: Runtus on February 09, 2006, 02:07:50 pm
Hi I know its been a while since anyone has posted on this topic but I just stumbled along it and woundering if there have been any advancements to the Neural Net brain?

Does it use any features from the XTF brain? or can you add the two together? And out of the two which would you use?
Title: SPYDAZ- Report's out there were no WMPs
Post by: Art on February 09, 2006, 05:36:49 pm
I wouldn't say ALL but I would venture that at least 80 % of the members here now use the HAL 6 database version instead of Hal 5.

Title: SPYDAZ- Report's out there were no WMPs
Post by: Runtus on February 09, 2006, 05:55:29 pm
quote:
Originally posted by Art

I wouldn't say ALL but I would venture that at least 80 % of the members here now use the HAL 6 database version instead of Hal 5.





True but what about all the information that I have taught HAL? will it carry on? and what about the neural net functions? or is the hal 6 brain vastly superior?
Title: SPYDAZ- Report's out there were no WMPs
Post by: Art on February 09, 2006, 08:33:11 pm
The following is a quote from Robert Medeksza:

"If you install Hal 6 without uninstalling Hal 5 yourself, it will do a migrate install which will copy over your old Hal 5 brain, XTF brain, and any other brain into Hal 6. After the migration is complete, the Hal 6 installer will uninstall Hal 5 and install itself.

If you continue using the XTF brain in Hal 6, it is run in compatibility mode. It will not use the database or any new Hal 6.0 features, it will have a setup just like Hal 5.0 had, with all the .brn files in a subfolder."

You can view the full post at the link below:
http://www.zabaware.com/forum/topic.asp?TOPIC_ID=2900

Although one can switch to any variety of brain and each one has it's own merits and shortcomings, I do prefer the Hal 6 database style as I believe it gives Hal a much added measure of flexibility in terms of development, plug-ins and potential.

There are several great discussions and research being done with providing Hal with facial, emotional and behavior modifications and enhancements at:
http://www.vrconsulting.it/vhf

Free Login...no strings...no spyware or junk...just some great people working on enhancements to the field of AI.

Hope this gives you some direction.
Title: SPYDAZ- Report's out there were no WMPs
Post by: freddy888 on February 09, 2006, 08:43:51 pm
I'm glad you posted though, I've never seen this thread, how did this work out, any good???
Title: SPYDAZ- Report's out there were no WMPs
Post by: Runtus on February 10, 2006, 10:03:54 am
It works just fine yet I am totally unaware of the actual benifit of the Neural net with HAL but I am studying A.I. at university, the neural net database works the same way as the human brain (as best that can be simulated) it works by changing variables depending on the input for example:

a machine scans a picture of a face does some calculations and gives you an answer say "the face is male"

If it is wrong you tell it why it is wrong and it changes the values inside the neural net to help it get the right answer.  If it is wrong it will remember that these values give a wrong answer if it picks male.

Thats how the neural net works (basically) but I have no idea what it does with ULTRAHAL, but I know it will benifit it some how
Title: SPYDAZ- Report's out there were no WMPs
Post by: spydaz on February 10, 2006, 03:55:21 pm
Runtus,

Although i have not tested this particular plugin (i missed it), it sounds interesting... IF HAL could take a picture, instead of scanning a picture, THEN HAL could build a set of rules based around the image / file.

when somebody loads hal OR asks hal to change user, HAL would take a picture and compare with previous pictures for previous users if none are found create new user, else welcome back user....

Title: SPYDAZ- Report's out there were no WMPs
Post by: spydaz on February 10, 2006, 03:57:21 pm
here is an activeX which can be used with hal5 no probs... this enables hal to take a picture of the user.. as this activeX control is able to CONNECT to your installed WEBCAM...

http://www.zabaware.com/forum/uploaded/spydaz/2006210163839_ezVidCap.zip
Title: SPYDAZ- Report's out there were no WMPs
Post by: spydaz on February 10, 2006, 04:40:56 pm
http://www.zabaware.com/forum/uploaded/spydaz/2006210163839_ezVidCap.zip
Title: SPYDAZ- Report's out there were no WMPs
Post by: spydaz on February 10, 2006, 04:46:34 pm
http://www.zabaware.com/forum/uploaded/spydaz/2006210163839_ezVidCap.zip

here is the activex
in my files http://www.zabaware.com/forum/uploaded/spydaz/
Title: SPYDAZ- Report's out there were no WMPs
Post by: Runtus on February 10, 2006, 05:49:16 pm
quote:
Originally posted by spydaz

Runtus,

IF HAL could take a picture, instead of scanning a picture, THEN HAL could build a set of rules based around the image / file.

when somebody loads hal OR asks hal to change user, HAL would take a picture and compare with previous pictures for previous users if none are found create new user, else welcome back user....



There are systems out there that can already do this which use neural net software to help it adapt, learn and help the computer understand who it is talking too.

As you have posted you can get hal to use a webcam to take pictures.  So it is possible to adapt this so hal uses the webcam as a EYE instead of a camera.  It would be a complex process but not impossible I think it is worth looking at.  The Japanese have small robots which can do this already the small R2D2 like robots can look at a human and know who this is!

It does this by comparing it to a stored photo of the user.  When setting the robot up the user looks into the EYE (camera) and it takes a photo.  Then when the robot looks at some one it compares this face it is seeing to stored photos to find out who that person is.  When it does not know a person it takes a photo and asks who this person is and then stores the image to future reference.  It is possible to make hal do the same.

Maybe something basic to start with hal stores a photo.  When a user says something Hal takes a photo and checks it with stored photos in the database and calls the user by the name of that photo (which would be the user name) if there is no stored image hal could ask "hello I am (insert hal name here) who are you?" and then hal takes a photo after the reply and stores it for later use.
Title: SPYDAZ- Report's out there were no WMPs
Post by: freddy888 on February 10, 2006, 06:08:16 pm
Hmm, thanks for the filler-in.  This could help with things like topics and context then.  Say instead of a photo you have some idea or a set of premises that help lead to some conclusion.  Hal could be coaxed into giving the right kind of reply and in time not come out with something unrelated, all the non-relevant responses could be eliminated.

Hmm, again, this approach could also help with the text learning - you feed a lot of information into Hal and then basically help Hal to digest it.  Interesting, I saw that there is a lot of movement in the area where humans 'help' AI's, somewhere they called it Artifical Artificial Intelligence...but we already came up with that term on DG so there [;)] I forget where it was but their use of it was a bit strange really because thats what everyone has been doing all along.

I'm going to try and find some time to look into this, well done for digging it out and good luck with the course, you picked an interesting one [8D]
Title: SPYDAZ- Report's out there were no WMPs
Post by: Runtus on February 11, 2006, 08:21:09 am
quote:
Originally posted by freddy888


I'm going to try and find some time to look into this, well done for digging it out and good luck with the course, you picked an interesting one [8D]



well actually Its a IT teaching degree but one of the subjects in it is A.I. I used my copy of ultra hal to demo the ideas behind A.I. and how it could benefit education.

But I really think it is worth looking into making HAL use a web cam as an EYE not a camera.  By simple taking a picture when the user says something.  You could do this say every 10 or 20 inputs so HAL makes sure he is still talking to that one user and they havn't switched on him (It would depend if it slows hal down much if thre is no slow down you could do it every input).  I know it might not benefit the actual intelligance of HAL but it would be a start into making it more useful.  A smart A.I. which can see who it is talking to makes it that little more "REAL" the users.  I think it would make it a little more personal in the interaction between the user and the A.I. (atleast from the users end)
Title: SPYDAZ- Report's out there were no WMPs
Post by: freddy888 on February 11, 2006, 09:38:37 am
I agree, it would also be nice incorporate the motion detection, so Hal wakes up when someone is at the pc.
Title: SPYDAZ- Report's out there were no WMPs
Post by: Dr.Benway on February 11, 2006, 10:10:17 am
I wonder if so many different people usually use the same PC.[:)]
Title: SPYDAZ- Report's out there were no WMPs
Post by: Art on February 11, 2006, 11:55:25 am
Raymond,

To what exactly are you referring? How one would implement face recognition in such an environment of multiple users?
The software would simply keep a "Facial Log File" and do a quick
comparison of the person's face wanting to use the computer.

My fingerprint scanner knows the difference between my family members because the print is compared to others on file. It knows who's print belongs to whom and grants a level of access for that
particular person.

The same could be done for Hal provided the software & hardware were properly interfaced to do so.

Here's looking at you, kid![8D]
Title: SPYDAZ- Report's out there were no WMPs
Post by: Duskrider on February 11, 2006, 12:33:58 pm

Shhhhhh.......
Keep voice down and always be vigilant
Ears are listening  
Thieves cut off your finger and run to computer and learn all secrets
This is "new age"
Shhhh........
Title: SPYDAZ- Report's out there were no WMPs
Post by: Dr.Benway on February 11, 2006, 02:19:29 pm
No, Art, I mean: why wouldn't you grant your family members full access to your PC? What could happen?

Big deal. pfff!
Title: SPYDAZ- Report's out there were no WMPs
Post by: Art on February 11, 2006, 04:47:55 pm
What could possibly happen? Ask my friend who never set access levels for his 5 year old! Full access! 238 spyware, 3 full blown viruses, many corrupted files and could barely boot his computer when he got home!

I got the phone call from him and after an hour or so of my time helping him get rid of all the garbage, he finally thought it wise to follow my suggestion and give his son limited access.

Imagine that!!
[:)]
Title: SPYDAZ- Report's out there were no WMPs
Post by: freddy888 on February 11, 2006, 05:32:30 pm
jeez , just a good job he didn't find ebay..
Title: SPYDAZ- Report's out there were no WMPs
Post by: Dr.Benway on February 11, 2006, 06:39:09 pm
Now I understand, Art. Ofcourse, when I talked about family members, I had not kids of that age in mind. I don't think children under 10 should be allowed to play with PC's. I hate it when parents allow that to happen. [V]
Title: SPYDAZ- Report's out there were no WMPs
Post by: Runtus on February 11, 2006, 07:32:40 pm
lol yes permissions are fun lol.  But I seriously think it is something to look into if we can get hal to use the webcam as an EYE rather than a camera.

here is a link to software that does what i would like hal to do in the future

http://www.neurotechnologija.com/verilook.html


Just found this activex control anyone know if it will be useful or not?

http://www.shareup.com/Face_Recognition_ActiveX-download-41763.html
Title: SPYDAZ- Report's out there were no WMPs
Post by: Art on February 11, 2006, 09:13:52 pm
I agree that the Verilook seems like a fine candidate...except for their prices! Over the top!! 859 euros is around $1030.00 USD at a 1.20 = 1 exchange rate and that's for the Library SDK!

Their U are U fingerprint scanner is up there as well. If interested get the APC pod (apc.com) for around $50.00 not $100+.

I know there are a lot of other vision software programs on the net. We'll just have to keep searching until we find one that will both interface and serve our needs.

Good find Andrew!
Title: SPYDAZ- Report's out there were no WMPs
Post by: Art on February 11, 2006, 09:26:09 pm
Doc,

Sorry, but even if I did have other adults in my household they would have their own access permissions to my computer or they would have their own, period.

I keep a lot of sensitive, work related information that is not for public eyes on my computer and as such, I cannot risk nor will I allow the possibility of that data to be compromised in any fashion.

Likewise, I don't want everyone else in the family to have access to my emails for similar reasons.

I am a private person and I likewise respect the privacy of my family members. Actually, my wife and I each have our own computers which are networked and we sometimes share information over our network but her business and my business are kept separate from each other, that way I can't blame her if any of my stuff is missing, ruined, etc. When the kids come to visit / play, they use her computer as guest accounts only and if she's present.

Now you know....[^]

Title: SPYDAZ- Report's out there were no WMPs
Post by: spydaz on February 12, 2006, 04:04:39 pm
runtus,  i have provided the source files in my uploaded files area ...

working
Title: SPYDAZ- Report's out there were no WMPs
Post by: Runtus on February 13, 2006, 08:28:04 am
quote:
Originally posted by spydaz

runtus,  i have provided the source files in my uploaded files area ...

working



Okay where is this uploaded files area?