Spark 的 StreamingLinearRegressionWithSGD 是如何工作的?
How does Spark's StreamingLinearRegressionWithSGD work?
我正在处理 StreamingLinearRegressionWithSGD
which has two methods trainOn
and predictOn
. This class has a model 对象,该对象随着训练数据到达 trainOn
参数中指定的流而更新。
同时它使用相同的模型给出预测。
我想知道如何在 workers/executors 中更新和同步模型权重。
任何 link 或参考资料都会有所帮助。谢谢。
这里没有魔法。 StreamingLinearAlgorithm
keeps a mutable reference 到当前 GeneralizedLinearModel
.
trainOn
uses DStream.foreachRDD
to train a new model on each batch, and then updates the model
. Similarly predictOn
uses DStream.map
to predict用当前版本model
.
由于 Spark 将为每个阶段序列化闭包,因此不需要任何额外的同步。每次计算闭包时,Spark 都会使用 model
的当前值。
实际上它等同于 运行 驱动程序上的循环 run
和 predict
。
我正在处理 StreamingLinearRegressionWithSGD
which has two methods trainOn
and predictOn
. This class has a model 对象,该对象随着训练数据到达 trainOn
参数中指定的流而更新。
同时它使用相同的模型给出预测。
我想知道如何在 workers/executors 中更新和同步模型权重。
任何 link 或参考资料都会有所帮助。谢谢。
这里没有魔法。 StreamingLinearAlgorithm
keeps a mutable reference 到当前 GeneralizedLinearModel
.
trainOn
uses DStream.foreachRDD
to train a new model on each batch, and then updates the model
. Similarly predictOn
uses DStream.map
to predict用当前版本model
.
由于 Spark 将为每个阶段序列化闭包,因此不需要任何额外的同步。每次计算闭包时,Spark 都会使用 model
的当前值。
实际上它等同于 运行 驱动程序上的循环 run
和 predict
。