pcuenq HF Staff commited on
Commit
a8bee82
·
1 Parent(s): 086f6c2

Latest version of notebook

Browse files
Files changed (1) hide show
  1. flexible_inputs_only.ipynb +37 -29
flexible_inputs_only.ipynb CHANGED
@@ -25,7 +25,7 @@
25
  },
26
  {
27
  "cell_type": "markdown",
28
- "id": "2b53abab",
29
  "metadata": {},
30
  "source": [
31
  "Checking whether setting flexible inputs is enough for model conversion to work, see https://github.com/apple/coremltools/issues/1806"
@@ -228,7 +228,7 @@
228
  },
229
  {
230
  "cell_type": "markdown",
231
- "id": "e6b2d0ef",
232
  "metadata": {},
233
  "source": [
234
  "Input shapes are already flexible. Let's check if outputs work fine after conversion."
@@ -341,7 +341,7 @@
341
  {
342
  "cell_type": "code",
343
  "execution_count": 21,
344
- "id": "42284296",
345
  "metadata": {},
346
  "outputs": [],
347
  "source": [
@@ -354,7 +354,7 @@
354
  {
355
  "cell_type": "code",
356
  "execution_count": 23,
357
- "id": "cf38a414",
358
  "metadata": {},
359
  "outputs": [],
360
  "source": [
@@ -364,7 +364,7 @@
364
  {
365
  "cell_type": "code",
366
  "execution_count": 24,
367
- "id": "6557878c",
368
  "metadata": {},
369
  "outputs": [
370
  {
@@ -384,15 +384,15 @@
384
  },
385
  {
386
  "cell_type": "markdown",
387
- "id": "3b1949cf",
388
  "metadata": {},
389
  "source": [
390
- "Works fine. Let's know test conversion without flexible inputs."
391
  ]
392
  },
393
  {
394
  "cell_type": "markdown",
395
- "id": "1c3f7b7d",
396
  "metadata": {},
397
  "source": [
398
  "### Conversion with fixed shapes"
@@ -401,7 +401,7 @@
401
  {
402
  "cell_type": "code",
403
  "execution_count": 25,
404
- "id": "e89c02c9",
405
  "metadata": {},
406
  "outputs": [],
407
  "source": [
@@ -411,7 +411,7 @@
411
  {
412
  "cell_type": "code",
413
  "execution_count": 26,
414
- "id": "4770599b",
415
  "metadata": {},
416
  "outputs": [
417
  {
@@ -443,7 +443,7 @@
443
  {
444
  "cell_type": "code",
445
  "execution_count": 27,
446
- "id": "9f979b44",
447
  "metadata": {},
448
  "outputs": [],
449
  "source": [
@@ -453,7 +453,7 @@
453
  {
454
  "cell_type": "code",
455
  "execution_count": 28,
456
- "id": "ba178554",
457
  "metadata": {},
458
  "outputs": [
459
  {
@@ -479,7 +479,7 @@
479
  {
480
  "cell_type": "code",
481
  "execution_count": 30,
482
- "id": "b3c1a2f0",
483
  "metadata": {},
484
  "outputs": [
485
  {
@@ -501,15 +501,15 @@
501
  },
502
  {
503
  "cell_type": "markdown",
504
- "id": "733c6e2a",
505
  "metadata": {},
506
  "source": [
507
- "Ok, it fails. Let's do conversion to neural network instead and see if it behaves the same."
508
  ]
509
  },
510
  {
511
  "cell_type": "markdown",
512
- "id": "2186fdc1",
513
  "metadata": {},
514
  "source": [
515
  "### Neural Network Conversion"
@@ -517,7 +517,7 @@
517
  },
518
  {
519
  "cell_type": "markdown",
520
- "id": "a40d4319",
521
  "metadata": {},
522
  "source": [
523
  "Using flexible shapes. In order to convert to neural network we have to decrease the deployment target to `macOS11` (from `macOS13`)."
@@ -526,7 +526,7 @@
526
  {
527
  "cell_type": "code",
528
  "execution_count": 31,
529
- "id": "a52ff3ac",
530
  "metadata": {},
531
  "outputs": [],
532
  "source": [
@@ -536,7 +536,7 @@
536
  {
537
  "cell_type": "code",
538
  "execution_count": 35,
539
- "id": "be5e7785",
540
  "metadata": {},
541
  "outputs": [
542
  {
@@ -568,7 +568,7 @@
568
  {
569
  "cell_type": "code",
570
  "execution_count": 36,
571
- "id": "3bfb5dd6",
572
  "metadata": {},
573
  "outputs": [],
574
  "source": [
@@ -578,7 +578,7 @@
578
  {
579
  "cell_type": "code",
580
  "execution_count": 37,
581
- "id": "8c14beef",
582
  "metadata": {},
583
  "outputs": [],
584
  "source": [
@@ -588,7 +588,7 @@
588
  {
589
  "cell_type": "code",
590
  "execution_count": 38,
591
- "id": "c52eeacb",
592
  "metadata": {},
593
  "outputs": [
594
  {
@@ -606,7 +606,7 @@
606
  },
607
  {
608
  "cell_type": "markdown",
609
- "id": "d3613014",
610
  "metadata": {},
611
  "source": [
612
  "Seems to work."
@@ -614,7 +614,7 @@
614
  },
615
  {
616
  "cell_type": "markdown",
617
- "id": "375e6eab",
618
  "metadata": {},
619
  "source": [
620
  "### Metadata"
@@ -622,7 +622,7 @@
622
  },
623
  {
624
  "cell_type": "markdown",
625
- "id": "f836c96a",
626
  "metadata": {},
627
  "source": [
628
  "What does the converted model look like in Netron or Xcode? Let's export to ML Program."
@@ -631,7 +631,7 @@
631
  {
632
  "cell_type": "code",
633
  "execution_count": 39,
634
- "id": "9ea2c28a",
635
  "metadata": {},
636
  "outputs": [
637
  {
@@ -663,7 +663,7 @@
663
  {
664
  "cell_type": "code",
665
  "execution_count": 43,
666
- "id": "96bcc86b",
667
  "metadata": {},
668
  "outputs": [],
669
  "source": [
@@ -672,7 +672,15 @@
672
  },
673
  {
674
  "cell_type": "markdown",
675
- "id": "489b28d2",
 
 
 
 
 
 
 
 
676
  "metadata": {},
677
  "source": [
678
  "![Xcode inputs](xcode-bert-test.png)"
@@ -681,7 +689,7 @@
681
  {
682
  "cell_type": "code",
683
  "execution_count": null,
684
- "id": "67a972a4",
685
  "metadata": {},
686
  "outputs": [],
687
  "source": []
 
25
  },
26
  {
27
  "cell_type": "markdown",
28
+ "id": "dd7d796e",
29
  "metadata": {},
30
  "source": [
31
  "Checking whether setting flexible inputs is enough for model conversion to work, see https://github.com/apple/coremltools/issues/1806"
 
228
  },
229
  {
230
  "cell_type": "markdown",
231
+ "id": "ee65ec32",
232
  "metadata": {},
233
  "source": [
234
  "Input shapes are already flexible. Let's check if outputs work fine after conversion."
 
341
  {
342
  "cell_type": "code",
343
  "execution_count": 21,
344
+ "id": "206c41b0",
345
  "metadata": {},
346
  "outputs": [],
347
  "source": [
 
354
  {
355
  "cell_type": "code",
356
  "execution_count": 23,
357
+ "id": "c14ffa7c",
358
  "metadata": {},
359
  "outputs": [],
360
  "source": [
 
364
  {
365
  "cell_type": "code",
366
  "execution_count": 24,
367
+ "id": "81fe194d",
368
  "metadata": {},
369
  "outputs": [
370
  {
 
384
  },
385
  {
386
  "cell_type": "markdown",
387
+ "id": "8a8b2010",
388
  "metadata": {},
389
  "source": [
390
+ "Works fine. Let's now test conversion without flexible inputs."
391
  ]
392
  },
393
  {
394
  "cell_type": "markdown",
395
+ "id": "6b768a11",
396
  "metadata": {},
397
  "source": [
398
  "### Conversion with fixed shapes"
 
401
  {
402
  "cell_type": "code",
403
  "execution_count": 25,
404
+ "id": "8f1d57f9",
405
  "metadata": {},
406
  "outputs": [],
407
  "source": [
 
411
  {
412
  "cell_type": "code",
413
  "execution_count": 26,
414
+ "id": "6b7f06f3",
415
  "metadata": {},
416
  "outputs": [
417
  {
 
443
  {
444
  "cell_type": "code",
445
  "execution_count": 27,
446
+ "id": "4c8f40bc",
447
  "metadata": {},
448
  "outputs": [],
449
  "source": [
 
453
  {
454
  "cell_type": "code",
455
  "execution_count": 28,
456
+ "id": "192df561",
457
  "metadata": {},
458
  "outputs": [
459
  {
 
479
  {
480
  "cell_type": "code",
481
  "execution_count": 30,
482
+ "id": "51e48285",
483
  "metadata": {},
484
  "outputs": [
485
  {
 
501
  },
502
  {
503
  "cell_type": "markdown",
504
+ "id": "00602d06",
505
  "metadata": {},
506
  "source": [
507
+ "Ok, it fails as expected. Let's convert to neural network instead and see if it behaves the same."
508
  ]
509
  },
510
  {
511
  "cell_type": "markdown",
512
+ "id": "61997b06",
513
  "metadata": {},
514
  "source": [
515
  "### Neural Network Conversion"
 
517
  },
518
  {
519
  "cell_type": "markdown",
520
+ "id": "4d5ed549",
521
  "metadata": {},
522
  "source": [
523
  "Using flexible shapes. In order to convert to neural network we have to decrease the deployment target to `macOS11` (from `macOS13`)."
 
526
  {
527
  "cell_type": "code",
528
  "execution_count": 31,
529
+ "id": "5c7e9249",
530
  "metadata": {},
531
  "outputs": [],
532
  "source": [
 
536
  {
537
  "cell_type": "code",
538
  "execution_count": 35,
539
+ "id": "4a611197",
540
  "metadata": {},
541
  "outputs": [
542
  {
 
568
  {
569
  "cell_type": "code",
570
  "execution_count": 36,
571
+ "id": "ec7d7d6c",
572
  "metadata": {},
573
  "outputs": [],
574
  "source": [
 
578
  {
579
  "cell_type": "code",
580
  "execution_count": 37,
581
+ "id": "df16844f",
582
  "metadata": {},
583
  "outputs": [],
584
  "source": [
 
588
  {
589
  "cell_type": "code",
590
  "execution_count": 38,
591
+ "id": "83dd359c",
592
  "metadata": {},
593
  "outputs": [
594
  {
 
606
  },
607
  {
608
  "cell_type": "markdown",
609
+ "id": "f6661539",
610
  "metadata": {},
611
  "source": [
612
  "Seems to work."
 
614
  },
615
  {
616
  "cell_type": "markdown",
617
+ "id": "0bbe7691",
618
  "metadata": {},
619
  "source": [
620
  "### Metadata"
 
622
  },
623
  {
624
  "cell_type": "markdown",
625
+ "id": "41953964",
626
  "metadata": {},
627
  "source": [
628
  "What does the converted model look like in Netron or Xcode? Let's export to ML Program."
 
631
  {
632
  "cell_type": "code",
633
  "execution_count": 39,
634
+ "id": "123ff055",
635
  "metadata": {},
636
  "outputs": [
637
  {
 
663
  {
664
  "cell_type": "code",
665
  "execution_count": 43,
666
+ "id": "4486fd5d",
667
  "metadata": {},
668
  "outputs": [],
669
  "source": [
 
672
  },
673
  {
674
  "cell_type": "markdown",
675
+ "id": "4246b382",
676
+ "metadata": {},
677
+ "source": [
678
+ "`xcode-bert-test.png`:"
679
+ ]
680
+ },
681
+ {
682
+ "cell_type": "markdown",
683
+ "id": "0678e157",
684
  "metadata": {},
685
  "source": [
686
  "![Xcode inputs](xcode-bert-test.png)"
 
689
  {
690
  "cell_type": "code",
691
  "execution_count": null,
692
+ "id": "e8329bba",
693
  "metadata": {},
694
  "outputs": [],
695
  "source": []