作者:mobiledu2502869467 | 来源:互联网 | 2023-09-25 13:17
Mycodeispastedhere.Belowismyghcidebugsession.Istilldontunderstandwhyithasarange
My code is pasted here. Below is my ghci debug session. I still don't understand why it has a range of (0, -193459561) when the 'len' binding is 90570.
我的代码粘贴在这里。下面是我的ghci调试会话。当'len'绑定为90570时,我仍然不明白为什么它的范围为(0,-193459561)。
*Main> :break 125
Breakpoint 4 activated at SVMCF.hs:125:13-86
*Main> :trace main
Stopped at SVMCF.hs:125:13-86
_result :: UA.Array Int [User] = _
len :: Int = 90570
rts :: [RTuple] = (1,1,5.0) : (1,2,3.0) : (1,3,4.0) : (1,4,3.0) :
(1,5,3.0) : ....
[SVMCF.hs:125:13-86] *Main> :lis
124 points :: A.Array Int [Int]
125 points = assert (len > 0) $ A.listArray (1::Int, len) $ map (\(u,i,r) -> [u,i]) rts
126 values :: UA.UArray Int Double
[SVMCF.hs:125:13-86] *Main> :ste
Stopped at SVMCF.hs:125:13-28
_result :: UA.Array Int [User] -> UA.Array Int [User] = _
len :: Int = 90570
[SVMCF.hs:125:13-28] *Main> :ste
Stopped at SVMCF.hs:125:21-27
_result :: Bool = _
len :: Int = 90570
[SVMCF.hs:125:21-27] *Main> :ste
Stopped at SVMCF.hs:125:32-86
_result :: UA.Array Int [User] = _
len :: Int = 90570
rts :: [RTuple] = (1,1,5.0) : (1,2,3.0) : (1,3,4.0) : (1,4,3.0) :
(1,5,3.0) : ....
[SVMCF.hs:125:32-86] *Main> :ste
Stopped at SVMCF.hs:125:32-56
_result :: [[User]] -> UA.Array Int [User] = _
len :: Int = 90570
[SVMCF.hs:125:32-56] *Main> :lis
124 points :: A.Array Int [Int]
125 points = assert (len > 0) $ A.listArray (1::Int, len) $ map (\(u,i,r) -> [u,i]) rts
126 values :: UA.UArray Int Double
[SVMCF.hs:125:32-56] *Main> len
90570
[SVMCF.hs:125:32-56] *Main> :ste
Stopped at SVMCF.hs:125:60-86
_result :: [[User]] = _
rts :: [RTuple] = (1,1,5.0) : (1,2,3.0) : (1,3,4.0) : (1,4,3.0) :
(1,5,3.0) : ....
[SVMCF.hs:125:60-86] *Main> :ste
*** Exception: Ix{Int}.index: Index (1) out of range ((1,-193459561))
1 个解决方案
3
I suspect the index out of range exception is not being caused in the expression that you think it is!
我怀疑索引超出范围异常不会在您认为的表达式中引起!
Data.Array.listArray (1,-10) [2,3,4,5]
Data.Array.listArray(1,-10)[2,3,4,5]
does not throw any exception, it just gives you an empty array. Also note the column numbers in the last debug message:
不抛出任何异常,只是给你一个空数组。另请注意上一个调试消息中的列号:
Stopped at SVMCF.hs:125:60-86
停在SVMCF.hs:125:60-86
60 to 86 is map (\(u,i,r) -> [u,i]) rts
which doesn't obviously have any indexing going on in it: There's certainly none in map, nor in its first argument, and rts
looks clean too as it comes straight from ua.base
via Parsec.
60到86是map(\(你,我,r) - > [u,i])rts,其中显然没有任何索引:地图中没有,也没有第一个参数和rts看起来很干净,因为它直接来自ua.base通过Parsec。
Because Haskell is allowed to be fairly free with its evaluation order, it's possible that the exception is being thrown by a reduction in a completely different expression. Are you sure all the other things you're passing into SVM are set up correctly? In particular, given that you're using Int
-indexed arrays, are you sure there's no integer overflow occurring in any array? Are any of your datasets, for example, 4101507735 or 8396475031 records long, because these overflow to -193459561 as Int
).
因为Haskell允许其评估顺序相当自由,所以可能通过减少完全不同的表达式来抛出异常。您确定要传递给SVM的所有其他内容是否已正确设置?特别是,鉴于您使用的是Int-indexed数组,您确定在任何数组中都没有发生整数溢出吗?您的任何数据集(例如,4101507735或8396475031)都是长的,因为这些数据集溢出到-193459561作为Int)。
Does the :history
command in the GHCi debugger give you any more information?
GHCi调试器中的:history命令是否为您提供了更多信息?