|
77 | 77 | "!wget https://raw.githubusercontent.com/JohnSnowLabs/spark-nlp-workshop/master/jsl_colab_setup.sh\n",
|
78 | 78 | "!bash jsl_colab_setup.sh"
|
79 | 79 | ],
|
80 |
| - "execution_count": 2, |
| 80 | + "execution_count": null, |
81 | 81 | "outputs": []
|
82 | 82 | },
|
83 | 83 | {
|
84 | 84 | "cell_type": "code",
|
85 | 85 | "metadata": {
|
86 |
| - "id": "WEreWOOOtANE", |
87 |
| - "colab": { |
88 |
| - "base_uri": "https://localhost:8080/" |
89 |
| - }, |
90 |
| - "outputId": "f6871f20-493b-45e2-cde5-a1706697ea81" |
| 86 | + "id": "WEreWOOOtANE" |
91 | 87 | },
|
92 | 88 | "source": [
|
93 | 89 | "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" |
95 | 94 | ],
|
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": [] |
106 | 97 | },
|
107 | 98 | {
|
108 | 99 | "cell_type": "code",
|
|
116 | 107 | "source": [
|
117 | 108 | "tf_graph.get_models()\n"
|
118 | 109 | ],
|
119 |
| - "execution_count": 4, |
| 110 | + "execution_count": null, |
120 | 111 | "outputs": [
|
121 | 112 | {
|
122 | 113 | "output_type": "execute_result",
|
|
153 | 144 | "source": [
|
154 | 145 | "tf_graph.print_model_params(\"ner_dl\")\n"
|
155 | 146 | ],
|
156 |
| - "execution_count": 5, |
| 147 | + "execution_count": null, |
157 | 148 | "outputs": [
|
158 | 149 | {
|
159 | 150 | "output_type": "stream",
|
|
174 | 165 | {
|
175 | 166 | "cell_type": "code",
|
176 | 167 | "metadata": {
|
177 |
| - "colab": { |
178 |
| - "base_uri": "https://localhost:8080/" |
179 |
| - }, |
180 |
| - "id": "jPOjkADCt9U8", |
181 |
| - "outputId": "171bb6c3-be4b-485c-b77e-a47420de9089" |
| 168 | + "id": "jPOjkADCt9U8" |
182 | 169 | },
|
183 | 170 | "source": [
|
184 | 171 | "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\")"
|
185 | 172 | ],
|
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": [] |
230 | 175 | },
|
231 | 176 | {
|
232 | 177 | "cell_type": "markdown",
|
|
249 | 194 | "source": [
|
250 | 195 | "tf_graph.print_model_params(\"assertion_dl\")\n"
|
251 | 196 | ],
|
252 |
| - "execution_count": 7, |
| 197 | + "execution_count": null, |
253 | 198 | "outputs": [
|
254 | 199 | {
|
255 | 200 | "output_type": "stream",
|
|
269 | 214 | {
|
270 | 215 | "cell_type": "code",
|
271 | 216 | "metadata": {
|
272 |
| - "colab": { |
273 |
| - "base_uri": "https://localhost:8080/" |
274 |
| - }, |
275 |
| - "id": "FZ0aQhKnuxxC", |
276 |
| - "outputId": "4494586a-7963-4bf8-8122-28328c2110ac" |
| 217 | + "id": "FZ0aQhKnuxxC" |
277 | 218 | },
|
278 | 219 | "source": [
|
279 | 220 | "tf_graph.build(\"assertion_dl\",build_params={\"n_classes\": 10}, model_location=\"/tmp\", model_filename=\"auto\")"
|
280 | 221 | ],
|
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": [] |
326 | 224 | },
|
327 | 225 | {
|
328 | 226 | "cell_type": "markdown",
|
|
345 | 243 | "source": [
|
346 | 244 | "tf_graph.print_model_params(\"generic_classifier\")\n"
|
347 | 245 | ],
|
348 |
| - "execution_count": 9, |
| 246 | + "execution_count": null, |
349 | 247 | "outputs": [
|
350 | 248 | {
|
351 | 249 | "output_type": "stream",
|
|
376 | 274 | "source": [
|
377 | 275 | "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\")"
|
378 | 276 | ],
|
379 |
| - "execution_count": 10, |
| 277 | + "execution_count": null, |
380 | 278 | "outputs": [
|
381 | 279 | {
|
382 | 280 | "output_type": "stream",
|
|
408 | 306 | "source": [
|
409 | 307 | "tf_graph.print_model_params(\"relation_extraction\")\n"
|
410 | 308 | ],
|
411 |
| - "execution_count": 11, |
| 309 | + "execution_count": null, |
412 | 310 | "outputs": [
|
413 | 311 | {
|
414 | 312 | "output_type": "stream",
|
|
439 | 337 | "source": [
|
440 | 338 | "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\")"
|
441 | 339 | ],
|
442 |
| - "execution_count": 12, |
| 340 | + "execution_count": null, |
443 | 341 | "outputs": [
|
444 | 342 | {
|
445 | 343 | "output_type": "stream",
|
|
0 commit comments