[英]Implementing gradient descent with Scala and Breeze - error : could not find implicit value for parameter op:
I'm attempting to apply a gradient descent implementation in Scala and breeze based on Octave from : Gradient Descent implementation in octave 我试图在Scala和基于八度的微风中应用梯度下降实现,方法是: 八度中的梯度下降实现
The octave code I'm attempting to re-write is : 我尝试重写的八度代码是:
theta = theta -((1/m) * ((X * theta) - y)' * X)' * alpha;
I've come up with : 我想出了:
val xv = DenseVector[Double](1.0, 1.0)
val yv = DenseVector[Double](1.0, 1.0)
val mymatrix : DenseMatrix[Double] = DenseMatrix( (1.0,2.0) , (3.0,4.0) )
val myvalue = (mymatrix - ((1 / m) * (( (xv * mymatrix - yv).t * xv).t * .0001)
but im receiving a compile time error : 但我收到一个编译时错误:
Multiple markers at this line:
◾could not find implicit value for parameter op: breeze.linalg.operators.OpSub.Impl2[breeze.linalg.DenseMatrix[Double],breeze.linalg.DenseVector[Double],That]
◾not enough arguments for method -: (implicit op: breeze.linalg.operators.OpSub.Impl2[breeze.linalg.DenseMatrix[Double],breeze.linalg.DenseVector[Double],That])That. Unspecified value parameter op.
Have I implemented gradient descent correctly using Scala and Breeze ? 我是否已使用Scala和Breeze正确实现了梯度下降?
It seems I need to provide an implicit for -
operator ? 看来我需要为提供一个隐含
-
操作?
val myvalue = (mymatrix - ((1 / m) * (( (xv * mymatrix - yv).t * xv).t * .0001)
xv
is Vector and the mymatrix
is the Matrix which is unsupported . xv
是向量,而mymatrix
是不受支持的矩阵 。 that is the error u are encountering 那就是你遇到的错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.