This commit is contained in:
Chris Basoglu 2017-02-02 17:40:20 -08:00
Родитель 9ddf5d9440
Коммит 6a603b0c79
9 изменённых файлов: 1359 добавлений и 285 удалений

Просмотреть файл

@ -32,7 +32,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 26,
"metadata": {
"collapsed": false
},
@ -46,14 +46,14 @@
"<IPython.core.display.Image object>"
]
},
"execution_count": 2,
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Figure 1\n",
"Image(url= \"https://www.cntk.ai/jup/cancer_data_plot.jpg\", width=400, height=400)"
"Image(url=\"https://www.cntk.ai/jup/cancer_data_plot.jpg\", width=400, height=400)"
]
},
{

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -1078,7 +1078,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.4"
"version": "3.5.2"
}
},
"nbformat": 4,

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -331,7 +331,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.5"
"version": "3.5.2"
}
},
"nbformat": 4,

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -51,11 +51,22 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Reusing locally cached: atis.train.ctf\n",
"Reusing locally cached: query.wl\n",
"Reusing locally cached: atis.test.ctf\n",
"Reusing locally cached: slots.wl\n"
]
}
],
"source": [
"from __future__ import print_function\n",
"import requests\n",
@ -104,7 +115,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {
"collapsed": true
},
@ -206,7 +217,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {
"collapsed": false
},
@ -239,11 +250,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3\n",
"(-1, 150)\n",
"[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n",
" 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n",
" 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n",
" 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n",
" 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n",
" 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n",
" 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n",
" 0. 0. 0.]\n"
]
}
],
"source": [
"# peek\n",
"model = create_model()\n",
@ -305,7 +333,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {
"collapsed": true
},
@ -321,11 +349,22 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"dict_keys(['slot_labels', 'query', 'intent_unused'])"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# peek\n",
"reader = create_reader(data['train']['file'], is_training=True)\n",
@ -343,7 +382,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {
"collapsed": true
},
@ -358,7 +397,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {
"collapsed": false
},
@ -430,12 +469,36 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {
"collapsed": false,
"scrolled": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Training 721479 parameters in 6 parameter tensors.\n",
"Finished Epoch[1 of 300]: [Training] loss = 1.108586 * 18010, metric = 20.8% * 18010 13.090s (1375.9 samples per second);\n",
"Finished Epoch[2 of 300]: [Training] loss = 0.443000 * 18051, metric = 9.7% * 18051 12.866s (1402.9 samples per second);\n",
"Finished Epoch[3 of 300]: [Training] loss = 0.291663 * 17941, metric = 6.1% * 17941 12.628s (1420.7 samples per second);\n",
"Finished Epoch[4 of 300]: [Training] loss = 0.212427 * 18059, metric = 4.7% * 18059 13.179s (1370.3 samples per second);\n",
"Finished Epoch[5 of 300]: [Training] loss = 0.159109 * 17957, metric = 3.5% * 17957 13.460s (1334.1 samples per second);\n",
"Finished Epoch[6 of 300]: [Training] loss = 0.142233 * 18021, metric = 3.2% * 18021 12.812s (1406.6 samples per second);\n",
"Finished Epoch[7 of 300]: [Training] loss = 0.117930 * 17980, metric = 2.5% * 17980 12.755s (1409.7 samples per second);\n",
"Finished Epoch[8 of 300]: [Training] loss = 0.120242 * 18025, metric = 2.6% * 18025 13.086s (1377.4 samples per second);\n",
"Finished Epoch[9 of 300]: [Training] loss = 0.080922 * 17956, metric = 1.9% * 17956 12.716s (1412.0 samples per second);\n",
"Finished Epoch[10 of 300]: [Training] loss = 0.082358 * 18039, metric = 1.9% * 18039 13.141s (1372.7 samples per second);\n",
"Finished Epoch[11 of 300]: [Training] loss = 0.088115 * 17966, metric = 1.9% * 17966 12.965s (1385.7 samples per second);\n",
"Finished Epoch[12 of 300]: [Training] loss = 0.062569 * 18041, metric = 1.4% * 18041 13.068s (1380.5 samples per second);\n",
"Finished Epoch[13 of 300]: [Training] loss = 0.063911 * 17984, metric = 1.4% * 17984 13.241s (1358.2 samples per second);\n",
"Finished Epoch[14 of 300]: [Training] loss = 0.068551 * 17976, metric = 1.6% * 17976 12.712s (1414.1 samples per second);\n",
"Finished Epoch[15 of 300]: [Training] loss = 0.060651 * 18030, metric = 1.4% * 18030 13.285s (1357.2 samples per second);\n",
"Finished Epoch[16 of 300]: [Training] loss = 0.051129 * 18014, metric = 1.1% * 18014 13.033s (1382.2 samples per second);\n"
]
}
],
"source": [
"def do_train():\n",
" global model\n",
@ -483,7 +546,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {
"collapsed": false
},
@ -525,11 +588,54 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Finished Epoch[1 of 300]: [Evaluation] loss = 0.000000 * 10984, metric = 2.8% * 10984 0.647s (16965.9 samples per second);\n"
]
},
{
"data": {
"text/plain": [
"array([-0.02837791, 0.19204265, 0.29575372, -0.19598489, -0.03410583,\n",
" -0.09407807, -0.23284099, -0.37752533, -0.2996434 , -0.44769478,\n",
" -0.23132119, -0.2716696 , -0.13469625, -0.30815303, 0.09526856,\n",
" 0.01435822, -0.56383151, -0.13835213, 0.36700198, -0.60481507,\n",
" 0.18038388, -0.04562518, -0.24895094, -0.42717773, -0.35798934,\n",
" 0.02361358, -0.2970126 , -0.17301746, -0.0318042 , -0.07101922,\n",
" -0.01057271, -0.20784923, 0.14633928, 0.35873517, -0.30594927,\n",
" 0.83192152, 0.32804897, 0.21413325, -0.02653755, -0.14812283,\n",
" -0.59234017, 0.02362779, 0.62482691, 0.21642356, 0.58094913,\n",
" 0.09689096, -0.12468328, -0.02449773, 0.14254686, -0.20319419,\n",
" -0.19622359, -0.09245761, -0.16968884, 0.22517064, 0.11014255,\n",
" -0.40459141, 0.23276719, -0.27685553, -0.18674734, -0.22256836,\n",
" -0.48430341, -0.30435693, -0.27846664, -0.52346534, -0.42545739,\n",
" -0.36948976, 0.36679974, -0.27925539, -0.43974242, -0.57423311,\n",
" -0.50748855, -0.38508397, -0.30795985, -0.4344044 , -0.50801384,\n",
" -0.46579114, -0.19437374, -0.04424706, -0.20896095, -0.32787323,\n",
" -0.29886407, -0.07475597, 0.09180388, -0.39841416, 0.03586446,\n",
" -0.20788129, -0.24650115, -0.33564699, -0.32168835, -0.03352401,\n",
" -0.48295277, 0.0352855 , -0.04374436, -0.2690483 , -0.28284746,\n",
" -0.27865919, -0.01388162, -0.22930908, -0.26097232, -0.24932495,\n",
" 0.2572065 , -0.41016701, -0.1311882 , -0.17149781, -0.4189409 ,\n",
" -0.03129933, -0.56162113, -0.0477305 , -0.07687513, 0.15989842,\n",
" -0.2717641 , -0.27184549, -0.30999917, -0.50349414, -0.44162413,\n",
" -0.20479326, -0.38902384, -0.48902571, -0.41697139, -0.06563264,\n",
" -0.6132099 , -0.14931475, -0.48903835, -0.39283147, 0.03994769,\n",
" -0.30232415, -0.16384917, -0.12924846, 0.43041009], dtype=float32)"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def do_test():\n",
" reader = create_reader(data['test']['file'], is_training=False)\n",
@ -547,11 +653,38 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[178, 429, 444, 619, 937, 851, 752, 179]\n",
"(1, 8, 129)\n",
"[128 128 128 48 110 128 78 128]\n"
]
},
{
"data": {
"text/plain": [
"[('BOS', 'O'),\n",
" ('flights', 'O'),\n",
" ('from', 'O'),\n",
" ('new', 'B-fromloc.city_name'),\n",
" ('york', 'I-fromloc.city_name'),\n",
" ('to', 'O'),\n",
" ('seattle', 'B-toloc.city_name'),\n",
" ('EOS', 'O')]"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# load dictionaries\n",
"query_wl = [line.rstrip('\\n') for line in open(data['query']['file'])]\n",
@ -653,7 +786,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"metadata": {
"collapsed": false
},
@ -699,7 +832,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"metadata": {
"collapsed": false
},
@ -786,7 +919,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"metadata": {
"collapsed": false
},
@ -826,11 +959,36 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 16,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Training 722379 parameters in 10 parameter tensors.\n",
"Finished Epoch[1 of 300]: [Training] loss = 0.437275 * 18010, metric = 7.9% * 18010 13.667s (1317.8 samples per second);\n",
"Finished Epoch[2 of 300]: [Training] loss = 0.165572 * 18051, metric = 3.6% * 18051 13.570s (1330.2 samples per second);\n",
"Finished Epoch[3 of 300]: [Training] loss = 0.115475 * 17941, metric = 2.4% * 17941 13.493s (1329.6 samples per second);\n",
"Finished Epoch[4 of 300]: [Training] loss = 0.082943 * 18059, metric = 2.0% * 18059 13.849s (1304.0 samples per second);\n",
"Finished Epoch[5 of 300]: [Training] loss = 0.045742 * 17957, metric = 1.1% * 17957 13.508s (1329.4 samples per second);\n",
"Finished Epoch[6 of 300]: [Training] loss = 0.045034 * 18021, metric = 1.2% * 18021 13.342s (1350.7 samples per second);\n",
"Finished Epoch[7 of 300]: [Training] loss = 0.038062 * 17980, metric = 1.0% * 17980 13.709s (1311.6 samples per second);\n",
"Finished Epoch[8 of 300]: [Training] loss = 0.031484 * 18025, metric = 0.8% * 18025 13.487s (1336.5 samples per second);\n",
"Finished Epoch[9 of 300]: [Training] loss = 0.020861 * 17956, metric = 0.6% * 17956 13.639s (1316.5 samples per second);\n",
"Finished Epoch[10 of 300]: [Training] loss = 0.023312 * 18039, metric = 0.7% * 18039 13.460s (1340.2 samples per second);\n",
"Finished Epoch[11 of 300]: [Training] loss = 0.025335 * 17966, metric = 0.7% * 17966 13.608s (1320.3 samples per second);\n",
"Finished Epoch[12 of 300]: [Training] loss = 0.014906 * 18041, metric = 0.4% * 18041 13.376s (1348.8 samples per second);\n",
"Finished Epoch[13 of 300]: [Training] loss = 0.015349 * 17984, metric = 0.5% * 17984 14.100s (1275.4 samples per second);\n",
"Finished Epoch[14 of 300]: [Training] loss = 0.016894 * 17976, metric = 0.5% * 17976 13.360s (1345.5 samples per second);\n",
"Finished Epoch[15 of 300]: [Training] loss = 0.016119 * 18030, metric = 0.5% * 18030 13.652s (1320.7 samples per second);\n",
"Finished Epoch[16 of 300]: [Training] loss = 0.012435 * 18014, metric = 0.4% * 18014 13.647s (1320.0 samples per second);\n",
"Finished Epoch[1 of 300]: [Evaluation] loss = 0.000000 * 10984, metric = 2.0% * 10984 0.667s (16462.5 samples per second);\n"
]
}
],
"source": [
"def create_model():\n",
" with default_options(initial_state=0.1):\n",
@ -855,11 +1013,36 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 17,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Training 901479 parameters in 6 parameter tensors.\n",
"Finished Epoch[1 of 300]: [Training] loss = 1.046946 * 18010, metric = 19.5% * 18010 13.865s (1299.0 samples per second);\n",
"Finished Epoch[2 of 300]: [Training] loss = 0.370800 * 18051, metric = 8.3% * 18051 13.772s (1310.7 samples per second);\n",
"Finished Epoch[3 of 300]: [Training] loss = 0.242616 * 17941, metric = 5.3% * 17941 13.461s (1332.8 samples per second);\n",
"Finished Epoch[4 of 300]: [Training] loss = 0.162854 * 18059, metric = 3.8% * 18059 13.991s (1290.7 samples per second);\n",
"Finished Epoch[5 of 300]: [Training] loss = 0.116818 * 17957, metric = 2.6% * 17957 13.890s (1292.8 samples per second);\n",
"Finished Epoch[6 of 300]: [Training] loss = 0.102683 * 18021, metric = 2.2% * 18021 13.608s (1324.3 samples per second);\n",
"Finished Epoch[7 of 300]: [Training] loss = 0.087191 * 17980, metric = 2.0% * 17980 13.624s (1319.7 samples per second);\n",
"Finished Epoch[8 of 300]: [Training] loss = 0.083708 * 18025, metric = 1.8% * 18025 13.735s (1312.3 samples per second);\n",
"Finished Epoch[9 of 300]: [Training] loss = 0.054805 * 17956, metric = 1.1% * 17956 14.533s (1235.5 samples per second);\n",
"Finished Epoch[10 of 300]: [Training] loss = 0.056238 * 18039, metric = 1.2% * 18039 14.586s (1236.7 samples per second);\n",
"Finished Epoch[11 of 300]: [Training] loss = 0.059140 * 17966, metric = 1.4% * 17966 14.027s (1280.8 samples per second);\n",
"Finished Epoch[12 of 300]: [Training] loss = 0.039401 * 18041, metric = 0.8% * 18041 14.516s (1242.8 samples per second);\n",
"Finished Epoch[13 of 300]: [Training] loss = 0.042961 * 17984, metric = 0.9% * 17984 14.968s (1201.5 samples per second);\n",
"Finished Epoch[14 of 300]: [Training] loss = 0.046064 * 17976, metric = 1.0% * 17976 14.820s (1213.0 samples per second);\n",
"Finished Epoch[15 of 300]: [Training] loss = 0.036290 * 18030, metric = 0.8% * 18030 14.775s (1220.3 samples per second);\n",
"Finished Epoch[16 of 300]: [Training] loss = 0.034278 * 18014, metric = 0.8% * 18014 14.049s (1282.2 samples per second);\n",
"Finished Epoch[1 of 300]: [Evaluation] loss = 0.000000 * 10984, metric = 2.2% * 10984 0.686s (16001.2 samples per second);\n"
]
}
],
"source": [
"def OneWordLookahead():\n",
" x = Placeholder()\n",
@ -888,11 +1071,36 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 18,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Training 541479 parameters in 9 parameter tensors.\n",
"Finished Epoch[1 of 300]: [Training] loss = 1.062458 * 18010, metric = 19.8% * 18010 23.600s (763.1 samples per second);\n",
"Finished Epoch[2 of 300]: [Training] loss = 0.403749 * 18051, metric = 8.9% * 18051 23.130s (780.4 samples per second);\n",
"Finished Epoch[3 of 300]: [Training] loss = 0.258083 * 17941, metric = 5.6% * 17941 23.774s (754.7 samples per second);\n",
"Finished Epoch[4 of 300]: [Training] loss = 0.180761 * 18059, metric = 4.2% * 18059 24.032s (751.4 samples per second);\n",
"Finished Epoch[5 of 300]: [Training] loss = 0.130766 * 17957, metric = 2.9% * 17957 23.146s (775.8 samples per second);\n",
"Finished Epoch[6 of 300]: [Training] loss = 0.116795 * 18021, metric = 2.4% * 18021 23.495s (767.0 samples per second);\n",
"Finished Epoch[7 of 300]: [Training] loss = 0.098472 * 17980, metric = 2.2% * 17980 22.901s (785.1 samples per second);\n",
"Finished Epoch[8 of 300]: [Training] loss = 0.096911 * 18025, metric = 2.1% * 18025 23.063s (781.6 samples per second);\n",
"Finished Epoch[9 of 300]: [Training] loss = 0.063399 * 17956, metric = 1.3% * 17956 23.379s (768.0 samples per second);\n",
"Finished Epoch[10 of 300]: [Training] loss = 0.064536 * 18039, metric = 1.5% * 18039 22.913s (787.3 samples per second);\n",
"Finished Epoch[11 of 300]: [Training] loss = 0.068733 * 17966, metric = 1.5% * 17966 22.883s (785.1 samples per second);\n",
"Finished Epoch[12 of 300]: [Training] loss = 0.047495 * 18041, metric = 1.1% * 18041 22.561s (799.6 samples per second);\n",
"Finished Epoch[13 of 300]: [Training] loss = 0.053885 * 17984, metric = 1.2% * 17984 23.638s (760.8 samples per second);\n",
"Finished Epoch[14 of 300]: [Training] loss = 0.056533 * 17976, metric = 1.2% * 17976 22.605s (795.2 samples per second);\n",
"Finished Epoch[15 of 300]: [Training] loss = 0.041905 * 18030, metric = 0.9% * 18030 23.237s (775.9 samples per second);\n",
"Finished Epoch[16 of 300]: [Training] loss = 0.043438 * 18014, metric = 1.0% * 18014 22.966s (784.4 samples per second);\n",
"Finished Epoch[1 of 300]: [Evaluation] loss = 0.000000 * 10984, metric = 2.0% * 10984 1.037s (10587.4 samples per second);\n"
]
}
],
"source": [
"def BiRecurrence(fwd, bwd):\n",
" F = Recurrence(fwd)\n",
@ -940,7 +1148,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
"version": "3.5.2"
}
},
"nbformat": 4,

Различия файлов скрыты, потому что одна или несколько строк слишком длинны