I've been trying to understand the contrastive divergence training of RBMs and back-propagation for NNs, so I implemented them in Haskell, and it works! Take a look at https://github.com/aeyakovenko/rbm. I would love some feedback. Cross-post from /r/machinelearningsubmitted by aeyakovenko
[link] [10 comments]
Hi, I have been looking for a cabal package that handle CNN (Convolutionnal Neural Network) with no success. Is there such a package available?
Thanks!submitted by Dref360
[link] [11 comments]
I figured it out now, but my first instinct was to recreate the error by evaluating by hand. So, I typed
Prelude> 2 ^ 3
Prelude> 8 ^ 4
Prelude> 4096 ^ 5
1152921504606846976 (I hope I typed that correctly)
But, then, I realized, this was being associated in the other direction. So, I checked that out by hand.
prelude> 4 ^ 5 1024 Prelude> 3 ^ 1024 --do I dare even test this one? it will be a 300+ digit number.
3733918(etc) . . . .for 4 lines. I can't even guess how much it would take to calculate 2 ^ (300 digit number) but it would require more than the known universe turned into RAM memory to store the result.
So, at first I wondered what was wrong with Stack ghci, but now, just take this as a friendly public service announcement.submitted by Xalem
[link] [36 comments]
So I've read this: http://degoes.net/articles/modern-fp/ and a few years ago I also read this: http://www.haskellforall.com/2012/06/you-could-have-invented-free-monads.html
I "get" the mechanism for free monads, and catamorphisms, and algebras. Unfortunately, I'm still not convinced by the utility. When should I actually whip out a free monad? When is it that I really do need the flexibility of interpreters, and how is that more or less appropriate than the traditional approach of typeclasses, or multiparameter typeclasses? I see a lot of "how", and "what", but I think the articles I've linked to don't give a lot of "why"! What's the motivation, and what are the tradeoffs?submitted by saposcat
[link] [46 comments]
- December 30th, 2015: You have a string of 'digits' in base whatever to convert to an Int
debase :: [Int] -> Int -> Int
debase [12,21,3] 26 ~> 8661
- Gautier DI FOLCO @gautier_difolco
debase = curry (sum . uncurry (zipWith (*)) . bimap reverse (flip iterate 1 . (*)))
- bazzargh @bazzargh
debase a b = sum $ zipWith (*) (reverse a) (map (b^) [0..])
- obadz @obadzz
or debase l b = foldl (\ p n -> p * b + n) 0 l
- bazzargh @bazzargh
that's better than mine. how about:
flip (foldl1 . ((+) .) . (*))
- December 12th, 2015: #math You have this sequence: [1,1,1,1,1,1,2,1,1,1,3,3] What is this pattern? Is there one? Write #haskell to generate this list.
- December 3rd, 2015: Lens-y again Points-free-itize the following correctName :: Row -> Row correctName r = set lastName (init (view lastName r)) r
- December 3rd, 2015: Let's get a little lens-y with this one: accumer :: Getter a t a -> t -> [a] -> [a] accumer f s acc = ans where ans = view f s:acc
- Define the curried-accumer function that curries away the acc-argument.
- What would the curried definition be if the function type were: accumer :: Getter a t a -> t -> Set a -> Set a
- December 3rd, 2015: define minimax :: Ord eh => eh -> (eh, eh) -> (eh, eh) such that, e.g.: minimax 1 (2,3) ~> (1,3) minimax 10 (2,3) ~> (2,10)
- Thomas Dietert @thomasdietert In that case, minimax n (x,y) = (minimum [n,x,y], maximum [n,x,y])
- joomy @cattheory minimax = liftM2 (***) min max
- December 1st, 2015: define (->>) :: (a -> m ()) -> (a -> m ()) -> a -> m () All monadic effects must be evaluated.
- Jérôme @phollow (->>) f g a = f a >> g a
- then liftM2 (>>)
- Nicoλas @BeRewt but the full applicative is: liftA2 (*>)
I am writing a parser for email's headers with attoparsec. But while trying to optimize this code I stumble upon several questions that I cannot answer by myself.
So naturally I am looking for the help of the community.
Is function call cheap in haskell ? Because when displaying cost center with +RTS -p two near function's calls in the code seem pretty distant in time. (in a flamegraph you can detect that with huge gap between each step of the call stack). Inlining function seems to overcome most of this not solicited overhead.
Is it possible to see strictness in Haskell/GHC ? Often time I want to see at a certain point in the program (at runtime), what have been evaluated or not. Is there an equivalent of traceShow but for strictness ? This traceStrict will (without forcing any evaluation) recursively show the state of a variable (thunks, WHNF, NF, ...) Most of the time I am trying to guess around and add some $!, (or just adding it everywhere and see if it's making a difference). Or is it possible to use ghc to dump intermediate representation to see this at compile time ?
Why MonoTraversable is faster than Traversable ? I tend to use classyPrelude everywhere in my programs in replacement for prelude. By default classyPrelude uses functions from MonoTraversable instead of Traversable. For a reason that I cannot explain the Monoidic version seems faster. What is the benifit of adding the Monoid constraint instead of just using the Generic version ?
What's the difference between
Thisfunc = do ... toto where toto = do ...
andtoto = do .... func = do ... toto
For me there is none, but when I changed the first version for the later one. Performance seemed to improve for unknown reasons.
Any explanation will be welcome :)Compilation of answers
- Is function call cheap in haskell ?
Look at tibbe answer
- Is it possible to see strictness in Haskell/GHC ?
In GHCi you can use :sprint to print a variable without forcing its evaluation. I think if you stop the program in the GHCi debugger you should be able to then check if a value is a thunk or not
It's the perfect solution for me
Look at the intermediate output (-ddump-simpl) you can see if e.g. arguments are passed unboxed (e.g. Int#) or boxed (e.g. Int)
It's works but the dump is really tedious to read (at least with my current knowledge)
For more information about the runtime behavior
- What's the difference between
Top level functions are more likely to get inlined and memoized than where functions IIRC.submitted by erebe
[link] [11 comments]
Compared to Python/Java/C++, I find it really hard to read Haskell build errors. Does anyone have tips on how I could understand errors better?submitted by Maplicant
[link] [8 comments]
If your question wasn't answered last time feel free to ask again! (Sometimes it's just a matter of getting the right person to see your question.)
Here is a link to the previous thread: https://www.reddit.com/r/haskell/comments/3uvf4p/hask_anything_the_thread_where_you_ask_and_we_try/
Looking for questions to answer? Try sorting by new.submitted by dagit
[link] [66 comments]
I've been switching to Haskell as my main language for about 2 years now, and I think I'm pretty much up to speed with any scripting languages I used to use before. However, what is still killing me (and slowly me down) is the import process. For example, I'm writing a simple script which parse two (using cassava), compare them (these), and display them (tabular). Adding to that, the standard monad, maybe , monoid etc I end up with the following import sectionimport qualified Data.ByteString.Lazy as BL import Data.Char (toLower, ord) import Data.Csv import Data.List.Split (splitOn) import Data.Maybe (catMaybes) import Data.Monoid import System.Environment (getArgs) import Control.Monad import Control.Applicative import Data.String (fromString) import Data.Map(Map) import qualified Data.Map as Map import Data.Maybe import Data.Traversable (traverse) import Options.Applicative as Opt import Data.Align (align) import Data.These import Text.Regex.PCRE((=~~)) import Text.Regex(subRegex, mkRegex) import Text.Tabular as Table import qualified Text.Tabular.Ascii as Ascii
Not mentioning adding all the libraries to the cabal file. All of that is is somehow ridiculous for a 10 (ok 50) line script. If there is one feature in Haskell which I would like to see in the "new-haskell" is the "import problem". Is there any hope that it will be sorted somehow ? The solution I can see are- extension allowing to alias group of import into one - template haskell allowing to declare import allowing import group alias - a community effort to propose "currated" group of libraries. - something else
I could of course write my own "prelude" and push it on hackage, but if everybody do that, hackage will become cluttered unless the community agreed on a naming scheme like Prelude.maxigit or User.maxigit ...
Am I the only one having this problem and if not how do you solve it ?submitted by maxigit
[link] [46 comments]