{"id":1421,"date":"2017-04-15T00:16:21","date_gmt":"2017-04-14T15:16:21","guid":{"rendered":"http:\/\/now0930.tk\/wordpress\/?p=1421"},"modified":"2017-04-15T23:57:41","modified_gmt":"2017-04-15T14:57:41","slug":"%ec%9d%b8%ea%b5%ac-%eb%8d%b0%ec%9d%b4%ed%84%b0%eb%a1%9c-%eb%85%84-%ec%88%98%ec%9e%85-%ec%98%88%ec%b8%a1","status":"publish","type":"post","link":"https:\/\/now0930.pe.kr\/wordpress\/%ec%9d%b8%ea%b5%ac-%eb%8d%b0%ec%9d%b4%ed%84%b0%eb%a1%9c-%eb%85%84-%ec%88%98%ec%9e%85-%ec%98%88%ec%b8%a1\/","title":{"rendered":"\uc778\uad6c \ub370\uc774\ud130\ub85c \ub144 \uc218\uc785 \uc608\uce21"},"content":{"rendered":"<h1>\ub370\uc774\ud130 \uc5bb\uae30<\/h1>\n<p><a href=\"http:\/\/archive.ics.uci.edu\/ml\/datasets\/Adult\">\ub370\uc774\ud130 \uc14b\uc744 \ubb34\ub8cc\ub85c \uc81c\uacf5\ud558\ub294 \uc0ac\uc774\ud2b8<\/a>\uc5d0\uc11c \ubbf8\uad6d \uc131\uc778 \ub098\uc774, \ud559\ub825, \uac00\uc871\uad00\uacc4, \ub144 \uc18c\ub4dd\uc744 \ubc1b\uc744 \uc218 \uc788\ub2e4. \uc785\ub825\ub41c \ub370\uc774\ud130\ub85c \uc774 \uc0ac\ub78c\uc774 \uc5f0\uc18c\ub4dd 50k dollar\uc744 \ub118\uc5b4\uac00\ub294\uc9c0 \uc544\ub2cc\uc9c0\ub97c \uc608\uce21\ud574\ubcf4\ub824\uace0 \ud55c\ub2e4. \ub2e4\ud589\ud788 \uc774 \ub370\uc774\ud130 \uc14b\uc73c\ub85c \uc5f0\uc2b5\ud55c \uc0ac\ub78c\ub4e4\uc774 \ub9ce\uc740\uc9c0, \uc870\ud68c\uc218\uac00 \uc0c1\ub2f9\ud788 \ub9ce\ub2e4.<\/p>\n<h1>\uc804\uccb4\uc801\uc778 \uc811\uadfc \ubc29\ubc95<\/h1>\n<p>\ub370\uc774\ud130\uc758 \uad6c\uc870\ub294 \ub098\uc774, \uc774\ub984, \uac00\uc871\uad00\uacc4 \ub4f1\uacfc \uc5f0 \uc18c\ub4dd\uc774 \ub118\uc5b4\uac00\ub294\uc9c0 \uc544\ub2cc\uc9c0\ub85c \uad6c\uc131\ub418\uc5b4 \uc788\ub2e4. feature\ub85c \uc4f8 \ubd80\ubd84\uc744 \ubcf4\uba74 categorical, continuous \ub370\uc774\ud130\ub85c \uad6c\ubd84\ub41c\ub2e4.<br \/>\n1. \ud30c\uc77c\uc744 training, test set\uc73c\ub85c \uad6c\ubd84\ud558\uc5ec \uc77d\ub294\ub2e4.<br \/>\n2. categorical \ub370\uc774\ud130\ub294 \uc22b\uc790\ub85c \ubcc0\uacbd<br \/>\n3. integer \ub370\uc774\ud130\ub294 \uadf8\ub300\ub85c \uc0ac\uc6a9<br \/>\n4. training..<\/p>\n<p>feature\ub85c \uc4f8 \ud56d\ubaa9\ubcc4 \ub370\uc774\ud130\uac00 \uc0c1\ub2f9\ud788 \ub9ce\ub2e4. python\uc758 dictionary\ub85c \uc77c\uc77c\ud788 \uccd0 \ubcc0\ud658\ud558\uae30\ub294 \uadc0\ucc2e\ub2e4. \uad00\ub828 \uc18c\uc2a4\ub97c \ucc3e\uc544 \ubcf4\uc558\ub294\ub370 <a href=\"https:\/\/www.tensorflow.org\/tutorials\/wide\">tensorflow tutorial<\/a>\uc5d0 \uc774 \uc608\uc81c\uac00 \uc124\uba85\uc744 \ud588\ub2e4.!!\ube59\uace0!!!\uc774\ub798\uc11c \ub0a8\ub4e4\uc774 \uc4f0\ub294 \uc608\uc81c\ub97c \uc368\uc57c\ud55c\ub2e4!!<\/p>\n<h1>tensorflow tutorial \uc815\ub9ac<\/h1>\n<p>\ud29c\ud1a0\ub9ac\uc5bc\uc758 \uad6c\uc870\ub294 \ub300\ub7b5 \uc544\ub798\uc640 \uac19\ub2e4.<br \/>\n1. \ub370\uc774\ud130 \uc14b\uc744 \uc77d\uc74c<br \/>\n2. label\uc744 \ubd99\uc784(0 \ub610\ub294 1)<br \/>\n3. feature\ub97c categorical, continuous \uae30\uc900\uc73c\ub85c \ubd84\ub958<br \/>\n4. feature\ub97c tensor\ub85c \uc77d\uc5b4 \ub4e4\uc784<br \/>\n5. feature\ub97c \uc544\ub798 4\uac00\uc9c0 \uacbd\uc6b0\ub85c \uc138\ubd80 \ubd84\ub958<br \/>\n&#8211; SparseColumn : categorical<br \/>\n&#8211; RealValuedColumn : continuous<br \/>\n&#8211; BucketizedColumn : \uc77c\uc815\ud55c \uad6c\uac04\uc73c\ub85c \ubd84\ub958\ub418\ub294 \ub370\uc774\ud130\ub4e4<br \/>\n&#8211; CrossedColumn : \uc11c\ub85c \uc5f0\uad00\ub418\ub294 \ub370\uc774\ud130\ub4e4..<br \/>\n6. feature\uc5d0 \uc801\uc815\ud55c \ud568\uc218\ub97c \uc0ac\uc6a9\ud558\uc5ec ID\ub97c \ubd80\uc5ec..<br \/>\n7. training<br \/>\n\uc704 \uae30\ub2a5\ub4e4\uc744 \ubaa8\ub450 tensorflow\uac00 \uc81c\uacf5\ud558\ub294 \ud568\uc218\ub85c \uc27d\uac8c? \ub530\ub77c\uc11c \uad6c\ud604\ud560 \uc218 \uc788\ub2e4. tensorflow\uac00 \uc5c6\uc5c8\uc73c\uba74 machine learning\uc758 \uc811\uadfc\uc774 \uc0c1\ub2f9\ud788 \uc5b4\ub824\uc6e0\ub2e4\uace0 \uc0dd\uac01\ub41c\ub2e4.<\/p>\n<p>\ucf54\ub4dc\ub97c \uc368\ubcf4\uace0 \uc774\ud574\ud558\ub294 \uacfc\uc815\uc774 \ub0a8\uc544\uc788\ub2e4&#8230;<\/p>\n<h1>sparse tensor, 4.15 \ucd94\uac00\ubd84<\/h1>\n<p>\uc704 tutorial\uc740 categorical \ud615\uc2dd\uc758 \ub370\uc774\ud130\ub97c sparse tensor\ub97c \uc0ac\uc6a9\ud558\uc5ec \ud45c\ud604\ud558\uc600\ub2e4.<\/p>\n<pre class=\"lang:python decode:true \">sparse_tensor = tf.SparseTensor(indices=[[0,1], [2,4]],values=[6, 0.5],dense_shape=[3, 5])<\/pre>\n<p>sparse tensor\ub294 \uc77c\uc815 \ud589\ub82c\uc5d0 \ud2b9\uc815 \ubd80\ubd84(indices)\uc5d0\ub9cc \ub370\uc774\ud130(values)\uac00 \uc788\uace0 \ub098\uba38\uc9c0 \ubd80\ubd84\uc740 0\uc778 \ud150\uc11c\uc774\ub2e4. sparse tensor \uc120\uc5b8\uc2dc \uc804\uccb4 \ud589\ub82c\uc758 \ud06c\uae30(dense_shape)\ub3c4 \uc120\uc5b8\ud55c\ub2e4. \uc704\uc640 \uac19\uc774 \ub9cc\ub4e4\uba74 [0,1]\uc5d0 6\uc774 \ub4e4\uc5b4\uac00\uace0, [2,4]\uc5d0 0.5\uac00 \ub4e4\uc5b4\uac00\uac8c \ub41c\ub2e4. \uc804\uccb4 shape\ub294 [3,5]\ub85c \uc81c\ud55c\ub41c\ub2e4. \ub300\ub7b5 \uc544\ub798\uc640 \uac19\uc740 \ud615\uc2dd\uc758 \ub370\uc774\ud130\uac00 \ub41c\ub2e4.<br \/>\n[ [0 6 0 0 0 ]<br \/>\n[0 0 0 0 0 ]<br \/>\n[0 0 0 0 0.5 ] ]<br \/>\n\ubb38\uc81c\ub294 \uc704\uc758 \ud589\ub82c\uc744 print\ub85c \ubcf4\uace0 \uc2f6\uc740\ub370, \ubcfc \uc218 \uc788\ub294 \ubc29\ubc95\uc774 \uc5c6\ub2e4.<\/p>\n<pre class=\"lang:python decode:true \">sparse_tensor = tf.SparseTensor(indices=[[0,1], [2,4]],values=[6, 0.5],dense_shape=[3, 5]) \r\nwith tf.Session() as sess:\r\n    print sparse_tensor\r\n<\/pre>\n<p>\uc774\ub807\uac8c \uc2e4\ud589\ud558\uba74<\/p>\n<pre class=\"lang:sh decode:true\">SparseTensor(indices=Tensor(\"SparseTensor_2\/indices:0\", shape=(2, 2), dtype=int64), values=Tensor(\"SparseTensor_2\/values:0\", shape=(2,), dtype=float32), dense_shape=Tensor(\"SparseTensor_2\/dense_shape:0\", shape=(2,), dtype=int64))<\/pre>\n<p>\uc544\ub798\uc640 \uac19\uc774 \uba54\uc138\uc9c0\uac00 \ub098\uc628\ub2e4. \uc778\ud130\ub137\uc744 \ucc3e\uc544 \ubcf4\uc558\uc9c0\ub9cc sparse tensor\ub97c \ub208\uc73c\ub85c \ubcfc \uc218 \uc788\ub294 \ubc29\ubc95\uc774 \uc5c6\uc5b4 \ubcf4\uc778\ub2e4. \ud544\uc694\ub3c4 \uc5c6\uc5b4 \ubcf4\uc774\uace0<\/p>\n<p>\uba87 \uc2dc\uac04\uc758 \uc0bd\uc9c8 \uacb0\uacfc..\uc544\ub798\uc640 \uac19\uc774 \uacb0\ub860\uc744 \ub0b4\ub9b4 \uc218 \uc788\ub2e4.<\/p>\n<pre class=\"lang:python decode:true\">gender = tf.contrib.layers.sparse_column_with_keys(column_name=\"gender\", keys=[\"Female\", \"Male\"], combiner=\"sum\")\r\neducation = tf.contrib.layers.sparse_column_with_hash_bucket(\"education\", hash_bucket_size=1000, combiner=\"sum\")\r\n\r\nfeature, label = train_input_fn()\r\n<\/pre>\n<p>train_input_fn\uc740 \uc544\ub798\uc640 \uac19\ub2e4.<\/p>\n<pre class=\"lang:python decode:true\">def input_fn(df):\r\n    # Creates a dictionary mapping from each continuous feature column name (k) to\r\n    # the values of that column stored in a constant Tensor.\r\n    # Creates a dictionary mapping from each categorical feature column name (k)\r\n    # to the values of that column stored in a tf.SparseTensor.\r\n    categorical_cols = {k: tf.SparseTensor(\r\n        indices=[[i, 0] for i in range(df[k].size)],\r\n        values=df[k].values,\r\n        dense_shape=[df[k].size, 1])\r\n        for k in CATEGORICAL_COLUMNS}\r\n    # Merges the two dictionaries into one.\r\n    feature_cols = dict(categorical_cols.items())\r\n\r\n    # Converts the label column into a constant Tensor.\r\n    label = tf.constant(df[LABEL_COLUMN].values)\r\n    # Returns the feature columns and the label.\r\n    return feature_cols, label\r\n\r\ndef train_input_fn():\r\n    return input_fn(df_train)\r\n<\/pre>\n<p>1. training data\uc5d0\uc11c \ud574\ub2f9\ud558\ub294 column\uc744 key \ud615\uc2dd\uc73c\ub85c \uc77d\uc5b4 \ub4e4\uc778\ub2e4.<br \/>\n2. train_input_fn\uc5d0\uc11c\ub294 \ud574\ub2f9 key\ubcc4\ub85c sparse tensor\ub97c \uc0c8\ub85c \ub9cc\ub4e0\ub2e4. -&gt; \uce7c\ub7fc\ubcc4 \uc5b4\ub290 \ub370\uc774\ud130\uac00 \uc788\ub294\uc9c0 \ub2e4\ub978 \ub370\uc774\ud130\ub97c \ub9cc\ub4e0\ub2e4.<br \/>\n3. categorical_cols\uc744 feature_cols\ub85c dict \ud0c0\uc785\uc73c\ub85c \ubcc0\uacbd\ud55c\ub2e4.<br \/>\n4. \uc704 \uc608\uc81c\uc5d0\uc11c\ub294 key\uac00 gender, education\uc774 \ub418\uace0 values\uac00 \uac01 \ud0a4\uc5d0 \ud574\ub2f9\ud558\ub294 sparse tensor\uac00 \ub41c\ub2e4.<\/p>\n<p>\ub098\uc911\uc5d0 dict \ud615\uc2dd\uc758 feature\ub97c \ub7ec\ub2dd\ud558\uba74 \uc790\ub3d9\uc73c\ub85c \ubcc0\ud658\ub418\uc5b4\uc11c \uc785\ub825\uc774 \ub418\ub098\ubcf4\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ub370\uc774\ud130 \uc5bb\uae30 \ub370\uc774\ud130 \uc14b\uc744 \ubb34\ub8cc\ub85c \uc81c\uacf5\ud558\ub294 \uc0ac\uc774\ud2b8\uc5d0\uc11c \ubbf8\uad6d \uc131\uc778 \ub098\uc774, \ud559\ub825, \uac00\uc871\uad00\uacc4, \ub144 \uc18c\ub4dd\uc744 \ubc1b\uc744 \uc218 \uc788\ub2e4. \uc785\ub825\ub41c \ub370\uc774\ud130\ub85c \uc774 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1425,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[33],"tags":[114,109],"class_list":["post-1421","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tensorflow","tag-machinelearning","tag-tensorflow"],"jetpack_featured_media_url":"https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2017\/04\/Large2.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/1421","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/comments?post=1421"}],"version-history":[{"count":6,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/1421\/revisions"}],"predecessor-version":[{"id":1446,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/1421\/revisions\/1446"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/media\/1425"}],"wp:attachment":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/media?parent=1421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/categories?post=1421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/tags?post=1421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}