tag:blogger.com,1999:blog-37404288.post4207788230397604070..comments2023-11-02T14:40:18.756+01:00Comments on JP Moresmau's Programming Blog: A perceptron in HaskellJP Moresmauhttp://www.blogger.com/profile/09964251063221757176noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-37404288.post-20693692674840350132009-11-16T23:43:55.205+01:002009-11-16T23:43:55.205+01:00Just wanted to thank you. Your post on perceptrons...Just wanted to thank you. Your post on perceptrons in Haskell, your follow-up post on the neural net, and the comments people have made are helping me with a similar project of my own.Muddle-headed Wombathttps://www.blogger.com/profile/03615793782263571255noreply@blogger.comtag:blogger.com,1999:blog-37404288.post-23313044705088382722007-06-01T12:41:00.000+02:002007-06-01T12:41:00.000+02:00Thanks all for the tips!! Yes I do not think often...Thanks all for the tips!! Yes I do not think often enough about newtype and about the order of my parameters for partial application!! And I suppose the let syntax is closer to imperative style: I detail in order each result I need to have!<BR/>Justin, I don't really see what benefits having the funtion output in the type definition brings?JP Moresmauhttps://www.blogger.com/profile/09964251063221757176noreply@blogger.comtag:blogger.com,1999:blog-37404288.post-63015082069410498812007-05-27T08:08:00.000+02:002007-05-27T08:08:00.000+02:00Personally, I would reverse the order of the input...Personally, I would reverse the order of the inputs to neuronOutput, to facilitate partial application. The threshold changes least often, the weights change moderately often, and the inputs change the most often. So you could define neuronOutput as:<BR/><BR/>neuronOutput threshold weights inputs = ...<BR/><BR/>Then, creating a neuron with a given threshold could be done by:<BR/><BR/>neuron = neuronOutput threshold<BR/><BR/>and, after training, you could do:<BR/><BR/>trainedNeuron = neuron weights<BR/><BR/>and then use the trained neuron with:<BR/><BR/>trainedNeuron inputs<BR/><BR/>Anyway, I like what you've done!Aaron Tombhttps://www.blogger.com/profile/10098895869012902515noreply@blogger.comtag:blogger.com,1999:blog-37404288.post-73037657179072713662007-05-27T05:27:00.000+02:002007-05-27T05:27:00.000+02:00All of yourlet x = fooin bar = x ...would pro...All of your<BR/><BR/>let <BR/> x = foo<BR/>in<BR/> bar = x ...<BR/><BR/>would probably be more idiotmatically represented as<BR/><BR/>bar = x ...<BR/> where<BR/> x = fooAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-37404288.post-8631637694898505852007-05-25T22:45:00.000+02:002007-05-25T22:45:00.000+02:00I think the functions would be a bit clearer if yo...I think the functions would be a bit clearer if you defined a Neuron type rather than passing tons of floats around. I would start with<BR/><BR/>newtype Neuron = Nearon [Float] [Float] Float<BR/><BR/>which makes the neuron hold hte inputs, the weights and its threshold.<BR/><BR/>I would make then add some other types just to make the intent clear:<BR/><BR/>type Inputs = [Float]<BR/>type Weights = [Float]<BR/>type Threshold = Float<BR/><BR/>then Neuron becomes:<BR/><BR/>newtype Neuron = Inputs Weights Threshold<BR/><BR/>I like 'newtype' (as opposed to type) because the compiler will catch if you try to mix Neurons with something else. If Neuron was just a type synonym, the compiler can silently convert it on you. NOt sure if that's really bad or not but it seems safer to go with newtype.<BR/><BR/>Anyways, then you could add the "output" function as a value of the Neuron type:<BR/><BR/>newtype Neuron = { inputs :: Inputs, weights :: Weights, threshold :: Float, output :: (Inputs -> Weights -> Threshold -> Float)<BR/><BR/>I look forward to seeing how your code develops!Justinhttps://www.blogger.com/profile/04138857652921543796noreply@blogger.com