webdevRefinery Forum: Need an idea for an awesome Node project? - webdevRefinery Forum

Jump to content

  • 3 Pages +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5081
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 06 July 2012 - 10:46 AM (#1)

Need an idea for an awesome Node project?


Look no further.
So maybe I'm the only one fascinated by this shit, but I love neural nets. They're such an effing awesome data structure. Here's a super simple overview if you don't know what that is:

A neural net is designed to work like a very very very basic human brain. It's made up of arrays and arrays of anywhere from a handful of neurons and synapses to thousands and thousands of them. The idea is that you have a 'neuron' for every individual input that you want to feed into the neural net. For a black and white 20x20 pixel image, that would be 400 pixels = 400 input 'neurons'. Then you also have output neurons that give you the neural net's response to the input. The end result is that you can draw a tree on your 20x20 grid, give it to the neural net, and tell it that the output for this pattern should be "tree".

And you train it with that image. Like 20k times. Then you give it other pictures of trees, and you tell it those are also "tree". Then you show it a house and tell it that's a "house". 20k times. Rinse and repeat. Cat, dog, fish, baseball, chair, flower. Every time you do this, the neural net adjusts (in human-speak) the level of neurotransmitters in the synapses, so that the next time the neurons around it fires, it knows how likely it is to be a certain picture.

Now you let someone draw an object in that 20x20 space. You ask the neural net what it is. And it tells you. It's a picture it's never seen before, but because it's been trained to recognize patterns and enough pixels are similar to what it's seen before, it knows.

This isn't limited to just image processing, of course -- you could feed it a user's purchasing history on an ecommerce site and get a prediction about what they'll buy next. You could give it identifying qualities of a song and have it tell you what song it is (this is, in fact, how many such services work). The list goes on.

And a friend of mine just showed me this -- a well-supported neural net engine for Node.js (or frontend javascript) that is dead easy to use: https://github.com/harthur/brain

If my description above was hard to follow, just hit that link and look at the API. It's (ironically enough) brainlessly easy. And the training is largely automated for you, which rocks.

I'd be playing with this constantly if I had the time... but I don't :(. So I want to see what you guys make with it xD
0


User is offline cosmie 

  • Group: Members
  • Posts: 223
  • Joined: 30-April 11

Posted 06 July 2012 - 11:09 AM (#2)

The demo given is also pretty interesting: http://harthur.github.com/brain/
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5081
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 06 July 2012 - 11:19 AM (#3)

That's bad ass :D. About 60 seconds and I had a neural net that could determine a better font color for a given background than the traditional algorithm. It's just so damn fast! I'd love to see how quick it is to train the net for image recognition.
1


User is offline soulcyon 

  • 兄貴 シャンク
  • Group: Members
  • Posts: 1598
  • Joined: 14-April 10
  • LocationNew Brunswick, NJ
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,Graphics,MongoDB,CouchDB

Posted 06 July 2012 - 11:20 AM (#4)

Neural nets make me *gnoz*

I'm working on a project that requires generating humongous trees for cascading failures, perhaps neural nets will speed up this process. I'll have to do some reading ;)
Posted Image
0


User is offline cosmie 

  • Group: Members
  • Posts: 223
  • Joined: 30-April 11

Posted 06 July 2012 - 11:31 AM (#5)

View PostKyek, on 06 July 2012 - 11:19 AM, said:

That's bad ass :D. About 60 seconds and I had a neural net that could determine a better font color for a given background than the traditional algorithm. It's just so damn fast! I'd love to see how quick it is to train the net for image recognition.


Have you seen his kitty radar library, that identifies cat heads in pics? https://github.com/harthur/kittydar
I'm not sure if it's using the same code as brain.js for the training, but I'm assuming it's at least really similar, as it's also using a neural net and is only a few weeks old.

That only took 2GB worth of annotated cat pics to train (a few thousand images, in total). He doesn't mention how slow (or fast) the training was, but with something like AWS you could probably get it done in no time at all for a relatively low cost. The curating of the imageset was probably a killer, time wise. But that was done by a Microsoft research group, anyway.

Throw in a few dozen GBs of e-commerce page-tracking data and you could probably make one creepy backend brain to curate targeted content to show to consumers.
0


User is offline callumacrae 

  • {{ post.author }}
  • Group: Members
  • Posts: 2867
  • Joined: 20-January 11
  • LocationWarwickshire, England
  • Expertise:HTML,CSS,PHP,Javascript,Node.js,SQL

Posted 06 July 2012 - 11:51 AM (#6)

It's like 500 lines long in total 0_o
Front-end developer and writer
Twitter | GitHub | phpBB Contributor and Website Team Member | lynxphp
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5081
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 06 July 2012 - 11:15 PM (#7)

I so should not be taking the time to do this.

Posted Image

For some reason I'm having a rough time getting training to work... and I'm afraid the library wasn't built to handle 625 inputs. I may scale my grid down a bit :-/

Edit: Ahahahahaha scratch that, I got it working. Outputs have to be weighted -- so you can't just say an array of pixels is an "eye", you have to tell it it's
{eye: 1}
. This is a little on the hairy side, though, because for results, it spits out all the possible results and assigns a match quality to each one -- a number from 0-1. If your neural net knows what a lot of different things are, that means it's spitting out the entire dictionary every time you get results. That's a little ugly.

But this still rocks xD

Edit 2: Maybe I spoke too soon... I trained 'fish' and 'eye', then went back and drew a fish. It told me there was a 0.01% chance it was an eye. That's all well and good, but it didn't tell me what the chances are of it being a fish! If this can only report the weight of a single value.. boo.

Edit 3: Should've RTFM:

Quote

Use train() to train the network with an array of training data. The network has to be trained with all the data in bulk in one call to train().

That's incredibly shitty. That means a net can't be improved after it's initial training... making a neural net that gets smarter over time basically impossible without a lot of horrible re-training. Not a fan :-/

Edit 4: Ok, one last update before I go to bed. It now recognizes my drawings fairly well ;-). I tweaked it so it stores all the training data over time, and re-trains all of it every time it's given a new image. Not optimal, but it works and it's fun to play with.

Posted Image

Posted Image

Posted Image

Posted Image

Not bad for a couple hours of hacking ;-)
0


User is offline ianonavy 

  • Group: Members
  • Posts: 689
  • Joined: 14-April 10
  • Expertise:HTML,CSS,Java,Javascript,Python

Posted 06 July 2012 - 11:53 PM (#8)

@Kyek

GitHub linky link? D: Thinking about porting the library to Java for use on my Minecraft server. I have no idea what it'd be for though...
reputation += 1 if post.is_helpful else 0
0


User is offline TheMaster 

  • *-c0de master-*
  • Group: Members
  • Posts: 764
  • Joined: 24-May 10
  • LocationAustralia
  • Expertise:HTML,CSS,PHP,Java

Posted 07 July 2012 - 05:05 AM (#9)

View Postianonavy, on 06 July 2012 - 11:53 PM, said:

@Kyek

GitHub linky link? D: Thinking about porting the library to Java for use on my Minecraft server. I have no idea what it'd be for though...


Oh my. That could be epic. You could like...build something (say...a small house), it would recognise its a house - and then improve it for you - based on its understanding of a house!! (No idea why you'd want it to do that :P).

-----------

This is really cool! I wish there was a PHP version that stored the neural net in a database or something.
0


User is offline Quinn 

  • More pew-pew, less QQ
  • Group: Members
  • Posts: 1307
  • Joined: 08-March 10
  • LocationPalmyra, PA, USA
  • Expertise:HTML,PHP,Javascript

Posted 07 July 2012 - 05:24 AM (#10)

That is a dog.
Posted Image
<Imp> [F3ar 40]  [PWNbear 17]  [magik 15]  [dissident 10]  [mark 7]

View PostKyek, on 07 February 2011 - 07:11 AM, said:

Though anyone who thinks Europe is a country should be smacked in the face. By a train.
0


User is offline callumacrae 

  • {{ post.author }}
  • Group: Members
  • Posts: 2867
  • Joined: 20-January 11
  • LocationWarwickshire, England
  • Expertise:HTML,CSS,PHP,Javascript,Node.js,SQL

Posted 07 July 2012 - 05:24 AM (#11)

Something like this wouldn't work too well in PHP, it would use far too much (many?) resources and be pretty slow.
Front-end developer and writer
Twitter | GitHub | phpBB Contributor and Website Team Member | lynxphp
0


User is offline TheMaster 

  • *-c0de master-*
  • Group: Members
  • Posts: 764
  • Joined: 24-May 10
  • LocationAustralia
  • Expertise:HTML,CSS,PHP,Java

Posted 07 July 2012 - 07:10 AM (#12)

View Postcallumacrae, on 07 July 2012 - 05:24 AM, said:

Something like this wouldn't work too well in PHP, it would use far too much (many?) resources and be pretty slow.


Is Node.js faster/less resource hungry than Node.js? PHP? Didn't know that....

EDIT: Ooops. Meant PHP :P
0


User is offline Quinn 

  • More pew-pew, less QQ
  • Group: Members
  • Posts: 1307
  • Joined: 08-March 10
  • LocationPalmyra, PA, USA
  • Expertise:HTML,PHP,Javascript

Posted 07 July 2012 - 07:21 AM (#13)

View PostTheMaster, on 07 July 2012 - 07:10 AM, said:

Is Node faster/less resource hungry than Node.js? Didn't know that....

Node is Node.JS
<Imp> [F3ar 40]  [PWNbear 17]  [magik 15]  [dissident 10]  [mark 7]

View PostKyek, on 07 February 2011 - 07:11 AM, said:

Though anyone who thinks Europe is a country should be smacked in the face. By a train.
0


User is offline TheMaster 

  • *-c0de master-*
  • Group: Members
  • Posts: 764
  • Joined: 24-May 10
  • LocationAustralia
  • Expertise:HTML,CSS,PHP,Java

Posted 07 July 2012 - 07:49 AM (#14)

View PostQuinn, on 07 July 2012 - 07:21 AM, said:

Node is Node.JS


See correction :P
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5081
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 07 July 2012 - 09:02 AM (#15)

View Postianonavy, on 06 July 2012 - 11:53 PM, said:

@Kyek

GitHub linky link? D: Thinking about porting the library to Java for use on my Minecraft server. I have no idea what it'd be for though...

https://github.com/TomFrost/MindEye -- Although the neural net library itself is linked in my first post :)

I'm not sure how much help this would be in Minecraft though -- play with my sample a bit so you get the feeling for how much this has to be trained in order to be accurate, and how much a little variation can throw it off. Not very Mindcraft-friendly I'm afraid.


View PostTheMaster, on 07 July 2012 - 05:05 AM, said:

Oh my. That could be epic. You could like...build something (say...a small house), it would recognise its a house - and then improve it for you - based on its understanding of a house!! (No idea why you'd want it to do that :P).

Neural nets don't really work that way :) It could maybe tell you it's a house based on the shape, but suggesting additions would require a whole new algorithm.

Quote

This is really cool! I wish there was a PHP version that stored the neural net in a database or something.

There are quite a few libraries and guides for PHP.

View PostQuinn, on 07 July 2012 - 05:24 AM, said:

That is a dog.
Posted Image

That's why it's only 42% correct :)

View Postcallumacrae, on 07 July 2012 - 05:24 AM, said:

Something like this wouldn't work too well in PHP, it would use far too much (many?) resources and be pretty slow.

Slower for big ones maybe, but it's more about your implementation. Mine is fully blocking and gets slower with every training, but if I were launching this in production I'd just spin off a child process to queue up training jobs, and a small cluster of child processes to run neural net queries. While PHP is downright painful for dealing with child processes and such, it could technically be done and still be fast. It's just a very poor language choice for something like this.

View PostTheMaster, on 07 July 2012 - 07:10 AM, said:

Is Node.js faster/less resource hungry than Node.js? PHP? Didn't know that....

EDIT: Ooops. Meant PHP :P

Node compiles down to machine code at run time, and uses a single thread. PHP, Java, Python, Ruby, etc etc etc all compile down to opcode which has to be run through a VM to parse it every time something needs to be executed, and generally there's either a bunch of processes clogging up the CPU or a bunch of threads. They can run fast, and maybe in a few rare cases faster than Node.js, but if you're writing an app that Node is suited for then it tends to be very snappy.
0


User is offline dida 

  • Group: Members
  • Posts: 1982
  • Joined: 10-March 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,Node.js,SQL,Graphics,Flash,MongoDB,CouchDB,Cassandra

Posted 07 July 2012 - 02:15 PM (#16)

View PostKyek, on 07 July 2012 - 05:24 AM, said:

Posted Image


Uh, wtf?
0,42% not 42% . 0,42% is 0,42/100 ... report it as a bug or something.
0


User is offline soulcyon 

  • 兄貴 シャンク
  • Group: Members
  • Posts: 1598
  • Joined: 14-April 10
  • LocationNew Brunswick, NJ
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,Graphics,MongoDB,CouchDB

Posted 07 July 2012 - 02:19 PM (#17)

Haha yeah, it says 0.42% when its supposed to be 42% or 0.42 or 42/100
Posted Image
0


User is offline Quinn 

  • More pew-pew, less QQ
  • Group: Members
  • Posts: 1307
  • Joined: 08-March 10
  • LocationPalmyra, PA, USA
  • Expertise:HTML,PHP,Javascript

Posted 07 July 2012 - 02:20 PM (#18)

View Postdida, on 07 July 2012 - 02:15 PM, said:

Uh, wtf?
0,42% not 42% . 0,42% is 0,42/100 ... report it as a bug or something.

Report it as a bug to..himself?
<Imp> [F3ar 40]  [PWNbear 17]  [magik 15]  [dissident 10]  [mark 7]

View PostKyek, on 07 February 2011 - 07:11 AM, said:

Though anyone who thinks Europe is a country should be smacked in the face. By a train.
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5081
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 07 July 2012 - 04:21 PM (#19)

Ha, yeah, I noticed that right after I took the screenshots, but it wasn't worth fixing. Just forgot the * 100 is all. I'm about to push a version to github with that fix, as well as non-blocking training so it can be launched on a server with multiple users and still function. It saves the training data every time now too, so restarts don't blow your knowledge base away.
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5081
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 07 July 2012 - 06:32 PM (#20)

Annnnd pushed. Enjoy, if anyone's playing with it :)

Edit: Ok, one more bump, but with good reason -- I launched this on the wdR server for fun ;-). I'll be taking it down when I'm not nearby to monitor it (ie when I'm asleep) but for now it's rolling.

http://webdevrefinery.com:8888

Edit 2: I just looked at our word list and was very impressed that the word 'penis' was not there. Good on you, random wdR people ;-)
0


Share this topic:


  • 3 Pages +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services