{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "tf2.0_text_binary_classification_sentence_embed.ipynb",
      "provenance": [],
      "collapsed_sections": [],
      "toc_visible": true,
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "accelerator": "GPU",
    "widgets": {
      "application/vnd.jupyter.widget-state+json": {
        "022820b963f647439f28956badd51763": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_4c76de831aa2468ea91f300153277979",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_5ea7c111d4d94d5bb487238545edbe7b",
              "IPY_MODEL_619c31e601b24c89a4822cb6dabb39ba"
            ]
          }
        },
        "4c76de831aa2468ea91f300153277979": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "5ea7c111d4d94d5bb487238545edbe7b": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "IntProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_9623d6e659294fae981a42f34784b000",
            "_dom_classes": [],
            "description": "Dl Completed...",
            "_model_name": "IntProgressModel",
            "bar_style": "success",
            "max": 1,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 1,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_2a21f68ddbd144bd887613db8c7d4b7e"
          }
        },
        "619c31e601b24c89a4822cb6dabb39ba": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_96d40f5233784416b405f29db478d4aa",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": "1/|/100% 1/1 [00:08&lt;00:00,  8.18s/ url]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_c9fe186734b94ccea4de4c9e9f15db3b"
          }
        },
        "9623d6e659294fae981a42f34784b000": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "initial",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "2a21f68ddbd144bd887613db8c7d4b7e": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "96d40f5233784416b405f29db478d4aa": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "c9fe186734b94ccea4de4c9e9f15db3b": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "e6ff112d5e694b45be7fdc8ce3c70c6b": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_3d9a1e17312143988b49a3edc09ffe19",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_ea1fca99592742e8853c6b70af2d05a7",
              "IPY_MODEL_6870deb00b514fc0916c5ab910d9f249"
            ]
          }
        },
        "3d9a1e17312143988b49a3edc09ffe19": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "ea1fca99592742e8853c6b70af2d05a7": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "IntProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_f998803be67f4ce1b1b3bbbbf190d3d4",
            "_dom_classes": [],
            "description": "Dl Size...",
            "_model_name": "IntProgressModel",
            "bar_style": "success",
            "max": 1,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 1,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_15b3892348dd44499ee685e45bf9e308"
          }
        },
        "6870deb00b514fc0916c5ab910d9f249": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_6f422f5f72824a0394ef5ee8ced7df5c",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": "80/|/100% 80/80 [00:08&lt;00:00,  9.81 MiB/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_3aaf96a17a354a6aaa1f063add63011d"
          }
        },
        "f998803be67f4ce1b1b3bbbbf190d3d4": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "initial",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "15b3892348dd44499ee685e45bf9e308": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "6f422f5f72824a0394ef5ee8ced7df5c": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "3aaf96a17a354a6aaa1f063add63011d": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "b068cf37bbc84d388606fc0a035faac8": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_3c33c12a11cb4d23aefe34d46f126b11",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_e52dde1ac25748b8908878cfb07cb363",
              "IPY_MODEL_c2a6602535d74afb838e7e4ec3a43c34"
            ]
          }
        },
        "3c33c12a11cb4d23aefe34d46f126b11": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "e52dde1ac25748b8908878cfb07cb363": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "IntProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_017a09d655fa4c09aae5bc7310022343",
            "_dom_classes": [],
            "description": "",
            "_model_name": "IntProgressModel",
            "bar_style": "info",
            "max": 1,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 1,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_5db8a4f923bf4efc92ad71205cbcd778"
          }
        },
        "c2a6602535d74afb838e7e4ec3a43c34": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_01689f59098046daabcd91183ce40d8f",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": "24672 examples [00:09, 3536.61 examples/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_3deb060faf3345b8995bfd5c7bf6756b"
          }
        },
        "017a09d655fa4c09aae5bc7310022343": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "5db8a4f923bf4efc92ad71205cbcd778": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "01689f59098046daabcd91183ce40d8f": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "3deb060faf3345b8995bfd5c7bf6756b": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "48f06d29974d49b58fc369dbb95ab7de": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_5ffa7aa6aca449f5ab1827d6b4cfae80",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_5f777d163283467890b846ad8477fbae",
              "IPY_MODEL_3c1a1f2b85f94335a876b3d2174ae2d5"
            ]
          }
        },
        "5ffa7aa6aca449f5ab1827d6b4cfae80": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "5f777d163283467890b846ad8477fbae": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "IntProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_d0709f02603a4b94939798a508a1e699",
            "_dom_classes": [],
            "description": "",
            "_model_name": "IntProgressModel",
            "bar_style": "danger",
            "max": 25000,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 10796,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_8cd88bde688d45e9bdbf21f87ad24170"
          }
        },
        "3c1a1f2b85f94335a876b3d2174ae2d5": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_8ee633a2e6334c938b9899a0474f6026",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": " 43% 10796/25000 [00:00&lt;00:00, 107957.79 examples/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_7c7396eefb2b4349895f6fbf645f5829"
          }
        },
        "d0709f02603a4b94939798a508a1e699": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "8cd88bde688d45e9bdbf21f87ad24170": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "8ee633a2e6334c938b9899a0474f6026": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "7c7396eefb2b4349895f6fbf645f5829": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "17c2e45964ce4c9a9cf6cad4a5c60ecf": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_8dfa76e8e2a6430aaaa2a68a5b016bcc",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_21fd03beec2c4a9b8c5aac7625a420e1",
              "IPY_MODEL_a17673bc460940779a78a0d3c479fb34"
            ]
          }
        },
        "8dfa76e8e2a6430aaaa2a68a5b016bcc": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "21fd03beec2c4a9b8c5aac7625a420e1": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "IntProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_a87d24a863444f3eb1ece7f220b15883",
            "_dom_classes": [],
            "description": "",
            "_model_name": "IntProgressModel",
            "bar_style": "info",
            "max": 1,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 1,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_63f43c444858408badbda7987acad538"
          }
        },
        "a17673bc460940779a78a0d3c479fb34": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_cb554221ab844242a6d87b9840f3d905",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": "24888 examples [00:07, 3738.90 examples/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_e2122110d10f4002a8931e34a5761238"
          }
        },
        "a87d24a863444f3eb1ece7f220b15883": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "63f43c444858408badbda7987acad538": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "cb554221ab844242a6d87b9840f3d905": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "e2122110d10f4002a8931e34a5761238": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "1fe93f027a3a4db793c23366e6181481": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_533dd88cfa87448ebfcd247403b89c08",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_b00f65fe2bd54d249e0b15872fc3ba22",
              "IPY_MODEL_63ac051d84344a1ba7e51ca6fcc0a698"
            ]
          }
        },
        "533dd88cfa87448ebfcd247403b89c08": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "b00f65fe2bd54d249e0b15872fc3ba22": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "IntProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_bed7032e44a44745b016b6f5c30a9f00",
            "_dom_classes": [],
            "description": "",
            "_model_name": "IntProgressModel",
            "bar_style": "danger",
            "max": 25000,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 9800,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_d22052268d8943d08b5ea67a4b23cf02"
          }
        },
        "63ac051d84344a1ba7e51ca6fcc0a698": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_9a9c23782b4d4bee83830f012a01a147",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": " 39% 9800/25000 [00:00&lt;00:00, 97997.99 examples/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_09d7f83b9b6445699d01b2ebfac77b77"
          }
        },
        "bed7032e44a44745b016b6f5c30a9f00": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "d22052268d8943d08b5ea67a4b23cf02": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "9a9c23782b4d4bee83830f012a01a147": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "09d7f83b9b6445699d01b2ebfac77b77": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "7da97caa0cb24c40a46941b0fc775fa2": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_f13ec2792052489cb064723d07b3fd73",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_7b7bd5745d4d454d8d6da48c48bc023d",
              "IPY_MODEL_796de92e6b814422a48122239249d467"
            ]
          }
        },
        "f13ec2792052489cb064723d07b3fd73": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "7b7bd5745d4d454d8d6da48c48bc023d": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "IntProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_a3fa529e3e104822b523939e63cf3c05",
            "_dom_classes": [],
            "description": "",
            "_model_name": "IntProgressModel",
            "bar_style": "info",
            "max": 1,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 1,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_0d8d32c6e1c2404fa216484175978066"
          }
        },
        "796de92e6b814422a48122239249d467": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_af86da650735432484fe0db7a9c42ce2",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": "49945 examples [00:17, 3727.77 examples/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_a73ab5318acc4dbfb8b92a1abf91b1dc"
          }
        },
        "a3fa529e3e104822b523939e63cf3c05": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "0d8d32c6e1c2404fa216484175978066": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "af86da650735432484fe0db7a9c42ce2": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "a73ab5318acc4dbfb8b92a1abf91b1dc": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "bb76e876ccb448b5a7aabcf25b2c0029": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_7b55e61259dd48e489eb13661b8ad3c7",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_fd012261fa4c4d4d947606ea39036632",
              "IPY_MODEL_bb2d40636f424255ae9c3da5b91088c4"
            ]
          }
        },
        "7b55e61259dd48e489eb13661b8ad3c7": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "fd012261fa4c4d4d947606ea39036632": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "IntProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_8ece79a63e4b44f4b78295abf6a1e4fd",
            "_dom_classes": [],
            "description": "",
            "_model_name": "IntProgressModel",
            "bar_style": "danger",
            "max": 50000,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 45987,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_b7dd1e02a4d84bfc9768e3ae7f155eb1"
          }
        },
        "bb2d40636f424255ae9c3da5b91088c4": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_b4663f620fed472cb138dc431f53fb19",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": " 92% 45987/50000 [00:00&lt;00:00, 104987.98 examples/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_e99378274e4d491c8fbe28aa522e14a7"
          }
        },
        "8ece79a63e4b44f4b78295abf6a1e4fd": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "b7dd1e02a4d84bfc9768e3ae7f155eb1": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "b4663f620fed472cb138dc431f53fb19": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "e99378274e4d491c8fbe28aa522e14a7": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        }
      }
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/gmihaila/machine_learning_things/blob/master/learning_tensorflow/tf2_0_text_binary_classification_sentence_embed.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "mAkHHj2ABkIK",
        "colab_type": "text"
      },
      "source": [
        "## Regular Classificaiton [sentence embedding]"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "V8NGywAXKazI",
        "colab_type": "code",
        "outputId": "b7b24212-b763-46f9-9ccd-89afab435669",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 318
        }
      },
      "source": [
        "!nvidia-smi"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Sat Feb  8 22:59:23 2020       \n",
            "+-----------------------------------------------------------------------------+\n",
            "| NVIDIA-SMI 440.48.02    Driver Version: 418.67       CUDA Version: 10.1     |\n",
            "|-------------------------------+----------------------+----------------------+\n",
            "| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |\n",
            "| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |\n",
            "|===============================+======================+======================|\n",
            "|   0  Tesla T4            Off  | 00000000:00:04.0 Off |                    0 |\n",
            "| N/A   36C    P8     9W /  70W |      0MiB / 15079MiB |      0%      Default |\n",
            "+-------------------------------+----------------------+----------------------+\n",
            "                                                                               \n",
            "+-----------------------------------------------------------------------------+\n",
            "| Processes:                                                       GPU Memory |\n",
            "|  GPU       PID   Type   Process name                             Usage      |\n",
            "|=============================================================================|\n",
            "|  No running processes found                                                 |\n",
            "+-----------------------------------------------------------------------------+\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "27jF_okvy53u",
        "colab_type": "text"
      },
      "source": [
        "### Imports"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "44oVj91SohKO",
        "colab_type": "code",
        "outputId": "5d25f365-4ad0-49c2-f070-06a9b4022ae9",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        }
      },
      "source": [
        "import os\n",
        "os.environ[\"CUDA_VISIBLE_DEVICES\"]=\"0\"\n",
        "try:\n",
        "  # %tensorflow_version only exists in Colab.\n",
        "  %tensorflow_version 2.x\n",
        "except Exception:\n",
        "  pass\n",
        "from __future__ import absolute_import, division, print_function, unicode_literals\n",
        "import tensorflow as tf\n",
        "# tf.debugging.set_log_device_placement(True)\n",
        "import tensorflow_datasets as tfds\n",
        "import tensorflow_hub as hub\n",
        "import numpy as np\n",
        "import matplotlib.pyplot as plt\n",
        "from sklearn.model_selection import train_test_split\n",
        "from sklearn.metrics import classification_report\n",
        "import time\n",
        "print(\"Num GPUs Available: \", len(tf.config.experimental.list_physical_devices('GPU')))\n",
        "\n",
        "BUFFER_SIZE = 1000\n",
        "BATCH = 1000\n",
        "EPOCHS = 20\n",
        "MAX_LEN = 500"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "TensorFlow 2.x selected.\n",
            "Num GPUs Available:  1\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Xp5GT3-etzF2",
        "colab_type": "text"
      },
      "source": [
        "### Dataset"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ea1l-5wMt0wN",
        "colab_type": "code",
        "outputId": "64a76641-4c2e-4c68-d710-b291fa10ae67",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 410,
          "referenced_widgets": [
            "022820b963f647439f28956badd51763",
            "4c76de831aa2468ea91f300153277979",
            "5ea7c111d4d94d5bb487238545edbe7b",
            "619c31e601b24c89a4822cb6dabb39ba",
            "9623d6e659294fae981a42f34784b000",
            "2a21f68ddbd144bd887613db8c7d4b7e",
            "96d40f5233784416b405f29db478d4aa",
            "c9fe186734b94ccea4de4c9e9f15db3b",
            "e6ff112d5e694b45be7fdc8ce3c70c6b",
            "3d9a1e17312143988b49a3edc09ffe19",
            "ea1fca99592742e8853c6b70af2d05a7",
            "6870deb00b514fc0916c5ab910d9f249",
            "f998803be67f4ce1b1b3bbbbf190d3d4",
            "15b3892348dd44499ee685e45bf9e308",
            "6f422f5f72824a0394ef5ee8ced7df5c",
            "3aaf96a17a354a6aaa1f063add63011d",
            "b068cf37bbc84d388606fc0a035faac8",
            "3c33c12a11cb4d23aefe34d46f126b11",
            "e52dde1ac25748b8908878cfb07cb363",
            "c2a6602535d74afb838e7e4ec3a43c34",
            "017a09d655fa4c09aae5bc7310022343",
            "5db8a4f923bf4efc92ad71205cbcd778",
            "01689f59098046daabcd91183ce40d8f",
            "3deb060faf3345b8995bfd5c7bf6756b",
            "48f06d29974d49b58fc369dbb95ab7de",
            "5ffa7aa6aca449f5ab1827d6b4cfae80",
            "5f777d163283467890b846ad8477fbae",
            "3c1a1f2b85f94335a876b3d2174ae2d5",
            "d0709f02603a4b94939798a508a1e699",
            "8cd88bde688d45e9bdbf21f87ad24170",
            "8ee633a2e6334c938b9899a0474f6026",
            "7c7396eefb2b4349895f6fbf645f5829",
            "17c2e45964ce4c9a9cf6cad4a5c60ecf",
            "8dfa76e8e2a6430aaaa2a68a5b016bcc",
            "21fd03beec2c4a9b8c5aac7625a420e1",
            "a17673bc460940779a78a0d3c479fb34",
            "a87d24a863444f3eb1ece7f220b15883",
            "63f43c444858408badbda7987acad538",
            "cb554221ab844242a6d87b9840f3d905",
            "e2122110d10f4002a8931e34a5761238",
            "1fe93f027a3a4db793c23366e6181481",
            "533dd88cfa87448ebfcd247403b89c08",
            "b00f65fe2bd54d249e0b15872fc3ba22",
            "63ac051d84344a1ba7e51ca6fcc0a698",
            "bed7032e44a44745b016b6f5c30a9f00",
            "d22052268d8943d08b5ea67a4b23cf02",
            "9a9c23782b4d4bee83830f012a01a147",
            "09d7f83b9b6445699d01b2ebfac77b77",
            "7da97caa0cb24c40a46941b0fc775fa2",
            "f13ec2792052489cb064723d07b3fd73",
            "7b7bd5745d4d454d8d6da48c48bc023d",
            "796de92e6b814422a48122239249d467",
            "a3fa529e3e104822b523939e63cf3c05",
            "0d8d32c6e1c2404fa216484175978066",
            "af86da650735432484fe0db7a9c42ce2",
            "a73ab5318acc4dbfb8b92a1abf91b1dc",
            "bb76e876ccb448b5a7aabcf25b2c0029",
            "7b55e61259dd48e489eb13661b8ad3c7",
            "fd012261fa4c4d4d947606ea39036632",
            "bb2d40636f424255ae9c3da5b91088c4",
            "8ece79a63e4b44f4b78295abf6a1e4fd",
            "b7dd1e02a4d84bfc9768e3ae7f155eb1",
            "b4663f620fed472cb138dc431f53fb19",
            "e99378274e4d491c8fbe28aa522e14a7"
          ]
        }
      },
      "source": [
        "train_data, validation_data, test_data = tfds.load(name=\"imdb_reviews\", \n",
        "                                                   split=('train[:60%]', 'train[60%:]', 'test'),\n",
        "                                                   as_supervised=True)\n",
        "\n",
        "# batch padding\n",
        "train_batches = (train_data.batch(BATCH))\n",
        "valid_batched = (validation_data.batch(BATCH))\n",
        "test_batches = (test_data.batch(BATCH))\n",
        "\n",
        "# sample\n",
        "texts, labels = next(iter(train_batches))\n",
        "\n",
        "print(\"Text sample:           {}\".format(texts[0]))\n",
        "print(\"Label:                 {}\".format(labels[0]))\n",
        "print(\"Encoding batch shape:  {}\".format(texts.shape))\n",
        "print(\"Labels batch shape:    {}\".format(labels.shape))"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "\u001b[1mDownloading and preparing dataset imdb_reviews (80.23 MiB) to /root/tensorflow_datasets/imdb_reviews/plain_text/1.0.0...\u001b[0m\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "022820b963f647439f28956badd51763",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(IntProgress(value=1, bar_style='info', description='Dl Completed...', max=1, style=ProgressStyl…"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "e6ff112d5e694b45be7fdc8ce3c70c6b",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(IntProgress(value=1, bar_style='info', description='Dl Size...', max=1, style=ProgressStyle(des…"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "\n",
            "\n",
            "\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "b068cf37bbc84d388606fc0a035faac8",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(IntProgress(value=1, bar_style='info', max=1), HTML(value='')))"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "\rShuffling and writing examples to /root/tensorflow_datasets/imdb_reviews/plain_text/1.0.0.incomplete8043KK/imdb_reviews-train.tfrecord\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "48f06d29974d49b58fc369dbb95ab7de",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(IntProgress(value=0, max=25000), HTML(value='')))"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "\r"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "17c2e45964ce4c9a9cf6cad4a5c60ecf",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(IntProgress(value=1, bar_style='info', max=1), HTML(value='')))"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "\rShuffling and writing examples to /root/tensorflow_datasets/imdb_reviews/plain_text/1.0.0.incomplete8043KK/imdb_reviews-test.tfrecord\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "1fe93f027a3a4db793c23366e6181481",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(IntProgress(value=0, max=25000), HTML(value='')))"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "\r"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "7da97caa0cb24c40a46941b0fc775fa2",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(IntProgress(value=1, bar_style='info', max=1), HTML(value='')))"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "\rShuffling and writing examples to /root/tensorflow_datasets/imdb_reviews/plain_text/1.0.0.incomplete8043KK/imdb_reviews-unsupervised.tfrecord\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "bb76e876ccb448b5a7aabcf25b2c0029",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(IntProgress(value=0, max=50000), HTML(value='')))"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "\r\u001b[1mDataset imdb_reviews downloaded and prepared to /root/tensorflow_datasets/imdb_reviews/plain_text/1.0.0. Subsequent calls will reuse this data.\u001b[0m\n",
            "Text sample:           b\"This was an absolutely terrible movie. Don't be lured in by Christopher Walken or Michael Ironside. Both are great actors, but this must simply be their worst role in history. Even their great acting could not redeem this movie's ridiculous storyline. This movie is an early nineties US propaganda piece. The most pathetic scenes were those when the Columbian rebels were making their cases for revolutions. Maria Conchita Alonso appeared phony, and her pseudo-love affair with Walken was nothing but a pathetic emotional plug in a movie that was devoid of any real meaning. I am disappointed that there are movies like this, ruining actor's like Christopher Walken's good name. I could barely sit through it.\"\n",
            "Label:                 0\n",
            "Encoding batch shape:  (1000,)\n",
            "Labels batch shape:    (1000,)\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "CmW_oANksLcX",
        "colab_type": "text"
      },
      "source": [
        "### Sequential Model + regular train"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "wp8klPONqLxZ",
        "colab_type": "code",
        "outputId": "922e0be1-e2d5-496f-fd31-906c07f57051",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        }
      },
      "source": [
        "embedding = \"https://tfhub.dev/google/tf2-preview/gnews-swivel-20dim/1\"\n",
        "hub_layer = hub.KerasLayer(embedding, input_shape=[], \n",
        "                           dtype=tf.string, trainable=True)\n",
        "model = tf.keras.Sequential()\n",
        "model.add(hub_layer)\n",
        "model.add(tf.keras.layers.Dense(16, activation='relu'))\n",
        "model.add(tf.keras.layers.Dense(1, activation='sigmoid'))\n",
        "\n",
        "model.summary()\n",
        "\n",
        "model.compile(optimizer='adam',\n",
        "              loss='binary_crossentropy',\n",
        "              metrics=['accuracy'])\n",
        "\n",
        "history = model.fit(train_batches,\n",
        "                    epochs=20,\n",
        "                    validation_data=valid_batched,\n",
        "                    verbose=1)\n",
        "\n",
        "results = model.evaluate(test_data.batch(512), verbose=2)\n",
        "\n",
        "# loss: 0.320\n",
        "# accuracy: 0.863\n",
        "for name, value in zip(model.metrics_names, results):\n",
        "  print(\"%s: %.3f\" % (name, value))\n"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Model: \"sequential\"\n",
            "_________________________________________________________________\n",
            "Layer (type)                 Output Shape              Param #   \n",
            "=================================================================\n",
            "keras_layer (KerasLayer)     (None, 20)                400020    \n",
            "_________________________________________________________________\n",
            "dense (Dense)                (None, 16)                336       \n",
            "_________________________________________________________________\n",
            "dense_1 (Dense)              (None, 1)                 17        \n",
            "=================================================================\n",
            "Total params: 400,373\n",
            "Trainable params: 400,373\n",
            "Non-trainable params: 0\n",
            "_________________________________________________________________\n",
            "Epoch 1/20\n",
            "15/15 [==============================] - 6s 379ms/step - loss: 0.7418 - accuracy: 0.5295 - val_loss: 0.7055 - val_accuracy: 0.5644\n",
            "Epoch 2/20\n",
            "15/15 [==============================] - 4s 236ms/step - loss: 0.6773 - accuracy: 0.5959 - val_loss: 0.6603 - val_accuracy: 0.6150\n",
            "Epoch 3/20\n",
            "15/15 [==============================] - 4s 261ms/step - loss: 0.6365 - accuracy: 0.6420 - val_loss: 0.6273 - val_accuracy: 0.6473\n",
            "Epoch 4/20\n",
            "15/15 [==============================] - 4s 244ms/step - loss: 0.6042 - accuracy: 0.6778 - val_loss: 0.5994 - val_accuracy: 0.6834\n",
            "Epoch 5/20\n",
            "15/15 [==============================] - 4s 242ms/step - loss: 0.5752 - accuracy: 0.7071 - val_loss: 0.5737 - val_accuracy: 0.7076\n",
            "Epoch 6/20\n",
            "15/15 [==============================] - 4s 244ms/step - loss: 0.5474 - accuracy: 0.7305 - val_loss: 0.5491 - val_accuracy: 0.7315\n",
            "Epoch 7/20\n",
            "15/15 [==============================] - 4s 250ms/step - loss: 0.5203 - accuracy: 0.7545 - val_loss: 0.5251 - val_accuracy: 0.7498\n",
            "Epoch 8/20\n",
            "15/15 [==============================] - 4s 249ms/step - loss: 0.4937 - accuracy: 0.7757 - val_loss: 0.5026 - val_accuracy: 0.7656\n",
            "Epoch 9/20\n",
            "15/15 [==============================] - 4s 259ms/step - loss: 0.4681 - accuracy: 0.7931 - val_loss: 0.4814 - val_accuracy: 0.7786\n",
            "Epoch 10/20\n",
            "15/15 [==============================] - 4s 253ms/step - loss: 0.4435 - accuracy: 0.8079 - val_loss: 0.4616 - val_accuracy: 0.7926\n",
            "Epoch 11/20\n",
            "15/15 [==============================] - 4s 257ms/step - loss: 0.4199 - accuracy: 0.8218 - val_loss: 0.4432 - val_accuracy: 0.8029\n",
            "Epoch 12/20\n",
            "15/15 [==============================] - 4s 274ms/step - loss: 0.3975 - accuracy: 0.8325 - val_loss: 0.4264 - val_accuracy: 0.8113\n",
            "Epoch 13/20\n",
            "15/15 [==============================] - 4s 250ms/step - loss: 0.3762 - accuracy: 0.8428 - val_loss: 0.4110 - val_accuracy: 0.8202\n",
            "Epoch 14/20\n",
            "15/15 [==============================] - 4s 252ms/step - loss: 0.3556 - accuracy: 0.8532 - val_loss: 0.3964 - val_accuracy: 0.8301\n",
            "Epoch 15/20\n",
            "15/15 [==============================] - 4s 258ms/step - loss: 0.3354 - accuracy: 0.8636 - val_loss: 0.3832 - val_accuracy: 0.8348\n",
            "Epoch 16/20\n",
            "15/15 [==============================] - 4s 257ms/step - loss: 0.3167 - accuracy: 0.8732 - val_loss: 0.3719 - val_accuracy: 0.8409\n",
            "Epoch 17/20\n",
            "15/15 [==============================] - 4s 253ms/step - loss: 0.2995 - accuracy: 0.8806 - val_loss: 0.3615 - val_accuracy: 0.8453\n",
            "Epoch 18/20\n",
            "15/15 [==============================] - 4s 252ms/step - loss: 0.2828 - accuracy: 0.8902 - val_loss: 0.3515 - val_accuracy: 0.8502\n",
            "Epoch 19/20\n",
            "15/15 [==============================] - 4s 258ms/step - loss: 0.2663 - accuracy: 0.8960 - val_loss: 0.3435 - val_accuracy: 0.8533\n",
            "Epoch 20/20\n",
            "15/15 [==============================] - 4s 253ms/step - loss: 0.2509 - accuracy: 0.9035 - val_loss: 0.3371 - val_accuracy: 0.8573\n",
            "loss: 0.349\n",
            "accuracy: 0.847\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "V_SY7mXisReQ",
        "colab_type": "text"
      },
      "source": [
        "### Sequential Model + gradient tape\n",
        "\n",
        "Apply with logits if we apply optimizer to values coming form softmax"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "rPLeKsklsSN_",
        "colab_type": "code",
        "outputId": "748287ec-2975-4bd0-baa3-51dfa3fdbcbc",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 372
        }
      },
      "source": [
        "class Classification(tf.keras.Model):\n",
        "  def __init__(self, embedding):\n",
        "    super(Classification, self).__init__()\n",
        "    self.hub_layer = hub.KerasLayer(embedding, input_shape=[], dtype=tf.string, trainable=True)\n",
        "    self.l1 = tf.keras.layers.Dense(units=16, activation=tf.nn.relu)\n",
        "    self.l2 = tf.keras.layers.Dense(units=1, activation=tf.nn.sigmoid)\n",
        "    return\n",
        "\n",
        "  def call(self, input_):\n",
        "    output_ = self.hub_layer(input_)\n",
        "    output_ = self.l1(output_)\n",
        "    output_ = self.l2(output_)\n",
        "    return output_\n",
        "\n",
        "\n",
        "def loss_func(target, logits):\n",
        "  bce = tf.losses.BinaryCrossentropy(from_logits=False)\n",
        "  return bce(y_true=target, y_pred=logits)\n",
        "\n",
        "\n",
        "@tf.function\n",
        "def train_step(input_batch, lables_batch, optim):\n",
        "  loss = 0\n",
        "  with tf.GradientTape() as tape:\n",
        "    preds_batch = model(input_batch)\n",
        "    loss = loss_func(lables_batch, preds_batch)\n",
        "\n",
        "  variables = model.variables\n",
        "  gradients = tape.gradient(loss, variables)\n",
        "  optim.apply_gradients(zip(gradients, variables))\n",
        "  return loss\n",
        "\n",
        "\n",
        "\n",
        "model = Classification(embedding=\"https://tfhub.dev/google/tf2-preview/gnews-swivel-20dim/1\")\n",
        "model_optimizer = tf.optimizers.Adam()\n",
        "model_metrics = tf.metrics.Accuracy()\n",
        "\n",
        "EPOCHS = 20\n",
        "\n",
        "for epoch in range(EPOCHS):\n",
        "  batch_loss = 0\n",
        "  batch_val_loss = 0\n",
        "\n",
        "  batch_acc = 0\n",
        "  batch_val_acc = 0\n",
        "\n",
        "  for batch, (text_batch, label_batch) in enumerate(train_batches, start=1):\n",
        "    batch_loss += train_step(text_batch, label_batch, model_optimizer)\n",
        "\n",
        "    preds_batch = model(text_batch)\n",
        "    preds_batch = tf.keras.backend.round(preds_batch)\n",
        "    batch_acc += model_metrics(label_batch, preds_batch) \n",
        "\n",
        "  batch_loss = tf.get_static_value(batch_loss) / batch\n",
        "  batch_acc = tf.get_static_value(batch_acc) / batch\n",
        "\n",
        "  for batch, (text_batch, label_batch) in enumerate(valid_batched, start=1):\n",
        "    preds_batch = model(text_batch)\n",
        "    batch_val_loss += loss_func(label_batch, preds_batch)\n",
        "\n",
        "    preds_batch = tf.keras.backend.round(preds_batch)\n",
        "    batch_val_acc += model_metrics(label_batch, preds_batch) \n",
        "\n",
        "  \n",
        "  batch_val_loss = tf.get_static_value(batch_val_loss) / batch\n",
        "  batch_val_acc =tf.get_static_value(batch_val_acc) / batch\n",
        "\n",
        "  print('Epoch: %s/%s\\tloss: %.4f\\tacc: %.4f\\tval_loss: %.4f\\tval_acc: %.4f'%(epoch+1, EPOCHS, batch_loss, batch_acc, batch_val_loss, batch_val_acc))\n",
        "    \n"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Epoch: 1/20\tloss: 0.7262\tacc: 0.5716\tval_loss: 0.6859\tval_acc: 0.5821\n",
            "Epoch: 2/20\tloss: 0.6592\tacc: 0.5921\tval_loss: 0.6381\tval_acc: 0.6026\n",
            "Epoch: 3/20\tloss: 0.6214\tacc: 0.6126\tval_loss: 0.6104\tval_acc: 0.6216\n",
            "Epoch: 4/20\tloss: 0.5954\tacc: 0.6301\tval_loss: 0.5890\tval_acc: 0.6378\n",
            "Epoch: 5/20\tloss: 0.5730\tacc: 0.6451\tval_loss: 0.5681\tval_acc: 0.6516\n",
            "Epoch: 6/20\tloss: 0.5499\tacc: 0.6579\tval_loss: 0.5465\tval_acc: 0.6638\n",
            "Epoch: 7/20\tloss: 0.5270\tacc: 0.6694\tval_loss: 0.5260\tval_acc: 0.6750\n",
            "Epoch: 8/20\tloss: 0.5039\tacc: 0.6804\tval_loss: 0.5063\tval_acc: 0.6855\n",
            "Epoch: 9/20\tloss: 0.4807\tacc: 0.6905\tval_loss: 0.4875\tval_acc: 0.6953\n",
            "Epoch: 10/20\tloss: 0.4583\tacc: 0.7001\tval_loss: 0.4695\tval_acc: 0.7046\n",
            "Epoch: 11/20\tloss: 0.4367\tacc: 0.7091\tval_loss: 0.4526\tval_acc: 0.7133\n",
            "Epoch: 12/20\tloss: 0.4159\tacc: 0.7175\tval_loss: 0.4369\tval_acc: 0.7215\n",
            "Epoch: 13/20\tloss: 0.3960\tacc: 0.7254\tval_loss: 0.4223\tval_acc: 0.7291\n",
            "Epoch: 14/20\tloss: 0.3767\tacc: 0.7328\tval_loss: 0.4086\tval_acc: 0.7364\n",
            "Epoch: 15/20\tloss: 0.3579\tacc: 0.7399\tval_loss: 0.3958\tval_acc: 0.7432\n",
            "Epoch: 16/20\tloss: 0.3398\tacc: 0.7466\tval_loss: 0.3839\tval_acc: 0.7498\n",
            "Epoch: 17/20\tloss: 0.3223\tacc: 0.7530\tval_loss: 0.3732\tval_acc: 0.7561\n",
            "Epoch: 18/20\tloss: 0.3055\tacc: 0.7592\tval_loss: 0.3635\tval_acc: 0.7621\n",
            "Epoch: 19/20\tloss: 0.2896\tacc: 0.7650\tval_loss: 0.3549\tval_acc: 0.7678\n",
            "Epoch: 20/20\tloss: 0.2748\tacc: 0.7706\tval_loss: 0.3473\tval_acc: 0.7733\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "FaKeZxQh6irj",
        "colab_type": "text"
      },
      "source": [
        "### Separate Models + gradient tape"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "k_HJy4BGhG_f",
        "colab_type": "code",
        "outputId": "8be1f682-7c50-42b9-ce1f-4e7681219675",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 372
        }
      },
      "source": [
        "class Embed(tf.keras.Model):\n",
        "  def __init__(self, embedding):\n",
        "    super(Embed, self).__init__()\n",
        "    self.hub_layer = hub.KerasLayer(embedding, input_shape=[], dtype=tf.string, trainable=True)\n",
        "    return\n",
        "\n",
        "  def call(self, input_):\n",
        "    output_ = self.hub_layer(input_)\n",
        "    return output_\n",
        "\n",
        "class Dens(tf.keras.Model):\n",
        "  def __init__(self):\n",
        "    super(Dens, self).__init__()\n",
        "    self.l1 = tf.keras.layers.Dense(units=16, activation=tf.nn.relu)\n",
        "    self.l2 = tf.keras.layers.Dense(units=1, activation=tf.nn.sigmoid)\n",
        "    return\n",
        "\n",
        "  def call(self, input_):\n",
        "    output_ = self.l1(input_)\n",
        "    output_ = self.l2(output_)\n",
        "    return output_\n",
        "\n",
        "\n",
        "def loss_func(target, logits):\n",
        "  bce = tf.losses.BinaryCrossentropy(from_logits=False)\n",
        "  return bce(y_true=target, y_pred=logits)\n",
        "\n",
        "\n",
        "@tf.function\n",
        "def train_step(input_batch, lables_batch, optim):\n",
        "  loss = 0\n",
        "  with tf.GradientTape() as tape:\n",
        "    preds_batch = model_embed(input_batch)\n",
        "    preds_batch = model_dens(preds_batch)\n",
        "\n",
        "    loss = loss_func(lables_batch, preds_batch)\n",
        "\n",
        "  variables = model_embed.variables + model_dens.variables\n",
        "  gradients = tape.gradient(loss, variables)\n",
        "  optim.apply_gradients(zip(gradients, variables))\n",
        "  return loss\n",
        "\n",
        "\n",
        "\n",
        "model_embed = Embed(embedding=\"https://tfhub.dev/google/tf2-preview/gnews-swivel-20dim/1\")\n",
        "model_dens = Dens()\n",
        "\n",
        "model_optimizer = tf.optimizers.Adam()\n",
        "model_metrics = tf.metrics.Accuracy()\n",
        "\n",
        "EPOCHS = 20\n",
        "\n",
        "for epoch in range(EPOCHS):\n",
        "  batch_loss = 0\n",
        "  batch_val_loss = 0\n",
        "\n",
        "  batch_acc = 0\n",
        "  batch_val_acc = 0\n",
        "\n",
        "  for batch, (text_batch, label_batch) in enumerate(train_batches, start=1):\n",
        "    batch_loss += train_step(text_batch, label_batch, model_optimizer)\n",
        "\n",
        "    preds_batch = model_embed(text_batch)\n",
        "    preds_batch = model_dens(preds_batch)\n",
        "\n",
        "    preds_batch = tf.keras.backend.round(preds_batch)\n",
        "    batch_acc += model_metrics(label_batch, preds_batch) \n",
        "\n",
        "  batch_loss = tf.get_static_value(batch_loss) / batch\n",
        "  batch_acc = tf.get_static_value(batch_acc) / batch\n",
        "\n",
        "  for batch, (text_batch, label_batch) in enumerate(valid_batched, start=1):\n",
        "    preds_batch = model_embed(text_batch)\n",
        "    preds_batch = model_dens(preds_batch)\n",
        "\n",
        "    batch_val_loss += loss_func(label_batch, preds_batch)\n",
        "\n",
        "    preds_batch = tf.keras.backend.round(preds_batch)\n",
        "    batch_val_acc += model_metrics(label_batch, preds_batch) \n",
        "\n",
        "  \n",
        "  batch_val_loss = tf.get_static_value(batch_val_loss) / batch\n",
        "  batch_val_acc =tf.get_static_value(batch_val_acc) / batch\n",
        "\n",
        "  print('Epoch: %s/%s\\tloss: %.4f\\tacc: %.4f\\tval_loss: %.4f\\tval_acc: %.4f'%(epoch+1, EPOCHS, batch_loss, batch_acc, batch_val_loss, batch_val_acc))\n",
        "    \n"
      ],
      "execution_count": 0,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Epoch: 1/20\tloss: 0.6764\tacc: 0.5869\tval_loss: 0.6475\tval_acc: 0.6076\n",
            "Epoch: 2/20\tloss: 0.6281\tacc: 0.6194\tval_loss: 0.6108\tval_acc: 0.6325\n",
            "Epoch: 3/20\tloss: 0.5923\tacc: 0.6438\tval_loss: 0.5807\tval_acc: 0.6538\n",
            "Epoch: 4/20\tloss: 0.5618\tacc: 0.6634\tval_loss: 0.5543\tval_acc: 0.6722\n",
            "Epoch: 5/20\tloss: 0.5339\tacc: 0.6803\tval_loss: 0.5301\tval_acc: 0.6877\n",
            "Epoch: 6/20\tloss: 0.5076\tacc: 0.6950\tval_loss: 0.5075\tval_acc: 0.7015\n",
            "Epoch: 7/20\tloss: 0.4823\tacc: 0.7079\tval_loss: 0.4862\tval_acc: 0.7137\n",
            "Epoch: 8/20\tloss: 0.4577\tacc: 0.7194\tval_loss: 0.4662\tval_acc: 0.7245\n",
            "Epoch: 9/20\tloss: 0.4340\tacc: 0.7295\tval_loss: 0.4473\tval_acc: 0.7341\n",
            "Epoch: 10/20\tloss: 0.4113\tacc: 0.7388\tval_loss: 0.4296\tval_acc: 0.7431\n",
            "Epoch: 11/20\tloss: 0.3892\tacc: 0.7474\tval_loss: 0.4132\tval_acc: 0.7513\n",
            "Epoch: 12/20\tloss: 0.3679\tacc: 0.7553\tval_loss: 0.3975\tval_acc: 0.7590\n",
            "Epoch: 13/20\tloss: 0.3474\tacc: 0.7627\tval_loss: 0.3836\tval_acc: 0.7662\n",
            "Epoch: 14/20\tloss: 0.3283\tacc: 0.7697\tval_loss: 0.3713\tval_acc: 0.7730\n",
            "Epoch: 15/20\tloss: 0.3106\tacc: 0.7764\tval_loss: 0.3605\tval_acc: 0.7795\n",
            "Epoch: 16/20\tloss: 0.2942\tacc: 0.7825\tval_loss: 0.3510\tval_acc: 0.7854\n",
            "Epoch: 17/20\tloss: 0.2790\tacc: 0.7883\tval_loss: 0.3428\tval_acc: 0.7910\n",
            "Epoch: 18/20\tloss: 0.2650\tacc: 0.7937\tval_loss: 0.3358\tval_acc: 0.7962\n",
            "Epoch: 19/20\tloss: 0.2520\tacc: 0.7988\tval_loss: 0.3298\tval_acc: 0.8012\n",
            "Epoch: 20/20\tloss: 0.2399\tacc: 0.8036\tval_loss: 0.3248\tval_acc: 0.8058\n"
          ],
          "name": "stdout"
        }
      ]
    }
  ]
}