From 093e1b095c26e758cc1ccd1eb34be9d318b2bd1e Mon Sep 17 00:00:00 2001 From: Lawrence Sinclair Date: Sun, 16 Feb 2020 18:39:09 -0800 Subject: [PATCH] bias(error) should not be in linear_regression fn Having + b in the calculation biases the results. It give you a regression like y = W*x + W2*b + e where e~N(0,1). You effectively add the error term into the regression. The result looks a bit like having a hidden constant term in the model. Using regular linear regression, the coefficient estimate (W) is 0.36, and removing +b, you get exactly the same results with this tf version. --- tensorflow_v2/notebooks/2_BasicModels/linear_regression.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow_v2/notebooks/2_BasicModels/linear_regression.ipynb b/tensorflow_v2/notebooks/2_BasicModels/linear_regression.ipynb index 17b57b8a..588f0342 100644 --- a/tensorflow_v2/notebooks/2_BasicModels/linear_regression.ipynb +++ b/tensorflow_v2/notebooks/2_BasicModels/linear_regression.ipynb @@ -72,7 +72,7 @@ "\n", "# Linear regression (Wx + b).\n", "def linear_regression(x):\n", - " return W * x + b\n", + " return W * x\n", "\n", "# Mean square error.\n", "def mean_square(y_pred, y_true):\n",