[Noisebridge-discuss] ML Wednesday: code up a neuron!

Mikolaj Habryn dichro at rcpt.to
Tue Mar 10 21:56:41 UTC 2009


On Tue, Mar 10, 2009 at 2:32 PM, David Stainton <dstainton415 at gmail.com> wrote:
> Hey,
>
> This programmer/audience idea sounds really fun!
> I imagine making incremental changes to my source tree with each ML class....
>
> hmm the ruby code kind of looks like python...
>
> def dot_product(a, b):
>    sum = 0
>    i = 0
>    while i < len(a):
>        sum += a[i] * b[i]
>        i += 1
>    return sum

I think most languages will look similar if written in accessible
style. Real Python would say:

import operator

def dot_product(a, b):
  return sum(map(operator.mul, a, b))

Which just goes to show that most high-level languages look the same
when written in real style too ;)

m.

>
>
> On Tue, Mar 10, 2009 at 1:48 PM, Josh Myer <josh at joshisanerd.com> wrote:
>> Hey, an early announcement, crazy!
>>
>> Tomorrow night, 8PM, at 83c, we'll have a machine learning workshop.
>> This week's ML Wednesday is going to be another experiment in format.
>> We'll have a real quick introduction to perceptrons (cute little
>> baaaaby neural networks), then we'll all code one up in our language
>> of choice.  By the time you leave, you should have written your own
>> little artificial neuron.
>>
>>
>> To that end, I need a couple of things from the audience:
>>
>> 1. My ML-aware peeps to step up to shepherd a bit on Wednesday night
>>   (You've all been awesome about this thus far, so I'm not worried
>>   about it.  You might want to brush up on the learning  algorithm
>>   used, though.  I'll do a preso, too, so it should be smooth going.)
>>
>> 2. Some sample code in your language of choice.  As long as you can
>>   write a the following function, we're probably good.  Here's that
>>   function; please have it working before you come Wednesday.
>>
>>
>> dot_product:
>>
>> takes two arrays of equal length, multiples them along each other, and
>> sums the products.
>>
>> Test cases for dot_product:
>>
>> dot_product([0],[1]) = 0
>> dot_product([1,2,3,4],[1,10,100,1000]) = 4321
>>
>> And, a quick version in accessible ruby:
>>
>> def dot_product(a, b)
>>  sum = 0.0
>>  i = 0
>>
>>  while(i < a.length)
>>    sum += a[i]*b[i]
>>    i += 1
>>  end
>>
>>  return sum
>> end
>>
>>
>> If this experimental format goes well, we could move on to doing more
>> complex neural networks on top of the same ideas in another workshop,
>> or maybe try some other learning algorithms in the same format.
>>
>> I hope you can join us and build your own little learner tomorrow!
>> --
>> Josh Myer   650.248.3796
>>  josh at joshisanerd.com
> _______________________________________________
> Noisebridge-discuss mailing list
> Noisebridge-discuss at lists.noisebridge.net
> https://www.noisebridge.net/mailman/listinfo/noisebridge-discuss
>



More information about the Noisebridge-discuss mailing list