Skip to content

Commit

Permalink
added
Browse files Browse the repository at this point in the history
  • Loading branch information
nipunbatra committed May 30, 2024
1 parent 0bcfcc5 commit d37fecd
Show file tree
Hide file tree
Showing 2 changed files with 854 additions and 1 deletion.
285 changes: 284 additions & 1 deletion posts/2024-attention.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -703,9 +703,292 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 71,
"id": "453dc18a",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>0</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" <th>3</th>\n",
" <th>4</th>\n",
" <th>5</th>\n",
" <th>6</th>\n",
" <th>7</th>\n",
" <th>8</th>\n",
" <th>9</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0.102279</td>\n",
" <td>0.116902</td>\n",
" <td>0.095548</td>\n",
" <td>0.103101</td>\n",
" <td>0.090652</td>\n",
" <td>0.092365</td>\n",
" <td>0.103101</td>\n",
" <td>0.102647</td>\n",
" <td>0.097894</td>\n",
" <td>0.095509</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0.098137</td>\n",
" <td>0.103838</td>\n",
" <td>0.096373</td>\n",
" <td>0.100781</td>\n",
" <td>0.096004</td>\n",
" <td>0.100102</td>\n",
" <td>0.100781</td>\n",
" <td>0.104920</td>\n",
" <td>0.097907</td>\n",
" <td>0.101158</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0.099379</td>\n",
" <td>0.096506</td>\n",
" <td>0.099920</td>\n",
" <td>0.098203</td>\n",
" <td>0.107403</td>\n",
" <td>0.102867</td>\n",
" <td>0.098203</td>\n",
" <td>0.097955</td>\n",
" <td>0.099648</td>\n",
" <td>0.099917</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>0.100661</td>\n",
" <td>0.107542</td>\n",
" <td>0.096716</td>\n",
" <td>0.102229</td>\n",
" <td>0.092731</td>\n",
" <td>0.096318</td>\n",
" <td>0.102229</td>\n",
" <td>0.103722</td>\n",
" <td>0.098675</td>\n",
" <td>0.099177</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0.093831</td>\n",
" <td>0.089897</td>\n",
" <td>0.094899</td>\n",
" <td>0.091359</td>\n",
" <td>0.157125</td>\n",
" <td>0.103029</td>\n",
" <td>0.091359</td>\n",
" <td>0.090467</td>\n",
" <td>0.093837</td>\n",
" <td>0.094197</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>0.103120</td>\n",
" <td>0.109096</td>\n",
" <td>0.096438</td>\n",
" <td>0.103056</td>\n",
" <td>0.091776</td>\n",
" <td>0.094960</td>\n",
" <td>0.103056</td>\n",
" <td>0.100971</td>\n",
" <td>0.098732</td>\n",
" <td>0.098796</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>0.100661</td>\n",
" <td>0.107542</td>\n",
" <td>0.096716</td>\n",
" <td>0.102229</td>\n",
" <td>0.092731</td>\n",
" <td>0.096318</td>\n",
" <td>0.102229</td>\n",
" <td>0.103722</td>\n",
" <td>0.098675</td>\n",
" <td>0.099177</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>0.094160</td>\n",
" <td>0.128211</td>\n",
" <td>0.092408</td>\n",
" <td>0.100973</td>\n",
" <td>0.090542</td>\n",
" <td>0.092696</td>\n",
" <td>0.100973</td>\n",
" <td>0.109109</td>\n",
" <td>0.093650</td>\n",
" <td>0.097276</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>0.100667</td>\n",
" <td>0.109200</td>\n",
" <td>0.097085</td>\n",
" <td>0.102458</td>\n",
" <td>0.092360</td>\n",
" <td>0.095326</td>\n",
" <td>0.102458</td>\n",
" <td>0.103196</td>\n",
" <td>0.098727</td>\n",
" <td>0.098525</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>0.104278</td>\n",
" <td>0.101318</td>\n",
" <td>0.098286</td>\n",
" <td>0.101434</td>\n",
" <td>0.094502</td>\n",
" <td>0.098512</td>\n",
" <td>0.101434</td>\n",
" <td>0.099883</td>\n",
" <td>0.100485</td>\n",
" <td>0.099867</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0 1 2 3 4 5 6 \\\n",
"0 0.102279 0.116902 0.095548 0.103101 0.090652 0.092365 0.103101 \n",
"1 0.098137 0.103838 0.096373 0.100781 0.096004 0.100102 0.100781 \n",
"2 0.099379 0.096506 0.099920 0.098203 0.107403 0.102867 0.098203 \n",
"3 0.100661 0.107542 0.096716 0.102229 0.092731 0.096318 0.102229 \n",
"4 0.093831 0.089897 0.094899 0.091359 0.157125 0.103029 0.091359 \n",
"5 0.103120 0.109096 0.096438 0.103056 0.091776 0.094960 0.103056 \n",
"6 0.100661 0.107542 0.096716 0.102229 0.092731 0.096318 0.102229 \n",
"7 0.094160 0.128211 0.092408 0.100973 0.090542 0.092696 0.100973 \n",
"8 0.100667 0.109200 0.097085 0.102458 0.092360 0.095326 0.102458 \n",
"9 0.104278 0.101318 0.098286 0.101434 0.094502 0.098512 0.101434 \n",
"\n",
" 7 8 9 \n",
"0 0.102647 0.097894 0.095509 \n",
"1 0.104920 0.097907 0.101158 \n",
"2 0.097955 0.099648 0.099917 \n",
"3 0.103722 0.098675 0.099177 \n",
"4 0.090467 0.093837 0.094197 \n",
"5 0.100971 0.098732 0.098796 \n",
"6 0.103722 0.098675 0.099177 \n",
"7 0.109109 0.093650 0.097276 \n",
"8 0.103196 0.098727 0.098525 \n",
"9 0.099883 0.100485 0.099867 "
]
},
"execution_count": 71,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = pd.DataFrame(attns.detach().numpy())\n",
"df"
]
},
{
"cell_type": "code",
"execution_count": 73,
"id": "309f12fe",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 1.0\n",
"1 1.0\n",
"2 1.0\n",
"3 1.0\n",
"4 1.0\n",
"5 1.0\n",
"6 1.0\n",
"7 1.0\n",
"8 1.0\n",
"9 1.0\n",
"dtype: float32"
]
},
"execution_count": 73,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.sum(axis=1)"
]
},
{
"cell_type": "code",
"execution_count": 77,
"id": "5a46630a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"torch.Size([10, 10, 8])"
]
},
"execution_count": 77,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"updated_embedding_1.shape"
]
},
{
"cell_type": "code",
"execution_count": 78,
"id": "d82992c5",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"torch.Size([1, 8])"
]
},
"execution_count": 78,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"vs[0].shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f73b719a",
"metadata": {},
"outputs": [],
"source": []
}
Expand Down
570 changes: 570 additions & 0 deletions posts/2024-forecast.ipynb

Large diffs are not rendered by default.

0 comments on commit d37fecd

Please sign in to comment.