Skip to content

Commit 7278391

Browse files
authored
Merge pull request #322 from JohnSnowLabs/ms2508
notebook updated
2 parents 8771b5e + a6947d0 commit 7278391

File tree

1 file changed

+21
-123
lines changed

1 file changed

+21
-123
lines changed

tutorials/Certification_Trainings/Healthcare/17.Graph_builder_for_DL_models.ipynb

Lines changed: 21 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -77,32 +77,23 @@
7777
"!wget https://raw.githubusercontent.com/JohnSnowLabs/spark-nlp-workshop/master/jsl_colab_setup.sh\n",
7878
"!bash jsl_colab_setup.sh"
7979
],
80-
"execution_count": 2,
80+
"execution_count": null,
8181
"outputs": []
8282
},
8383
{
8484
"cell_type": "code",
8585
"metadata": {
86-
"id": "WEreWOOOtANE",
87-
"colab": {
88-
"base_uri": "https://localhost:8080/"
89-
},
90-
"outputId": "f6871f20-493b-45e2-cde5-a1706697ea81"
86+
"id": "WEreWOOOtANE"
9187
},
9288
"source": [
9389
"from sparknlp_jsl.training import tf_graph\n",
94-
"%tensorflow_version 1.x"
90+
"\n",
91+
"\n",
92+
"# before sparknlp_jsl 3.2.1 version run the code below\n",
93+
"# %tensorflow_version 1.x"
9594
],
96-
"execution_count": 3,
97-
"outputs": [
98-
{
99-
"output_type": "stream",
100-
"text": [
101-
"TensorFlow 1.x selected.\n"
102-
],
103-
"name": "stdout"
104-
}
105-
]
95+
"execution_count": null,
96+
"outputs": []
10697
},
10798
{
10899
"cell_type": "code",
@@ -116,7 +107,7 @@
116107
"source": [
117108
"tf_graph.get_models()\n"
118109
],
119-
"execution_count": 4,
110+
"execution_count": null,
120111
"outputs": [
121112
{
122113
"output_type": "execute_result",
@@ -153,7 +144,7 @@
153144
"source": [
154145
"tf_graph.print_model_params(\"ner_dl\")\n"
155146
],
156-
"execution_count": 5,
147+
"execution_count": null,
157148
"outputs": [
158149
{
159150
"output_type": "stream",
@@ -174,59 +165,13 @@
174165
{
175166
"cell_type": "code",
176167
"metadata": {
177-
"colab": {
178-
"base_uri": "https://localhost:8080/"
179-
},
180-
"id": "jPOjkADCt9U8",
181-
"outputId": "171bb6c3-be4b-485c-b77e-a47420de9089"
168+
"id": "jPOjkADCt9U8"
182169
},
183170
"source": [
184171
"tf_graph.build(\"ner_dl\",build_params={\"embeddings_dim\": 200, \"nchars\": 80, \"ntags\": 12, \"is_medical\": 1}, model_location=\"./medical_ner_graphs\", model_filename=\"auto\")"
185172
],
186-
"execution_count": 6,
187-
"outputs": [
188-
{
189-
"output_type": "stream",
190-
"text": [
191-
"WARNING:tensorflow:From /tensorflow-1.15.2/python3.7/tensorflow_core/python/compat/v2_compat.py:68: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.\n",
192-
"Instructions for updating:\n",
193-
"non-resource variables are not supported in the long term\n",
194-
"WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/sparknlp_jsl/_tf_graph_builders/ner_dl/ner_model.py:12: The name tf.disable_v2_behavior is deprecated. Please use tf.compat.v1.disable_v2_behavior instead.\n",
195-
"\n",
196-
"WARNING:tensorflow:From /tensorflow-1.15.2/python3.7/tensorflow_core/python/ops/resource_variable_ops.py:1630: calling BaseResourceVariable.__init__ (from tensorflow.python.ops.resource_variable_ops) with constraint is deprecated and will be removed in a future version.\n",
197-
"Instructions for updating:\n",
198-
"If using Keras pass *_constraint arguments to layers.\n",
199-
"WARNING:tensorflow:From /tensorflow-1.15.2/python3.7/tensorflow_core/python/ops/init_ops.py:97: calling GlorotUniform.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.\n",
200-
"Instructions for updating:\n",
201-
"Call initializer instance with the dtype argument instead of passing it to the constructor\n",
202-
"WARNING:tensorflow:From /tensorflow-1.15.2/python3.7/tensorflow_core/python/ops/init_ops.py:97: calling Orthogonal.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.\n",
203-
"Instructions for updating:\n",
204-
"Call initializer instance with the dtype argument instead of passing it to the constructor\n",
205-
"WARNING:tensorflow:From /tensorflow-1.15.2/python3.7/tensorflow_core/python/ops/init_ops.py:97: calling Zeros.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.\n",
206-
"Instructions for updating:\n",
207-
"Call initializer instance with the dtype argument instead of passing it to the constructor\n",
208-
"WARNING:tensorflow:From /tensorflow-1.15.2/python3.7/tensorflow_core/python/keras/backend.py:3994: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.\n",
209-
"Instructions for updating:\n",
210-
"Use tf.where in 2.0, which has the same broadcast rule as np.where\n",
211-
"WARNING:tensorflow:\n",
212-
"The TensorFlow contrib module will not be included in TensorFlow 2.0.\n",
213-
"For more information, please see:\n",
214-
" * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md\n",
215-
" * https://github.com/tensorflow/addons\n",
216-
" * https://github.com/tensorflow/io (for I/O related ops)\n",
217-
"If you depend on functionality not listed there, please file an issue.\n",
218-
"\n",
219-
"WARNING:tensorflow:From /tensorflow-1.15.2/python3.7/tensorflow_core/contrib/rnn/python/ops/lstm_ops.py:597: Layer.add_variable (from tensorflow.python.keras.engine.base_layer) is deprecated and will be removed in a future version.\n",
220-
"Instructions for updating:\n",
221-
"Please use `layer.add_weight` method instead.\n",
222-
"WARNING:tensorflow:From /tensorflow-1.15.2/python3.7/tensorflow_core/contrib/crf/python/ops/crf.py:213: dynamic_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version.\n",
223-
"Instructions for updating:\n",
224-
"Please use `keras.layers.RNN(cell)`, which is equivalent to this API\n",
225-
"ner_dl graph exported to ./medical_ner_graphs/blstm_12_200_128_80.pb\n"
226-
],
227-
"name": "stdout"
228-
}
229-
]
173+
"execution_count": null,
174+
"outputs": []
230175
},
231176
{
232177
"cell_type": "markdown",
@@ -249,7 +194,7 @@
249194
"source": [
250195
"tf_graph.print_model_params(\"assertion_dl\")\n"
251196
],
252-
"execution_count": 7,
197+
"execution_count": null,
253198
"outputs": [
254199
{
255200
"output_type": "stream",
@@ -269,60 +214,13 @@
269214
{
270215
"cell_type": "code",
271216
"metadata": {
272-
"colab": {
273-
"base_uri": "https://localhost:8080/"
274-
},
275-
"id": "FZ0aQhKnuxxC",
276-
"outputId": "4494586a-7963-4bf8-8122-28328c2110ac"
217+
"id": "FZ0aQhKnuxxC"
277218
},
278219
"source": [
279220
"tf_graph.build(\"assertion_dl\",build_params={\"n_classes\": 10}, model_location=\"/tmp\", model_filename=\"auto\")"
280221
],
281-
"execution_count": 8,
282-
"outputs": [
283-
{
284-
"output_type": "stream",
285-
"text": [
286-
"WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/sparknlp_jsl/_tf_graph_builders/assertion_dl/assertion_model.py:6: The name tf.reset_default_graph is deprecated. Please use tf.compat.v1.reset_default_graph instead.\n",
287-
"\n",
288-
"WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/sparknlp_jsl/_tf_graph_builders/assertion_dl/assertion_model.py:9: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.\n",
289-
"\n",
290-
"WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/sparknlp_jsl/_tf_graph_builders/assertion_dl/assertion_model.py:16: The name tf.placeholder_with_default is deprecated. Please use tf.compat.v1.placeholder_with_default instead.\n",
291-
"\n",
292-
"WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/sparknlp_jsl/_tf_graph_builders/assertion_dl/assertion_model.py:20: The name tf.GPUOptions is deprecated. Please use tf.compat.v1.GPUOptions instead.\n",
293-
"\n",
294-
"WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/sparknlp_jsl/_tf_graph_builders/assertion_dl/assertion_model.py:21: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.\n",
295-
"\n",
296-
"WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/sparknlp_jsl/_tf_graph_builders/assertion_dl/assertion_model.py:22: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.\n",
297-
"\n",
298-
"Device mapping:\n",
299-
"/job:localhost/replica:0/task:0/device:XLA_CPU:0 -> device: XLA_CPU device\n",
300-
"\n",
301-
"WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/sparknlp_jsl/_tf_graph_builders/assertion_dl/assertion_model.py:43: BasicLSTMCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n",
302-
"Instructions for updating:\n",
303-
"This class is equivalent as tf.keras.layers.LSTMCell, and will be replaced by that in Tensorflow 2.0.\n",
304-
"WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/sparknlp_jsl/_tf_graph_builders/assertion_dl/assertion_model.py:44: The name tf.nn.rnn_cell.DropoutWrapper is deprecated. Please use tf.compat.v1.nn.rnn_cell.DropoutWrapper instead.\n",
305-
"\n",
306-
"WARNING:tensorflow:From /tensorflow-1.15.2/python3.7/tensorflow_core/contrib/rnn/python/ops/rnn.py:239: bidirectional_dynamic_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version.\n",
307-
"Instructions for updating:\n",
308-
"Please use `keras.layers.Bidirectional(keras.layers.RNN(cell))`, which is equivalent to this API\n",
309-
"WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/sparknlp_jsl/_tf_graph_builders/assertion_dl/assertion_model.py:27: The name tf.random_normal is deprecated. Please use tf.random.normal instead.\n",
310-
"\n",
311-
"WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/sparknlp_jsl/_tf_graph_builders/assertion_dl/assertion_model.py:82: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.\n",
312-
"\n",
313-
"WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/sparknlp_jsl/_tf_graph_builders/assertion_dl/assertion_model.py:87: The name tf.train.AdamOptimizer is deprecated. Please use tf.compat.v1.train.AdamOptimizer instead.\n",
314-
"\n",
315-
"WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/sparknlp_jsl/_tf_graph_builders/assertion_dl/assertion_model.py:90: The name tf.global_variables_initializer is deprecated. Please use tf.compat.v1.global_variables_initializer instead.\n",
316-
"\n",
317-
"WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/sparknlp_jsl/_tf_graph_builders/assertion_dl/assertion_model.py:170: The name tf.train.Saver is deprecated. Please use tf.compat.v1.train.Saver instead.\n",
318-
"\n",
319-
"WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/sparknlp_jsl/_tf_graph_builders/assertion_dl/assertion_model.py:171: The name tf.train.write_graph is deprecated. Please use tf.io.write_graph instead.\n",
320-
"\n",
321-
"assertion_dl graph exported to /tmp/blstm_34_32_30_200_10.pb\n"
322-
],
323-
"name": "stdout"
324-
}
325-
]
222+
"execution_count": null,
223+
"outputs": []
326224
},
327225
{
328226
"cell_type": "markdown",
@@ -345,7 +243,7 @@
345243
"source": [
346244
"tf_graph.print_model_params(\"generic_classifier\")\n"
347245
],
348-
"execution_count": 9,
246+
"execution_count": null,
349247
"outputs": [
350248
{
351249
"output_type": "stream",
@@ -376,7 +274,7 @@
376274
"source": [
377275
"tf_graph.build(\"generic_classifier\",build_params={\"input_dim\": 100, \"output_dim\": 10, \"hidden_layers\": [300, 200, 100], \"hidden_act\": \"tanh\"}, model_location=\"/tmp\", model_filename=\"auto\")"
378276
],
379-
"execution_count": 10,
277+
"execution_count": null,
380278
"outputs": [
381279
{
382280
"output_type": "stream",
@@ -408,7 +306,7 @@
408306
"source": [
409307
"tf_graph.print_model_params(\"relation_extraction\")\n"
410308
],
411-
"execution_count": 11,
309+
"execution_count": null,
412310
"outputs": [
413311
{
414312
"output_type": "stream",
@@ -439,7 +337,7 @@
439337
"source": [
440338
"tf_graph.build(\"relation_extraction\",build_params={\"input_dim\": 6000, \"output_dim\": 3, 'batch_norm':1, \"hidden_layers\": [300, 200], \"hidden_act\": \"relu\", 'hidden_act_l2':1}, model_location=\".\", model_filename=\"re_with_BN\")"
441339
],
442-
"execution_count": 12,
340+
"execution_count": null,
443341
"outputs": [
444342
{
445343
"output_type": "stream",

0 commit comments

Comments
 (0)