|
114 | 114 | {
|
115 | 115 | "data": {
|
116 | 116 | "text/plain": [
|
117 |
| - "<torch._C.Generator at 0x7f247d342fb0>" |
| 117 | + "<torch._C.Generator at 0x106951ed0>" |
118 | 118 | ]
|
119 | 119 | },
|
120 | 120 | "execution_count": 2,
|
|
265 | 265 | " [0.5000],\n",
|
266 | 266 | " [0.5000],\n",
|
267 | 267 | " [0.5000],\n",
|
268 |
| - " [0.5000]], grad_fn=<MulBackward0>)\n", |
| 268 | + " [0.5000]], grad_fn=<MulBackward>)\n", |
269 | 269 | "torch.Size([6, 1])\n"
|
270 | 270 | ]
|
271 | 271 | }
|
|
413 | 413 | }
|
414 | 414 | ],
|
415 | 415 | "source": [
|
416 |
| - "-(y_train[0] * torch.log(hypothesis[0]) + (1 - y_train[0]) * torch.log(1 - hypothesis[0]))" |
| 416 | + "-(y_train[0] * torch.log(hypothesis[0]) + \n", |
| 417 | + " (1 - y_train[0]) * torch.log(1 - hypothesis[0]))" |
417 | 418 | ]
|
418 | 419 | },
|
419 | 420 | {
|
|
442 | 443 | }
|
443 | 444 | ],
|
444 | 445 | "source": [
|
445 |
| - "losses = -(y_train * torch.log(hypothesis) + (1 - y_train) * torch.log(1 - hypothesis))\n", |
| 446 | + "losses = -(y_train * torch.log(hypothesis) + \n", |
| 447 | + " (1 - y_train) * torch.log(1 - hypothesis))\n", |
446 | 448 | "print(losses)"
|
447 | 449 | ]
|
448 | 450 | },
|
|
559 | 561 | "\n",
|
560 | 562 | " # Cost 계산\n",
|
561 | 563 | " hypothesis = torch.sigmoid(x_train.matmul(W) + b) # or .mm or @\n",
|
562 |
| - " cost = -(y_train * torch.log(hypothesis) + (1 - y_train) * torch.log(1 - hypothesis)).mean()\n", |
| 564 | + " cost = -(y_train * torch.log(hypothesis) + \n", |
| 565 | + " (1 - y_train) * torch.log(1 - hypothesis)).mean()\n", |
563 | 566 | "\n",
|
564 | 567 | " # cost로 H(x) 개선\n",
|
565 | 568 | " optimizer.zero_grad()\n",
|
|
595 | 598 | "Epoch 300/1000 Cost: 0.057900\n",
|
596 | 599 | "Epoch 400/1000 Cost: 0.045300\n",
|
597 | 600 | "Epoch 500/1000 Cost: 0.037261\n",
|
598 |
| - "Epoch 600/1000 Cost: 0.031673\n", |
| 601 | + "Epoch 600/1000 Cost: 0.031672\n", |
599 | 602 | "Epoch 700/1000 Cost: 0.027556\n",
|
600 | 603 | "Epoch 800/1000 Cost: 0.024394\n",
|
601 | 604 | "Epoch 900/1000 Cost: 0.021888\n",
|
|
708 | 711 | "Epoch 40/100 Cost: 0.507066\n",
|
709 | 712 | "Epoch 50/100 Cost: 0.498539\n",
|
710 | 713 | "Epoch 60/100 Cost: 0.492549\n",
|
711 |
| - "Epoch 70/100 Cost: 0.488208\n", |
| 714 | + "Epoch 70/100 Cost: 0.488209\n", |
712 | 715 | "Epoch 80/100 Cost: 0.484985\n",
|
713 | 716 | "Epoch 90/100 Cost: 0.482543\n",
|
714 | 717 | "Epoch 100/100 Cost: 0.480661\n"
|
|
1043 | 1046 | "name": "python",
|
1044 | 1047 | "nbconvert_exporter": "python",
|
1045 | 1048 | "pygments_lexer": "ipython3",
|
1046 |
| - "version": "3.7.0" |
| 1049 | + "version": "3.6.5" |
1047 | 1050 | }
|
1048 | 1051 | },
|
1049 | 1052 | "nbformat": 4,
|
|
0 commit comments