Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ object GradientDescent extends Logging {
* if it's L2 updater; for L1 updater, the same logic is followed.
*/
var regVal = updater.compute(
weights, Vectors.dense(new Array[Double](weights.size)), 0, 1, regParam)._2
weights, Vectors.zeros(weights.size), 0, 1, regParam)._2

for (i <- 1 to numIterations) {
val bcWeights = data.context.broadcast(weights)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ abstract class GeneralizedLinearAlgorithm[M <: GeneralizedLinearModel]
*/
val initialWeights = {
if (numOfLinearPredictor == 1) {
Vectors.dense(new Array[Double](numFeatures))
Vectors.zeros(numFeatures)
} else if (addIntercept) {
Vectors.dense(new Array[Double]((numFeatures + 1) * numOfLinearPredictor))
Vectors.zeros((numFeatures + 1) * numOfLinearPredictor)
} else {
Vectors.dense(new Array[Double](numFeatures * numOfLinearPredictor))
Vectors.zeros(numFeatures * numOfLinearPredictor)
}
}
run(input, initialWeights)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ abstract class StreamingLinearAlgorithm[
model match {
case Some(m) =>
m.weights
case None =>
val numFeatures = rdd.first().features.size
Vectors.dense(numFeatures)
}
model = Some(algorithm.run(rdd, initialWeights))
logInfo("Model updated at time %s".format(time.toString))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class StreamingLinearRegressionWithSGD private[mllib] (
this
}

/** Set the initial weights. Default: [0.0, 0.0]. */
/** Set the initial weights. */
def setInitialWeights(initialWeights: Vector): this.type = {
this.model = Some(algorithm.createModel(initialWeights, 0.0))
this
Expand Down