TensorFlow Basics - shefaas/PythonAI-BitDegree GitHub Wiki

Working Example (Linear Regression)

  • Linear regression formula: y = mx + b
  • Linear regression is one of the simple machine learning models.
  • The x value will be given as an input, and the model will return the value of y depending on the calculated optimal values for m and b.
  • The goal of training the model is to optimize the values for m and b that best fit the given training data (x and y).
  • The work will start by guess values for m and b, then the training will optimize them to minimize the loss.
  • Loss is the difference between the actual y value and the line itself.

General

  • Constant nodes doesn’t hold its value until the session actually started.
  • Tensor Shape: is the size of data where [5.0] has shape (1,) and [ [3.0], [2.0] ] has shape (2,1).
  • Variable nodes needs a global variables initializer to initialize all the variables before it being used during session running.
  • Assigning a new value for a variable needs to be taken during session running.

Node Types

  • Constant Node: holds a constant value. The value can be float number, integer, or even a string.
  • Operator Node: holds the type of the operator as well as the operands nodes.
  • Placeholder: holds no value until we pass the value during session running.
  • Variable Node: holds an initial value but it can be re-assigned by another one during the session. Also, it has some extra functions over the constant nodes.