【发布时间】:2016-05-17 03:31:07
【问题描述】:
所以我已经验证了我正在尝试做的起始版本的工作,但由于某种原因,当将它放入 Matrix.map 高阶函数时它会崩溃。
这是失败的功能:
let SumSquares (theta:Vector<float>) (y:Vector<float>) (trainingData:Matrix<float>) =
let m = trainingData.RowCount
let theta' = theta.ToRowMatrix()
trainingData
|> Matrix.mapRows(fun a r -> (theta' * r) - y.[a] )
这里有一些示例测试
设置:
let tData = matrix [[1.0; 2.0]
[1.0; 3.0]
[1.0; 3.0]
[1.0; 4.0]]
let yVals = vector [5.0; 6.0; 7.0; 11.0]
let theta = vector [1.0; 0.2]
测试基本操作的原始功能(theta transpose * vector - actual)
let theta' = theta.ToRowMatrix()
(theta.ToRowMatrix() * tData.[0, 0 .. 1]) - yVals.[0]
实际功能测试:
tData |> SumSquares theta yVals
这是实际错误的复制/粘贴。读起来好像我将较大的向量映射到较小的向量时遇到了问题。
参数名称:目标
在 MathNet.Numerics.LinearAlgebra.Storage.VectorStorage
1.CopyToRow(MatrixStorage1 目标,Int32 rowIndex,ExistingData existingData)
在 FSI_0061.SumSquares(Vector1 theta, Vector1 y, Matrix`1 trainingData) 在 C:\projects\deleteme\ASPNet5Test\ConsoleApplication1\ConsoleApplication1\MachineLearning.fsx:line 23
在 C:\projects\deleteme\ASPNet5Test\ConsoleApplication1\ConsoleApplication1\MachineLearning.fsx: 39 行中的 .$FSI_0084.main@()
由于错误而停止
【问题讨论】:
-
这是真正的例外,对吧?
System.ArgumentException: All vectors must have the same dimensionality. -
感兴趣的:Deep Learning Tag
-
是的,随着学习算法的进展,我们基本上会将其用作理解成本的一部分
标签: f# linear-algebra math.net mathnet-numerics