0
我想爲Scala Breeze矩陣實現我自己的elementwise UFunc,以便函數可以應用於矩陣的每個元素。使用Breeze.numerics軟件包作爲指導我已經嘗試過:在Scala Breeze中實現元素UFunc
object step extends UFunc with MappingUFunc {
implicit object stepImplDouble extends Impl[Double, Double] {
def apply(x: Double) = if (x >= 0.5) 1.0 else 0.0
}
看起來很簡單,是吧?我想使用的功能如下:
val H: BDM[Double] = step((M(::,*) + bias).t)
即通過元素的運用它的功能元素,一個矩陣,使輸出H.然而,代碼提供在編譯時錯誤:
Error:(60, 26) could not find implicit value for parameter impl: dev.elm.step.Impl[breeze.linalg.DenseMatrix[Double],VR]
case "step" => step((M(::, *) + bias).t)
Error:(60, 26) not enough arguments for method apply: (implicit impl: dev.elm.step.Impl[breeze.linalg.DenseMatrix[Double],VR])VR in trait UFunc.
Unspecified value parameter impl.
case "step" => step((M(::, *) + bias).t)
這與我在上一個問題中提出的錯誤非常相似。這聽起來像它可能需要矩陣參數,但我認爲這都是在MappingUFunc特徵中處理的。任何幫助感謝!謝謝