From 37661080a111768e565ae53299c4796ebe711a71 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Thu, 21 Mar 2024 14:29:50 -0600 Subject: fix mathjax stuff --- .../2024-03-21-Polynomial-Regression-in-TensorFlow-2.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'Content') diff --git a/Content/posts/2024-03-21-Polynomial-Regression-in-TensorFlow-2.md b/Content/posts/2024-03-21-Polynomial-Regression-in-TensorFlow-2.md index 4341f09..6317175 100644 --- a/Content/posts/2024-03-21-Polynomial-Regression-in-TensorFlow-2.md +++ b/Content/posts/2024-03-21-Polynomial-Regression-in-TensorFlow-2.md @@ -59,9 +59,8 @@ y = (x**3)*coefficients[3] + (x**2)*coefficients[2] + (x**1)*coefficients[1] (x* Which is equivalent to the general cubic equation: - + + $$ y = ax^3 + bx^2 + cx + d @@ -85,15 +84,15 @@ for epoch in range(num_epochs): In TensorFlow 1, we would have been using `tf.Session` instead. -Here we are using `GradientTape()` instead, to keep track of the loss evaluation and coefficients. This is crucial, as our optimizer needs these gradients to be able to optimize our coefficients. +Here we are using `GradientTape()` instead, to keep track of the loss evaluation and coefficients. This is crucial, as our optimizer needs these gradients to be able to optimize our coefficients. -Our loss function is Mean Squared Error (MSE) +Our loss function is Mean Squared Error (MSE): $$ -= \frac{1}{n}\sum_{i=1}^{n} (Y_i - \^{Y_i}) += \frac{1}{n} \sum_{i=1}^{n}{(Y\_i - \hat{Y\_i})^2} $$ -Where $\^{Y_i}$ is the predicted value and $Y_i$ is the actual value +Where Yi^ is the predicted value and Yi is the actual value ### Plotting Final Coefficients @@ -228,7 +227,9 @@ As always, remember to tweak the parameters and choose the correct model for the ## Further Programming -How would you modify this code to use another type of nonlinear regression? Say, $ y = ab^x $ +How would you modify this code to use another type of nonlinear regression? Say, + +$$ y = ab^x $$ Hint: Your loss calculation would be similar to: -- cgit v1.2.3