Skip to content

Commit 9e971fd

Browse files
authored
Merge pull request #988 from KonduitAI/master
Refactor Examples repository
2 parents f9a89d5 + cb47cd5 commit 9e971fd

File tree

557 files changed

+9494
-27675
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

557 files changed

+9494
-27675
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,5 @@ Word2vec-index/
6262
*end.model
6363

6464
arbiterExample/
65+
dl4j-examples/*.zip
66+

LICENSE.txt

+7-58
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
Copyright (c) 2020 Konduit K.K
12
Copyright 2015-2019 Skymind Inc.
23

34
Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,71 +18,19 @@ limitations under the License.
1718

1819
-- Misc files --
1920
*README.md
21+
*FAQ.md
2022
*readme.md
21-
.github/CONTRIBUTING.md
23+
CONTRIBUTORS.md
2224
.github/ISSUE_TEMPLATE.md
2325
.github/PULL_REQUEST_TEMPLATE.md
2426
org/deeplearning4j/examples/misc/customlayers/CustomLayerExampleReadme.md
25-
org/deeplearning4j/examples/tictactoe/ReadMe.txt
26-
lstm-hdfs/src/resources/test/f1
27-
lstm-hdfs/src/resources/test/f2
28-
lstm-hdfs/src/resources/train/f1
29-
lstm-hdfs/src/resources/train/f2
30-
lstm-hdfs/src/resources/train/f3
31-
nd4j-examples/src/main/resources/numpy_cheatsheet/file.csv
32-
nd4j-examples/src/main/resources/numpy_cheatsheet/file.txt
33-
nd4j-examples/src/main/resources/numpy_cheatsheet/saveFile.csv
34-
nd4j-examples/src/main/resources/numpy_cheatsheet/saveFile.txt
27+
nd4j-ndarray-examples/src/main/resources/numpy_cheatsheet/file.txt
28+
nd4j-ndarray-examples/src/main/resources/numpy_cheatsheet/saveFile.txt
29+
nd4j-ndarray-examples/src/main/resources/numpyz.npz
3530
pydatavec-examples/basic_example.csv
3631
pydatavec-examples/reduction_example.csv
37-
rl4j-examples/cartpole.gif
38-
rl4j-examples/cliffwalk.gif
39-
rl4j-examples/cliffwalk_block.gif
40-
rl4j-examples/doom.gif
41-
rl4j-examples/scoregraph.png
42-
tutorials/00. Quickstart for Deeplearning4j.json
43-
tutorials/00. Quickstart for Deeplearning4j.zepp.ipynb
44-
tutorials/01. MultiLayerNetwork and ComputationGraph.json
45-
tutorials/01. MultiLayerNetwork and ComputationGraph.zepp.ipynb
46-
tutorials/02. Built-in Data Iterators.json
47-
tutorials/02. Built-in Data Iterators.zepp.ipynb
48-
tutorials/03. Logistic Regression.json
49-
tutorials/03. Logistic Regression.zepp.ipynb
50-
tutorials/04. Feed-forward.json
51-
tutorials/04. Feed-forward.zepp.ipynb
52-
tutorials/05. Basic Autoencoder- Anomaly Detection Using Reconstruction Error.json
53-
tutorials/05. Basic Autoencoder- Anomaly Detection Using Reconstruction Error.zepp.ipynb
54-
tutorials/06. Advanced Autoencoder- Trajectory Clustering using AIS.json
55-
tutorials/06. Advanced Autoencoder- Trajectory Clustering using AIS.zepp.ipynb
56-
tutorials/07. Convolutions- Train FaceNet Using Center Loss.json
57-
tutorials/07. Convolutions- Train FaceNet Using Center Loss.zepp.ipynb
58-
tutorials/08. RNNs- Sequence Classification of Synthetic Control Data.json
59-
tutorials/08. RNNs- Sequence Classification of Synthetic Control Data.zepp.ipynb
60-
tutorials/09. Early Stopping.ipynb
61-
tutorials/09. Early Stopping.zepp.json
62-
tutorials/10. Layers and Preprocessors.ipynb
63-
tutorials/10. Layers and Preprocessors.zepp.json
64-
tutorials/11. Hyperparameter Optimization.json
65-
tutorials/11. Hyperparameter Optimization.zepp.ipynb
66-
tutorials/12. Clinical Time Series LSTM Example.json
67-
tutorials/12. Clinical Time Series LSTM Example.zepp.ipynb
68-
tutorials/13. Clinical LSTM Time Series Example Using SKIL.json
69-
tutorials/13. Clinical LSTM Time Series Example Using SKIL.zepp.ipynb
70-
tutorials/14. Parallel Training.json
71-
tutorials/14. Parallel Training.zepp.ipynb
72-
tutorials/15. Sea Temperature Convolutional LSTM Example.json
73-
tutorials/15. Sea Temperature Convolutional LSTM Example.zepp.ipynb
74-
tutorials/16. Sea Temperature Convolutional LSTM Example 2.json
75-
tutorials/16. Sea Temperature Convolutional LSTM Example 2.zepp.ipynb
76-
tutorials/17. Instacart Multitask Example.json
77-
tutorials/17. Instacart Multitask Example.zepp.ipynb
78-
tutorials/18. Instacart Single Task Example.json
79-
tutorials/18. Instacart Single Task Example.zepp.ipynb
80-
tutorials/19. Cloud Detection Example.json
81-
tutorials/19. Cloud Detection Example.zepp.ipynb
82-
83-
8432

33+
Copyright (c) 2020 Konduit K.K
8534
Copyright (c) 2015-2019 Skymind, Inc.
8635
Apache 2.0 License
8736

README.md

+59-40
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,79 @@
1-
Deeplearning4J Examples
2-
=========================
1+
<pre>
2+
######## ## ## ##
3+
## ## ## ## ## ##
4+
## ## ## ## ## ##
5+
**$** ## ## ## ## ## ## **$**
6+
## ## ## ######### ## ##
7+
## ## ## ## ## ##
8+
######## ######## ## ######
9+
. :::: : : : : : :::: : :::: ::::: :::: :::: ::::: .
10+
. : : : : : :: :: : : : : : : : : : : : .
11+
. : : : : : : : : : : : : : : : : : : : : .
12+
. ::: : : : : : : :::: : ::: ::::: ::: :::: : : .
13+
. : : : ::::: : : : : : : : : : : : .
14+
. : : : : : : : : : : : : : : : : .
15+
. :::: : : : : : : : ::::: :::: : : :::: : ::::: .
16+
</pre>
317

4-
## NOTE: HOW to interpret these examples
18+
## Introduction
19+
The **Eclipse Deeplearning4J** (DL4J) ecosystem is a set of projects intended to support all the needs of a JVM based deep learning application. This means starting with the raw data, loading and preprocessing it from wherever and whatever format it is in to building and tuning a wide variety of simple and complex deep learning networks.
520

6-
## Data Loading
7-
In this repository, you may likely see custom [datasetiterators](https://github.com/eclipse/deeplearning4j/blob/master/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dataset/api/iterator/DataSetIterator.java) - these iterators are only for special examples and 1 off use cases. Consult the [gitter](https://gitter.im/deeplearning4j/deeplearning4j) if you are not sure how to proceed.
8-
Once you find a record reader for your use case, you then should use one of pre made iterators that knows how to interpret record reader output, either [RecordReaderDataSetIterator](https://deeplearning4j.org/api/latest/org/deeplearning4j/datasets/datavec/RecordReaderDataSetIterator.html) for normal data or [SequenceRecordReaderDataSetIterator](https://deeplearning4j.org/api/latest/org/deeplearning4j/datasets/datavec/SequenceRecordReaderDataSetIterator.html) for sequence data. For more on sequences, please see our [rnns page](http://deeplearning4j.org/usingrnns)
21+
The DL4J stack comprises of:
22+
- **DL4J**: High level API to build MultiLayerNetworks and ComputationGraphs with a variety of layers, including custom ones. Supports importing Keras models from h5, including tf.keras models (as of 1.0.0-beta7) and also supports distributed training on Apache Spark
23+
- **ND4J**: General purpose linear algebra library with over 500 mathematical, linear algebra and deep learning operations. ND4J is based on the highly-optimized C++ codebase LibND4J that provides CPU (AVX2/512) and GPU (CUDA) support and acceleration by libraries such as OpenBLAS, OneDNN (MKL-DNN), cuDNN, cuBLAS, etc
24+
- **SameDiff** : Part of the ND4J library, SameDiff is our automatic differentiation / deep learning framework. SameDiff uses a graph-based (define then run) approach, similar to TensorFlow graph mode. Eager graph (TensorFlow 2.x eager/PyTorch) graph execution is planned. SameDiff supports importing TensorFlow frozen model format .pb (protobuf) models. Import for ONNX, TensorFlow SavedModel and Keras models are planned. Deeplearning4j also has full SameDiff support for easily writing custom layers and loss functions.
25+
- **DataVec**: ETL for machine learning data in a wide variety of formats and files (HDFS, Spark, Images, Video, Audio, CSV, Excel etc)
26+
- **Arbiter**: Library for hyperparameter search
27+
- **LibND4J** : C++ library that underpins everything. For more information on how the JVM acceses native arrays and operations refer to [JavaCPP](https://github.com/bytedeco/javacpp)
928

29+
All projects in the DL4J ecosystem support Windows, Linux and macOS. Hardware support includes CUDA GPUs (10.0, 10.1, 10.2 except OSX), x86 CPU (x86_64, avx2, avx512), ARM CPU (arm, arm64, armhf) and PowerPC (ppc64le).
1030

11-
We have special iterators for 1 off use cases where normal data does not quite exist, or sometimes it is legacy.
12-
99% of the time you should be using [datavec](https://deeplearning4j.org/datavec) and writing your own custom [record readers](https://deeplearning4j.org/api/latest/org/datavec/api/records/reader/RecordReader.html) if one of our pre provided ones is not suitable. If you are not sure what is available, please again consult the [gitter](https://gitter.im/deeplearning4j/deeplearning4j) - In general, you can find both [normal record readers](https://deeplearning4j.org/api/latest/org/datavec/api/records/reader/RecordReader.html) and [sequence record readers](https://deeplearning4j.org/api/latest/org/datavec/api/records/reader/SequenceRecordReader.html) in the datavec [javadoc](https://deeplearning4j.org/docs/latest/datavec-overview).
31+
## Prerequisites
32+
This example repo consists of several separate Maven Java projects, each with their own pom files. Maven is a popular build automation tool for Java Projects. The contents of a "pom.xml" file dictate the configurations. Read more about how to configure Maven [here](https://deeplearning4j.konduit.ai/config/maven).
1333

34+
Users can also refer to the [simple sample project provided](./mvn-project-template/pom.xml) to get started with a clean project from scratch.
1435

15-
## Dependencies
36+
Build tools are considered standard software engineering best practice. Besides this the complexities posed by the projects in the DL4J ecosystem make dependencies too difficult to manage manually. All the projects in the DL4J ecosystem can be used with other build tools like Gradle, SBT etc. More information on that can be found [here](https://deeplearning4j.konduit.ai/config/buildtools).
1637

17-
Note that this repository contains all dl4j examples for all modules. It will download about 1.5g of dependencies from maven central when you are first starting out. That being said, this makes it easier to get started without worrying about what to download. This examples repository is meant to be a reference point to get started with most common use cases.
18-
It is broken up in to modules. If you would like to just have a more minimal/simple, guide please go [here](http://www.dubs.tech/guides/maven-essentials/)
38+
## Example Content
39+
Projects are based on what functionality the included examples demonstrate to the user and not necessarily which library in the DL4J stack the functionality lives in.
1940

41+
Examples in a project are in general separated into "quickstart" and "advanced".
2042

21-
Repository of Deeplearning4J neural net examples:
43+
Each project README also lists all the examples it contains, with a recommended order to explore them in.
2244

23-
- MLP Neural Nets
24-
- Convolutional Neural Nets
25-
- Recurrent Neural Nets
26-
- TSNE
27-
- Word2Vec
28-
- Anomaly Detection
29-
- User interface examples.
45+
- [dl4j-examples](dl4j-examples/README.md)
46+
This project contains a set of examples that demonstrate use of the high level DL4J API to build a variety of neural networks.
47+
Some of these examples are end to end, in the sense they start with raw data, process it and then build and train neural networks on it.
3048

31-
DL4J-Examples is released under an Apache 2.0 license. By contributing code to this repository, you agree to make your contribution available under an Apache 2.0 license.
49+
- [tensorflow-keras-import-examples](tensorflow-keras-import-examples/README.md)
50+
This project contains a set of examples that demonstrate how to import Keras h5 models and TensorFlow frozen pb models into the DL4J ecosystem. Once imported into DL4J these models can be treated like any other DL4J model - meaning you can continue to run training on them or modify them with the transfer learning API or simply run inference on them.
3251

33-
---
52+
- [dl4j-distributed-training-examples](dl4j-distributed-training-examples/README.md)
53+
This project contains a set of examples that demonstrate how to do distributed training, inference and evaluation in DL4J on Apache Spark. DL4J distributed training employs a "hybrid" asynchronous SGD approach - further details can be found in the distributed deep learning documentation [here](https://deeplearning4j.konduit.ai/distributed-deep-learning/intro)
3454

35-
## Build and Run
55+
- [cuda-specific-examples](cuda-specific-examples/README.md)
56+
This project contains a set of examples that demonstrate how to leverage multiple GPUs for data-parallel training of neural networks for increased performance.
3657

37-
Use [Maven](https://maven.apache.org/) to build the examples.
58+
- [samediff-examples](samediff-examples/README.md)
59+
This project contains a set of examples that demonstrate the SameDiff API. SameDiff (which is part of the ND4J library) can be used to build lower level auto-differentiating computation graphs. An analogue to the SameDiff API vs the DL4J API is the low level TensorFlow API vs the higher level of abstraction Keras API.
3860

39-
```
40-
mvn clean package
41-
```
61+
- [data-pipeline-examples](data-pipeline-examples/README.md)
62+
This project contains a set of examples that demonstrate how raw data in various formats can be loaded, split and preprocessed to build serializable (and hence reproducible) ETL pipelines.
4263

43-
This downloads binaries for all platforms, but we can also append `-Djavacpp.platform=` with `android-arm`, `android-x86`, `linux-ppc64le`, `linux-x86_64`, `macosx-x86_64`, or `windows-x86_64` to get binaries for only one platform and produce much smaller archives.
64+
- [nd4j-ndarray-examples](nd4j-ndarray-examples/README.md)
65+
This project contains a set of examples that demonstrate how to manipulate NDArrays. The functionality of ND4J demonstrated here can be likened to NumPy.
4466

45-
Run the `runexamples.sh` script to run the examples (requires [bash](https://www.gnu.org/software/bash/)). It will list the examples and prompt you for the one to run. Pass the `--all` argument to run all of them. (Other options are shown with `-h`).
67+
- [arbiter-examples](arbiter-examples/README.md)
68+
This project contains a set of examples that demonstrate usage of the Arbiter library for hyperparameter tuning of Deeplearning4J neural networks.
4669

47-
```
48-
./runexamples.sh [-h | --help]
49-
```
70+
- [rl4j-examples](rl4j-examples/README.md)
71+
This project contains examples of using RL4J, the reinforcement learning library in DL4J.
5072

73+
- [android-examples](android-examples/README.md)
74+
This project contains an Android example project, that shows DL4J being used in an Android application.
5175

52-
## Documentation
53-
For more information, check out [deeplearning4j.org](http://deeplearning4j.org/) and its [JavaDoc](https://deeplearning4j.org/docs/latest/).
54-
55-
`GradientsListenerExample.java` in dl4j-examples/src/main/java/org/deeplearning4j/examples/userInterface uses JavaFX. If you're using Java 8 or greater, it should run as is. If you're using Java 7 or an earlier version, you should set JAVAFX_HOME to point to the root directory of the JavaFX 2.0 SDK.
56-
57-
## Other Issues
58-
59-
If you notice issues, please log them, and if you want to contribute, submit a pull request. Input is welcome here.
60-
76+
## Feedback & Contributions
77+
While these set of examples don't cover all the features available in DL4J the intent is to cover functionality required for most users - beginners and advanced. File an issue [here](https://github.com/eclipse/deeplearning4j-examples/issues) if you have feedback or feature requests that are not covered here. We are also available via our [community forum](https://community.konduit.ai/) for questions.
78+
We welcome contributions from the community. More information can be found [here](CONTRIBUTORS.md)
79+
We **love** hearing from you. Cheers!

android-examples/.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx

android-examples/README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Eclipse Deeplearning4J Examples for Android
2+
3+
This project shows a simple example of using Deeplearning4J in an Android application. As Gradle is the preferred build tool for Android, this project uses Gradle instead of Maven.
4+
5+
The neural networks shown in this example are the same as are used in the [Moon](../dl4j-examples/src/main/java/org/deeplearning4j/examples/quickstart/modeling/feedforward/classification/MoonClassifier.java) and [Saturn](../dl4j-examples/src/main/java/org/deeplearning4j/examples/quickstart/modeling/feedforward/classification/SaturnClassifier.java) examples of the dl4j-examples.
6+
7+
The build configuration for Android can be found in [app/build.gradle](./app/build.gradle).
8+
9+
[Go back](../README.md) to the main repository page to explore other features/functionality of the **Eclipse Deeplearning4J** ecosystem. File an issue [here](https://github.com/eclipse/deeplearning4j-examples/issues) to request new features.
10+
11+
# Known Issues
12+
Due to an unfortunately timed change, the 1.0.0-beta7 release doesn't work well with most Android devices. For this reason, this example project uses the SNAPSHOT version.
13+
14+
Again unfortunately, gradle has issues retrieving SNAPSHOT versions when combined with classifiers, which are used here to retrieve only the android specific backend dependencies.
15+
16+
If you want to run this example locally, you will therefore need to have Maven installed in order to download those specific dependencies.
17+
18+
Once you have installed Maven, you will need to run the following commands from the command line to download the correct android backend files:
19+
20+
```
21+
mvn dependency:get -DremoteRepositories=snapshots::::https://oss.sonatype.org/content/repositories/snapshots -Dartifact=org.nd4j:nd4j-native:1.0.0-SNAPSHOT:jar:android-arm
22+
mvn dependency:get -DremoteRepositories=snapshots::::https://oss.sonatype.org/content/repositories/snapshots -Dartifact=org.nd4j:nd4j-native:1.0.0-SNAPSHOT:jar:android-arm64
23+
mvn dependency:get -DremoteRepositories=snapshots::::https://oss.sonatype.org/content/repositories/snapshots -Dartifact=org.nd4j:nd4j-native:1.0.0-SNAPSHOT:jar:android-x86
24+
mvn dependency:get -DremoteRepositories=snapshots::::https://oss.sonatype.org/content/repositories/snapshots -Dartifact=org.nd4j:nd4j-native:1.0.0-SNAPSHOT:jar:android-x86_64
25+
```

android-examples/app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

0 commit comments

Comments
 (0)