Skip to content

Commit 46e2d0a

Browse files
committed
Rebuild
1 parent a69602f commit 46e2d0a

File tree

54 files changed

+4413
-4401
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+4413
-4401
lines changed

β€Ždocs/_downloads/03a48646520c277662581e858e680809/model_parallel_tutorial.ipynbβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
},
124124
"outputs": [],
125125
"source": [
126-
"# \uc2e4\ud5d8 \uacb0\uacfc, \ubaa8\ub378 \ubcd1\ub82c \ucca0\ub9ac\ud558\uc5ec \ud559\uc2b5\ud558\ub294 \uc2dc\uac04\uc774 \ub2e8\uc77c GPU\ub85c \ud559\uc2b5\ud558\ub294 \uc2dc\uac04\ubcf4\ub2e4 \uc57d 7% ``4.02/3.75-1=7%``\uc815\ub3c4\n# \uc624\ub798 \uac78\ub9ac\ub294 \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uadf8\ub7ec\ubbc0\ub85c, \uc21c\uc804\ud30c\uc640 \uc5ed\uc804\ud30c\ub97c \uc9c4\ud589\ud558\uba74\uc11c GPU \uac04 \ud150\uc11c\uac12\ub4e4\uc774\n# \ubcf5\uc81c\ub418\uc5b4 \uc774\uc6a9\ud558\ub294 \uc2dc\uac04\uc774 \uc57d 7%\uc815\ub3c4 \uc18c\uc694\ub418\ub294 \uac83\uc73c\ub85c \uacb0\ub860\uc9c0\uc744 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \ud559\uc2b5\ud558\ub294 \uacfc\uc815 \uc18d\uc5d0\uc11c\n# 2\uac1c\uc758 GPU \uc911 1\uac1c\uc758 GPU\uac00 \uacc4\uc0b0\ud558\uc9c0 \uc54a\uace0 \ub300\uae30\ud558\uace0 \uc788\uae30 \ub54c\ubb38\uc5d0, \uc774\ub97c \ud574\uacb0\ud558\uc5ec\n# \ud559\uc2b5 \uc2dc\uac04\uc744 \ube60\ub974\uac8c \uac1c\uc120\uc2dc\ud0ac \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uadf8 \uc911 \ud55c \uac00\uc9c0 \ubc29\ubc95\uc740, \ud559\uc2b5 \ub2e8\uc704\uc778 \ubbf8\ub2c8 \ubc30\uce58 1\uac1c\uc758 \ub370\uc774\ud130\ub97c\n# 2\uac1c\ub85c \ubd84\ud560\ud558\ub294 \ud30c\uc774\ud504\ub77c\uc778\uc744 \uc0dd\uc131\ud558\uc5ec, \ubd84\ud560\ub41c \uccab \ubc88\uc9f8 \ub370\uc774\ud130\uac00 \uccab \ubc88\uc9f8 \uce35\uc744 \ud1b5\uacfc\ud558\uc5ec \ub450 \ubc88\uc9f8 \uce35\uc73c\ub85c\n# \ubcf5\uc81c\ub418\uace0, \ub450 \ubc88\uc9f8 \uce35\uc744 \ud1b5\uacfc\ud560 \ub54c, \ub450\ubc88\uc7ac\ub85c \ubd84\ud560\ub41c \ub370\uc774\ud130\uac00 \uccab \ubc88\uca30 \uce35\uc744 \ud1b5\ud574 \uacc4\uc0b0\ub418\ub294 \ubc29\uc2dd\uc73c\ub85c \uc124\uc815\ud558\ub294 \uac83\uc785\ub2c8\ub2e4.\n# \uc774\ub7ec\ud55c \ubc29\ubc95\uc744 \ud1b5\ud574\uc11c 2\uac1c\uc758 GPU\uac00 2\uac1c\ub85c \ubd84\ud560\ub41c \ub370\uc774\ud130\ub97c \ub3d9\uc2dc\uc5d0 \ucc98\ub9ac\ud560 \uc218 \uc788\uc73c\uba70 \ud559\uc2b5 \uc2dc\uac04\uc744 \ub2e8\ucd95\uc2dc\ud0ac \uc218 \uc788\uc2b5\ub2c8\ub2e4."
126+
"# \uc2e4\ud5d8 \uacb0\uacfc, \ubaa8\ub378 \ubcd1\ub82c \ucc98\ub9ac\ud558\uc5ec \ud559\uc2b5\ud558\ub294 \uc2dc\uac04\uc774 \ub2e8\uc77c GPU\ub85c \ud559\uc2b5\ud558\ub294 \uc2dc\uac04\ubcf4\ub2e4 \uc57d 7% ``4.02/3.75-1=7%``\uc815\ub3c4\n# \uc624\ub798 \uac78\ub9ac\ub294 \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uadf8\ub7ec\ubbc0\ub85c, \uc21c\uc804\ud30c\uc640 \uc5ed\uc804\ud30c\ub97c \uc9c4\ud589\ud558\uba74\uc11c GPU \uac04 \ud150\uc11c\uac12\ub4e4\uc774\n# \ubcf5\uc81c\ub418\uc5b4 \uc774\uc6a9\ud558\ub294 \uc2dc\uac04\uc774 \uc57d 7%\uc815\ub3c4 \uc18c\uc694\ub418\ub294 \uac83\uc73c\ub85c \uacb0\ub860\uc9c0\uc744 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \ud559\uc2b5\ud558\ub294 \uacfc\uc815 \uc18d\uc5d0\uc11c\n# 2\uac1c\uc758 GPU \uc911 1\uac1c\uc758 GPU\uac00 \uacc4\uc0b0\ud558\uc9c0 \uc54a\uace0 \ub300\uae30\ud558\uace0 \uc788\uae30 \ub54c\ubb38\uc5d0, \uc774\ub97c \ud574\uacb0\ud558\uc5ec\n# \ud559\uc2b5 \uc2dc\uac04\uc744 \ube60\ub974\uac8c \uac1c\uc120\uc2dc\ud0ac \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uadf8 \uc911 \ud55c \uac00\uc9c0 \ubc29\ubc95\uc740, \ud559\uc2b5 \ub2e8\uc704\uc778 \ubbf8\ub2c8 \ubc30\uce58 1\uac1c\uc758 \ub370\uc774\ud130\ub97c\n# 2\uac1c\ub85c \ubd84\ud560\ud558\ub294 \ud30c\uc774\ud504\ub77c\uc778\uc744 \uc0dd\uc131\ud558\uc5ec, \ubd84\ud560\ub41c \uccab \ubc88\uc9f8 \ub370\uc774\ud130\uac00 \uccab \ubc88\uc9f8 \uce35\uc744 \ud1b5\uacfc\ud558\uc5ec \ub450 \ubc88\uc9f8 \uce35\uc73c\ub85c\n# \ubcf5\uc81c\ub418\uace0, \ub450 \ubc88\uc9f8 \uce35\uc744 \ud1b5\uacfc\ud560 \ub54c, \ub450\ubc88\uc7ac\ub85c \ubd84\ud560\ub41c \ub370\uc774\ud130\uac00 \uccab \ubc88\uca30 \uce35\uc744 \ud1b5\ud574 \uacc4\uc0b0\ub418\ub294 \ubc29\uc2dd\uc73c\ub85c \uc124\uc815\ud558\ub294 \uac83\uc785\ub2c8\ub2e4.\n# \uc774\ub7ec\ud55c \ubc29\ubc95\uc744 \ud1b5\ud574\uc11c 2\uac1c\uc758 GPU\uac00 2\uac1c\ub85c \ubd84\ud560\ub41c \ub370\uc774\ud130\ub97c \ub3d9\uc2dc\uc5d0 \ucc98\ub9ac\ud560 \uc218 \uc788\uc73c\uba70 \ud559\uc2b5 \uc2dc\uac04\uc744 \ub2e8\ucd95\uc2dc\ud0ac \uc218 \uc788\uc2b5\ub2c8\ub2e4."
127127
]
128128
},
129129
{

β€Ždocs/_downloads/1b58d206e701317cf46c92dcf2a8978d/parallelism_tutorial.ipynbβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"cell_type": "markdown",
3434
"metadata": {},
3535
"source": [
36-
"CPU \ubaa8\ub4dc\uc778 \ucf54\ub4dc\ub97c \ubc14\uafc0 \ud544\uc694\uac00 \uc5c6\uc2b5\ub2c8\ub2e4.\n\nDataParallel\uc5d0 \ub300\ud55c \ubb38\uc11c\ub294 [\uc5ec\uae30](https://pytorch.org/docs/stable/nn.html#dataparallel-layers-multi-gpu-distributed)\n\uc5d0\uc11c \ud655\uc778\ud558\uc2e4 \uc218 \uc788\uc2b5\ub2c8\ub2e4.\n\n**\ub798\ud551\ub41c \ubaa8\ub4c8\uc758 \uc18d\uc131**\n\n\ubaa8\ub4c8\uc744 ``DataParallel`` \ub85c \uac10\uc2fc \ud6c4\uc5d0\ub294 \ubaa8\ub4c8\uc758 \uc18d\uc131(\uc608. \uc0ac\uc6a9\uc790 \uc815\uc758 \uba54\uc18c\ub4dc)\uc5d0\n\uc811\uadfc\ud560 \uc218 \uc5c6\uac8c \ub429\ub2c8\ub2e4. \uc774\ub294 ``DataParallel`` \uc774 \uba87\uba87 \uc0c8\ub85c\uc6b4 \uba64\ubc84\ub97c \uc815\uc758\ud558\uae30 \ub584\ubb38\uc5d0\n\ub2e4\ub978 \uc18d\uc131\uc5d0 \uc811\uadfc\uc744 \ud5c8\uc6a9\ud558\ub294 \uac83\uc774 \ucda9\ub3cc\uc744 \uc77c\uc73c\ud0ac \uc218\ub3c4 \uc788\uae30 \ub54c\ubb38\uc785\ub2c8\ub2e4.\n\uadf8\ub798\ub3c4 \uc18d\uc131\uc5d0 \uc811\uadfc\ud558\uace0\uc790 \ud55c\ub2e4\uba74 \uc544\ub798\uc640 \uac19\uc774 ``DataParallel`` \uc758 \uc11c\ube0c\ud074\ub798\uc2a4\ub97c\n\uc0ac\uc6a9\ud558\ub294 \uac83\uc774 \uc88b\uc2b5\ub2c8\ub2e4.\n\n"
36+
"CPU \ubaa8\ub4dc\uc778 \ucf54\ub4dc\ub97c \ubc14\uafc0 \ud544\uc694\uac00 \uc5c6\uc2b5\ub2c8\ub2e4.\n\nDataParallel\uc5d0 \ub300\ud55c \ubb38\uc11c\ub294 [\uc5ec\uae30](https://pytorch.org/docs/stable/nn.html#dataparallel-layers-multi-gpu-distributed)\n\uc5d0\uc11c \ud655\uc778\ud558\uc2e4 \uc218 \uc788\uc2b5\ub2c8\ub2e4.\n\n**\ub798\ud551\ub41c \ubaa8\ub4c8\uc758 \uc18d\uc131**\n\n\ubaa8\ub4c8\uc744 ``DataParallel`` \ub85c \uac10\uc2fc \ud6c4\uc5d0\ub294 \ubaa8\ub4c8\uc758 \uc18d\uc131(\uc608. \uc0ac\uc6a9\uc790 \uc815\uc758 \uba54\uc18c\ub4dc)\uc5d0\n\uc811\uadfc\ud560 \uc218 \uc5c6\uac8c \ub429\ub2c8\ub2e4. \uc774\ub294 ``DataParallel`` \uc774 \uba87\uba87 \uc0c8\ub85c\uc6b4 \uba64\ubc84\ub97c \uc815\uc758\ud558\uae30 \ub54c\ubb38\uc5d0\n\ub2e4\ub978 \uc18d\uc131\uc5d0 \uc811\uadfc\uc744 \ud5c8\uc6a9\ud558\ub294 \uac83\uc774 \ucda9\ub3cc\uc744 \uc77c\uc73c\ud0ac \uc218\ub3c4 \uc788\uae30 \ub54c\ubb38\uc785\ub2c8\ub2e4.\n\uadf8\ub798\ub3c4 \uc18d\uc131\uc5d0 \uc811\uadfc\ud558\uace0\uc790 \ud55c\ub2e4\uba74 \uc544\ub798\uc640 \uac19\uc774 ``DataParallel`` \uc758 \uc11c\ube0c\ud074\ub798\uc2a4\ub97c\n\uc0ac\uc6a9\ud558\ub294 \uac83\uc774 \uc88b\uc2b5\ub2c8\ub2e4.\n\n"
3737
]
3838
},
3939
{
6.46 KB
Loading

β€Ždocs/_downloads/363afc3b7c522e4e56981679c22f1ad6/word_embeddings_tutorial.ipynbβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
},
5656
"outputs": [],
5757
"source": [
58-
"CONTEXT_SIZE = 2\nEMBEDDING_DIM = 10\n# \uc170\uc775\uc2a4\ud53c\uc5b4 \uc18c\ub124\ud2b8(Sonnet) 2\ub97c \uc0ac\uc6a9\ud558\uaca0\uc2b5\ub2c8\ub2e4.\ntest_sentence = \"\"\"When forty winters shall besiege thy brow,\nAnd dig deep trenches in thy beauty's field,\nThy youth's proud livery so gazed on now,\nWill be a totter'd weed of small worth held:\nThen being asked, where all thy beauty lies,\nWhere all the treasure of thy lusty days;\nTo say, within thine own deep sunken eyes,\nWere an all-eating shame, and thriftless praise.\nHow much more praise deserv'd thy beauty's use,\nIf thou couldst answer 'This fair child of mine\nShall sum my count, and make my old excuse,'\nProving his beauty by succession thine!\nThis were to be new made when thou art old,\nAnd see thy blood warm when thou feel'st it cold.\"\"\".split()\n# \uc6d0\ub798\ub294 \uc785\ub825\uc744 \uc81c\ub300\ub85c \ud1a0\ud070\ud654(tokenize) \ud574\uc57c\ud558\uc9c0\ub9cc \uc774\ubc88\uc5d4 \uac04\uc18c\ud654\ud558\uc5ec \uc9c4\ud589\ud558\uaca0\uc2b5\ub2c8\ub2e4.\n# \ud29c\ud50c\ub85c \uc774\ub8e8\uc5b4\uc9c4 \ub9ac\uc2a4\ud2b8\ub97c \ub9cc\ub4e4\uaca0\uc2b5\ub2c8\ub2e4. \uac01 \ud29c\ud50c\uc740 ([ i-CONTEXT_SIZE \ubc88\uc9f8 \ub2e8\uc5b4, ..., i-1 \ubc88\uc9f8 \ub2e8\uc5b4 ], \ubaa9\ud45c \ub2e8\uc5b4)\uc785\ub2c8\ub2e4.\nngrams = [\n (\n [test_sentence[i - j - 1] for j in range(CONTEXT_SIZE)],\n test_sentence[i]\n )\n for i in range(CONTEXT_SIZE, len(test_sentence))\n]\n# \uccab 3\uac1c\uc758 \ud29c\ud50c\uc744 \ucd9c\ub825\ud558\uc5ec \ub370\uc774\ud130\uac00 \uc5b4\ub5bb\uac8c \uc0dd\uacbc\ub294\uc9c0 \ubcf4\uaca0\uc2b5\ub2c8\ub2e4.\nprint(ngrams[:3])\n\nvocab = set(test_sentence)\nword_to_ix = {word: i for i, word in enumerate(vocab)}\n\n\nclass NGramLanguageModeler(nn.Module):\n\n def __init__(self, vocab_size, embedding_dim, context_size):\n super(NGramLanguageModeler, self).__init__()\n self.embeddings = nn.Embedding(vocab_size, embedding_dim)\n self.linear1 = nn.Linear(context_size * embedding_dim, 128)\n self.linear2 = nn.Linear(128, vocab_size)\n\n def forward(self, inputs):\n embeds = self.embeddings(inputs).view((1, -1))\n out = F.relu(self.linear1(embeds))\n out = self.linear2(out)\n log_probs = F.log_softmax(out, dim=1)\n return log_probs\n\n\nlosses = []\nloss_function = nn.NLLLoss()\nmodel = NGramLanguageModeler(len(vocab), EMBEDDING_DIM, CONTEXT_SIZE)\noptimizer = optim.SGD(model.parameters(), lr=0.001)\n\nfor epoch in range(10):\n total_loss = 0\n for context, target in ngrams:\n\n # \uccab\ubc88\uc9f8. \ubaa8\ub378\uc5d0 \ub123\uc5b4\uc904 \uc785\ub825\uac12\uc744 \uc900\ube44\ud569\ub2c8\ub2e4. (i.e, \ub2e8\uc5b4\ub97c \uc815\uc218 \uc778\ub371\uc2a4\ub85c\n # \ubc14\uafb8\uace0 \ud30c\uc774\ud1a0\uce58 \ud150\uc11c\ub85c \uac10\uc2f8\uc90d\uc2dc\ub2e4.)\n context_idxs = torch.tensor([word_to_ix[w] for w in context], dtype=torch.long)\n\n # \ub450\ubc88\uc9f8. \ud1a0\uce58\ub294 \uae30\uc6b8\uae30\uac00 *\ub204\uc801* \ub429\ub2c8\ub2e4. \uc0c8 \uc778\uc2a4\ud134\uc2a4\ub97c \ub123\uc5b4\uc8fc\uae30 \uc804\uc5d0\n # \uae30\uc6b8\uae30\ub97c \ucd08\uae30\ud654\ud569\ub2c8\ub2e4.\n model.zero_grad()\n\n # \uc138\ubc88\uc9f8. \uc21c\uc804\ud30c\ub97c \ud1b5\ud574 \ub2e4\uc74c\uc5d0 \uc62c \ub2e8\uc5b4\uc5d0 \ub300\ud55c \ub85c\uadf8 \ud655\ub960\uc744 \uad6c\ud569\ub2c8\ub2e4.\n log_probs = model(context_idxs)\n\n # \ub124\ubc88\uc9f8. \uc190\uc2e4\ud568\uc218\ub97c \uacc4\uc0b0\ud569\ub2c8\ub2e4. (\ud30c\uc774\ud1a0\uce58\uc5d0\uc11c\ub294 \ubaa9\ud45c \ub2e8\uc5b4\ub97c \ud150\uc11c\ub85c \uac10\uc2f8\uc918\uc57c \ud569\ub2c8\ub2e4.)\n loss = loss_function(log_probs, torch.tensor([word_to_ix[target]], dtype=torch.long))\n\n # \ub2e4\uc12f\ubc88\uc9f8. \uc5ed\uc804\ud30c\ub97c \ud1b5\ud574 \uae30\uc6b8\uae30\ub97c \uc5c5\ub370\uc774\ud2b8 \ud574\uc90d\ub2c8\ub2e4.\n loss.backward()\n optimizer.step()\n\n # tensor.item()\uc744 \ud638\ucd9c\ud558\uc5ec \ub2e8\uc77c\uc6d0\uc18c \ud150\uc11c\uc5d0\uc11c \uc22b\uc790\ub97c \ubc18\ud658\ubc1b\uc2b5\ub2c8\ub2e4.\n total_loss += loss.item()\n losses.append(total_loss)\nprint(losses) # \ubc18\ubcf5\ud560 \ub584\ub9c8\ub2e4 \uc190\uc2e4\uc774 \uc904\uc5b4\ub4dc\ub294 \uac83\uc744 \ubd05\uc2dc\ub2e4!\n\n# \"beauty\"\uc640 \uac19\uc774 \ud2b9\uc815 \ub2e8\uc5b4\uc5d0 \ub300\ud55c \uc784\ubca0\ub529\uc744 \ud655\uc778\ud558\ub824\uba74,\nprint(model.embeddings.weight[word_to_ix[\"beauty\"]])"
58+
"CONTEXT_SIZE = 2\nEMBEDDING_DIM = 10\n# \uc170\uc775\uc2a4\ud53c\uc5b4 \uc18c\ub124\ud2b8(Sonnet) 2\ub97c \uc0ac\uc6a9\ud558\uaca0\uc2b5\ub2c8\ub2e4.\ntest_sentence = \"\"\"When forty winters shall besiege thy brow,\nAnd dig deep trenches in thy beauty's field,\nThy youth's proud livery so gazed on now,\nWill be a totter'd weed of small worth held:\nThen being asked, where all thy beauty lies,\nWhere all the treasure of thy lusty days;\nTo say, within thine own deep sunken eyes,\nWere an all-eating shame, and thriftless praise.\nHow much more praise deserv'd thy beauty's use,\nIf thou couldst answer 'This fair child of mine\nShall sum my count, and make my old excuse,'\nProving his beauty by succession thine!\nThis were to be new made when thou art old,\nAnd see thy blood warm when thou feel'st it cold.\"\"\".split()\n# \uc6d0\ub798\ub294 \uc785\ub825\uc744 \uc81c\ub300\ub85c \ud1a0\ud070\ud654(tokenize) \ud574\uc57c\ud558\uc9c0\ub9cc \uc774\ubc88\uc5d4 \uac04\uc18c\ud654\ud558\uc5ec \uc9c4\ud589\ud558\uaca0\uc2b5\ub2c8\ub2e4.\n# \ud29c\ud50c\ub85c \uc774\ub8e8\uc5b4\uc9c4 \ub9ac\uc2a4\ud2b8\ub97c \ub9cc\ub4e4\uaca0\uc2b5\ub2c8\ub2e4. \uac01 \ud29c\ud50c\uc740 ([ i-CONTEXT_SIZE \ubc88\uc9f8 \ub2e8\uc5b4, ..., i-1 \ubc88\uc9f8 \ub2e8\uc5b4 ], \ubaa9\ud45c \ub2e8\uc5b4)\uc785\ub2c8\ub2e4.\nngrams = [\n (\n [test_sentence[i - j - 1] for j in range(CONTEXT_SIZE)],\n test_sentence[i]\n )\n for i in range(CONTEXT_SIZE, len(test_sentence))\n]\n# \uccab 3\uac1c\uc758 \ud29c\ud50c\uc744 \ucd9c\ub825\ud558\uc5ec \ub370\uc774\ud130\uac00 \uc5b4\ub5bb\uac8c \uc0dd\uacbc\ub294\uc9c0 \ubcf4\uaca0\uc2b5\ub2c8\ub2e4.\nprint(ngrams[:3])\n\nvocab = set(test_sentence)\nword_to_ix = {word: i for i, word in enumerate(vocab)}\n\n\nclass NGramLanguageModeler(nn.Module):\n\n def __init__(self, vocab_size, embedding_dim, context_size):\n super(NGramLanguageModeler, self).__init__()\n self.embeddings = nn.Embedding(vocab_size, embedding_dim)\n self.linear1 = nn.Linear(context_size * embedding_dim, 128)\n self.linear2 = nn.Linear(128, vocab_size)\n\n def forward(self, inputs):\n embeds = self.embeddings(inputs).view((1, -1))\n out = F.relu(self.linear1(embeds))\n out = self.linear2(out)\n log_probs = F.log_softmax(out, dim=1)\n return log_probs\n\n\nlosses = []\nloss_function = nn.NLLLoss()\nmodel = NGramLanguageModeler(len(vocab), EMBEDDING_DIM, CONTEXT_SIZE)\noptimizer = optim.SGD(model.parameters(), lr=0.001)\n\nfor epoch in range(10):\n total_loss = 0\n for context, target in ngrams:\n\n # \uccab\ubc88\uc9f8. \ubaa8\ub378\uc5d0 \ub123\uc5b4\uc904 \uc785\ub825\uac12\uc744 \uc900\ube44\ud569\ub2c8\ub2e4. (i.e, \ub2e8\uc5b4\ub97c \uc815\uc218 \uc778\ub371\uc2a4\ub85c\n # \ubc14\uafb8\uace0 \ud30c\uc774\ud1a0\uce58 \ud150\uc11c\ub85c \uac10\uc2f8\uc90d\uc2dc\ub2e4.)\n context_idxs = torch.tensor([word_to_ix[w] for w in context], dtype=torch.long)\n\n # \ub450\ubc88\uc9f8. \ud1a0\uce58\ub294 \uae30\uc6b8\uae30\uac00 *\ub204\uc801* \ub429\ub2c8\ub2e4. \uc0c8 \uc778\uc2a4\ud134\uc2a4\ub97c \ub123\uc5b4\uc8fc\uae30 \uc804\uc5d0\n # \uae30\uc6b8\uae30\ub97c \ucd08\uae30\ud654\ud569\ub2c8\ub2e4.\n model.zero_grad()\n\n # \uc138\ubc88\uc9f8. \uc21c\uc804\ud30c\ub97c \ud1b5\ud574 \ub2e4\uc74c\uc5d0 \uc62c \ub2e8\uc5b4\uc5d0 \ub300\ud55c \ub85c\uadf8 \ud655\ub960\uc744 \uad6c\ud569\ub2c8\ub2e4.\n log_probs = model(context_idxs)\n\n # \ub124\ubc88\uc9f8. \uc190\uc2e4\ud568\uc218\ub97c \uacc4\uc0b0\ud569\ub2c8\ub2e4. (\ud30c\uc774\ud1a0\uce58\uc5d0\uc11c\ub294 \ubaa9\ud45c \ub2e8\uc5b4\ub97c \ud150\uc11c\ub85c \uac10\uc2f8\uc918\uc57c \ud569\ub2c8\ub2e4.)\n loss = loss_function(log_probs, torch.tensor([word_to_ix[target]], dtype=torch.long))\n\n # \ub2e4\uc12f\ubc88\uc9f8. \uc5ed\uc804\ud30c\ub97c \ud1b5\ud574 \uae30\uc6b8\uae30\ub97c \uc5c5\ub370\uc774\ud2b8 \ud574\uc90d\ub2c8\ub2e4.\n loss.backward()\n optimizer.step()\n\n # tensor.item()\uc744 \ud638\ucd9c\ud558\uc5ec \ub2e8\uc77c\uc6d0\uc18c \ud150\uc11c\uc5d0\uc11c \uc22b\uc790\ub97c \ubc18\ud658\ubc1b\uc2b5\ub2c8\ub2e4.\n total_loss += loss.item()\n losses.append(total_loss)\nprint(losses) # \ubc18\ubcf5\ud560 \ub54c\ub9c8\ub2e4 \uc190\uc2e4\uc774 \uc904\uc5b4\ub4dc\ub294 \uac83\uc744 \ubd05\uc2dc\ub2e4!\n\n# \"beauty\"\uc640 \uac19\uc774 \ud2b9\uc815 \ub2e8\uc5b4\uc5d0 \ub300\ud55c \uc784\ubca0\ub529\uc744 \ud655\uc778\ud558\ub824\uba74,\nprint(model.embeddings.weight[word_to_ix[\"beauty\"]])"
5959
]
6060
},
6161
{

β€Ždocs/_downloads/382ee257041a0b8faf7974c3946c40a4/audio_data_augmentation_tutorial.pyβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,8 @@ def plot_specgram(waveform, sample_rate, title="Spectrogram", xlim=None):
345345
# μ „ν™” λ…ΉμŒ λͺ¨μ˜ μ‹€ν—˜ν•˜κΈ°
346346
# ---------------------------
347347
#
348-
# 이전 κΈ°μˆ λ“€μ„ ν˜Όν•©ν•˜μ—¬, 반ν–₯μžˆλŠ” 방의 μ‚¬λžŒλ“€μ΄ μ΄μ•ΌκΈ°ν•˜λŠ” λ°°κ²½μ—μ„œ μ „ν™” ν†΅ν™”ν•˜λŠ”
349-
# 것 처럼 λ“€λ¦¬λŠ” μ˜€λ””μ˜€λ₯Ό λͺ¨μ˜ μ‹€ν—˜ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
348+
# 이전 κΈ°μˆ λ“€μ„ ν˜Όν•©ν•˜μ—¬, 반ν–₯ μžˆλŠ” 방의 μ‚¬λžŒλ“€μ΄ μ΄μ•ΌκΈ°ν•˜λŠ” λ°°κ²½μ—μ„œ μ „ν™” ν†΅ν™”ν•˜λŠ”
349+
# κ²ƒμ²˜λŸΌ λ“€λ¦¬λŠ” μ˜€λ””μ˜€λ₯Ό λͺ¨μ˜ μ‹€ν—˜ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
350350
#
351351

352352
sample_rate = 16000

0 commit comments

Comments
Β (0)