Skip to content

Commit f0a9d59

Browse files
committed
Fix kernel
1 parent 0b55e8d commit f0a9d59

File tree

1 file changed

+79
-28
lines changed

1 file changed

+79
-28
lines changed

introduction_to_amazon_algorithms/seq2seq_translation_en-de/SageMaker-Seq2Seq-Translation-English-German.ipynb

Lines changed: 79 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"cell_type": "code",
4242
"execution_count": null,
4343
"metadata": {
44+
"collapsed": true,
4445
"isConfigCell": true
4546
},
4647
"outputs": [],
@@ -53,7 +54,9 @@
5354
{
5455
"cell_type": "code",
5556
"execution_count": null,
56-
"metadata": {},
57+
"metadata": {
58+
"collapsed": true
59+
},
5760
"outputs": [],
5861
"source": [
5962
"import boto3\n",
@@ -74,7 +77,9 @@
7477
{
7578
"cell_type": "code",
7679
"execution_count": null,
77-
"metadata": {},
80+
"metadata": {
81+
"collapsed": true
82+
},
7883
"outputs": [],
7984
"source": [
8085
"from time import gmtime, strftime\n",
@@ -107,7 +112,9 @@
107112
{
108113
"cell_type": "code",
109114
"execution_count": null,
110-
"metadata": {},
115+
"metadata": {
116+
"collapsed": true
117+
},
111118
"outputs": [],
112119
"source": [
113120
"%%bash\n",
@@ -154,7 +161,9 @@
154161
{
155162
"cell_type": "code",
156163
"execution_count": null,
157-
"metadata": {},
164+
"metadata": {
165+
"collapsed": true
166+
},
158167
"outputs": [],
159168
"source": [
160169
"%%time\n",
@@ -182,7 +191,9 @@
182191
{
183192
"cell_type": "code",
184193
"execution_count": null,
185-
"metadata": {},
194+
"metadata": {
195+
"collapsed": true
196+
},
186197
"outputs": [],
187198
"source": [
188199
"def upload_to_s3(bucket, prefix, channel, file):\n",
@@ -200,7 +211,9 @@
200211
{
201212
"cell_type": "code",
202213
"execution_count": null,
203-
"metadata": {},
214+
"metadata": {
215+
"collapsed": true
216+
},
204217
"outputs": [],
205218
"source": [
206219
"region_name = boto3.Session().region_name"
@@ -209,7 +222,9 @@
209222
{
210223
"cell_type": "code",
211224
"execution_count": null,
212-
"metadata": {},
225+
"metadata": {
226+
"collapsed": true
227+
},
213228
"outputs": [],
214229
"source": [
215230
"containers = {'us-west-2': '433757028032.dkr.ecr.us-west-2.amazonaws.com/seq2seq:latest',\n",
@@ -230,7 +245,9 @@
230245
{
231246
"cell_type": "code",
232247
"execution_count": null,
233-
"metadata": {},
248+
"metadata": {
249+
"collapsed": true
250+
},
234251
"outputs": [],
235252
"source": [
236253
"job_name = 'seq2seq-en-de-small-p2-16x-' + strftime(\"%Y-%m-%d-%H\", gmtime())\n",
@@ -314,7 +331,9 @@
314331
{
315332
"cell_type": "code",
316333
"execution_count": null,
317-
"metadata": {},
334+
"metadata": {
335+
"collapsed": true
336+
},
318337
"outputs": [],
319338
"source": [
320339
"status = sagemaker_client.describe_training_job(TrainingJobName=job_name)['TrainingJobStatus']\n",
@@ -355,7 +374,9 @@
355374
{
356375
"cell_type": "code",
357376
"execution_count": null,
358-
"metadata": {},
377+
"metadata": {
378+
"collapsed": true
379+
},
359380
"outputs": [],
360381
"source": [
361382
"# !curl https://s3-us-west-2.amazonaws.com/gsaur-seq2seq-data/seq2seq/eng-german/full-nb-translation-eng-german-p2-16x-2017-11-24-22-25-53/output/model.tar.gz > model.tar.gz\n",
@@ -369,7 +390,9 @@
369390
{
370391
"cell_type": "code",
371392
"execution_count": null,
372-
"metadata": {},
393+
"metadata": {
394+
"collapsed": true
395+
},
373396
"outputs": [],
374397
"source": [
375398
"%%time\n",
@@ -415,7 +438,9 @@
415438
{
416439
"cell_type": "code",
417440
"execution_count": null,
418-
"metadata": {},
441+
"metadata": {
442+
"collapsed": true
443+
},
419444
"outputs": [],
420445
"source": [
421446
"from time import gmtime, strftime\n",
@@ -444,7 +469,9 @@
444469
{
445470
"cell_type": "code",
446471
"execution_count": null,
447-
"metadata": {},
472+
"metadata": {
473+
"collapsed": true
474+
},
448475
"outputs": [],
449476
"source": [
450477
"%%time\n",
@@ -488,7 +515,9 @@
488515
{
489516
"cell_type": "code",
490517
"execution_count": null,
491-
"metadata": {},
518+
"metadata": {
519+
"collapsed": true
520+
},
492521
"outputs": [],
493522
"source": [
494523
"runtime = boto3.client(service_name='sagemaker-runtime') "
@@ -518,7 +547,9 @@
518547
{
519548
"cell_type": "code",
520549
"execution_count": null,
521-
"metadata": {},
550+
"metadata": {
551+
"collapsed": true
552+
},
522553
"outputs": [],
523554
"source": [
524555
"sentences = [\"you are so good !\",\n",
@@ -555,7 +586,9 @@
555586
{
556587
"cell_type": "code",
557588
"execution_count": null,
558-
"metadata": {},
589+
"metadata": {
590+
"collapsed": true
591+
},
559592
"outputs": [],
560593
"source": [
561594
"sentence = 'can you drive a car ?'\n",
@@ -583,7 +616,9 @@
583616
{
584617
"cell_type": "code",
585618
"execution_count": null,
586-
"metadata": {},
619+
"metadata": {
620+
"collapsed": true
621+
},
587622
"outputs": [],
588623
"source": [
589624
"# Define a function for plotting the attentioan matrix\n",
@@ -604,7 +639,9 @@
604639
{
605640
"cell_type": "code",
606641
"execution_count": null,
607-
"metadata": {},
642+
"metadata": {
643+
"collapsed": true
644+
},
608645
"outputs": [],
609646
"source": [
610647
"plot_matrix(attention_matrix, target, source)"
@@ -629,7 +666,9 @@
629666
{
630667
"cell_type": "code",
631668
"execution_count": null,
632-
"metadata": {},
669+
"metadata": {
670+
"collapsed": true
671+
},
633672
"outputs": [],
634673
"source": [
635674
"import io\n",
@@ -647,7 +686,9 @@
647686
{
648687
"cell_type": "code",
649688
"execution_count": null,
650-
"metadata": {},
689+
"metadata": {
690+
"collapsed": true
691+
},
651692
"outputs": [],
652693
"source": [
653694
"sentences = [\"this is so cool\",\n",
@@ -666,7 +707,9 @@
666707
{
667708
"cell_type": "code",
668709
"execution_count": null,
669-
"metadata": {},
710+
"metadata": {
711+
"collapsed": true
712+
},
670713
"outputs": [],
671714
"source": [
672715
"# Convert strings to integers using source vocab mapping. Out-of-vocabulary strings are mapped to 1 - the mapping for <unk>\n",
@@ -680,7 +723,9 @@
680723
{
681724
"cell_type": "code",
682725
"execution_count": null,
683-
"metadata": {},
726+
"metadata": {
727+
"collapsed": true
728+
},
684729
"outputs": [],
685730
"source": [
686731
"response = runtime.invoke_endpoint(EndpointName=endpoint_name, \n",
@@ -700,7 +745,9 @@
700745
{
701746
"cell_type": "code",
702747
"execution_count": null,
703-
"metadata": {},
748+
"metadata": {
749+
"collapsed": true
750+
},
704751
"outputs": [],
705752
"source": [
706753
"def _parse_proto_response(received_bytes):\n",
@@ -725,7 +772,9 @@
725772
{
726773
"cell_type": "code",
727774
"execution_count": null,
728-
"metadata": {},
775+
"metadata": {
776+
"collapsed": true
777+
},
729778
"outputs": [],
730779
"source": [
731780
"targets = _parse_proto_response(response)\n",
@@ -746,7 +795,9 @@
746795
{
747796
"cell_type": "code",
748797
"execution_count": null,
749-
"metadata": {},
798+
"metadata": {
799+
"collapsed": true
800+
},
750801
"outputs": [],
751802
"source": [
752803
"# sage.delete_endpoint(EndpointName=endpoint_name)"
@@ -755,9 +806,9 @@
755806
],
756807
"metadata": {
757808
"kernelspec": {
758-
"display_name": "Python 3",
809+
"display_name": "conda_python3",
759810
"language": "python",
760-
"name": "python3"
811+
"name": "conda_python3"
761812
},
762813
"language_info": {
763814
"codemirror_mode": {
@@ -769,7 +820,7 @@
769820
"name": "python",
770821
"nbconvert_exporter": "python",
771822
"pygments_lexer": "ipython3",
772-
"version": "3.6.3"
823+
"version": "3.6.2"
773824
},
774825
"notice": "Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with the License. A copy of the License is located at http://aws.amazon.com/apache2.0/ or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License."
775826
},

0 commit comments

Comments
 (0)