|
430 | 430 | },
|
431 | 431 | {
|
432 | 432 | "cell_type": "code",
|
433 |
| - "execution_count": 7, |
| 433 | + "execution_count": null, |
434 | 434 | "metadata": {},
|
435 | 435 | "outputs": [
|
436 | 436 | {
|
|
488 | 488 | },
|
489 | 489 | {
|
490 | 490 | "cell_type": "code",
|
491 |
| - "execution_count": 8, |
| 491 | + "execution_count": null, |
492 | 492 | "metadata": {},
|
493 | 493 | "outputs": [
|
494 | 494 | {
|
|
502 | 502 | "(?, 1500)\n",
|
503 | 503 | "(?, 600)\n",
|
504 | 504 | "71600\n",
|
505 |
| - "INFO:tensorflow:Restoring parameters from snnmodel_chars/model71600.ckpt\n", |
506 |
| - "Final accurary on test dataset : 0.582\n", |
507 |
| - "Confusion matrix\n", |
508 |
| - "[[ 170. 32. 32. 11. 34.]\n", |
509 |
| - " [ 30. 108. 30. 24. 35.]\n", |
510 |
| - " [ 57. 44. 214. 24. 50.]\n", |
511 |
| - " [ 17. 32. 16. 175. 24.]\n", |
512 |
| - " [ 28. 34. 42. 28. 201.]]\n", |
513 |
| - "Precision\n", |
514 |
| - "[ 0.609319 0.47577093 0.55012853 0.66287879 0.6036036 ]\n", |
515 |
| - "Recall\n", |
516 |
| - "[ 0.56291391 0.432 0.64071856 0.66793893 0.58430233]\n", |
517 |
| - "\n", |
518 |
| - "\n", |
519 |
| - "<Performance evaluation on Test dataset>\n", |
520 |
| - "Accurary : 0.582\n", |
521 |
| - "Precision : 0.580\n", |
522 |
| - "Recall : 0.578\n" |
| 505 | + "INFO:tensorflow:Restoring parameters from snnmodel_chars/model71600.ckpt\n" |
523 | 506 | ]
|
524 | 507 | }
|
525 | 508 | ],
|
|
581 | 564 | },
|
582 | 565 | {
|
583 | 566 | "cell_type": "code",
|
584 |
| - "execution_count": 9, |
| 567 | + "execution_count": null, |
585 | 568 | "metadata": {},
|
586 |
| - "outputs": [ |
587 |
| - { |
588 |
| - "name": "stdout", |
589 |
| - "output_type": "stream", |
590 |
| - "text": [ |
591 |
| - "(13825, 50320) (1524, 50320) (1492, 50320)\n", |
592 |
| - "((13825, 50320), (1524, 50320), (5, 50320), (1492, 50320))\n" |
593 |
| - ] |
594 |
| - } |
595 |
| - ], |
| 569 | + "outputs": [], |
596 | 570 | "source": [
|
597 | 571 | "import siamese_model_phone_hu as siamese_model\n",
|
598 | 572 | "\n",
|
|
640 | 614 | },
|
641 | 615 | {
|
642 | 616 | "cell_type": "code",
|
643 |
| - "execution_count": 10, |
| 617 | + "execution_count": null, |
644 | 618 | "metadata": {},
|
645 |
| - "outputs": [ |
646 |
| - { |
647 |
| - "name": "stdout", |
648 |
| - "output_type": "stream", |
649 |
| - "text": [ |
650 |
| - "(?, 91520)\n", |
651 |
| - "(?, 1500)\n", |
652 |
| - "(?, 600)\n", |
653 |
| - "(?, 91520)\n", |
654 |
| - "(?, 1500)\n", |
655 |
| - "(?, 600)\n", |
656 |
| - "60400\n", |
657 |
| - "INFO:tensorflow:Restoring parameters from snnmodel_phone_hu_backup/model60400.ckpt\n", |
658 |
| - "Final accurary on test dataset : 0.548\n", |
659 |
| - "Confusion matrix\n", |
660 |
| - "[[ 170. 34. 73. 19. 50.]\n", |
661 |
| - " [ 25. 132. 62. 21. 27.]\n", |
662 |
| - " [ 46. 55. 137. 19. 51.]\n", |
663 |
| - " [ 17. 11. 15. 187. 25.]\n", |
664 |
| - " [ 44. 18. 47. 16. 191.]]\n", |
665 |
| - "Precision\n", |
666 |
| - "[ 0.49132948 0.49438202 0.44480519 0.73333333 0.60443038]\n", |
667 |
| - "Recall\n", |
668 |
| - "[ 0.56291391 0.528 0.41017964 0.71374046 0.55523256]\n", |
669 |
| - "\n", |
670 |
| - "\n", |
671 |
| - "<Performance evaluation on Test dataset>\n", |
672 |
| - "Accurary : 0.548\n", |
673 |
| - "Precision : 0.554\n", |
674 |
| - "Recall : 0.554\n" |
675 |
| - ] |
676 |
| - } |
677 |
| - ], |
| 619 | + "outputs": [], |
678 | 620 | "source": [
|
679 | 621 | "# init variables\n",
|
680 | 622 | "sess = tf.InteractiveSession()\n",
|
|
733 | 675 | },
|
734 | 676 | {
|
735 | 677 | "cell_type": "code",
|
736 |
| - "execution_count": 11, |
| 678 | + "execution_count": null, |
737 | 679 | "metadata": {},
|
738 |
| - "outputs": [ |
739 |
| - { |
740 |
| - "name": "stdout", |
741 |
| - "output_type": "stream", |
742 |
| - "text": [ |
743 |
| - "\n", |
744 |
| - "\n", |
745 |
| - "<Performance evaluation on Test dataset>\n", |
746 |
| - "Accurary : 0.755\n", |
747 |
| - "Precision : 0.554\n", |
748 |
| - "Recall : 0.554\n" |
749 |
| - ] |
750 |
| - } |
751 |
| - ], |
| 680 | + "outputs": [], |
752 | 681 | "source": [
|
753 | 682 | "# Fusion 1 : ivector + chars\n",
|
754 | 683 | "\n",
|
755 | 684 | "tst_scores = tst_scores_ivectors + tst_scores_chars\n",
|
756 | 685 | "hypo_lang = np.argmax(tst_scores,axis = 0)\n",
|
757 | 686 | "temp = ((tst_labels-1) - hypo_lang)\n",
|
758 | 687 | "acc =1- np.size(np.nonzero(temp)) / float(np.size(tst_labels))\n",
|
| 688 | + "confusionmat = np.zeros((5,5))\n", |
| 689 | + "for i,lang in enumerate(languages):\n", |
| 690 | + " hypo_bylang = hypo_lang[ tst_labels == i+1]\n", |
| 691 | + " hist_bylang = np.histogram(hypo_bylang,5)\n", |
| 692 | + " confusionmat[:,i] = hist_bylang[0]\n", |
| 693 | + "\n", |
| 694 | + "precision = np.diag(confusionmat) / np.sum(confusionmat,axis=1) #precision\n", |
| 695 | + "recall = np.diag(confusionmat) / np.sum(confusionmat,axis=0) # recall\n", |
759 | 696 | "\n",
|
760 | 697 | "print '\\n\\n<Performance evaluation on Test dataset>'\n",
|
761 | 698 | "print 'Accurary : %0.3f' %(acc)\n",
|
|
765 | 702 | },
|
766 | 703 | {
|
767 | 704 | "cell_type": "code",
|
768 |
| - "execution_count": 12, |
| 705 | + "execution_count": null, |
769 | 706 | "metadata": {},
|
770 |
| - "outputs": [ |
771 |
| - { |
772 |
| - "name": "stdout", |
773 |
| - "output_type": "stream", |
774 |
| - "text": [ |
775 |
| - "\n", |
776 |
| - "\n", |
777 |
| - "<Performance evaluation on Test dataset>\n", |
778 |
| - "Accurary : 0.751\n", |
779 |
| - "Precision : 0.554\n", |
780 |
| - "Recall : 0.554\n" |
781 |
| - ] |
782 |
| - } |
783 |
| - ], |
| 707 | + "outputs": [], |
784 | 708 | "source": [
|
785 | 709 | "# Fusion 2 : ivector + words\n",
|
786 | 710 | "\n",
|
787 | 711 | "tst_scores = tst_scores_ivectors + tst_scores_words\n",
|
788 | 712 | "hypo_lang = np.argmax(tst_scores,axis = 0)\n",
|
789 | 713 | "temp = ((tst_labels-1) - hypo_lang)\n",
|
790 | 714 | "acc =1- np.size(np.nonzero(temp)) / float(np.size(tst_labels))\n",
|
| 715 | + "confusionmat = np.zeros((5,5))\n", |
| 716 | + "for i,lang in enumerate(languages):\n", |
| 717 | + " hypo_bylang = hypo_lang[ tst_labels == i+1]\n", |
| 718 | + " hist_bylang = np.histogram(hypo_bylang,5)\n", |
| 719 | + " confusionmat[:,i] = hist_bylang[0]\n", |
| 720 | + "\n", |
| 721 | + "precision = np.diag(confusionmat) / np.sum(confusionmat,axis=1) #precision\n", |
| 722 | + "recall = np.diag(confusionmat) / np.sum(confusionmat,axis=0) # recall\n", |
791 | 723 | "\n",
|
792 | 724 | "print '\\n\\n<Performance evaluation on Test dataset>'\n",
|
793 | 725 | "print 'Accurary : %0.3f' %(acc)\n",
|
|
797 | 729 | },
|
798 | 730 | {
|
799 | 731 | "cell_type": "code",
|
800 |
| - "execution_count": 13, |
| 732 | + "execution_count": null, |
801 | 733 | "metadata": {},
|
802 |
| - "outputs": [ |
803 |
| - { |
804 |
| - "name": "stdout", |
805 |
| - "output_type": "stream", |
806 |
| - "text": [ |
807 |
| - "\n", |
808 |
| - "\n", |
809 |
| - "<Performance evaluation on Test dataset>\n", |
810 |
| - "Accurary : 0.716\n", |
811 |
| - "Precision : 0.554\n", |
812 |
| - "Recall : 0.554\n" |
813 |
| - ] |
814 |
| - } |
815 |
| - ], |
| 734 | + "outputs": [], |
816 | 735 | "source": [
|
817 | 736 | "# Fusion 3 : ivector + phone_hu\n",
|
818 | 737 | "\n",
|
819 | 738 | "tst_scores = tst_scores_ivectors + tst_scores_phone_hu\n",
|
820 | 739 | "hypo_lang = np.argmax(tst_scores,axis = 0)\n",
|
821 | 740 | "temp = ((tst_labels-1) - hypo_lang)\n",
|
822 | 741 | "acc =1- np.size(np.nonzero(temp)) / float(np.size(tst_labels))\n",
|
| 742 | + "confusionmat = np.zeros((5,5))\n", |
| 743 | + "for i,lang in enumerate(languages):\n", |
| 744 | + " hypo_bylang = hypo_lang[ tst_labels == i+1]\n", |
| 745 | + " hist_bylang = np.histogram(hypo_bylang,5)\n", |
| 746 | + " confusionmat[:,i] = hist_bylang[0]\n", |
| 747 | + "\n", |
| 748 | + "precision = np.diag(confusionmat) / np.sum(confusionmat,axis=1) #precision\n", |
| 749 | + "recall = np.diag(confusionmat) / np.sum(confusionmat,axis=0) # recall\n", |
823 | 750 | "\n",
|
824 | 751 | "print '\\n\\n<Performance evaluation on Test dataset>'\n",
|
825 | 752 | "print 'Accurary : %0.3f' %(acc)\n",
|
|
829 | 756 | },
|
830 | 757 | {
|
831 | 758 | "cell_type": "code",
|
832 |
| - "execution_count": 14, |
| 759 | + "execution_count": null, |
833 | 760 | "metadata": {},
|
834 |
| - "outputs": [ |
835 |
| - { |
836 |
| - "name": "stdout", |
837 |
| - "output_type": "stream", |
838 |
| - "text": [ |
839 |
| - "\n", |
840 |
| - "\n", |
841 |
| - "<Performance evaluation on Test dataset>\n", |
842 |
| - "Accurary : 0.752\n", |
843 |
| - "Precision : 0.554\n", |
844 |
| - "Recall : 0.554\n" |
845 |
| - ] |
846 |
| - } |
847 |
| - ], |
| 761 | + "outputs": [], |
848 | 762 | "source": [
|
849 | 763 | "# Fusion 4 : All\n",
|
850 | 764 | "\n",
|
851 | 765 | "tst_scores = 1*tst_scores_ivectors + 1*tst_scores_words + 1*tst_scores_chars + 1*tst_scores_phone_hu\n",
|
852 | 766 | "hypo_lang = np.argmax(tst_scores,axis = 0)\n",
|
853 | 767 | "temp = ((tst_labels-1) - hypo_lang)\n",
|
854 | 768 | "acc =1- np.size(np.nonzero(temp)) / float(np.size(tst_labels))\n",
|
| 769 | + "confusionmat = np.zeros((5,5))\n", |
| 770 | + "for i,lang in enumerate(languages):\n", |
| 771 | + " hypo_bylang = hypo_lang[ tst_labels == i+1]\n", |
| 772 | + " hist_bylang = np.histogram(hypo_bylang,5)\n", |
| 773 | + " confusionmat[:,i] = hist_bylang[0]\n", |
855 | 774 | "\n",
|
| 775 | + "precision = np.diag(confusionmat) / np.sum(confusionmat,axis=1) #precision\n", |
| 776 | + "recall = np.diag(confusionmat) / np.sum(confusionmat,axis=0) # recall\n", |
856 | 777 | "print '\\n\\n<Performance evaluation on Test dataset>'\n",
|
857 | 778 | "print 'Accurary : %0.3f' %(acc)\n",
|
858 | 779 | "print 'Precision : %0.3f' %(np.mean(precision))\n",
|
|
861 | 782 | },
|
862 | 783 | {
|
863 | 784 | "cell_type": "code",
|
864 |
| - "execution_count": 15, |
| 785 | + "execution_count": null, |
865 | 786 | "metadata": {},
|
866 |
| - "outputs": [ |
867 |
| - { |
868 |
| - "name": "stdout", |
869 |
| - "output_type": "stream", |
870 |
| - "text": [ |
871 |
| - "\n", |
872 |
| - "\n", |
873 |
| - "<Performance evaluation on Test dataset>\n", |
874 |
| - "Accurary : 0.775\n", |
875 |
| - "Precision : 0.554\n", |
876 |
| - "Recall : 0.554\n" |
877 |
| - ] |
878 |
| - } |
879 |
| - ], |
| 787 | + "outputs": [], |
880 | 788 | "source": [
|
881 | 789 | "# Fusion - : All + linear combination\n",
|
882 | 790 | "\n",
|
883 | 791 | "tst_scores = 2.5*tst_scores_ivectors + 1*tst_scores_words + 1*tst_scores_chars + 1*tst_scores_phone_hu\n",
|
884 | 792 | "hypo_lang = np.argmax(tst_scores,axis = 0)\n",
|
885 | 793 | "temp = ((tst_labels-1) - hypo_lang)\n",
|
886 | 794 | "acc =1- np.size(np.nonzero(temp)) / float(np.size(tst_labels))\n",
|
| 795 | + "confusionmat = np.zeros((5,5))\n", |
| 796 | + "for i,lang in enumerate(languages):\n", |
| 797 | + " hypo_bylang = hypo_lang[ tst_labels == i+1]\n", |
| 798 | + " hist_bylang = np.histogram(hypo_bylang,5)\n", |
| 799 | + " confusionmat[:,i] = hist_bylang[0]\n", |
887 | 800 | "\n",
|
| 801 | + "precision = np.diag(confusionmat) / np.sum(confusionmat,axis=1) #precision\n", |
| 802 | + "recall = np.diag(confusionmat) / np.sum(confusionmat,axis=0) # recall\n", |
888 | 803 | "print '\\n\\n<Performance evaluation on Test dataset>'\n",
|
889 | 804 | "print 'Accurary : %0.3f' %(acc)\n",
|
890 | 805 | "print 'Precision : %0.3f' %(np.mean(precision))\n",
|
|
0 commit comments