Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,322
    • Issues 4,322
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 357
    • Merge Requests 357
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #14535

Closed
Open
Opened Nov 27, 2017 by iTotallyExist@trac-iTotallyExist

ghc: panic! (the 'impossible' happened) (GHC version 8.2.1 for x86_64-apple-darwin): stack depth overflow

I created a neural network library within haskell. I was able to create, test, and train the net (using data from the mNist dataset). I could only test manually (try one input at a time and compare the two outputs), so i made a function which allowed me to test many test inputs on the net at once.

Recreating bug: first, load main.hs in ghci (duh) then, run the entirety of trainedNetwork.txt as a command to initialise the network (i.e. copy paste the file into the ghci command line) then run the entirety of test.txt as a command. Here you will get the error. To test with different input values for the function "test" (the function whose being run caused the crash), you can open the jupyter notebook and run the function mnistTest with higher or lower values (higher using more test cases, lower using less) and run the output of that function as a command in haskell. (i know from testing that 41 inputs does not cause a crash, but 42 does (seriously, this is not a joke)) .

What i know is not the problem/probably causes: I know that y was initiliased correctly. The function being run here is :

--takes in a network and an array of test inputs and their corresponding outputs and returns the accuracy of the network
--only works for classification networks
testClassification :: [Layer] -> [[Double]] -> [[Double]] -> Double
testClassification net inputs outputs = testClassificationHelper net inputs outputs 0 0

testClassificationHelper :: [Layer] -> [[Double]] -> [[Double]] -> Double -> Double -> Double
testClassificationHelper _ [] _ correct incorrect = (correct/(correct+incorrect))
testClassificationHelper net (input:inputs) (output:outputs) correct incorrect | netMax == outMax = next (correct+1) incorrect
                                                                               | otherwise = next correct (incorrect+1)
                                                                               where
                                                                                next = testClassificationHelper net inputs outputs
                                                                                netMax = greatestIndex (getOutput net input)
                                                                                outMax = greatestIndex output

I know that getOutput and greatestIndex work\\ I know that it works with a small amount of inputs (test3.txt is essentially the same command except instead of using the first 100 test examples of the mnist data set, it uses the first 3)\\ I know that it works when using the first 30 data points, but not with the first 50.\\ I know that doing it for the first 30 inputs only takes 2 seconds and 270 MB, while training the network took 40 minutes and 820GB, take from that what you will\\

Note: trainedNetwork.txt is too large to upload, so it is available at https://drive.google.com/open?id=1HfCNknZ9AfJauQoNwzhlEwsQfcHTya0t

Edited Mar 10, 2019 by iTotallyExist
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#14535