Skip to content

Commit 40ea030

Browse files
committed
Adding Deeplearning4j UI to the sample
1 parent 809f8f1 commit 40ea030

File tree

1 file changed

+65
-19
lines changed

1 file changed

+65
-19
lines changed

samples/DeepLearning4j-Cuda.ipynb

+65-19
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"val outputNum = 10 // number of output classes\n",
4545
"val batchSize = 64 // batch size for each epoch\n",
4646
"val rngSeed = 123 // random number seed for reproducibility\n",
47-
"val numEpochs = 15 // number of epochs to perform\n",
47+
"val numEpochs = 5 // number of epochs to perform\n",
4848
"val rate = 0.0015 // learning rate"
4949
]
5050
},
@@ -124,7 +124,7 @@
124124
"cell_type": "markdown",
125125
"metadata": {},
126126
"source": [
127-
"### Train model"
127+
"### Launching Deeplearning4j UI"
128128
]
129129
},
130130
{
@@ -133,9 +133,39 @@
133133
"metadata": {},
134134
"outputs": [],
135135
"source": [
136+
"import org.deeplearning4j.ui.api.UIServer\n",
136137
"import org.deeplearning4j.optimize.listeners.ScoreIterationListener\n",
138+
"import org.deeplearning4j.api.storage.StatsStorageRouter\n",
139+
"import org.deeplearning4j.api.storage.impl.RemoteUIStatsStorageRouter\n",
140+
"import org.deeplearning4j.ui.stats.StatsListener\n",
137141
"\n",
138-
"model.setListeners(ScoreIterationListener(100))\n",
142+
"val uiServer: UIServer = UIServer.getInstance()\n",
143+
"uiServer.enableRemoteListener()\n",
144+
"//Create the remote stats storage router - this sends the results to the UI via HTTP, assuming the UI is at http://localhost:9000\n",
145+
"val remoteUIRouter: StatsStorageRouter = RemoteUIStatsStorageRouter(\"http://localhost:9000\")\n",
146+
"model.setListeners(ScoreIterationListener(100), StatsListener(remoteUIRouter))"
147+
]
148+
},
149+
{
150+
"cell_type": "markdown",
151+
"metadata": {},
152+
"source": [
153+
"open a new tab in your browser and go to [http://localhost:9000](http://localhost:9000)"
154+
]
155+
},
156+
{
157+
"cell_type": "markdown",
158+
"metadata": {},
159+
"source": [
160+
"### Train model"
161+
]
162+
},
163+
{
164+
"cell_type": "code",
165+
"execution_count": 6,
166+
"metadata": {},
167+
"outputs": [],
168+
"source": [
139169
"model.fit(mnistTrain, numEpochs)"
140170
]
141171
},
@@ -148,7 +178,7 @@
148178
},
149179
{
150180
"cell_type": "code",
151-
"execution_count": 6,
181+
"execution_count": 7,
152182
"metadata": {},
153183
"outputs": [
154184
{
@@ -159,26 +189,26 @@
159189
"\n",
160190
"========================Evaluation Metrics========================\n",
161191
" # of classes: 10\n",
162-
" Accuracy: 0,9820\n",
163-
" Precision: 0,9819\n",
164-
" Recall: 0,9818\n",
165-
" F1 Score: 0,9819\n",
192+
" Accuracy: 0,9718\n",
193+
" Precision: 0,9722\n",
194+
" Recall: 0,9711\n",
195+
" F1 Score: 0,9714\n",
166196
"Precision, recall & F1: macro-averaged (equally weighted avg. of 10 classes)\n",
167197
"\n",
168198
"\n",
169199
"=========================Confusion Matrix=========================\n",
170200
" 0 1 2 3 4 5 6 7 8 9\n",
171201
"---------------------------------------------------\n",
172-
" 969 0 0 0 1 1 3 1 3 2 | 0 = 0\n",
173-
" 0 1128 1 1 0 1 2 1 1 0 | 1 = 1\n",
174-
" 2 1 1014 2 3 0 1 3 6 0 | 2 = 2\n",
175-
" 1 0 4 992 0 2 0 2 3 6 | 3 = 3\n",
176-
" 1 0 2 0 964 0 3 3 0 9 | 4 = 4\n",
177-
" 2 0 0 7 1 872 4 1 3 2 | 5 = 5\n",
178-
" 4 2 1 1 2 5 942 0 1 0 | 6 = 6\n",
179-
" 0 6 7 2 0 0 0 1005 4 4 | 7 = 7\n",
180-
" 4 0 1 5 2 3 3 2 952 2 | 8 = 8\n",
181-
" 2 2 1 5 9 1 1 3 3 982 | 9 = 9\n",
202+
" 967 0 0 1 1 0 4 2 2 3 | 0 = 0\n",
203+
" 0 1123 2 1 0 0 5 1 3 0 | 1 = 1\n",
204+
" 4 3 995 0 2 0 4 14 10 0 | 2 = 2\n",
205+
" 0 1 2 988 0 1 0 10 6 2 | 3 = 3\n",
206+
" 3 0 0 0 956 0 6 4 0 13 | 4 = 4\n",
207+
" 7 1 0 19 2 825 20 1 11 6 | 5 = 5\n",
208+
" 6 3 0 0 4 1 943 1 0 0 | 6 = 6\n",
209+
" 0 8 5 2 0 0 0 1010 1 2 | 7 = 7\n",
210+
" 5 0 2 6 4 1 8 7 937 4 | 8 = 8\n",
211+
" 3 6 1 6 10 0 2 6 1 974 | 9 = 9\n",
182212
"\n",
183213
"Confusion matrix format: Actual (rowClass) predicted as (columnClass) N times\n",
184214
"==================================================================\n"
@@ -189,6 +219,22 @@
189219
"val eval: org.nd4j.evaluation.classification.Evaluation = model.evaluate(mnistTest)\n",
190220
"println(eval.stats())"
191221
]
222+
},
223+
{
224+
"cell_type": "markdown",
225+
"metadata": {},
226+
"source": [
227+
"To stop the UI:"
228+
]
229+
},
230+
{
231+
"cell_type": "code",
232+
"execution_count": 8,
233+
"metadata": {},
234+
"outputs": [],
235+
"source": [
236+
"uiServer.stop()"
237+
]
192238
}
193239
],
194240
"metadata": {
@@ -203,7 +249,7 @@
203249
"mimetype": "text/x-kotlin",
204250
"name": "kotlin",
205251
"pygments_lexer": "kotlin",
206-
"version": "1.3.70-eap-274"
252+
"version": "1.4.0-dev-7568"
207253
}
208254
},
209255
"nbformat": 4,

0 commit comments

Comments
 (0)