【问题标题】:Compile error on transposing a dense matrix in Spark MLlib在 Spark MLlib 中转置密集矩阵时出现编译错误
【发布时间】:2019-12-19 04:07:32
【问题描述】:

我正在尝试在 Spark 中创建一个密集矩阵,然后使用以下代码对其进行转置:

val weightsMatrix = Matrices.dense(1, 3, Array.fill[Double](3)(0))

val weightsMatrix_t = weightsMatrix.transpose()

但它失败并出现以下编译错误。

not enough arguments for method apply: (i: Int, j: Int)Double in 
trait Matrix.
[error] Unspecified value parameters i, j.
[error]     val weightsMatrix_t = weightsMatrix.transpose()
[error]                                                  ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed

我在文档中检查了函数transpose 不带任何参数,但似乎涉及到一个名为apply 的方法。

【问题讨论】:

    标签: scala apache-spark apache-spark-mllib


    【解决方案1】:

    apply 指的是 () 试用你的转置。 Transpose 是矩阵的成员变量,因此当您调用 tanspose 时,它​​会返回一个矩阵,然后您将调用该矩阵上的索引,而没有给出索引值。 解决办法是

    val weightsMatrix_t = weightsMatrix.transpose
    

    没有 ()

    【讨论】:

    • 谢谢!你是对的,这解决了问题。我一定是在查看旧文档。
    猜你喜欢
    • 1970-01-01
    • 2013-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-13
    • 1970-01-01
    • 2018-08-05
    • 2016-04-01
    相关资源
    最近更新 更多