简体中文 / [English]


TensorFlow Learning Diary-2 Regression and Classification Problems

 

This article is currently an experimental machine translation and may contain errors. If anything is unclear, please refer to the original Chinese version. I am continuously working to improve the translation.

TensorFlow Learning Diary-2

p.s.: Finally had some time to continue learning TensorFlow during summer break. Even though I’m just going over the basics of the framework and fundamental concepts, it’s actually kind of fun. (?)

What I learned today:

  • Solving linear regression problems using gradient descent: y = w*x + b

Learned how to apply gradient descent to linear regression. It feels like an extension of the least squares method from high school—instead of solving it algebraically, we use gradient descent (iteratively adjusting parameters in the direction of steepest descent) to minimize the loss, making it applicable to a wider range of problems.

  • Using matrix multiplication for classification (handwritten digit recognition): h = ReLU(X@W + b)

Experimented with the MNIST handwritten digit dataset. Building upon linear regression, I introduced non-linear activation functions and multiple hidden layers to tackle more complex, non-linear tasks—like recognizing handwritten digits.

General workflow: Convert input data into matrices, then repeatedly apply transformations like h = ReLU(X@Wi + bi) to gradually reduce dimensionality. After several layers of transformation, compute the loss by comparing the output with One-Hot Encoded labels using mean squared error. Then use gradient descent to find the optimal set of parameters that minimizes this loss.

I originally wanted to try implementing deep learning from scratch without relying on TensorFlow—but time was tight. Even building a simple two- or three-layer network turned out to be way more work than expected… so I gave up.

This article is licensed under the CC BY-NC-SA 4.0 license.

Author: lyc8503, Article link: https://blog.lyc8503.net/en/post/tensorflow-2-regression-and-classification/
If this article was helpful or interesting to you, consider buy me a coffee¬_¬
Feel free to comment in English below o/