Skip to content

Commit a0f6e8e

Browse files
committed
Move javafx examples to separate directory
Signed-off-by: Alex Black <[email protected]>
1 parent 890a132 commit a0f6e8e

File tree

18 files changed

+634
-37
lines changed

18 files changed

+634
-37
lines changed

README.md

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -54,37 +54,6 @@ For more information, check out [deeplearning4j.org](http://deeplearning4j.org/)
5454

5555
`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.
5656

57-
58-
### Known issues with JavaFX
59-
60-
If you are running on JDK 1.7 or inferior, the maven-enforcer plugin will require you to set the variable `JAVAFX_HOME` before building.
61-
That variable should point to a directory containing `jfxrt.jar`, a file that is part of the JavaFX 2.0 distrbution.
62-
63-
Please set it to an instance of JavaFX that matches the JDK with which you are trying to use this project. Usually, the Sun JDK comes with JavaFX. However, OpenJDK does not and you may have to install OpenJFX, a free distribution of JavaFX.
64-
65-
Beware that your editor (e.g. IntelliJ) may not be using the JDK that is your system default (and that you may ancounter on the command line).
66-
67-
### On IntelliJ
68-
69-
To run the JavaFX examples from IntelliJ, you'll have to add the `jfxrt.jar` as an exernal dependency of your project. Here's a screencast on how to do it: https://youtu.be/si146q7WkSY
70-
71-
#### On Ubuntu
72-
73-
If you are using OpenJDK, on Ubuntu 16, you can install OpenJFX with `sudo apt-get install openjfx libopenjfx-java`. A typical `JAVAFX_HOME` is then `/usr/share/java/openjfx/jre/lib/ext/`. If you are on Ubuntu 14, you can install OpenJFX with the following process:
74-
75-
- edit `/etc/apt/sources.list.d/openjdk-r-ppa-trusty.list` and uncomment the line for deb-src
76-
- `sudo apt-get update`
77-
- `sudo apt-get install libicu-dev`
78-
- `sudo aptitude build-dep libopenjfx-java`
79-
- `sudo apt-get --compile source libopenjfx-java`
80-
- `ls -1 *.deb|xargs sudo dpkg -i`
81-
82-
#### On JDK 1.8
83-
84-
The Sun version of JDK8 still comes with its own JavaFX, so that there should be no need to configure anything particular there and the build will succeed. If using OpenJDK8, you will still have to install OpenJFX and set `JAVAFX_HOME`, but the maven-enforcer plugin will not catch you — the reason being that it's difficult to distinguish between OpenJDK and Sun's JDK since version 8, with both adoptiong the same Vendor ID.
85-
86-
If you are using OpenJDK 8, install OpenJFX and set JAVAFX_HOME as indicated above. Compile with `mvn clean install -POpenJFX`
87-
8857
## Other Issues
8958

9059
If you notice issues, please log them, and if you want to contribute, submit a pull request. Input is welcome here.

dl4j-examples/src/main/java/org/deeplearning4j/examples/misc/centerloss/CenterLossLenetMnistExample.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator;
2020
import org.deeplearning4j.examples.unsupervised.variational.plot.PlotUtil;
21-
import org.deeplearning4j.examples.userInterface.util.GradientsAndParamsListener;
2221
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
2322
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
2423
import org.deeplearning4j.nn.conf.inputs.InputType;
@@ -108,7 +107,7 @@ public static void main(String[] args) throws Exception {
108107

109108

110109
log.info("Train model....");
111-
model.setListeners(new GradientsAndParamsListener(model,100),new ScoreIterationListener(100));
110+
model.setListeners(new ScoreIterationListener(100));
112111

113112
List<Pair<INDArray, INDArray>> embeddingByEpoch = new ArrayList<>();
114113
List<Integer> epochNum = new ArrayList<>();

dl4j-examples_javafx/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# dl4j-examples_javafx
2+
3+
This directory contains examples using JavaFX
4+
5+
JavaFX is not available by default with all JVMs, and its absence can cause compilation issues.
6+
Consequently, all JavaFX examples are contained in this standalone directory, not part of the main examples.
7+
8+
9+
### Known issues with JavaFX
10+
11+
If you are running on JDK 1.7 or inferior, the maven-enforcer plugin will require you to set the variable `JAVAFX_HOME` before building.
12+
That variable should point to a directory containing `jfxrt.jar`, a file that is part of the JavaFX 2.0 distrbution.
13+
14+
Please set it to an instance of JavaFX that matches the JDK with which you are trying to use this project. Usually, the Sun JDK comes with JavaFX. However, OpenJDK does not and you may have to install OpenJFX, a free distribution of JavaFX.
15+
16+
Beware that your editor (e.g. IntelliJ) may not be using the JDK that is your system default (and that you may ancounter on the command line).
17+
18+
### On IntelliJ
19+
20+
To run the JavaFX examples from IntelliJ, you'll have to add the `jfxrt.jar` as an exernal dependency of your project. Here's a screencast on how to do it: https://youtu.be/si146q7WkSY
21+
22+
#### On Ubuntu
23+
24+
If you are using OpenJDK, on Ubuntu 16, you can install OpenJFX with `sudo apt-get install openjfx libopenjfx-java`. A typical `JAVAFX_HOME` is then `/usr/share/java/openjfx/jre/lib/ext/`. If you are on Ubuntu 14, you can install OpenJFX with the following process:
25+
26+
- edit `/etc/apt/sources.list.d/openjdk-r-ppa-trusty.list` and uncomment the line for deb-src
27+
- `sudo apt-get update`
28+
- `sudo apt-get install libicu-dev`
29+
- `sudo aptitude build-dep libopenjfx-java`
30+
- `sudo apt-get --compile source libopenjfx-java`
31+
- `ls -1 *.deb|xargs sudo dpkg -i`
32+
33+
#### On JDK 1.8
34+
35+
The Sun version of JDK8 still comes with its own JavaFX, so that there should be no need to configure anything particular there and the build will succeed. If using OpenJDK8, you will still have to install OpenJFX and set `JAVAFX_HOME`, but the maven-enforcer plugin will not catch you — the reason being that it's difficult to distinguish between OpenJDK and Sun's JDK since version 8, with both adoptiong the same Vendor ID.
36+
37+
If you are using OpenJDK 8, install OpenJFX and set JAVAFX_HOME as indicated above. Compile with `mvn clean install -POpenJFX`

dl4j-examples_javafx/pom.xml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
~ Copyright (c) 2015-2019 Skymind, Inc.
4+
~
5+
~ This program and the accompanying materials are made available under the
6+
~ terms of the Apache License, Version 2.0 which is available at
7+
~ https://www.apache.org/licenses/LICENSE-2.0.
8+
~
9+
~ Unless required by applicable law or agreed to in writing, software
10+
~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
~ License for the specific language governing permissions and limitations
13+
~ under the License.
14+
~
15+
~ SPDX-License-Identifier: Apache-2.0
16+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
17+
18+
<project xmlns="http://maven.apache.org/POM/4.0.0"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
23+
<!-- Group-ID, artifact ID and version of the project. You can modify these as you want -->
24+
<groupId>org.deeplearning4j</groupId>
25+
<artifactId>deeplearning4j-examples</artifactId>
26+
<version>1.0.0-beta5</version>
27+
28+
<!-- Properties Section. Change DL4J and ND4J versions here, if required -->
29+
<properties>
30+
<dl4j.version>1.0.0-beta5</dl4j.version>
31+
<nd4j.version>1.0.0-beta5</nd4j.version>
32+
<logback.version>1.2.3</logback.version>
33+
<java.version>1.8</java.version>
34+
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
35+
</properties>
36+
37+
38+
<dependencies>
39+
<!-- deeplearning4j-core: contains main functionality and neural networks -->
40+
<dependency>
41+
<groupId>org.deeplearning4j</groupId>
42+
<artifactId>deeplearning4j-core</artifactId>
43+
<version>${dl4j.version}</version>
44+
</dependency>
45+
46+
<!--
47+
ND4J backend: every project needs one of these. The backend defines the hardware on which network training
48+
will occur. "nd4j-native-platform" is for CPUs only (for running on all operating systems).
49+
-->
50+
<dependency>
51+
<groupId>org.nd4j</groupId>
52+
<artifactId>nd4j-native</artifactId>
53+
<version>${nd4j.version}</version>
54+
</dependency>
55+
56+
<!-- CUDA: to use GPU for training (CUDA) instead of CPU, uncomment this, and remove nd4j-native-platform -->
57+
<!-- Requires CUDA to be installed to use. Change the version (9.2, 10.0, 10.1) to change the CUDA version -->
58+
<!--
59+
<dependency>
60+
<groupId>org.nd4j</groupId>
61+
<artifactId>nd4j-cuda-10.1-platform</artifactId>
62+
<version>${nd4j.version}</version>
63+
</dependency>
64+
-->
65+
66+
<!-- Optional, but recommended: if you use CUDA, also use CuDNN. To use this, CuDNN must also be installed -->
67+
<!-- See: https://deeplearning4j.org/cudnn -->
68+
<!--
69+
<dependency>
70+
<groupId>org.deeplearning4j</groupId>
71+
<artifactId>deeplearning4j-cuda-10.1</artifactId>
72+
<version>${dl4j.version}</version>
73+
</dependency>
74+
-->
75+
76+
<dependency>
77+
<groupId>org.deeplearning4j</groupId>
78+
<artifactId>deeplearning4j-ui_2.11</artifactId>
79+
<version>${dl4j.version}</version>
80+
</dependency>
81+
82+
<dependency>
83+
<groupId>ch.qos.logback</groupId>
84+
<artifactId>logback-classic</artifactId>
85+
<version>${logback.version}</version>
86+
</dependency>
87+
88+
<!-- Used for downloading data in some of the examples -->
89+
<dependency>
90+
<groupId>org.apache.httpcomponents</groupId>
91+
<artifactId>httpclient</artifactId>
92+
<version>4.3.5</version>
93+
</dependency>
94+
</dependencies>
95+
96+
97+
98+
<build>
99+
<plugins>
100+
<!-- Maven compiler plugin: compile for Java 8 -->
101+
<plugin>
102+
<groupId>org.apache.maven.plugins</groupId>
103+
<artifactId>maven-compiler-plugin</artifactId>
104+
<version>3.5.1</version>
105+
<configuration>
106+
<source>${java.version}</source>
107+
<target>${java.version}</target>
108+
</configuration>
109+
</plugin>
110+
111+
112+
<!--
113+
Maven shade plugin configuration: this is required so that if you build a single JAR file (an "uber-jar")
114+
it will contain all the required native libraries, and the backends will work correctly.
115+
Used for example when running the following commants
116+
117+
mvn package
118+
cd target
119+
java -cp deeplearning4j-examples-1.0.0-beta-bin.jar org.deeplearning4j.LenetMnistExample
120+
-->
121+
<plugin>
122+
<groupId>org.apache.maven.plugins</groupId>
123+
<artifactId>maven-shade-plugin</artifactId>
124+
<version>${maven-shade-plugin.version}</version>
125+
<configuration>
126+
<shadedArtifactAttached>true</shadedArtifactAttached>
127+
<shadedClassifierName>bin</shadedClassifierName>
128+
<createDependencyReducedPom>true</createDependencyReducedPom>
129+
<filters>
130+
<filter>
131+
<artifact>*:*</artifact>
132+
<excludes>
133+
<exclude>org/datanucleus/**</exclude>
134+
<exclude>META-INF/*.SF</exclude>
135+
<exclude>META-INF/*.DSA</exclude>
136+
<exclude>META-INF/*.RSA</exclude>
137+
</excludes>
138+
</filter>
139+
</filters>
140+
</configuration>
141+
142+
<executions>
143+
<execution>
144+
<phase>package</phase>
145+
<goals>
146+
<goal>shade</goal>
147+
</goals>
148+
<configuration>
149+
<transformers>
150+
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
151+
<resource>reference.conf</resource>
152+
</transformer>
153+
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
154+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
155+
</transformer>
156+
</transformers>
157+
</configuration>
158+
</execution>
159+
</executions>
160+
</plugin>
161+
</plugins>
162+
</build>
163+
164+
</project>

0 commit comments

Comments
 (0)