operations |
comment | "parent_author":"",<br>"parent_permlink":"kr",<br>"author":"codingart",<br>"permlink":"tensorflow-softmax-rosenblatt-perceptron-n-1",<br>"title":"2-7 \uac13 \uba38\uc2e0 \ub7ec\ub2dd \ud234 TensorFlow Softmax \uc5d0 \uc758\ud55c Rosenblatt Perceptron N =1 \uc608\uc81c \uccb4\ud06c",<br>"body":"Rosenblatt \uc758 \ud37c\uc149\ud2b8\ub860 \uc7a5\uce58\ub97c \ubc18\ub4dc\uc2dc \uc54c\uace0\ub9ac\ub4ec\uc774\ub098 \uc218\ud559\uc744 \uc4f0\uc9c0 \uc54a\uc73c\uba74\uc11c\ub3c4 \uc880 \ub354 \uc27d\uac8c \uc774\ud574\ud560 \uc218 \uc788\ub294 \uc218\ub2e8\uc744 \uac15\uad6c\ud574 \ubcf4\uc790. \uadf8\uac83\uc740 \ubc14\ub85c \uc6b0\ub9ac\uac00 \uc798 \uc54c\uace0 \uc788\ub294 \uc544\ub450\uc774\ub178 \uc870\ub3c4\uc13c\uc11c \uc7a5\uce58\uc774\ub2e4. \uc774 \uc870\ub3c4 \uc13c\uc11c \ubc30\uc120 \ubc0f \ucf54\ub529\uc740 \ucd08\uc911\uace0 \uc544\ub450\uc774\ub178 \ucef4\ud4e8\ud130 \ucf54\ub529 \uacfc\uc815\uc5d0\uc11c \ub204\uad6c\ub098 \ub2e4\ub8e8\uc5b4 \ubcf4\ub294 \uc798 \uc54c\ub824\uc9c4 \uacfc\uc81c\ub77c\uace0 \ubcf4\uba74 \ub41c\ub2e4.\n\n\uc870\ub3c4 \uc13c\uc11c\ub294 \ube5b\uc758 \ubc1d\uae30\uc5d0 \uc758\ud574 \uc800\ud56d \uac12\uc774 \uc870\uc808 \ub418\ub294 \uc77c\uc885\uc758 \ubc18\ub3c4\uccb4\uc131 \uac00\ubcc0 \uc800\ud56d\uc73c\ub85c \uc2e4\uc81c\ub85c \ub3c4\uc2dc\uc758 \uc218\ub9ce\uc740 \uac00\ub85c\ub4f1 ON OFF\uc5d0 \uc0ac\uc6a9\ub418\ub294 \uc13c\uc11c\uc774\uba70 \uc601\ubb38 \uba85\uce6d\uc744 Photocell \uc774\ub77c\uace0 \ud55c\ub2e4. \uc77c\ub144\uc5ec \uc804\uc5d0 \uc870\ub3c4\uc13c\uc11c \ubc30\uc120 \ubc0f \ucf54\ub529\uc744 \ub2e4\ub8f0 \ub54c\ub9cc \ud574\ub3c4 \uadf8 \uc815\uc2dd \uc601\ubb38 \uba85\uce6d\uc744 \ubaa8\ub974\uace0 \uc788\uc5c8\ub294\ub370 \uadfc\uc790\uc5d0 Rosenblatt \ud37c\uc149\ud2b8\ub860\uc5d0 \uad00\ud55c Wikipedia \uc124\uba85\uc5d0\uc11c \ubcf4\uac8c \ub41c \uc6a9\uc5b4\uac00 Photocell \uc774\uc5c8\ub2e4. \ud314\uc790\uac00 \uc544\ub294 \ubc18\ub3c4\uccb4 \uc18c\uc790\ub85c\uc11c \uc815\ub958\uc6a9 \ub2e4\uc774\uc624\ub4dc(Diode)\uc640 \ubc1c\uad11\uc6a9 \ub2e4\uc774\uc624\ub4dc(LED)\uac00 \uc788\uace0 \ud55c\ud3b8 \ube5b\uc744 \ubc1b\uc544\ub4e4\uc774\ub294 Photodiode\uac00 \uc788\ub294 \uac83\uc73c\ub85c \uc54c\uace0 \uc788\uc5c8\ub2e4. Photodiode\ub294 \uc194\ub77c\uc140\ub85c \uc774\ud574\ud558\uba74 \ub41c\ub2e4. \ube5b\uc744 \ucabc\uc5ec\uc8fc\uba74 \ube5b \uc5d0\ub108\uc9c0\ub97c 10\u223c20% \uc758 \ud6a8\uc728\ub85c \uc804\ub958\ub97c \ubc1c\uc0dd\uc2dc\ucf1c \uc804\uae30 \uc5d0\ub108\uc9c0\ub85c \ubc14\uafb8\uc5b4 \uc8fc\ub294 \ubc18\ub3c4\uccb4 \uc18c\uc790\uc774\ub2e4. \n\n\ubc18\uba74\uc5d0 Cds \ub77c\ub294 \uba85\uce6d\uc73c\ub85c \uc798 \uc54c\ub824\uc9c4 \uc870\ub3c4\uc13c\uc11c Photocell\uc740 \ube5b\uc744 \ucb2c\uc5ec \uc8fc\uba74 \ubc18\ub3c4\uccb4 \uc870\uc9c1\uc758 \uc800\ud56d \uac12\uc774 \ubbfc\uac10\ud558\uac8c \ubcc0\ub3d9\ub418\ub294 \ud2b9\uc131\uc744 \uac00\uc9c0\uace0 \uc788\ub2e4. \ub530\ub77c\uc11c \uc800\ub141 \ubb34\ub835\uc5d0 \uc5b4\ub450\uc6cc\uc9c8 \ub54c\uc640 \uc544\uce68\ub141\uc5d0 \ubc1d\uc544\uc9c8 \ub54c\uc758 \uc800\ud56d\uac12 \ubcc0\ud654 \ud2b9\uc131\uc744 \uc798 \uc54c\uace0 \uc788\uc73c\uba74 \ub3c4\uc2dc\uc5d0 \uae55\ub824 \uc788\ub294 \uc218\ub9ce\uc740 \uac00\ub85c\ub4f1 \uc2dc\uc2a4\ud15c\uc5d0 \uc804\uae30\ub97c \uacf5\uae09\ud558\uac70\ub098 \ucc28\ub2e8\ud560 \uc218 \uc788\ub294 \uac83\uc774\ub2e4.\n\uc774 \uc870\ub3c4\uc13c\uc11c\uc640 1K\u03a9 \uc800\ud56d\uc744 \uc9c1\ub82c \uc5f0\uacb0\ud558\uace0 LOLIN \ubcf4\ub4dc\uc758 3.3V \uc640 GND\uc5d0 \uc544\ub798 \uadf8\ub9bc\uacfc \uac19\uc774 \uc5f0\uacb0 \ubc30\uc120\ud558\uc790.\n\n![noname01.png (https:\/\/cdn.steemitimages.com\/DQmNmJYJgKGTzrukHZr1pw97FuSXFrc2Y87x5mGzeQRzpWh\/noname01.png)\n \nWeMos LOLIN \ubcf4\ub4dc\uc5d0\uc11c \uc544\ub0a0\ub85c\uadf8 \uc804\uc555\uc744 \uc77d\uc5b4 \ub4e4\uc77c \ub54c\uc5d0\ub294 0.0\u223c3.3V\ub97c 0\u223c4095 \uc0ac\uc774\uc758 \uc815\uc218 \uac12\uc73c\ub85c \uc77d\ub294\ub2e4. \ubc18\uba74\uc5d0 \uc544\ub450\uc774\ub178 \uc6b0\ub178\ub97c \uc0ac\uc6a9\ud558\uba74 \uc804\uc555\uc740 5V \uc640 3.3V \uc911\uc5d0\uc11c \uc120\ud0dd\ud560 \uc218 \uc788\uc73c\uba70 \uc544\ub0a0\ub85c\uadf8 \ud540\uc5d0\uc11c \uc77d\uc5b4\ub4e4\uc774\ub294 \uc815\uc218 \uac12\uc758 \ubc94\uc704\uac00 0\u223c1023\uc774 \ub428\uc5d0 \uc720\uc758\ud558\uc790. \uc5ec\uae30\uc11c\ub294 LOLIN \ubcf4\ub4dc\ub97c \uc0ac\uc6a9\ud55c\ub2e4.\n\n\n\uc870\ub3c4\uc13c\uc11c \ud68c\ub85c\uc5d0\uc11c \uc544\ub0a0\ub85c\uadf8 \ud540 \uc704\uce58\uc5d0\uc11c \uce21\uc815\ud560 \uc218 \uc788\ub294 \uc804\uc555\uc744 \uc634(Ohm)\uc758 \ubc95\uce59\uc5d0 \uc758\ud574\uc11c \uacc4\uc0b0\ud574 \ubcf4\uc790. \n\n![noname11.png (https:\/\/cdn.steemitimages.com\/DQmU3By1SrsXyGFiXyyBfSGetaaN1Cp7FUxNXzftKjT87hA\/noname11.png)\n\n\uc5b4\ub450\uc6b8 \uacbd\uc6b0 \uc870\ub3c4\uc13c\uc11c\uc758 \uc800\ud56d \uac12\uc774 \ucee4\uc838 \uc9c1\ub82c \uc5f0\uacb0\ub41c \ud569\uc131 \uc800\ud56d \uac12\uc740 41K\u03a9\uc774 \ub41c\ub2e4. \ub530\ub77c\uc11c \uc774 \ud68c\ub85c\uc5d0 \ud750\ub974\ub294 \uc804\ub958\ub294 \ub2e4\uc74c\uacfc \uac19\uc774 \uacc4\uc0b0\ub41c\ub2e4.\n\n![noname12.png (https:\/\/cdn.steemitimages.com\/DQmQH9Hbkteo2e4gf123KwkfaDzTC1qWUbtxk2A7oW4SsL5\/noname12.png)\n\n\uc804\ub958\uac00 \ud750\ub974\ub294 \ubc30\uc120\uc774 \ud55c \uac00\ub2e5\uc774\ubbc0\ub85c 1K\u03a9\uc800\ud56d\uacfc 40K\u03a9 \uc870\ub3c4\uc13c\uc11c \uc800\ud56d\uc5d0 \ud750\ub974\ub294 \uc804\ub958\uac12\uc740 \ub3d9\uc77c\ud558\uba70 \uac01\uac01\uc758 \uc800\ud56d\uc5d0 \uac00\ud574\uc9c0\ub294 \uc804\uc555\uc740 \uc804\ub958X\uc800\ud56d \uacf5\uc2dd\uc73c\ub85c \uacc4\uc0b0\uc774 \uac00\ub2a5\ud558\ub2e4. \uce21\uc815\ud558\uace0\uc790 \ud558\ub294 \uc804\uc555\uc774 GND\uc758 0V \ub300\ube44 1K\u03a9\uc800\ud56d\uc758 \ubc18\ub300\ud3b8\uc73c\ub85c \uc870\ub3c4\uc13c\uc11c\uc640 \uc5f0\uacb0\ub418\ub294 \ubd80\ubd84\uc774\ub2e4.\n\n![noname13.png (https:\/\/cdn.steemitimages.com\/DQmV1JJqXZRYuJYr7VLQLsc52CHAYyAXgnG54k8Dotstsg6\/noname13.png)\n\n0.08V\ub294 0V\uc5d0 \uadfc\uc811\ud55c \uac12\uc73c\ub85c\uc11c 0\u223c4095 \uc0ac\uc774\uc758 \uc815\uc218 \uac12\uc73c\ub85c \ud658\uc0b0\ud558\uba74 \uc57d 99 \ub0b4\uc9c0\ub294 100 \uc815\ub3c4\uac00 \ub41c\ub2e4. \n\n\ubc18\uba74\uc5d0 \ubc1d\uc744 \uacbd\uc6b0 \uc870\ub3c4\uc13c\uc11c \ud68c\ub85c\uc5d0\uc11c \uc544\ub0a0\ub85c\uadf8 \ud540\uc5d0\uc11c \uce21\uc815\ud560 \uc218 \uc788\ub294 \uc804\uc555\uc744 \uc634(Ohm)\uc758 \ubc95\uce59\uc5d0 \uc758\ud574\uc11c \uacc4\uc0b0\ud574 \ubcf4\uc790. \n\uc9c1\ub82c \uc5f0\uacb0\ub41c \ud569\uc131 \uc800\ud56d \uac12\uc740 1.1K\u03a9\uc774\ub2e4. \ub530\ub77c\uc11c \uc774 \ud68c\ub85c\uc5d0 \ud750\ub974\ub294 \uc804\ub958\ub294 \ub2e4\uc74c\uacfc \uac19\uc774 \uacc4\uc0b0\ub41c\ub2e4.\n\n![noname14.png (https:\/\/cdn.steemitimages.com\/DQmZmy814ZC5Dd5EgZyJBBrWvNakZLVfs1mFB2q6x7oaSJ4\/noname14.png)\n\n\uc804\ub958\uac00 \ud750\ud750\ub294 \ubc30\uc120\uc774 \ud55c \uac00\ub2e5\uc774\ubbc0\ub85c 1K\u03a9\uc800\ud56d\uacfc 100\u03a9 \uc870\ub3c4\uc13c\uc11c \uc800\ud56d\uc5d0 \ud750\ub974\ub294 \uc804\ub958\uac12\uc740 \ub3d9\uc77c\ud558\uba70 \uac01\uac01\uc758 \uc800\ud56d\uc5d0 \uac00\ud574\uc9c0\ub294 \uc804\uc555\uc740 \uc804\ub958X\uc800\ud56d \uacf5\uc2dd\uc73c\ub85c \uacc4\uc0b0\uc774 \uac00\ub2a5\ud558\ub2e4. \uce21\uc815\ud558\uace0\uc790 \ud558\ub294 \uc804\uc555\uc774 GND \uc758 0V \ub300\ube44 1K\u03a9\uc800\ud56d\uc758 \ubc18\ub300\ud3b8\uc73c\ub85c \uc870\ub3c4\uc13c\uc11c\uc640 \uc5f0\uacb0\ub418\ub294 \ubd80\ubd84\uc774\ub2e4.\n\n3.0V\ub294 3.3V\uc5d0 \uadfc\uc811\ud55c \uac12\uc73c\ub85c\uc11c 0\u223c4095 \uc0ac\uc774\uc758 \uc815\uc218 \uac12\uc73c\ub85c \ud658\uc0b0\ud558\uba74 \uc57d 3723 \uc815\ub3c4\uac00 \ub41c\ub2e4.\n\n\ub2e4\uc74c\uc740 \uc870\ub3c4\uc13c\uc11c\uc5d0 \uc758\ud574 \uc544\ub0a0\ub85c\uadf8 \ud540\uc758 \uac12\uc744 \uc77d\uc5b4 \ucd9c\ub825\ud558\ub294 WeMos LOLIN \ucf54\ub4dc\uc774\ub2e4.\n\/\/WeMos_lolin_ML_Cds_01\nfloat Volt = 3.3; \/\/\uc544\ub450\uc774\ub178 \uc804\uc555 \uc2e4\uce21\uce58\nfloat r = 987.0; \/\/1K\uc634 \uc2e4\uce21\uce58\nint ledPin = 27;\nvoid setup() \nSerial.begin(9600);\npinMode(ledPin,<br>OUTPUT);\n \n\nvoid loop() \nint analogV = analogRead(36);\/\/0-4095\nSerial.println(analogV);\ndelay(3000);\n \/\/\ud504\ub85c\uadf8\ub7a8 \ub05d\n\n\uc774 \ubb38\uc81c\uc758 \uc81c\uae30\ub294 \ube44\ub85d Rosenblatt\uc774\uc9c0\ub9cc \uc6b0\ub9ac\uac00 \uccb4\ud06c\ud574 \ubcf8\ub2e4\ub294 \uc785\uc7a5\uc5d0\uc11c \uac13(God) \uba38\uc2e0 \ub7ec\ub2dd \ud234\ub85c \ubd10\ub3c4 \ubb34\ubc29\ud55c TensorFlow Softmax \ucf54\ub4dc\uc5d0 \uc758\ud574 2\uac1c\uc758 \ub370\uc774\ud130\ub97c \ub300\uc0c1\uc73c\ub85c \uba38\uc2e0 \ub7ec\ub2dd \uc9c0\ub3c4 \ud559\uc2b5(Supervised Learning)\uc744 \uc2dc\ud0a8 \ud6c4 \uc5b4\ub514\uae4c\uc9c0\uac00 \ubc1d\uc74c\uc758 \uc601\uc5ed\uc774\uace0 \uc5b4\ub514\uae4c\uc9c0\uac00 \uc5b4\ub460\uc758 \uc601\uc5ed\uc778\uc9c0 \ud655\uc778\ud574 \ub098\uac00\ub294 \uc5b4\ub824\uc6b4 \ubd84\ub958\ubb38\uc81c( clasification)\ub97c \ubd80\uacfc\ud558\ub3c4\ub85d \ud55c\ub2e4.\n\n\ubc1d\uae30 \ub370\uc774\ud130\ub97c 4095\ub85c \ub098\ub204\uc5b4 normalization \ud558\uba74 100\uc740 \uc57d 0.02,<br> 3723\uc740 0.909 \uc774\ub2e4. \uadf8 \uc0ac\uc774 \ubc1d\uae30\uac00 \uc560\ub9e4\ud55c \uc815\ub3c4\ub85c\uc11c \uad6c\ub984\uc774 \ub080 \uc0c1\ud0dc\uc5d0\uc11c \uc120\uae00\ub77c\uc2a4\ub85c \uac00\ub9ac\uba74 \uc57d 2000 \uac00\uae4c\uc6b4 \uac12\uc774 \ucd9c\ub825\ub418\ubbc0\ub85c 0.5 \uae4c\uc9c0\ub294 \ubc1d\uc740 \ucabd\uc73c\ub85c \ubcfc \uc218 \uc788\uc744 \ub4ef\ud558\ub2e4. \ud574\ubd10\uc57c \uc54c\uc9c0?\n\nTensorFlow\uc5d0 \uc758\ud55c softmax \ucf54\ub4dc\ub97c \uc900\ube44\ud558\uc790. \uc5b4\ub460 \ub370\uc774\ud130 0.02,<br> \ubc1d\uc74c \ub370\uc774\ud130 0.909,<br> \ub77c\ubca8 \uac12\uc740 on hot code\ub97c \uc0ac\uc6a9\ud55c\ub2e4. \uc989 \uc5b4\ub460\uc740 10,<br> \ubc1d\uc74c\uc740 01 \uc774\uba70 \ub098\uc911\uc5d0 \ucd9c\ub825\ud574\uc57c \ud560 \ub77c\ubca8 \uac12\uc73c\ub85c\ub294 \uc5b4\ub460\uc740 \u201c0\u201d,<br> \ubc1d\uc74c\uc740 \u201c1\u201d \uc774\ub2e4.\n\n![noname02.png (https:\/\/cdn.steemitimages.com\/DQmRBHzmzeN9uqJgFbNNe9o2K2eKcZiZaPcyhTwHzsGKMGk\/noname02.png)\n\n\ud559\uc2b5(trainning)\uc774 \uc644\ub8cc\ub41c \ud6c4 classification \ubb38\uc81c\ub97c \ud480\uc5b4\ubcf4\ub3c4\ub85d \ud55c\ub2e4. \uc608\uc81c\ub294 \ubc1d\uae30 \ub370\uc774\ud130 [0.01 ,<br> [0.95 \ub97c \uba3c\uc800 \ud14c\uc2a4\ud2b8 \ud558\uace0 \uadf8 \ub2e4\uc74c\uc5d0\ub294 \uc54c\uc73c\ucf1c \uc8fc\uc9c0 \uc54a\uc740 0.445\uc640 0.5\ub97c \ud14c\uc2a4\ud2b8\ud558\uae30\ub85c \ud55c\ub2e4. \uc55e\uc758 \ub450\ubb38\uc81c\uc758 \ud574\ub2f5 \ub77c\ubca8\uc740 [0 \uacfc [1 \uc774\ub2e4. \ub4a4\uc758 \ub450 \ubb38\uc81c\ub3c4 \ub77c\ubca8\uc740 [0 \uacfc [1 \uc774\uc9c0\ub9cc \uc911\uc694\ud55c \uc0ac\uc2e4\uc740 \uc55e\uacfc \ub4a4\uc758 \ud655\ub960 \uac12 \ub610\ub294 \ud655\uc2e0 \uc815\ub3c4\uac00 \ud06c\uac8c \ub2e4\ub974\ub2e4\ub294 \uc810\uc774\ub2e4.\n\nTensorFlow \ud574\uc11d \uacb0\uacfc\ub97c \ubcf4\ub3c4\ub85d \ud558\uc790. \ub2e4\uc74c\uc740 cost \ud568\uc218\uac00 \ud559\uc2b5\ud69f\uc218\uc5d0 \ub530\ub77c \ucd5c\uc18c\ud654\uac00 \uc774\ub8e8\uc5b4\uc9c0\ub294 \uc18d\ub3c4\ub97c \ubcf4\uc5ec\uc900\ub2e4.\n \n![noname03.png (https:\/\/cdn.steemitimages.com\/DQmVENQjivuEoCqvMo7u2yAjCYKs8iXaSQnaQUuMfD8MHod\/noname03.png)\n\n\ud14c\uc2a4\ud2b8 \ub370\uc774\ud130\ub294 [0.01 ,<br> [0.95 ,<br> [0.447 ,<br> [0.5 \ub97c \ub300\uc0c1\uc73c\ub85c \ud558\uc600\ub2e4. 0.01 \uc774\ub098 0.95\ub294 \ud559\uc2b5 \ubc94\uc704 \ub0b4\uc5d0 \ub4e4\uc5b4\uc624\ubbc0\ub85c \ub2f9\uc5f0\ud55c \uacb0\uacfc\ub97c \uc900\ub2e4. \ud558\uc9c0\ub9cc 0.5\ub294 62.37% \ud655\ub960\ub85c \uac00\uae4c\uc2a4\ub85c \ubc1d\uc740 \ubc94\uc8fc\ub85c \ud310\uc815\ub418\uc5c8\uace0 0.447\uc740 50.17%\ub85c \uac00\uae4c\uc2a4\ub85c \uc5b4\ub460\uc73c\ub85c \ud310\uc815\ub418\uc5c8\uc9c0\ub9cc \ud655\ub960\uc774 \uac70\uc758 50 \ub300 50\uc778 \uc148\uc774 \ub41c\ub2e4. \uc989 Rosenblatt\uc758 \ud37c\uc149\ud2b8\ub860 \uc54c\uace0\ub9ac\ub4ec \ubd84\uc11d\ud574\uc11c \ucd9c\ud604\ud588\ub358 N=1 \uc778 \uacbd\uc6b0\uc758 \ubb38\uc81c\ub97c TensorFlow Softmax \uc5d0 \uc758\ud574 \uccb4\ud06c\ud574 \ubcf4\uc558\uc744 \ub54c \ub9c8\uc74c\uc5d0 \ub4dc\ub294 \ud569\ub9ac\uc801\uc778 \uacb0\uacfc\ub97c \ubcf4\uc5ec\uc900\ub2e4.\n\n![noname04.png (https:\/\/cdn.steemitimages.com\/DQmaz2ZN9XND5zD1vrzA6mnqC1cHZ7RF91bZocWFAiHjXrZ\/noname04.png)\n\n\ud55c\ud3b8 Rosenblatt\uc758 \uc54c\uace0\ub9ac\ub4ec \uccb4\ud06c\uacfc\uc815\uc5d0\uc11c\uc758 \ub531\ub531\ud55c \uc218\ud559\uc801\uc778 \ud615\ud0dc\ub4e4\uc5d0 \ub300\ud574 \uc5b4\ub835\uace0 \ub09c\ud574\ud574\uc11c \ub9c8\uc74c\uc5d0 \ub4e4\uc5b4\ud558\uc9c0 \uc54a\ub294 \uc218\uc54c\ubabb \ubd84\ub4e4\ub3c4 \uacc4\uc168\ub2e4. \uc774 \uc608\uc81c\uac00 Rosenblatt \ud37c\uc149\ud2b8\ub860 N=1 \uacbd\uc6b0\ub97c \uc774\ud574\ud558\uae30 \uc704\ud55c \ubcf4\ub2e4 \uc801\uc808\ud55c \uc124\uba85\uc774 \ub418\uc5c8\uc73c\uba74 \ud55c\ub2e4.\n\uc544\ub798\uc758 \ucf54\ub4dc\ub97c \ubcf5\uc0ac\ud574\uc11c \uc2e4\ud589\ud560 \uacbd\uc6b0 \ud639 indentation \uc774 \uc798\ubabb\ub418\uc5b4 \uc5d0\ub7ec\uac00 \uac80\ucd9c\ub418\uba74 2018\ub144 8\uc6d4 10\uc77c\uc758 AS \ub0b4\uc6a9\uc744 \ucc38\uc870\ud558\uae30 \ubc14\ub780\ub2e4. \uc2e4\uc81c \ud3b8\uc9d1\uacfc\uc815\uc5d0\uc11c paste \ud558\ub294 \uc21c\uac04\uc5d0 indentation \uc774 \uc0ac\ub77c\uc9c0\ub294\uad70\uc694. \uc624\ud638\ud1b5\uc7ac\ub77c \ub204\uad74 \uc6d0\ub9dd\ud558\ub7b4! indentation \uc704\uce58 AS \uaf2d \ubcf4\uc2dc\uace0 \uc218\uc815\uc791\uc5c5\ud558\uc138\uc694.\n\n#Softmax Classifier\nimport tensorflow as tf\ntf.set_random_seed(777) # for reproducibility\n\nx_data = [[0.02 ,<br> [0.909 \ny_data = [[1,<br> 0 ,<br>[0,<br> 1 \n\nX = tf.placeholder(\"float\",<br> [None,<br> 1 )\nY = tf.placeholder(\"float\",<br> [None,<br> 2 )\nnb_classes = 2\n\nW = tf.Variable(tf.random_normal([1,<br> nb_classes ),<br> name='weight')\nb = tf.Variable(tf.random_normal([nb_classes ),<br> name='bias')\n\n#tf.nn.softmax computes softmax activations\n#softmax = exp(logits) \/ reduce_sum(exp(logits),<br> dim)\nhypothesis = tf.nn.softmax(tf.matmul(X,<br> W) + b)\n\n#Cross entropy cost\/loss\ncost = tf.reduce_mean(-tf.reduce_sum(Y * tf.log(hypothesis),<br> axis=1))\n\noptimizer = tf.train.GradientDescentOptimizer(learning_rate=0.1).minimize(cost)\n\n#Launch graph\nwith tf.Session() as sess:\n sess.run(tf.global_variables_initializer())\n\n for step in range(2001):\n sess.run(optimizer,<br> feed_dict= X: x_data,<br> Y: y_data )\n if step % 200 == 0:\n print(step,<br> sess.run(cost,<br> feed_dict= X: x_data,<br> Y: y_data ))\n\n print('--------------')\n\n # Testing & One-hot encoding\n a = sess.run(hypothesis,<br> feed_dict= X: [[0.01 )\n print(a,<br> sess.run(tf.argmax(a,<br> 1)))\n\n print('--------------')\n\n b = sess.run(hypothesis,<br> feed_dict= X: [[0.95 )\n print(b,<br> sess.run(tf.argmax(b,<br> 1)))\n\n print('--------------')\n\n c = sess.run(hypothesis,<br> feed_dict= X: [[0.447 )\n print(c,<br> sess.run(tf.argmax(c,<br> 1)))\n\n print('--------------')\n \n d = sess.run(hypothesis,<br> feed_dict= X: [[0.5 )\n print(d,<br> sess.run(tf.argmax(d,<br> 1)))\n\n print('--------------')\n\n all = sess.run(hypothesis,<br> feed_dict= \n X: [[0.01 ,<br>[0.95 ,<br>[0.445 ,<br>[0.5 )\n print(all,<br> sess.run(tf.argmax(all,<br> 1)))",<br>"json_metadata":" \"tags\":[\"kr\",<br>\"kr-new\",<br>\"manamine\",<br>\"jjangjjangman\",<br>\"kr-dev\" ,<br>\"image\":[\"https:\/\/cdn.steemitimages.com\/DQmNmJYJgKGTzrukHZr1pw97FuSXFrc2Y87x5mGzeQRzpWh\/noname01.png\",<br>\"https:\/\/cdn.steemitimages.com\/DQmU3By1SrsXyGFiXyyBfSGetaaN1Cp7FUxNXzftKjT87hA\/noname11.png\",<br>\"https:\/\/cdn.steemitimages.com\/DQmQH9Hbkteo2e4gf123KwkfaDzTC1qWUbtxk2A7oW4SsL5\/noname12.png\",<br>\"https:\/\/cdn.steemitimages.com\/DQmV1JJqXZRYuJYr7VLQLsc52CHAYyAXgnG54k8Dotstsg6\/noname13.png\",<br>\"https:\/\/cdn.steemitimages.com\/DQmZmy814ZC5Dd5EgZyJBBrWvNakZLVfs1mFB2q6x7oaSJ4\/noname14.png\",<br>\"https:\/\/cdn.steemitimages.com\/DQmRBHzmzeN9uqJgFbNNe9o2K2eKcZiZaPcyhTwHzsGKMGk\/noname02.png\",<br>\"https:\/\/cdn.steemitimages.com\/DQmVENQjivuEoCqvMo7u2yAjCYKs8iXaSQnaQUuMfD8MHod\/noname03.png\",<br>\"https:\/\/cdn.steemitimages.com\/DQmaz2ZN9XND5zD1vrzA6mnqC1cHZ7RF91bZocWFAiHjXrZ\/noname04.png\" ,<br>\"app\":\"steemit\/0.1\",<br>\"format\":\"markdown\" " |
|