diff --git a/scala-package/core/src/main/scala/org/apache/mxnet/Context.scala b/scala-package/core/src/main/scala/org/apache/mxnet/Context.scala
index ab44f434b160..b04cd31ff67f 100644
--- a/scala-package/core/src/main/scala/org/apache/mxnet/Context.scala
+++ b/scala-package/core/src/main/scala/org/apache/mxnet/Context.scala
@@ -38,11 +38,12 @@ object Context {
}
/**
- * Constructing a context.
-
- * @param deviceTypeName {'cpu', 'gpu'} String representing the device type
- * @param deviceId (default=0) The device id of the device, needed for GPU
- */
+ * Constructing a context which is used to specify the device and device type that will
+ * be utilized by the engine.
+ *
+ * @param deviceTypeName {'cpu', 'gpu'} String representing the device type
+ * @param deviceId (default=0) The device id of the device, needed for GPU
+ */
class Context(deviceTypeName: String, val deviceId: Int = 0) extends Serializable {
val deviceTypeid: Int = Context.devstr2type(deviceTypeName)
@@ -61,9 +62,9 @@ class Context(deviceTypeName: String, val deviceId: Int = 0) extends Serializabl
}
/**
- * Return device type of current context.
- * @return device_type
- */
+ * Return device type of current context.
+ * @return device_type
+ */
def deviceType: String = Context.devtype2str(deviceTypeid)
override def toString: String = {
diff --git a/scala-package/core/src/main/scala/org/apache/mxnet/NDArray.scala b/scala-package/core/src/main/scala/org/apache/mxnet/NDArray.scala
index 4324b3dbe63e..ca2e986e7f29 100644
--- a/scala-package/core/src/main/scala/org/apache/mxnet/NDArray.scala
+++ b/scala-package/core/src/main/scala/org/apache/mxnet/NDArray.scala
@@ -728,12 +728,15 @@ object NDArray extends NDArrayBase {
}
/**
- * NDArray object in mxnet.
- * NDArray is basic ndarray/Tensor like data structure in mxnet.
- *
- * WARNING: it is your responsibility to clear this object through dispose().
- *
- */
+ * NDArray object in mxnet.
+ * NDArray is basic ndarray/Tensor like data structure in mxnet.
+ *
+ * NOTE: NDArray is stored in native memory. Use NDArray in a try-with-resources() construct
+ * or a [[org.apache.mxnet.ResourceScope]] in a try-with-resource to have them
+ * automatically disposed. You can explicitly control the lifetime of NDArray
+ * by calling dispose manually. Failure to do this will result in leaking native memory.
+ *
+ */
class NDArray private[mxnet](private[mxnet] val handle: NDArrayHandle,
val writable: Boolean = true,
addToCollector: Boolean = true) extends NativeResource {
@@ -775,21 +778,22 @@ class NDArray private[mxnet](private[mxnet] val handle: NDArrayHandle,
}
/**
- * Dispose all NDArrays who help to construct this array.
- * e.g. (a * b + c).disposeDeps() will dispose a, b, c (including their deps) and a * b
- * @return this array
- */
+ * Dispose all NDArrays who help to construct this array.
+ * e.g. (a * b + c).disposeDeps() will dispose a, b, c (including their deps) and a * b
+ * @return this NDArray
+ */
def disposeDeps(): NDArray = {
disposeDepsExcept()
}
/**
- * Dispose all NDArrays who help to construct this array, excepts those in the arguments.
- * e.g. (a * b + c).disposeDepsExcept(a, b)
- * will dispose c and a * b.
- * Note that a, b's dependencies will not be disposed either.
- * @return this array
- */
+ * Dispose all NDArrays who help to construct this array, excepts those in the arguments.
+ * e.g. (a * b + c).disposeDepsExcept(a, b)
+ * will dispose c and a * b.
+ * Note that a, b's dependencies will not be disposed either.
+ * @param arrs array of NDArrays
+ * @return this array
+ */
def disposeDepsExcept(arrs: NDArray*): NDArray = {
if (dependencies != null) {
val excepts = mutable.HashSet.empty[Long]
diff --git a/scala-package/infer/src/main/scala/org/apache/mxnet/infer/ObjectDetector.scala b/scala-package/infer/src/main/scala/org/apache/mxnet/infer/ObjectDetector.scala
index 78b237a4a9c6..7146156d7cc5 100644
--- a/scala-package/infer/src/main/scala/org/apache/mxnet/infer/ObjectDetector.scala
+++ b/scala-package/infer/src/main/scala/org/apache/mxnet/infer/ObjectDetector.scala
@@ -28,7 +28,8 @@ import org.apache.mxnet.Context
import scala.collection.mutable.ListBuffer
/**
- * A class for object detection tasks
+ * The ObjectDetector class helps to run ObjectDetection tasks where the goal
+ * is to find bounding boxes and corresponding labels for objects in a image.
*
* @param modelPathPrefix Path prefix from where to load the model artifacts.
* These include the symbol, parameters, and synset.txt.