

{"id":16076,"date":"2018-05-20T07:00:08","date_gmt":"2018-05-20T07:00:08","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=16076"},"modified":"2021-05-14T11:00:20","modified_gmt":"2021-05-14T05:30:20","slug":"tensorflow-linear-model","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/","title":{"rendered":"TensorFlow Linear Model Using Kernel Methods"},"content":{"rendered":"<p><span style=\"font-weight: 400\">In this <strong>TensorFlow <\/strong>tutorial, for TensorFlow Linear Model, we will be learning the preparation and loading of <em>MNIST dataset<\/em>. Also, we will look at how to train a simple linear model in TensorFlow. <\/span><\/p>\n<p><span style=\"font-weight: 400\">We will get to know, how to improve the linear model which will use in TensorFlow by adding explicit kernel methods to the model. This article is for the ones who have the knowledge of <strong>kernel<\/strong> and <strong>Support Vector Machines(SVMs)<\/strong>.<\/span><\/p>\n<p>So, let&#8217;s start the TensorFlow Linear Model with Kernel Methods.<\/p>\n<h2><span style=\"font-weight: 400\">TensorFlow Linear Model Using Kernel Methods<\/span><\/h2>\n<p><span style=\"font-weight: 400\">Explicit kernel mappings are supported by TensorFlow for dense purposes solely. At later releases extended support will be provided by TensorFlow.<\/span><\/p>\n<p><span style=\"font-weight: 400\">You will be using tf.contrib.learn which a is high-level API used for <strong>machine learning<\/strong> along with MNIST dataset. The following contents will be taught:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Load and prepare the <strong>MNIST dataset<\/strong>.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Make a linear model, train it and then evaluate it on eval data.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">How to substitute the linear model with the kernel linear model, retrain it and then evaluate it.<\/span><\/li>\n<\/ul>\n<h2><span style=\"font-weight: 400\">Preparing and Loading the MNIST Dataset<\/span><\/h2>\n<p><span style=\"font-weight: 400\">Run the following:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">data = tf.contrib.learn.datasets.mnist.load_mnist()<\/pre>\n<p><span style=\"font-weight: 400\">This will load the whole dataset and as you are already aware the data is split into validation data, test data and training data.<\/span><\/p>\n<p><span style=\"font-weight: 400\">You\u2019ll be using validation and training data to evaluate and train the models respectively. It is a good practice to convert your data to tensors for convenient use. A function that will add operations to the TensorFlow graph could be used which will create sub-batches to be used further.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The <\/span><strong><a href=\"https:\/\/www.tensorflow.org\/api_docs\/python\/tf\/train\/shuffle_batch\">tf.train.shuffle_batch<\/a><\/strong><span style=\"font-weight: 400\">\u00a0operation converts the numpy array to a tensor, making it easier to specify the batch_size. Also, to shuffle the input for every execution, the input_fn Ops should be used. The code for doing the same is as follows: <\/span><\/p>\n<pre class=\"EnlighterJSRAW\">import numpy as np\r\nimport tensorflow as tf\r\ndef get_input_fn(dataset_split, batch_size, capacity=10000, min_after_dequeue=3000):\r\n  def _input_fn():\r\n    images_batch, labels_batch = tf.train.shuffle_batch(\r\n        tensors=[dataset_split.images, dataset_split.labels.astype(np.int32)],\r\n        batch_size=batch_size,\r\n        capacity=capacity,\r\n        min_after_dequeue=min_after_dequeue,\r\n        enqueue_many=True,\r\n        num_threads=4)\r\n    features_map = {'images': images_batch}\r\n    return features_map, labels_batch\r\n  return _input_fn\r\ndata = tf.contrib.learn.datasets.mnist.load_mnist()\r\ntrain_input_fn = get_input_fn(data.train, batch_size=256)\r\neval_input_fn = get_input_fn(data.validation, batch_size=5000)<\/pre>\n<h2><span style=\"font-weight: 400\">Training a Simple TensorFlow Linear Model<\/span><\/h2>\n<p><span style=\"font-weight: 400\">It is time now to start the training process. You will include <\/span><a href=\"https:\/\/www.tensorflow.org\/api_docs\/python\/tf\/contrib\/learn\/LinearClassifier\"><i><span style=\"font-weight: 400\">tf.contrib.learn.LinearClassifier<\/span><\/i><\/a><span style=\"font-weight: 400\"> which has 10 digits represented by the 10 classes.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">image_column = tf.contrib.layers.real_valued_column('images', dimension=784)\r\n<\/pre>\n<p><span style=\"font-weight: 400\">A LinearClassifier is constructed, trained and evaluated using:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">import time\r\nimage_column = tf.contrib.layers.real_valued_column('images', dimension=784)\r\nestimator = tf.contrib.learn.LinearClassifier(feature_columns=[image_column], n_classes=10)\r\nstart = time.time()\r\nestimator.fit(input_fn=train_input_fn, steps=2000)\r\nend = time.time()\r\nprint('Elapsed time: {} seconds'.format(end - start))\r\neval_metrics = estimator.evaluate(input_fn=eval_input_fn, steps=1)\r\nprint(eval_metrics)\r\n<\/pre>\n<p><span style=\"font-family: Verdana, Geneva, sans-serif\">The results are shown as follows:<\/span><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Capture-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-16116 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Capture-3.png\" alt=\"\" width=\"772\" height=\"146\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Capture-3.png 772w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Capture-3-150x28.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Capture-3-300x57.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Capture-3-768x145.png 768w\" sizes=\"auto, (max-width: 772px) 100vw, 772px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400\">In addition to experimenting with the (training) batch size and the number of training steps, there are a couple of other parameters that can be altered. <\/span><\/p>\n<p><span style=\"font-weight: 400\">There are a variety of available optimizers from which you can choose the one which minimizes the loss. An example is given below, that creates a linear classifier that follows FTRL strategy of optimization.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">optimizer = tf.train.FtrlOptimizer(learning_rate=5.0, l2_regularization_strength=1.0)\r\nestimator = tf.contrib.learn.LinearClassifier(\r\n    feature_columns=[image_column], n_classes=10, optimizer=optimizer)\r\n<\/pre>\n<p><span style=\"font-weight: 400\">The maximum accuracy with this model turns out to be around 93%<\/span><br \/>\n<span style=\"font-weight: 400\">Technical details<\/span><\/p>\n<p><span style=\"font-weight: 400\">You will now get to know about the technical details. The use of the <\/span><b>Random Fourier Features<\/b><span style=\"font-weight: 400\"> to map the input data is crucial to the process. It maps a vector<\/span><span style=\"font-weight: 400\"> x\u2208<\/span><span style=\"font-weight: 400\">R<\/span><span style=\"font-weight: 400\">D<\/span><span style=\"font-weight: 400\"> to <\/span><span style=\"font-weight: 400\">x<\/span><span style=\"font-weight: 400\">&#8216;<\/span><span style=\"font-weight: 400\">\u2208<\/span><span style=\"font-weight: 400\">R<\/span><span style=\"font-weight: 400\">D<\/span><\/p>\n<p><span style=\"font-weight: 400\">via the following relation:<\/span><\/p>\n<div id=\"attachment_16117\" style=\"width: 602px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eqn.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-16117\" class=\"wp-image-16117 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eqn.png\" alt=\"TensorFlow Linear Model\" width=\"592\" height=\"32\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eqn.png 592w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eqn-150x8.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eqn-300x16.png 300w\" sizes=\"auto, (max-width: 592px) 100vw, 592px\" \/><\/a><p id=\"caption-attachment-16117\" class=\"wp-caption-text\">TensorFlow Linear Model<\/p><\/div>\n<p><span style=\"font-weight: 400\">where,<\/span><\/p>\n<div id=\"attachment_16118\" style=\"width: 297px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eqn2.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-16118\" class=\"wp-image-16118 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eqn2.png\" alt=\"TensorFlow Linear Model- Regression formula\" width=\"287\" height=\"33\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eqn2.png 287w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/eqn2-150x17.png 150w\" sizes=\"auto, (max-width: 287px) 100vw, 287px\" \/><\/a><p id=\"caption-attachment-16118\" class=\"wp-caption-text\">TensorFlow Linear Model- Regression formula<\/p><\/div>\n<p><span style=\"font-weight: 400\">with the element-wise application.<\/span><\/p>\n<p><span style=\"font-weight: 400\">You might notice, the values of <\/span><b>\u2126<\/b><span style=\"font-weight: 400\"> and <\/span><b>b<\/b><span style=\"font-weight: 400\"> are sampled from distributions only if the mapping satisfies the given property:<\/span><\/p>\n<p><span style=\"font-weight: 400\">The RHS of the expression above is a Gaussian kernel function which is most widely used function in the field of ML as it measures similarity in a vector space which is higher dimensional than the original one<\/span><span style=\"font-weight: 400\">.<\/span><\/p>\n<h2><span style=\"font-weight: 400\">Kernel Classifier in TensorFlow Linear Model<\/span><\/h2>\n<p><span style=\"font-weight: 400\">tf.contrib.kernel_methods.KernelLinearClassifier is an estimator which integrates the kernel mappings the rectilinear model. <\/span><\/p>\n<p><span style=\"font-weight: 400\">The constructor of the estimator is identical to that of the linear classifier and has an additional optionality to list out kernel mappings which can be applied to each feature used by the classifier. The following code will tell how to replace LinearClassifier with KernelLinearClassifier.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">image_column = tf.contrib.layers.real_valued_column('images', dimension=784)\r\noptimizer = tf.train.FtrlOptimizer(\r\n   learning_rate=50.0, l2_regularization_strength=0.001)\r\nkernel_mapper = tf.contrib.kernel_methods.RandomFourierFeatureMapper(\r\n  input_dim=784, output_dim=2000, stddev=5.0, name='rffm')\r\nkernel_mappers = {image_column: [kernel_mapper]}\r\nestimator = tf.contrib.kernel_methods.KernelLinearClassifier(\r\n   n_classes=10, optimizer=optimizer, kernel_mappers=kernel_mappers)\r\nstart = time.time()\r\nestimator.fit(input_fn=train_input_fn, steps=2000)\r\nend = time.time()\r\nprint('Elapsed time: {} seconds'.format(end - start))\r\neval_metrics = estimator.evaluate(input_fn=eval_input_fn, steps=1)\r\nprint(eval_metrics)<\/pre>\n<p><span style=\"font-weight: 400\">There is one additional parameter to KernelLinearClassifier which is a<strong> python dictionary<\/strong> from feature_columns. Using random Fourier features, the code below tells the classifier to the map the initial images to a 2K-D vector:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">kernel_mapper = tf.contrib.kernel_methods.RandomFourierFeatureMapper(\r\n  input_dim=784, output_dim=2000, stddev=5.0, name='rffm')\r\nkernel_mappers = {image_column: [kernel_mapper]}\r\nestimator = tf.contrib.kernel_methods.KernelLinearClassifier(\r\n   n_classes=10, optimizer=optimizer, kernel_mappers=kernel_mappers)<\/pre>\n<p><span style=\"font-weight: 400\">Note the stddev parameter. It is the standard deviation of the kernel.<\/span><br \/>\n<span style=\"font-weight: 400\">The results of running the above code summarize in the given table below. You can further increase the accuracy by increasing the output dimension of the mapping and by adjusting the standard deviation.<\/span><\/p>\n<div id=\"attachment_16119\" style=\"width: 781px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Captureasd.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-16119\" class=\"wp-image-16119 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Captureasd.png\" alt=\"Kernel Classifier in TensorFlow Linear Model\" width=\"771\" height=\"147\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Captureasd.png 771w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Captureasd-150x29.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Captureasd-300x57.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Captureasd-768x146.png 768w\" sizes=\"auto, (max-width: 771px) 100vw, 771px\" \/><\/a><p id=\"caption-attachment-16119\" class=\"wp-caption-text\">Kernel Classifier in TensorFlow Linear Model<\/p><\/div>\n<h2><span style=\"font-weight: 400\">Kernel Standard Deviation (Stddev)<\/span><\/h2>\n<p>The classification quality in TensorFlow Linear Model is very sensitive to the value of stddev. The below table shows the accuracy of the classifier on the valuation data for different values of stddev. The optimal value is 5.<\/p>\n<div id=\"attachment_16120\" style=\"width: 781px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Captureasdf.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-16120\" class=\"wp-image-16120 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Captureasdf.png\" alt=\"Kernel Standard Deviation\" width=\"771\" height=\"237\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Captureasdf.png 771w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Captureasdf-150x46.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Captureasdf-300x92.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Captureasdf-768x236.png 768w\" sizes=\"auto, (max-width: 771px) 100vw, 771px\" \/><\/a><p id=\"caption-attachment-16120\" class=\"wp-caption-text\">Kernel Standard Deviation<\/p><\/div>\n<h3><span style=\"font-weight: 400\">a. Output dimension<\/span><\/h3>\n<p><span style=\"font-weight: 400\">The larger the output dimension of the mapping, the closer is the inner product of two mapped vectors giving a newly improved classification accuracy. It can think of as output dimension being equal to the number of weights of the rectilinear model. <\/span><\/p>\n<p><span style=\"font-weight: 400\">The degree of freedom of the model is directly proportional to the dimension. However, after a certain limit, the accuracy starts to saturate as you increase the vector dimension, with the downside of increased time. <\/span><\/p>\n<p><span style=\"font-weight: 400\">This is shown in the below two Figures that depict the accuracy vs output dimension and the training time, respectively.<\/span><\/p>\n<div id=\"attachment_16121\" style=\"width: 530px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/graqph-1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-16121\" class=\"wp-image-16121 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/graqph-1.png\" alt=\"Output Dimension of Kernel Standard Deviation\" width=\"520\" height=\"368\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/graqph-1.png 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/graqph-1-150x106.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/graqph-1-300x212.png 300w\" sizes=\"auto, (max-width: 520px) 100vw, 520px\" \/><\/a><p id=\"caption-attachment-16121\" class=\"wp-caption-text\">Output Dimension of Kernel Standard Deviation<\/p><\/div>\n<div id=\"attachment_16122\" style=\"width: 524px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/graph-2.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-16122\" class=\"wp-image-16122 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/graph-2.png\" alt=\"Eval accuracy vs training time in kernel stddev\" width=\"514\" height=\"368\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/graph-2.png 514w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/graph-2-150x107.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/graph-2-300x215.png 300w\" sizes=\"auto, (max-width: 514px) 100vw, 514px\" \/><\/a><p id=\"caption-attachment-16122\" class=\"wp-caption-text\">Eval accuracy vs training time in kernel stddev<\/p><\/div>\n<p>So, this was all about TensorFlow Linear model with Kernel Methods. Hope you like our explanation,<\/p>\n<h2><span style=\"font-weight: 400\">Conclusion<\/span><\/h2>\n<p><span style=\"font-weight: 400\">Hence, in this TensorFlow Linear Model tutorial, we saw the linear model with the kernel method. Moreover, we discussed logistics regressions model, the regression formula. <\/span><\/p>\n<p><span style=\"font-weight: 400\">Also, we discussed preparing the MNIST dataset, Kernel classifier, and Standard Deviation of Kernel. Still, if any doubt regarding TensorFlow Linear Model, ask in the comment tab.<\/span><span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:1940,&quot;href&quot;:&quot;https:\\\/\\\/www.tensorflow.org\\\/api_docs\\\/python\\\/tf\\\/train\\\/shuffle_batch&quot;,&quot;archived_href&quot;:&quot;&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:1941,&quot;href&quot;:&quot;https:\\\/\\\/www.tensorflow.org\\\/api_docs\\\/python\\\/tf\\\/contrib\\\/learn\\\/LinearClassifier&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20190327222520\\\/https:\\\/\\\/www.tensorflow.org\\\/api_docs\\\/python\\\/tf\\\/contrib\\\/learn\\\/LinearClassifier&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-10 12:29:45&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2025-12-31 02:20:26&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-02-03 05:48:35&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-02-21 14:48:56&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-07 19:14:37&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-28 02:21:05&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-06-20 08:45:23&quot;,&quot;http_code&quot;:503}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-20 08:45:23&quot;,&quot;http_code&quot;:503},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this TensorFlow tutorial, for TensorFlow Linear Model, we will be learning the preparation and loading of MNIST dataset. Also, we will look at how to train a simple linear model in TensorFlow. We&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":16157,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[8003,8008,8009,8390,11477,14563,14564,14565,14566,14568,14585,14602,14608],"class_list":["post-16076","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tensorflow","tag-kernel-classifier-in-tensorflow-linear-model","tag-kernel-methods","tag-kernel-standard-deviation-stddev","tag-logistic-regression-model","tag-regression-formula","tag-tensorflow-linear-classifier-example","tag-tensorflow-linear-function","tag-tensorflow-linear-mode","tag-tensorflow-linear-model-tutorial","tag-tensorflow-liner-function","tag-tensorflow-non-linear-regression","tag-tensorflow-regression-formula","tag-tensorflow-tutorial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>TensorFlow Linear Model Using Kernel Methods - DataFlair<\/title>\n<meta name=\"description\" content=\"TensorFlow Linear Model, Kernels Methods &amp; Classifier, Preparing MNIST Dataset,logistic regression,Kernel Standard Deviation,regression formula TensorFlow\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"TensorFlow Linear Model Using Kernel Methods - DataFlair\" \/>\n<meta property=\"og:description\" content=\"TensorFlow Linear Model, Kernels Methods &amp; Classifier, Preparing MNIST Dataset,logistic regression,Kernel Standard Deviation,regression formula TensorFlow\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-05-20T07:00:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-14T05:30:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/TensorFlow-Linear-Model-01.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"TensorFlow Linear Model Using Kernel Methods - DataFlair","description":"TensorFlow Linear Model, Kernels Methods & Classifier, Preparing MNIST Dataset,logistic regression,Kernel Standard Deviation,regression formula TensorFlow","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:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/","og_locale":"en_US","og_type":"article","og_title":"TensorFlow Linear Model Using Kernel Methods - DataFlair","og_description":"TensorFlow Linear Model, Kernels Methods & Classifier, Preparing MNIST Dataset,logistic regression,Kernel Standard Deviation,regression formula TensorFlow","og_url":"https:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-05-20T07:00:08+00:00","article_modified_time":"2021-05-14T05:30:20+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/TensorFlow-Linear-Model-01.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89"},"headline":"TensorFlow Linear Model Using Kernel Methods","datePublished":"2018-05-20T07:00:08+00:00","dateModified":"2021-05-14T05:30:20+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/"},"wordCount":959,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/TensorFlow-Linear-Model-01.jpg","keywords":["Kernel Classifier in TensorFlow Linear Model","Kernel Methods","Kernel Standard Deviation (stddev)","Logistic Regression Model","Regression Formula","TensorFlow Linear classifier example","TensorFlow Linear function","TensorFlow Linear Mode","TensorFlow Linear Model tutorial","TensorFlow Liner function","TensorFlow Non linear regression","TensorFlow Regression formula","Tensorflow Tutorial"],"articleSection":["Tensorflow Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/","url":"https:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/","name":"TensorFlow Linear Model Using Kernel Methods - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/TensorFlow-Linear-Model-01.jpg","datePublished":"2018-05-20T07:00:08+00:00","dateModified":"2021-05-14T05:30:20+00:00","description":"TensorFlow Linear Model, Kernels Methods & Classifier, Preparing MNIST Dataset,logistic regression,Kernel Standard Deviation,regression formula TensorFlow","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/TensorFlow-Linear-Model-01.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/TensorFlow-Linear-Model-01.jpg","width":1200,"height":628,"caption":"TensorFlow Linear Model"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/tensorflow-linear-model\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Tensorflow Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/tensorflow\/"},{"@type":"ListItem","position":3,"name":"TensorFlow Linear Model Using Kernel Methods"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"The DataFlair Team provides industry-driven content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our expert educators focus on delivering value-packed, easy-to-follow resources for tech enthusiasts and professionals.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam2\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/16076","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=16076"}],"version-history":[{"count":6,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/16076\/revisions"}],"predecessor-version":[{"id":94992,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/16076\/revisions\/94992"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/16157"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=16076"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=16076"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=16076"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}