{"id":40338,"date":"2019-03-30T19:05:13","date_gmt":"2019-03-30T16:05:13","guid":{"rendered":"https:\/\/www.altoros.com\/blog\/?p=40338"},"modified":"2019-06-08T05:28:49","modified_gmt":"2019-06-08T02:28:49","slug":"using-k-means-clustering-in-tensorflow","status":"publish","type":"post","link":"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/","title":{"rendered":"Implementing k-means Clustering with TensorFlow"},"content":{"rendered":"<p>In data science, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Cluster_analysis\" rel=\"noopener noreferrer\" target=\"_blank\">cluster analysis<\/a> (or clustering) is an <a href=\"https:\/\/en.wikipedia.org\/wiki\/Unsupervised_learning\" rel=\"noopener noreferrer\" target=\"_blank\">unsupervised-learning<\/a> method that can help to understand the nature of data by grouping information with similar characteristics. The clusters of data can then be used for creating hypotheses on classifying the data set. The <a href=\"https:\/\/www.altoros.com\/blog\/evaluating-the-apriori-algorithm-vs-k-means-clustering-for-a-recommendation-engine\/\" ><em>k<\/em>-means<\/a> algorithm is one of the clustering methods that proved to be very effective for the purpose.<\/p>\n<p>This step-by-step guide explains how to implement <em>k<\/em>-means cluster analysis with TensorFlow.<\/p>\n<p>&nbsp;<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/#Create_a_clustering_model\" >Create a clustering model<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/#Build_clusters_and_display_results\" >Build clusters and display results<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/#The_final_source_code\" >The final source code<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/#Further_reading\" >Further reading<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"Create_a_clustering_model\"><\/span>Create a clustering model<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>First, let\u2019s generate random data points with a uniform distribution and assign them to a 2D-tensor constant. Then, randomly choose initial centroids from the set of data points.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">points = tf.constant(np.random.uniform(0, 10, (points_n, 2)))\r\ncentroids = tf.Variable(tf.slice(tf.random_shuffle(points), &#x5B;0, 0], &#x5B;clusters_n, -1]))<\/pre>\n<p>For the next step, we want to be able to do element-wise subtraction of <em>points<\/em> and <em>centroids<\/em> that are 2D tensors. As the tensors have different shape, let\u2019s expand <em>points<\/em> and <em>centroids<\/em> into three dimensions, which enables us to use the <a href=\"https:\/\/docs.scipy.org\/doc\/numpy-1.10.1\/user\/basics.broadcasting.html\" target=\"_blank\" rel=\"noopener noreferrer\">broadcasting feature<\/a> of subtraction operation.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">points_expanded = tf.expand_dims(points, 0)\r\ncentroids_expanded = tf.expand_dims(centroids, 1)<\/pre>\n<p>Then, calculate the distances between points and centroids and determine the cluster assignments.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">distances = tf.reduce_sum(tf.square(tf.subtract(points_expanded, centroids_expanded)), 2)\r\nassignments = tf.argmin(distances, 0)<\/pre>\n<p>Next, we can compare each cluster with a cluster assignments vector, get points assigned to each cluster, and calculate mean values. These mean values are refined centroids, so let\u2019s update the centroids variable with the new values.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">means = &#x5B;]\r\nfor c in range(clusters_n):\r\n    means.append(tf.reduce_mean(\r\n      tf.gather(points, \r\n                tf.reshape(\r\n                  tf.where(\r\n                    tf.equal(assignments, c)\r\n                  ),&#x5B;1,-1])\r\n               ),reduction_indices=&#x5B;1]))\r\n\r\nnew_centroids = tf.concat(means, 0)\r\nupdate_centroids = tf.assign(centroids, new_centroids)<\/pre>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Build_clusters_and_display_results\"><\/span>Build clusters and display results<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>It\u2019s time to run the graph. For each iteration, we update the centroids and return their values along with the cluster assignments values.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">with tf.Session() as sess:\r\n  sess.run(init)\r\n  for step in xrange(iteration_n):\r\n    &#x5B;_, centroid_values, points_values, assignment_values] = sess.run(&#x5B;update_centroids, centroids, points, assignments])<\/pre>\n<p>Lastly, we display the coordinates of the final centroids and a multi-colored scatter plot showing how the data points have been clustered.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">print(&quot;centroids&quot;, centroid_values)\r\n\r\nplt.scatter(points_values&#x5B;:, 0], points_values&#x5B;:, 1], c=assignment_values, s=50, alpha=0.5)\r\nplt.plot(centroid_values&#x5B;:, 0], centroid_values&#x5B;:, 1], 'kx', markersize=15)\r\nplt.show()<\/pre>\n<p>After running the code, the clusters will be displayed as follows.<\/p>\n<p><center><a href=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/12\/using-k-means-clustering-in-tensorflow.png\"><img decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/12\/using-k-means-clustering-in-tensorflow.png\" alt=\"using-k-means-clustering-in-tensorflow\" width=\"640\" class=\"aligncenter size-full wp-image-10592\" \/><\/a><small>Clusters of data created with k-means<\/small><\/center><\/p>\n<p>The data in a training set is grouped into clusters as the result of implementing the <em>k<\/em>-means algorithm with TensorFlow.<\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"The_final_source_code\"><\/span>The final source code<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Here&#8217;s the full source code for this example\u2014combined all together.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">import matplotlib.pyplot as plt\r\nimport numpy as np\r\nimport tensorflow as tf\r\n\r\npoints_n = 200\r\nclusters_n = 3\r\niteration_n = 100\r\n\r\npoints = tf.constant(np.random.uniform(0, 10, (points_n, 2)))\r\ncentroids = tf.Variable(tf.slice(tf.random_shuffle(points), &#x5B;0, 0], &#x5B;clusters_n, -1]))\r\n\r\npoints_expanded = tf.expand_dims(points, 0)\r\ncentroids_expanded = tf.expand_dims(centroids, 1)\r\n\r\ndistances = tf.reduce_sum(tf.square(tf.subtract(points_expanded, centroids_expanded)), 2)\r\nassignments = tf.argmin(distances, 0)\r\n\r\nmeans = &#x5B;]\r\nfor c in range(clusters_n):\r\n    means.append(tf.reduce_mean(\r\n      tf.gather(points, \r\n                tf.reshape(\r\n                  tf.where(\r\n                    tf.equal(assignments, c)\r\n                  ),&#x5B;1,-1])\r\n               ),reduction_indices=&#x5B;1]))\r\n\r\nnew_centroids = tf.concat(means, 0)\r\n\r\nupdate_centroids = tf.assign(centroids, new_centroids)\r\ninit = tf.global_variables_initializer()\r\n\r\nwith tf.Session() as sess:\r\n  sess.run(init)\r\n  for step in range(iteration_n):\r\n    &#x5B;_, centroid_values, points_values, assignment_values] = sess.run(&#x5B;update_centroids, centroids, points, assignments])\r\n    \r\n  print(&quot;centroids&quot;, centroid_values)\r\n\r\nplt.scatter(points_values&#x5B;:, 0], points_values&#x5B;:, 1], c=assignment_values, s=50, alpha=0.5)\r\nplt.plot(centroid_values&#x5B;:, 0], centroid_values&#x5B;:, 1], 'kx', markersize=15)\r\nplt.show()<\/pre>\n<p>This is one of the many clustering methods available. While we presented one of the basic scenarios, other approaches exist for identifying centroids and ways to shape clusters (e.g., <a href=\"https:\/\/en.wikipedia.org\/wiki\/Hierarchical_clustering\" rel=\"noopener noreferrer\" target=\"_blank\">hierarchical clustering<\/a>).<\/p>\n<p>Check out the links below for tutorials on other algorithms that can be implemented with TensorFlow or attend <a href=\"https:\/\/www.altoros.com\/training\/artificial-intelligence\" rel=\"noopener noreferrer\" target=\"_blank\">our training<\/a> to get practical skills with machine learning.<\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Further_reading\"><\/span>Further reading<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/basic-concepts-and-manipulations-with-tensorflow\/\">Basic Concepts and Manipulations with TensorFlow<\/a><\/li>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/visualizing-tensorflow-graphs-with-tensorboard\/\">Visualizing TensorFlow Graphs with TensorBoard<\/a><\/li>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/using-linear-regression-in-tensorflow\/\">Using Linear Regression with TensorFlow<\/a><\/li>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/using-logistic-and-softmax-regression-with-tensorflow\/\">Using Logistic and Softmax Regression with TensorFlow<\/a><\/li>\n<\/ul>\n<hr \/>\n<p><center><small>This blog post is written by <a href=\"https:\/\/www.altoros.com\/blog\/author\/s-kovalev\/\">Sergey Kovalev<\/a>, Sergei Sintsov, and <a href=\"https:\/\/www.altoros.com\/blog\/author\/alex\/\">Alex Khizhniak<\/a><br \/>\nwith assistance from <a href=\"https:\/\/www.altoros.com\/blog\/author\/sophie.turol\/\">Sophia Turol<\/a>.<\/small><\/center><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In data science, cluster analysis (or clustering) is an unsupervised-learning method that can help to understand the nature of data by grouping information with similar characteristics. The clusters of data can then be used for creating hypotheses on classifying the data set. The k-means algorithm is one of the clustering [&#8230;]<\/p>\n","protected":false},"author":122,"featured_media":40343,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[214],"tags":[748,749],"class_list":["post-40338","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-machine-learning","tag-tensorflow"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Implementing k-means Clustering with TensorFlow | Altoros<\/title>\n<meta name=\"description\" content=\"With code samples, this tutorial demonstrates how to use the k-means algorithm for grouping data into clusters with similar characteristics.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Implementing k-means Clustering with TensorFlow | Altoros\" \/>\n<meta property=\"og:description\" content=\"In data science, cluster analysis (or clustering) is an unsupervised-learning method that can help to understand the nature of data by grouping information with similar characteristics. The clusters of data can then be used for creating hypotheses on classifying the data set. The k-means algorithm is one of the clustering [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/\" \/>\n<meta property=\"og:site_name\" content=\"Altoros\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-30T16:05:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-06-08T02:28:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/using-k-mean-clustering-with-tensorflow-machine-learning.gif\" \/>\n\t<meta property=\"og:image:width\" content=\"640\" \/>\n\t<meta property=\"og:image:height\" content=\"360\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/gif\" \/>\n<meta name=\"author\" content=\"Sergey Kovalev\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sergey Kovalev\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/\",\"url\":\"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/\",\"name\":\"Implementing k-means Clustering with TensorFlow | Altoros\",\"isPartOf\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/using-k-mean-clustering-with-tensorflow-machine-learning.gif\",\"datePublished\":\"2019-03-30T16:05:13+00:00\",\"dateModified\":\"2019-06-08T02:28:49+00:00\",\"author\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/7bb3c35a84eeaa32af69b53773e7fe1a\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/#primaryimage\",\"url\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/using-k-mean-clustering-with-tensorflow-machine-learning.gif\",\"contentUrl\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/using-k-mean-clustering-with-tensorflow-machine-learning.gif\",\"width\":640,\"height\":360},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.altoros.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Implementing k-means Clustering with TensorFlow\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.altoros.com\/blog\/#website\",\"url\":\"https:\/\/www.altoros.com\/blog\/\",\"name\":\"Altoros\",\"description\":\"Insight\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.altoros.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/7bb3c35a84eeaa32af69b53773e7fe1a\",\"name\":\"Sergey Kovalev\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2017\/01\/3faf706-150x150.jpg\",\"contentUrl\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2017\/01\/3faf706-150x150.jpg\",\"caption\":\"Sergey Kovalev\"},\"description\":\"Sergey Kovalev is a senior software engineer with extensive experience in high-load application development, big data and NoSQL solutions, cloud computing, data warehousing, and machine learning. He has strong expertise in back-end engineering, applying the best approaches for development, architecture design, and scaling. He has solid background in software development practices, such as the Agile methodology, prototyping, patterns, refactoring, and code review. Now, Sergey\u2019s main interest lies in big data distributed computing and machine learning.\",\"url\":\"https:\/\/www.altoros.com\/blog\/author\/s-kovalev\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Implementing k-means Clustering with TensorFlow | Altoros","description":"With code samples, this tutorial demonstrates how to use the k-means algorithm for grouping data into clusters with similar characteristics.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/","og_locale":"en_US","og_type":"article","og_title":"Implementing k-means Clustering with TensorFlow | Altoros","og_description":"In data science, cluster analysis (or clustering) is an unsupervised-learning method that can help to understand the nature of data by grouping information with similar characteristics. The clusters of data can then be used for creating hypotheses on classifying the data set. The k-means algorithm is one of the clustering [...]","og_url":"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/","og_site_name":"Altoros","article_published_time":"2019-03-30T16:05:13+00:00","article_modified_time":"2019-06-08T02:28:49+00:00","og_image":[{"width":640,"height":360,"url":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/using-k-mean-clustering-with-tensorflow-machine-learning.gif","type":"image\/gif"}],"author":"Sergey Kovalev","twitter_misc":{"Written by":"Sergey Kovalev","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/","url":"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/","name":"Implementing k-means Clustering with TensorFlow | Altoros","isPartOf":{"@id":"https:\/\/www.altoros.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/#primaryimage"},"image":{"@id":"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/#primaryimage"},"thumbnailUrl":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/using-k-mean-clustering-with-tensorflow-machine-learning.gif","datePublished":"2019-03-30T16:05:13+00:00","dateModified":"2019-06-08T02:28:49+00:00","author":{"@id":"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/7bb3c35a84eeaa32af69b53773e7fe1a"},"breadcrumb":{"@id":"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/#primaryimage","url":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/using-k-mean-clustering-with-tensorflow-machine-learning.gif","contentUrl":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2016\/04\/using-k-mean-clustering-with-tensorflow-machine-learning.gif","width":640,"height":360},{"@type":"BreadcrumbList","@id":"https:\/\/www.altoros.com\/blog\/using-k-means-clustering-in-tensorflow\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.altoros.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Implementing k-means Clustering with TensorFlow"}]},{"@type":"WebSite","@id":"https:\/\/www.altoros.com\/blog\/#website","url":"https:\/\/www.altoros.com\/blog\/","name":"Altoros","description":"Insight","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.altoros.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/7bb3c35a84eeaa32af69b53773e7fe1a","name":"Sergey Kovalev","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2017\/01\/3faf706-150x150.jpg","contentUrl":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2017\/01\/3faf706-150x150.jpg","caption":"Sergey Kovalev"},"description":"Sergey Kovalev is a senior software engineer with extensive experience in high-load application development, big data and NoSQL solutions, cloud computing, data warehousing, and machine learning. He has strong expertise in back-end engineering, applying the best approaches for development, architecture design, and scaling. He has solid background in software development practices, such as the Agile methodology, prototyping, patterns, refactoring, and code review. Now, Sergey\u2019s main interest lies in big data distributed computing and machine learning.","url":"https:\/\/www.altoros.com\/blog\/author\/s-kovalev\/"}]}},"_links":{"self":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts\/40338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/users\/122"}],"replies":[{"embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/comments?post=40338"}],"version-history":[{"count":30,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts\/40338\/revisions"}],"predecessor-version":[{"id":44046,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts\/40338\/revisions\/44046"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/media\/40343"}],"wp:attachment":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/media?parent=40338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/categories?post=40338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/tags?post=40338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}