An Introduction to TensorFlow and implementing a simple Linear Regression Model

After that is done we simply need to run the graph.So, there are basically 3 different types of nodes which are used to make these graphs : Constant, Variable, and Placeholder nodes.A Constant Node contains constant values which cannot be changed.A Variable Node can be used to store some initial values, but we can change them if we want to, later on..A special function is required to initialize the values in the beginning.Placeholder Nodes don’t need to have any particular values defined initially but can be assigned values when running sessions..Below we have a code snippet which shows how these nodes actually work.The output for the above codeIn line 6 we see how a constant node is defined..We can also define a node in the way we did in line 7 without explicitly mentioning the data type of the node..It is very easy to understand the output of the addition of the constant nodes..We can also see how we can define the variable nodes and change their values as and when we want..The initial value of the variable node is given as [5.0] in line 17 but we change its value to [10.0] in line 24.We will be using the placeholder nodes a lot and it is crucial that we understand them in a better manner..Unlike the constant or variable nodes we don’t provide any particular data which a placeholder has to hold when defining them..We define another operator node to multiply the values of these placeholder nodes once their values are provided..In line 35 we provide the value of the placeholder nodes in the form of 2 arrays and the output that we get is the element-wise multiplication of the 2 arrays.Linear RegressionSo, in the next part of our tutorial we will now see how we can implement a Linear Regression model using TensorFlow.Imagine we have a function y=mx+c..Here y is the dependent variable and x is the independent variable..Hence, the change in variable x produces a change in variable y.. More details

Leave a Reply