Skip to content

Commit

Permalink
Reverting namespace change since this needs a major version change an…
Browse files Browse the repository at this point in the history
…d breaks backward compatibility.

Revert "Refactor scala code/tests/examples/docs to use org.apache.mxnet (apache#9324)"

This reverts commit deb25bc.
  • Loading branch information
nswamy committed Jan 26, 2018
1 parent 55163bd commit 7986078
Show file tree
Hide file tree
Showing 182 changed files with 710 additions and 707 deletions.
20 changes: 10 additions & 10 deletions docs/api/scala/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MXNet - Scala API

See the [MXNet Scala API Documentation](http://mxnet.incubator.apache.org/api/scala/docs/index.html).
See the [MXNet Scala API Documentation](http://mxnet.io/api/scala/docs/index.html).

MXNet supports the Scala programming language. The MXNet Scala package brings flexible and efficient GPU
computing and state-of-art deep learning to Scala. It enables you to write seamless tensor/matrix computation with multiple GPUs in Scala. It also lets you construct and customize the state-of-art deep learning models in Scala,
Expand All @@ -9,20 +9,20 @@ computing and state-of-art deep learning to Scala. It enables you to write seaml
You can perform tensor or matrix computation in pure Scala:

```scala
scala> import org.apache.mxnet._
import org.apache.mxnet._
scala> import ml.dmlc.mxnet._
import ml.dmlc.mxnet._

scala> val arr = NDArray.ones(2, 3)
arr: org.apache.mxnet.NDArray = org.apache.mxnet.NDArray@f5e74790
arr: ml.dmlc.mxnet.NDArray = ml.dmlc.mxnet.NDArray@f5e74790

scala> arr.shape
res0: org.apache.mxnet.Shape = (2,3)
res0: ml.dmlc.mxnet.Shape = (2,3)

scala> (arr * 2).toArray
res2: Array[Float] = Array(2.0, 2.0, 2.0, 2.0, 2.0, 2.0)

scala> (arr * 2).shape
res3: org.apache.mxnet.Shape = (2,3)
res3: ml.dmlc.mxnet.Shape = (2,3)
```

## Scala API Reference
Expand All @@ -36,7 +36,7 @@ You can perform tensor or matrix computation in pure Scala:

## Resources

* [MXNet Scala API Documentation](http://mxnet.incubator.apache.org/api/scala/docs/index.html)
* [Handwritten Digit Classification in Scala](http://mxnet.incubator.apache.org/tutorials/scala/mnist.html)
* [Neural Style in Scala on MXNet](https://github.com/apache/incubator-mxnet/blob/master/scala-package/examples/src/main/scala/org/apache/mxnetexamples/neuralstyle/NeuralStyle.scala)
* [More Scala Examples](https://github.com/apache/incubator-mxnet/tree/master/scala-package/examples/src/main/scala/org/apache/mxnetexamples)
* [MXNet Scala API Documentation](http://mxnet.io/api/scala/docs/index.html)
* [Handwritten Digit Classification in Scala](http://mxnet.io/tutorials/scala/mnist.html)
* [Neural Style in Scala on MXNet](https://github.com/dmlc/mxnet/blob/master/scala-package/examples/src/main/scala/ml/dmlc/mxnetexamples/neuralstyle/NeuralStyle.scala)
* [More Scala Examples](https://github.com/dmlc/mxnet/tree/master/scala-package/examples/src/main/scala/ml/dmlc/mxnetexamples)
6 changes: 3 additions & 3 deletions docs/api/scala/io.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Topics:
* [Data Iterator Parameters](#parameters-for-data-iterator) clarifies the different usages for dataiter parameters.
* [Create a Data Iterator](#create-a-data-iterator) introduces how to create a data iterator in MXNet for Scala.
* [How to Get Data](#how-to-get-data) introduces the data resource and data preparation tools.
* [IO API Reference](http://mxnet.incubator.apache.org/api/scala/docs/index.html#org.apache.mxnet.IO$) explains the IO API.
* [IO API Reference](http://mxnet.io/api/scala/docs/index.html#ml.dmlc.mxnet.IO$) explains the IO API.


## Data Iterator Parameters
Expand Down Expand Up @@ -83,7 +83,7 @@ First, explicitly specify the kind of data (MNIST, ImageRecord, etc.) to fetch.
## How to Get Data


We provide [scripts](https://github.com/apache/incubator-mxnet/tree/master/scala-package/core/scripts) to download MNIST data and CIFAR10 ImageRecord data. If you want to create your own dataset, we recommend using the Image RecordIO data format.
We provide [scripts](https://github.com/dmlc/mxnet/tree/master/scala-package/core/scripts) to download MNIST data and CIFAR10 ImageRecord data. If you want to create your own dataset, we recommend using the Image RecordIO data format.

## Create a Dataset Using RecordIO

Expand All @@ -93,7 +93,7 @@ RecordIO implements a file format for a sequence of records. We recommend storin
* Packing data together allows continuous reading on the disk.
* RecordIO has a simple way to partition, simplifying distributed setting. We provide an example later.

We provide the [im2rec tool](https://github.com/apache/incubator-mxnet/blob/master/tools/im2rec.cc) so you can create an Image RecordIO dataset by yourself. The following walkthrough shows you how.
We provide the [im2rec tool](https://github.com/dmlc/mxnet/blob/master/tools/im2rec.cc) so you can create an Image RecordIO dataset by yourself. The following walkthrough shows you how.

### Prerequisites
Download the data. You don't need to resize the images manually. You can use `im2rec` to resize them automatically. For details, see "Extension: Using Multiple Labels for a Single Image," later in this topic.
Expand Down
5 changes: 4 additions & 1 deletion docs/api/scala/kvstore.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Topics:
* [Basic Push and Pull](#basic-push-and-pull)
* [List Key-Value Pairs](#list-key-value-pairs)
* [API Reference](http://mxnet.incubator.apache.org/api/scala/docs/index.html#org.apache.mxnet.KVStore)
* [API Reference](http://mxnet.io/api/scala/docs/index.html#ml.dmlc.mxnet.KVStore)


## Basic Push and Pull
Expand Down Expand Up @@ -103,3 +103,6 @@ the interface for generating a list of key-value pairs. For a single device, use
scala> b(1).toArray
Array[Float] = Array(3.0, 3.0, 3.0, 3.0, 3.0, 3.0)
```

## Next Steps
* [Scala Tutorials](http://mxnet.io/tutorials/index.html#Python-Tutorials)
4 changes: 2 additions & 2 deletions docs/api/scala/model.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Topics:
* [Save the Model](#save-the-model)
* [Periodic Checkpoint](#periodic-checkpointing)
* [Multiple Devices](#use-multiple-devices)
* [Model API Reference](#http://mxnet.incubator.apache.org/api/scala/docs/index.html#org.apache.mxnet.Model)
* [Model API Reference](#http://mxnet.io/api/scala/docs/index.html#ml.dmlc.mxnet.Model)

## Train the Model

Expand Down Expand Up @@ -48,7 +48,7 @@ You can also use the `scikit-learn-style` construct and `fit` function to create

model.fit(trainData = train)
```
For more information, see [API Reference](http://mxnet.incubator.apache.org/api/scala/docs/index.html).
For more information, see [API Reference](http://mxnet.io/api/scala/docs/index.html).

## Save the Model

Expand Down
10 changes: 5 additions & 5 deletions docs/api/scala/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ A subclass of modules might have extra interface functions. This topic provides
To construct a module, refer to the constructors for the module class. For example, the `Module` class accepts a `Symbol` as input:

```scala
import org.apache.mxnet._
import org.apache.mxnet.module.{FitParams, Module}
import ml.dmlc.mxnet._
import ml.dmlc.mxnet.module.{FitParams, Module}

// construct a simple MLP
val data = Symbol.Variable("data")
Expand Down Expand Up @@ -40,21 +40,21 @@ Now you can compute with the module using functions like `forward()`, `backward(
Modules provide high-level APIs for training, predicting, and evaluating. To fit a module, call the `fit()` function with some `DataIter`s:

```scala
import org.apache.mxnet.optimizer.SGD
import ml.dmlc.mxnet.optimizer.SGD
val mod = new Module(softmax)

mod.fit(train_dataiter, evalData = scala.Option(eval_dataiter), \
numEpoch = n_epoch, fitParams = new FitParams()\
.setOptimizer(new SGD(learningRate = 0.1f, momentum = 0.9f, wd = 0.0001f)))
```

The interface is very similar to the old `FeedForward` class. You can pass in batch-end callbacks using `setBatchEndCallback` and epoch-end callbacks using `setEpochEndCallback`. You can also set parameters using methods like `setOptimizer` and `setEvalMetric`. To learn more about the `FitParams()`, see the [API page](http://mxnet.io/api/scala/docs/index.html#org.apache.mxnet.module.FitParams). To predict with a module, call `predict()` with a `DataIter`:
The interface is very similar to the old `FeedForward` class. You can pass in batch-end callbacks using `setBatchEndCallback` and epoch-end callbacks using `setEpochEndCallback`. You can also set parameters using methods like `setOptimizer` and `setEvalMetric`. To learn more about the `FitParams()`, see the [API page](http://mxnet.io/api/scala/docs/index.html#ml.dmlc.mxnet.module.FitParams). To predict with a module, call `predict()` with a `DataIter`:

```scala
mod.predict(val_dataiter)
```

The module collects and returns all of the prediction results. For more details about the format of the return values, see the documentation for the [`predict()` function](http://mxnet.incubator.apache.org/api/scala/docs/index.html#org.apache.mxnet.module.BaseModule).
The module collects and returns all of the prediction results. For more details about the format of the return values, see the documentation for the [`predict()` function](http://mxnet.io/api/scala/docs/index.html#ml.dmlc.mxnet.module.BaseModule).

When prediction results might be too large to fit in memory, use the `predictEveryBatch` API:

Expand Down
26 changes: 13 additions & 13 deletions docs/api/scala/ndarray.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ Topics:

* [Create NDArray](#create-ndarray)
* [NDArray Operations](#ndarray-operations)
* [NDArray API Reference](http://mxnet.incubator.apache.org/api/scala/docs/index.html#org.apache.mxnet.NDArray)
* [NDArray API Reference](http://mxnet.io/api/scala/docs/index.html#ml.dmlc.mxnet.NDArray)

## Create NDArray

Create `mxnet.ndarray` as follows:

```scala
scala> import org.apache.mxnet._
scala> import ml.dmlc.mxnet._
scala> // all-zero array of dimension 100x50
scala> val a = NDArray.zeros(100, 50)
scala> // all-one array of dimension 256x32x128x1
Expand All @@ -30,10 +30,10 @@ We provide some basic ndarray operations, like arithmetic and slice operations.
### Arithmetic Operations

```scala
scala> import org.apache.mxnet._
scala> import ml.dmlc.mxnet._
scala> val a = NDArray.zeros(100, 50)
scala> a.shape
org.apache.mxnet.Shape = (100,50)
ml.dmlc.mxnet.Shape = (100,50)
scala> val b = NDArray.ones(100, 50)
scala> // c and d will be calculated in parallel here!
scala> val c = a + b
Expand All @@ -45,7 +45,7 @@ We provide some basic ndarray operations, like arithmetic and slice operations.
### Multiplication/Division Operations

```scala
scala> import org.apache.mxnet._
scala> import ml.dmlc.mxnet._
//Multiplication
scala> val ndones = NDArray.ones(2, 1)
scala> val ndtwos = ndones * 2
Expand Down Expand Up @@ -79,7 +79,7 @@ We provide some basic ndarray operations, like arithmetic and slice operations.
### Slice Operations

```scala
scala> import org.apache.mxnet._
scala> import ml.dmlc.mxnet._
scala> val a = NDArray.array(Array(1f, 2f, 3f, 4f, 5f, 6f), shape = Shape(3, 2))
scala> val a1 = a.slice(1)
scala> assert(a1.shape === Shape(1, 2))
Expand All @@ -93,12 +93,12 @@ We provide some basic ndarray operations, like arithmetic and slice operations.
### Dot Product

```scala
scala> import org.apache.mxnet._
scala> import ml.dmlc.mxnet._
scala> val arr1 = NDArray.array(Array(1f, 2f), shape = Shape(1, 2))
scala> val arr2 = NDArray.array(Array(3f, 4f), shape = Shape(2, 1))
scala> val res = NDArray.dot(arr1, arr2)
scala> res.shape
org.apache.mxnet.Shape = (1,1)
ml.dmlc.mxnet.Shape = (1,1)
scala> res.toArray
Array[Float] = Array(11.0)
```
Expand All @@ -108,7 +108,7 @@ We provide some basic ndarray operations, like arithmetic and slice operations.
You can use MXNet functions to save and load a list or dictionary of NDArrays from file systems, as follows:

```scala
scala> import org.apache.mxnet._
scala> import ml.dmlc.mxnet._
scala> val a = NDArray.zeros(100, 200)
scala> val b = NDArray.zeros(100, 200)
scala> // save list of NDArrays
Expand All @@ -128,20 +128,20 @@ The good thing about using the `save` and `load` interface is that you can use t
Device information is stored in the `mxnet.Context` structure. When creating NDArray in MXNet, you can use the context argument (the default is the CPU context) to create arrays on specific devices as follows:

```scala
scala> import org.apache.mxnet._
scala> import ml.dmlc.mxnet._
scala> val cpu_a = NDArray.zeros(100, 200)
scala> cpu_a.context
org.apache.mxnet.Context = cpu(0)
ml.dmlc.mxnet.Context = cpu(0)
scala> val ctx = Context.gpu(0)
scala> val gpu_b = NDArray.zeros(Shape(100, 200), ctx)
scala> gpu_b.context
org.apache.mxnet.Context = gpu(0)
ml.dmlc.mxnet.Context = gpu(0)
```

Currently, we *do not* allow operations among arrays from different contexts. To manually enable this, use the `copyto` member function to copy the content to different devices, and continue computation:

```scala
scala> import org.apache.mxnet._
scala> import ml.dmlc.mxnet._
scala> val x = NDArray.zeros(100, 200)
scala> val ctx = Context.gpu(0)
scala> val y = NDArray.zeros(Shape(100, 200), ctx)
Expand Down
16 changes: 8 additions & 8 deletions docs/api/scala/symbol.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Topics:
* [Symbol Attributes](#symbol-attributes) describes how to attach attributes to symbols.
* [Serialization](#serialization) explains how to save and load symbols.
* [Executing Symbols](#executing-symbols) explains how to evaluate the symbols with data.
* [Execution API Reference](http://mxnet.incubator.apache.org/api/scala/docs/index.html#org.apache.mxnet.Executor) documents the execution APIs.
* [Execution API Reference](http://mxnet.io/api/scala/docs/index.html#ml.dmlc.mxnet.Executor) documents the execution APIs.
* [Multiple Outputs](#multiple-outputs) explains how to configure multiple outputs.
* [Symbol Creation API Reference](http://mxnet.incubator.apache.org/api/scala/docs/index.html#org.apache.mxnet.Symbol) documents functions.
* [Symbol Creation API Reference](http://mxnet.io/api/scala/docs/index.html#ml.dmlc.mxnet.Symbol) documents functions.

We also highly encourage you to read [Symbolic Configuration and Execution in Pictures](symbol_in_pictures.md).

Expand All @@ -20,14 +20,14 @@ You can configure the graphs either at the level of neural network layer operati
The following example configures a two-layer neural network.

```scala
scala> import org.apache.mxnet._
scala> import ml.dmlc.mxnet._
scala> val data = Symbol.Variable("data")
scala> val fc1 = Symbol.FullyConnected(name = "fc1")()(Map("data" -> data, "num_hidden" -> 128))
scala> val act1 = Symbol.Activation(name = "relu1")()(Map("data" -> fc1, "act_type" -> "relu"))
scala> val fc2 = Symbol.FullyConnected(name = "fc2")()(Map("data" -> act1, "num_hidden" -> 64))
scala> val net = Symbol.SoftmaxOutput(name = "out")()(Map("data" -> fc2))
scala> :type net
org.apache.mxnet.Symbol
ml.dmlc.mxnet.Symbol
```

The basic arithmetic operators (plus, minus, div, multiplication) are overloaded for
Expand All @@ -36,7 +36,7 @@ The basic arithmetic operators (plus, minus, div, multiplication) are overloaded
The following example creates a computation graph that adds two inputs together.

```scala
scala> import org.apache.mxnet._
scala> import ml.dmlc.mxnet._
scala> val a = Symbol.Variable("a")
scala> val b = Symbol.Variable("b")
scala> val c = a + b
Expand Down Expand Up @@ -79,12 +79,12 @@ To attach attributes, you can use ```AttrScope```. ```AttrScope``` automatically
There are two ways to save and load the symbols. You can use the `mxnet.Symbol.save` and `mxnet.Symbol.load` functions to serialize the ```Symbol``` objects.
The advantage of using `save` and `load` functions is that it is language agnostic and cloud friendly.
The symbol is saved in JSON format. You can also get a JSON string directly using `mxnet.Symbol.toJson`.
Refer to [API documentation](http://mxnet.incubator.apache.org/api/scala/docs/index.html#org.apache.mxnet.Symbol) for more details.
Refer to [API documentation](http://mxnet.io/api/scala/docs/index.html#ml.dmlc.mxnet.Symbol) for more details.

The following example shows how to save a symbol to an S3 bucket, load it back, and compare two symbols using a JSON string.

```scala
scala> import org.apache.mxnet._
scala> import ml.dmlc.mxnet._
scala> val a = Symbol.Variable("a")
scala> val b = Symbol.Variable("b")
scala> val c = a + b
Expand Down Expand Up @@ -112,7 +112,7 @@ which is typically constructed by calling the [`simpleBind(<parameters>)`] metho
To group the symbols together, use the [mxnet.symbol.Group](#mxnet.symbol.Group) function.

```scala
scala> import org.apache.mxnet._
scala> import ml.dmlc.mxnet._
scala> val data = Symbol.Variable("data")
scala> val fc1 = Symbol.FullyConnected(name = "fc1")()(Map("data" -> data, "num_hidden" -> 128))
scala> val act1 = Symbol.Activation(name = "relu1")()(Map("data" -> fc1, "act_type" -> "relu"))
Expand Down
4 changes: 2 additions & 2 deletions docs/mxdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ def build_r_docs(app):

def build_scala_docs(app):
"""build scala doc and then move the outdir"""
scala_path = app.builder.srcdir + '/../scala-package/core/src/main/scala/org/apache/mxnet'
scala_path = app.builder.srcdir + '/../scala-package/core/src/main/scala/ml/dmlc/mxnet'
# scaldoc fails on some apis, so exit 0 to pass the check
_run_cmd('cd ' + scala_path + '; scaladoc `find . | grep .*scala`; exit 0')
dest_path = app.builder.outdir + '/api/scala/docs'
_run_cmd('rm -rf ' + dest_path)
_run_cmd('mkdir -p ' + dest_path)
scaladocs = ['index', 'index.html', 'org', 'lib', 'index.js', 'package.html']
scaladocs = ['index', 'index.html', 'ml', 'lib', 'index.js', 'package.html']
for doc_file in scaladocs:
_run_cmd('cd ' + scala_path + ' && mv -f ' + doc_file + ' ' + dest_path)

Expand Down
Loading

0 comments on commit 7986078

Please sign in to comment.