Github user feynmanliang commented on a diff in the pull request:
https://github.com/apache/spark/pull/9229#discussion_r42794479
--- Diff: mllib/src/main/scala/org/apache/spark/ml/ann/Layer.scala ---
@@ -208,14 +214,18 @@ private[ann] object AffineLayerModel {
* Generate random weights for the layer
* @param numIn number of inputs
* @param numOut number of outputs
- * @param seed seed
+ * @param weights vector for weights initialization
+ * @param random random number generator
* @return (matrix A, vector b)
*/
- def randomWeights(numIn: Int, numOut: Int, seed: Long = 11L):
(BDM[Double], BDV[Double]) = {
- val rand: XORShiftRandom = new XORShiftRandom(seed)
- val weights = BDM.fill[Double](numOut, numIn){ (rand.nextDouble * 4.8
- 2.4) / numIn }
- val bias = BDV.fill[Double](numOut){ (rand.nextDouble * 4.8 - 2.4) /
numIn }
- (weights, bias)
+ def randomWeights(numIn: Int, numOut: Int, weights: BDV[Double], random:
Random):
+ (BDM[Double], BDV[Double]) = {
--- End diff --
nit: I would prefer to line break at arguments rather than return type. Not
sure if it's part of official style guide but it's what I've seen elsewhere
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]