Re: [Haskell-cafe] Backpropagation implementation for a neural net library

2009-06-15 Thread Trin Trin
Hi Alp,
- even with correctly programmed back-propagation, it is usually hard to
make the net converge.
- usually you initialize neuron weights with somewhat random values, when
working with back-propagation.
- do some debug prints of the net error while training to see how it is
going
- xor function cannot be trained with a single layer neural net !!!
Cheers,
Martin
PS: I did not check the back-propagation algorithm itself.


On Mon, Jun 15, 2009 at 9:58 AM, Alp Mestan a...@mestan.fr wrote:

 Dear List,

 I'm working with a friend of mine on a Neural Net library in Haskell.

 There are 3 files : neuron.hs, layer.hs and net.hs.
 neuron.hs defines the Neuron data type and many utility functions, all of
 which have been tested and work well.
 layer.hs defines layer-level functions (computing the output of a whole
 layer of neurons, etc). Tested and working.
 net.hs defines net-level functions (computing the output of a whole neural
 net) and the famous -- but annoying -- back-propagation algorithm.

 You can find them there : http://mestan.fr/haskell/nn/html/

 The problem is that here when I ask for final_net or test_output (anything
 after the train call, in net.hs), it seems to loop and loop around, as if it
 never gets the error under 0.1.

 So I was just wondering if there was one or more Neural Nets and Haskell
 wizard in there to check the back-propagation implementation, given in
 net.hs, that seems to be wrong.

 Thanks a lot !

 --
 Alp Mestan

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ideas for a phd in the area of paralleism?

2009-01-07 Thread Trin

Frederik Deweerdt wrote:

On Wed, Jan 07, 2009 at 10:35:25AM +0100, Michael Lesniak wrote:
  

Hello,

currently I'm searching for a topic for my phd-thesis or at least for
a workshop-paper (as a starting point, to get my feet wet...). My
academic group has specialized itself on (practical, i.e. not too
theoretical stuff like verification, etc...) parallel programming and
related topics, so my future thesis has to be in this area, but as
long as its related I'm free to choose whatever I want.



GPU programming seems to be hot:

http://www.cse.unsw.edu.au/~chak/papers/gpugen.pdf
http://www.cs.chalmers.se/Cs/Education/Courses/svh/Slides/may-15-Obsidian-short.pdf
  

Make OpenCL bindings please, please ... pretty please.
Martin

Regards,
Frederik
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
  


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] HOpenGL shading problem

2008-11-12 Thread Trin

Hi,

last few days I spent making remake of glxgears. Nothing
fancy, I just wanted easily configurable gears. The current
performance is only about 70% of glxgears.
But I have a problem with shading. Whatever I have been trying,
I still don't understand how the shading can be activated. I have
light, I have color, but not even Flat shading.

Please can you give me a hand?

Thanks,
Martin

PS: I didn't find any attachment size policy for this list, so I hope 
that the attachment is small enough.
-
-- 
-- Copyright (c) 2008 Martin 'Trin' Kudlvasr
-- All rights reserved.
--
-- Redistribution and use in sourse and binary forms are permitted
-- provided that the above copyright notice and this paragraph are
-- duplicated in all such forms and that any documentation,
-- advertising materials, and other materials related to such
-- distribution and use acknowledge that the software was developed
-- by Martin Kudlvasr. The name of Martin Kudlvasr 
-- may not be used to endorse or promote products derived from this
-- software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED 'AS IS' AND WITHOUT ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING LIMITATION, THE IMPLIED
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
--
---

-
--
-- Author -
-- Martin 'Trin' Kudlvasr
-- www.trinpad.eu
-- November, 2008

module Gear where

import Graphics.Rendering.OpenGL
import Data.List

data ToothDim = ToothDim { top :: GLfloat, -- width at the top of a tooth
   bottom :: GLfloat, -- width at the base of a tooth
   height :: GLfloat } -- height of the tooth

data Gear = Gear { bottomRadius,  -- from center to tooth bottom corner
   topRadius, -- from center to tooth top corner
   bottomAngle,   -- angle that tooth bottom line takes
   topAngle,  -- angle that  tooth top line takes
   betweenAngle,  -- angle between top and bottom tooth line
   innerRadius,   -- inner circle of gear
   thickness :: GLfloat, -- z axis thickness
   gColor :: Color4 GLfloat
 }

-- angles of gear contour points
angles gear = 0 : takeWhile (2*pi) [ sum $ take i as | i - [1..] ] ++ [0]
  where
as = cycle $ map (\f - f gear) [ bottomAngle, betweenAngle, topAngle, betweenAngle ]

-- angle of 1 phase
toothAngle gear = sum $ map (\f - f gear) [bottomAngle, betweenAngle, topAngle, betweenAngle]

-- radius depends on teeth amount and dimensions. This is error with which radius is calculated 
_MAX_ERROR = 0.001

calculateGearRadius toothDim teethCount = 
  calculateGearRadius' toothDim teethCount 1000 0.5

calculateGearRadius' toothDim targetTeeth tmpRadius factor = 
case countTeeth top bottom newRadius of
tmpTeeth
| tmpTeeth  targetTeeth + _MAX_ERROR - calculateGearRadius' toothDim targetTeeth newRadius factor
| tmpTeeth  targetTeeth  - calculateGearRadius' toothDim targetTeeth tmpRadius (factor/2)
| otherwise   - newRadius
where
ToothDim top bottom height = toothDim
newRadius = tmpRadius*(1-factor)

countTeeth top bottom radius = 
  pi / ( asin (top / (2*radius)) + asin(bottom / (2*radius) ) )

newTeethCountGear toothDim teethCount innerR thickness c = 
Gear bottomR topR bottomA topA betweenA innerR thickness c 
  where
bottomR = calculateGearRadius toothDim teethCount
topR= sqrt ( (bottomR*bottomR) - (bottom*bottom/4) ) + height
ToothDim top bottom height = toothDim
bottomA = 2 * asin (top / (2*bottomR))
topA= 2 * asin (top / (2*(bottomR+height)))
totalA  = 2 * pi / teethCount
betweenA= (totalA - topA - bottomA) / 2

newGear = newTeethCountGear

newMinimumRadiusGear toothDim minRadius innerR thickness c = 
newGear toothDim (fromIntegral teethCount + 1) innerR thickness c
  where
ToothDim top bottom height = toothDim
toothA = 2 * ( asin (top / (2*minRadius)) +  asin (bottom / (2*minRadius)) )
(teethCount, _) = properFraction ( 2 * pi / toothA )

gearContourPoints gear = 
zipWith3 zipF [0,1..] inCircle outCircle
  where
zipF i inP outP | i `mod` 4 == 0 = inP
| i `mod` 4 == 1 = inP
| otherwise  = outP
inCircle  = angleCirclePoints as $ bottomRadius gear
outCircle = angleCirclePoints as $ topRadiusgear
as = angles gear

gearFacePoints gear = 
concat $ zipWith (\x y - [x,y]) contourPs innerPs
  where
contourPs = gearContourPoints gear
innerPs   = angleCirclePoints (angles gear) (innerRadius gear)

setZ ps newZ