Haskell 'n' layered ANN forward pass
\(col, row) -&gt; (take 10000 $ randomRs (-1.0, 1.0) generator)!!(col * row)


Oh man you got me going "no no no no no no" like I long haven't :D. take 10000 does nothing here. col * row is going to come out to the same when you switch row and col, perhaps you want col + inputSize * row? randomRs is going to be recalculated for each (col,row) pair - fromList fixes that. Calling the line's result weights is little more than a comment. MonadRandom can avert the generator passery, and also stop you generating the same random values for each call to randomWeights.

activate :: [Double] -&gt; [Matrix Double] -&gt; Matrix Double
activate i = foldl squash (fromLists [i]) where
  squash inputs weights = fmap leakyRelu $ multStd2 inputs weights
  leakyRelu a
    | a &gt; 0.0 = a
    | otherwise = 0.01 * a

randomWeights :: Int -&gt; Int -&gt; IO (Matrix Double)
randomWeights rows cols = fromList rows cols &lt;$&gt; getRandomRs (-1.0, 1.0)

main :: IO ()
main = do
  let inputs = [0, 1]

  inputWeights &lt;- randomWeights (length inputs) 3
  hiddenWeights &lt;- randomWeights 3 1
  outputWeights &lt;- randomWeights 1 1

  let outputs = activate inputs [inputWeights, hiddenWeights, outputWeights]

  print inputs
  print outputs