Skip to content

Commit c7efc56

Browse files
zhengruifengsrowen
authored andcommitted
[MINOR] Fix Typos
## What changes were proposed in this pull request? 1,Rename matrix args in BreezeUtil to upper to match the doc 2,Fix several typos in ML and SQL ## How was this patch tested? manual tests Author: Zheng RuiFeng <[email protected]> Closes #13078 from zhengruifeng/fix_ann.
1 parent f5576a0 commit c7efc56

File tree

6 files changed

+42
-41
lines changed

6 files changed

+42
-41
lines changed

docs/ml-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ Currently, `spark.ml` supports model selection using the [`CrossValidator`](api/
257257

258258
The `Evaluator` can be a [`RegressionEvaluator`](api/scala/index.html#org.apache.spark.ml.evaluation.RegressionEvaluator)
259259
for regression problems, a [`BinaryClassificationEvaluator`](api/scala/index.html#org.apache.spark.ml.evaluation.BinaryClassificationEvaluator)
260-
for binary data, or a [`MultiClassClassificationEvaluator`](api/scala/index.html#org.apache.spark.ml.evaluation.MulticlassClassificationEvaluator)
260+
for binary data, or a [`MulticlassClassificationEvaluator`](api/scala/index.html#org.apache.spark.ml.evaluation.MulticlassClassificationEvaluator)
261261
for multiclass problems. The default metric used to choose the best `ParamMap` can be overridden by the `setMetricName`
262262
method in each of these evaluators.
263263

mllib/src/main/scala/org/apache/spark/ml/ann/BreezeUtil.scala

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,39 @@ import com.github.fommil.netlib.BLAS.{getInstance => NativeBLAS}
2626
private[ann] object BreezeUtil {
2727

2828
// TODO: switch to MLlib BLAS interface
29-
private def transposeString(a: BDM[Double]): String = if (a.isTranspose) "T" else "N"
29+
private def transposeString(A: BDM[Double]): String = if (A.isTranspose) "T" else "N"
3030

3131
/**
3232
* DGEMM: C := alpha * A * B + beta * C
3333
* @param alpha alpha
34-
* @param a A
35-
* @param b B
34+
* @param A A
35+
* @param B B
3636
* @param beta beta
37-
* @param c C
37+
* @param C C
3838
*/
39-
def dgemm(alpha: Double, a: BDM[Double], b: BDM[Double], beta: Double, c: BDM[Double]): Unit = {
39+
def dgemm(alpha: Double, A: BDM[Double], B: BDM[Double], beta: Double, C: BDM[Double]): Unit = {
4040
// TODO: add code if matrices isTranspose!!!
41-
require(a.cols == b.rows, "A & B Dimension mismatch!")
42-
require(a.rows == c.rows, "A & C Dimension mismatch!")
43-
require(b.cols == c.cols, "A & C Dimension mismatch!")
44-
NativeBLAS.dgemm(transposeString(a), transposeString(b), c.rows, c.cols, a.cols,
45-
alpha, a.data, a.offset, a.majorStride, b.data, b.offset, b.majorStride,
46-
beta, c.data, c.offset, c.rows)
41+
require(A.cols == B.rows, "A & B Dimension mismatch!")
42+
require(A.rows == C.rows, "A & C Dimension mismatch!")
43+
require(B.cols == C.cols, "A & C Dimension mismatch!")
44+
NativeBLAS.dgemm(transposeString(A), transposeString(B), C.rows, C.cols, A.cols,
45+
alpha, A.data, A.offset, A.majorStride, B.data, B.offset, B.majorStride,
46+
beta, C.data, C.offset, C.rows)
4747
}
4848

4949
/**
5050
* DGEMV: y := alpha * A * x + beta * y
5151
* @param alpha alpha
52-
* @param a A
52+
* @param A A
5353
* @param x x
5454
* @param beta beta
5555
* @param y y
5656
*/
57-
def dgemv(alpha: Double, a: BDM[Double], x: BDV[Double], beta: Double, y: BDV[Double]): Unit = {
58-
require(a.cols == x.length, "A & b Dimension mismatch!")
59-
NativeBLAS.dgemv(transposeString(a), a.rows, a.cols,
60-
alpha, a.data, a.offset, a.majorStride, x.data, x.offset, x.stride,
57+
def dgemv(alpha: Double, A: BDM[Double], x: BDV[Double], beta: Double, y: BDV[Double]): Unit = {
58+
require(A.cols == x.length, "A & x Dimension mismatch!")
59+
require(A.rows == y.length, "A & y Dimension mismatch!")
60+
NativeBLAS.dgemv(transposeString(A), A.rows, A.cols,
61+
alpha, A.data, A.offset, A.majorStride, x.data, x.offset, x.stride,
6162
beta, y.data, y.offset, y.stride)
6263
}
6364
}

mllib/src/main/scala/org/apache/spark/ml/ann/Layer.scala

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ private[ann] trait Layer extends Serializable {
6464
* @return the layer model
6565
*/
6666
def createModel(initialWeights: BDV[Double]): LayerModel
67+
6768
/**
68-
* Returns the instance of the layer with random generated weights
69+
* Returns the instance of the layer with random generated weights.
6970
*
7071
* @param weights vector for weights initialization, must be equal to weightSize
7172
* @param random random number generator
@@ -83,23 +84,23 @@ private[ann] trait LayerModel extends Serializable {
8384

8485
val weights: BDV[Double]
8586
/**
86-
* Evaluates the data (process the data through the layer)
87+
* Evaluates the data (process the data through the layer).
8788
* Output is allocated based on the size provided by the
88-
* LayerModel implementation and the stack (batch) size
89+
* LayerModel implementation and the stack (batch) size.
8990
* Developer is responsible for checking the size of output
90-
* when writing to it
91+
* when writing to it.
9192
*
9293
* @param data data
9394
* @param output output (modified in place)
9495
*/
9596
def eval(data: BDM[Double], output: BDM[Double]): Unit
9697

9798
/**
98-
* Computes the delta for back propagation
99+
* Computes the delta for back propagation.
99100
* Delta is allocated based on the size provided by the
100-
* LayerModel implementation and the stack (batch) size
101+
* LayerModel implementation and the stack (batch) size.
101102
* Developer is responsible for checking the size of
102-
* prevDelta when writing to it
103+
* prevDelta when writing to it.
103104
*
104105
* @param delta delta of this layer
105106
* @param output output of this layer
@@ -108,10 +109,10 @@ private[ann] trait LayerModel extends Serializable {
108109
def computePrevDelta(delta: BDM[Double], output: BDM[Double], prevDelta: BDM[Double]): Unit
109110

110111
/**
111-
* Computes the gradient
112-
* cumGrad is a wrapper on the part of the weight vector
113-
* size of cumGrad is based on weightSize provided by
114-
* implementation of LayerModel
112+
* Computes the gradient.
113+
* cumGrad is a wrapper on the part of the weight vector.
114+
* Size of cumGrad is based on weightSize provided by
115+
* implementation of LayerModel.
115116
*
116117
* @param delta delta for this layer
117118
* @param input input data
@@ -197,11 +198,11 @@ private[ann] object AffineLayerModel {
197198
}
198199

199200
/**
200-
* Initialize weights randomly in the interval
201-
* Uses [Bottou-88] heuristic [-a/sqrt(in); a/sqrt(in)]
202-
* where a is chosen in a such way that the weight variance corresponds
201+
* Initialize weights randomly in the interval.
202+
* Uses [Bottou-88] heuristic [-a/sqrt(in); a/sqrt(in)],
203+
* where `a` is chosen in such a way that the weight variance corresponds
203204
* to the points to the maximal curvature of the activation function
204-
* (which is approximately 2.38 for a standard sigmoid)
205+
* (which is approximately 2.38 for a standard sigmoid).
205206
*
206207
* @param numIn number of inputs
207208
* @param numOut number of outputs
@@ -306,7 +307,7 @@ private[ann] class FunctionalLayer (val activationFunction: ActivationFunction)
306307
/**
307308
* Functional layer model. Holds no weights.
308309
*
309-
* @param layer functiona layer
310+
* @param layer functional layer
310311
*/
311312
private[ann] class FunctionalLayerModel private[ann] (val layer: FunctionalLayer)
312313
extends LayerModel {
@@ -352,6 +353,7 @@ private[ann] trait TopologyModel extends Serializable {
352353
* Array of layer models
353354
*/
354355
val layerModels: Array[LayerModel]
356+
355357
/**
356358
* Forward propagation
357359
*
@@ -410,7 +412,7 @@ private[ml] object FeedForwardTopology {
410412
* Creates a multi-layer perceptron
411413
*
412414
* @param layerSizes sizes of layers including input and output size
413-
* @param softmaxOnTop wether to use SoftMax or Sigmoid function for an output layer.
415+
* @param softmaxOnTop whether to use SoftMax or Sigmoid function for an output layer.
414416
* Softmax is default
415417
* @return multilayer perceptron topology
416418
*/

sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import org.apache.spark.sql.catalyst.plans.logical.{LocalRelation, LogicalPlan,
3939
import org.apache.spark.sql.execution._
4040
import org.apache.spark.sql.execution.datasources.LogicalRelation
4141
import org.apache.spark.sql.execution.ui.SQLListener
42-
import org.apache.spark.sql.internal.{CatalogImpl, SessionState, SharedState, SQLConf}
42+
import org.apache.spark.sql.internal.{CatalogImpl, SessionState, SharedState}
4343
import org.apache.spark.sql.sources.BaseRelation
4444
import org.apache.spark.sql.types.{DataType, LongType, StructType}
4545
import org.apache.spark.sql.util.ExecutionListenerManager

sql/core/src/main/scala/org/apache/spark/sql/api/r/SQLUtils.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ import org.apache.spark.api.r.SerDe
2626
import org.apache.spark.broadcast.Broadcast
2727
import org.apache.spark.rdd.RDD
2828
import org.apache.spark.sql.{DataFrame, Row, SaveMode, SQLContext}
29-
import org.apache.spark.sql.catalyst.encoders.RowEncoder
3029
import org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema
31-
import org.apache.spark.sql.Encoder
3230
import org.apache.spark.sql.types._
3331

3432
private[sql] object SQLUtils {
@@ -75,19 +73,19 @@ private[sql] object SQLUtils {
7573
org.apache.spark.sql.types.MapType(getSQLDataType(keyType), getSQLDataType(valueType))
7674
case r"\Astruct<(.+)${fieldsStr}>\Z" =>
7775
if (fieldsStr(fieldsStr.length - 1) == ',') {
78-
throw new IllegalArgumentException(s"Invaid type $dataType")
76+
throw new IllegalArgumentException(s"Invalid type $dataType")
7977
}
8078
val fields = fieldsStr.split(",")
8179
val structFields = fields.map { field =>
8280
field match {
8381
case r"\A(.+)${fieldName}:(.+)${fieldType}\Z" =>
8482
createStructField(fieldName, fieldType, true)
8583

86-
case _ => throw new IllegalArgumentException(s"Invaid type $dataType")
84+
case _ => throw new IllegalArgumentException(s"Invalid type $dataType")
8785
}
8886
}
8987
createStructType(structFields)
90-
case _ => throw new IllegalArgumentException(s"Invaid type $dataType")
88+
case _ => throw new IllegalArgumentException(s"Invalid type $dataType")
9189
}
9290
}
9391

sql/core/src/main/scala/org/apache/spark/sql/expressions/scalalang/typed.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ object typed {
3838
// The reason we have separate files for Java and Scala is because in the Scala version, we can
3939
// use tighter types (primitive types) for return types, whereas in the Java version we can only
4040
// use boxed primitive types.
41-
// For example, avg in the Scala veresion returns Scala primitive Double, whose bytecode
41+
// For example, avg in the Scala version returns Scala primitive Double, whose bytecode
4242
// signature is just a java.lang.Object; avg in the Java version returns java.lang.Double.
4343

4444
// TODO: This is pretty hacky. Maybe we should have an object for implicit encoders.

0 commit comments

Comments
 (0)