我会在两个密集向量之间进行减法,它们都是数据集和函数的结果。有一个例子
1. The first dense vector is a row of dataset(*, 2)
BroadcastedRows(DenseVector(0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0))
2. The second dense vector is a return of predict_coef_sgd(dataset, coef)
DenseVector(0.2987569855650975, 0.14595105593031163, 0.08533326519733725,
0.21973731424800344, 0.24705900008926596, 0.9547021347460022,
0.8620341905282771, 0.9717729050420985, 0.9992954520878627,
0.9054893228110497)
我减去它时出错了
dataset(*, 2) - predict_coef_sgd(dataset, coef)
Name: Compile Error
Message: <console>:36: error: could not find implicit value for parameter op: breeze.linalg.operators.OpSub.Impl2[breeze.linalg.BroadcastedRows[breeze.linalg.DenseVector[Double],breeze.linalg.DenseVector[Double]],breeze.linalg.DenseVector[Double],That]
dataset(*, 2) - predict_coef_sgd(dataset, coef)
^
StackTrace:
请评论如何转换&#34; BroadcastedRows(DenseVector&#34;到密集的矢量。谢谢。
答案 0 :(得分:0)
根据约翰的评论,提到row-broadcasting and transposed vectors?它解决了,然而,我不明白为什么,如果你能详细解释,请随时评论
(dataset.t(2,::) - predict_coef_sgd(dataset, coef).t).t
DenseVector(-0.2987569855650975, -0.14595105593031163, -0.08533326519733725,
-0.21973731424800344, -0.24705900008926596, 0.045297865253997815,
0.13796580947172288, 0.028227094957901544, 7.045479121372544E-4,
0.09451067718895034)