summaryrefslogtreecommitdiff
path: root/src/notebooks/07-try-gtn.ipynb
blob: d366dece39d4a74e43cd1e90de206a0f62008177 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import gtn\n",
    "from IPython.display import display, Image"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Make some graphs:\n",
    "g1 = gtn.Graph()\n",
    "g1.add_node(True)  # Add a start node\n",
    "g1.add_node()  # Add an internal node\n",
    "g1.add_node(False, True)  # Add an accepting node\n",
    "\n",
    "\n",
    "# Add arcs with (src node, dst node, label):\n",
    "g1.add_arc(0, 1, 1)\n",
    "g1.add_arc(0, 1, 2)\n",
    "g1.add_arc(1, 2, 1)\n",
    "g1.add_arc(1, 2, 0)\n",
    "\n",
    "\n",
    "g2 = gtn.Graph()\n",
    "g2.add_node(True, True)\n",
    "g2.add_arc(0, 0, 1)\n",
    "g2.add_arc(0, 0, 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAASUAAABFCAIAAACDhmfOAAAABmJLR0QA/wD/A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E86fPxVLNpIAAAE3SURBVD9lyhTN6nMDAOrq6lJSUn766SdjY+MPPvhgxYoVHh4eQxXS0tKSnZ2dnp5eXl7O4XASEhL6qJKgNq+5v6lQV1f36NGjx48f19TU8Pl8oVCIjdOsrKwcHR0dHR0nT56s8Yklf1lUToFBEGSAsnYjTHNzc1paWkZGxuPHj+3t7TkcDofD8fT0xNeuU6GhoeHhw4cFBQV5eXmlpaUMBmPx4sXR0dHTpk3TUpm/lr/p+CtTVFR08eLFq1evFhcXS6VSFEVtbW3NzMyYTKaxsbFIJIITuZqaGpFIBABwdnYOCAgIDAycN2+e9sNRiM7fdPzl6Orq4vF4VVVVPB5PIBAIhcK2tjY6nc5kMg0NDW1tbV1cXHqXsiMEnb/p0DFyDC2aqUOHDm3Q+ZsOHSOHzt906Bg5/g+1f34NLPiPzwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAEUAAACdCAIAAABtgiI8AAAABmJLR0QA/wD/AP+gvaeTAAAUNElEQVR4nO1ceVAUx/fvPTmWYwmwqyzKJceKWhohYqLghUlhIhCCV4mIBwYlIFoQSEw0KSGKJikTQ1kaIFErIPEoxQNRAdEEDyCBIJeIoNzIsRwL7DW/P94vXcPucu0OfqkUn79237yZeZ/pmdevX79uGkEQ6D8E+v/aAIoxyWdiY5LPxMYkn4mNST4TG5N8JjYm+UxsTPKZ2JjkM7ExyWdiY5LPxMYkn4mNST4TG5N8JjaYFF4rKSkpIyPDwcGhubl52bJl69evJx99+vSpUChsaGjg8XjDa2oFgiJ8/fXX1tbWHR0dBEF0dHRYW1sfO3aMrPDVV1+tXLlyNJragBo+L168YLFY33zzDZbExsbq6+u/evUKSxwdHZOTk0ejqQ2o4RMXF4cQevToEZbk5eUhhA4fPgx/CwoKdHR0Ojs7R9TUEtT4g/v37yOELC0tsWTatGkIoaKiIvibk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.display.Image object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "gtn.draw(g1, \"g1.png\")\n",
    "gtn.draw(g2, \"g2.png\")\n",
    "display(Image(\"g1.png\"), Image(\"g2.png\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAASUAAABFCAIAAACDhmfOAAAABmJLR0QA/wD/AP+gvaeTAAAexklEQVR4nO2deVwTSfbAq5Mm4Ui4CSCjHEKAhVFBhhHBgYDiNToiiOiILsoo8mFEXNHRUVHXVcH7XBQPRBB0xB3FWxRQR1QQUEQJIrAcAh4QjnCEHL8/an/9acMVkiZhnHz/IpXuVy9Fv66qV69eISKRCChRokQukBStgBIlfyGU9qZEifxQ2psSJfIDVbQCSpQohs7Ozrdv33I4HC6Xy+Fw1NXVaTSalpaWqampjo7OIFWqtDclfxWEQmFhYWFGRkZmZubLly8rKioEAkGPVzIYjL/97W/jx49nsVjjx49XV1cnSgdE6Z9U8sVTVFSUkJCQlJRUU1Ojp6fn7u7u6OjIZDKtra11dXU1NDR0dHS4XC6Xy21sbCwvL2ez2UVFRVlZWSUlJWpqarNmzVqwYIG3tzeKytw/iZQo+XK5ffu2h4cHAMDU1HTDhg35+fkCgUDy26urq48dO+bm5oYgyIgRIw4dOtTW1iaLPkp7U/Jl8vTp03HjxgEAvL2909PThUKhLNJKS0vDwsLU1NQMDQ1PnDghtTRixpN8Pv/58+clJSVsNvvDhw9tbW1cLldHR0ddXd3ExMTGxsbOzs7c3Fz2ipQo6ZempqZ169YdO3bM3d09Ojr6m2++IUpyfX399u3bjx49+s0338TGxo4aNWqgEmSyt48fP6akpFy/fv3Bgwetra19XzxixAhPT09fX9/JkyerqKhIXekXT2tr64MHDx4+fFhcXFxSUlJfX49/fw0fPtzGxubrr7/28PAYM2YMiaRc0fmM3NzcuXPntrW17d69e/78+QiCiF0gEAgKCgqgy+T169f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O6gKGptbR0cHJyUlNRjXA6Px4uJiaFSqZMmTRpogDEiEokktJbeaG5uvn///qNHj9hsNpvN/vDhA5fL5XK5Ojo6GhoaJiYmNjY2dnZ27u7uY8eO/QLyjcoNHo9XVlZWX18P21NbW5tGow0fPly6/EtSUFhYmJycnJqaWlJSoqur6+3tPW7cOCcnJ0dHxwFlvIU0NTWx2eyCgoLs7Ozs7Gw2m40giIODw7Rp06ZPn+7s7Ewifbb7+erVqzNmzEBRVE9PLysrS/I0NhkZGUuWLGloaNiyZUtoaGhvrhcAQHV1NTzjgcPhaGho0Gg0BoMxcuTIPm7JzMwMCwsrKyvbtGnTmjVrxHTuFwLsTckXT0lJydWrV9PT03Nycj5+/IiiqL29vbW1tbGxsYmJiZGRkaGhIeZtBgAIBIJPnz59/Pjx06dP79+/f/PmTXFxMUygoqGh4ezs7Orq6uLi4uLigs9+L4ZIJGIymTweLysrC/aBktPe3h4dHb1z504jI6OIiIilS5dK8YIQ4+HDh9HR0VevXvXy8jp8+LCNjY0UQpT2pmRglJWV5eTk5Obmvn37tq6urrq6ur6+vntObhRFsdDNkSNHWltb29ra2trampmZSd4nXL9+fcyYMdLl5wYAVFRUxMTEnDp1Sltbe968eQsXLnRwcBiokLq6upSUlISEhPz8fBaLtWHDhh6yJEiM0t6UEIDYKTAIgvSR1k7O1NbWxsXFJSYmvnnzxsLCgsVisVgsR0dHfO46MaqqqoqKirKysjIyMnJzc2k0mp+fX3Bw8Lhx42RURmlvSv4qZGdn37x58969e0+fPuXxeCiKmpmZ6enp0el0bW1tLpcLJ3JlZWVcLhcAYG1t7enp6eXlNW3aNNmHoxClvSn5y9He3s5ms0tKSthsNofDaW1tbWxs1NDQoNPpmpqaZmZmNjY23VPZEYLS3pQokR8D82YqUaJEFpT2pkSJ/FDamxIl8uP/AH3eepn8qwoBAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "intersect = gtn.intersect(g1, g2)\n",
    "gtn.draw(intersect, \"intersect.png\")\n",
    "Image(\"intersect.png\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1.0, 0.0, 1.0, 0.0]\n"
     ]
    }
   ],
   "source": [
    "score = gtn.viterbi_score(intersect)\n",
    "gtn.backward(score)\n",
    "\n",
    "# print gradients of arc weights \n",
    "print(g1.grad().weights_to_list()) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}