πββοΈ Introduction to Tensorflow
Brief Introduction to Tensorflow
π© Main flow of programs in Tensorflow
Create Tensors (variables) that are not yet executed/evaluated.
Write operations between those Tensors.
Initialize your Tensors.
Create a Session.
Run the Session. This will run the operations you'd written above.
To summarize, remember to initialize your variables, create a session and run the operations inside the session. π©βπ«
π©βπ» Code Example
To calculate the following formula:
When we created a variable for the loss, we simply defined the loss as a function of other quantities, but did not evaluate its value. To evaluate it, we had to use the initializer.
β DeΔiΕken BaΕlatma (initalization) HakkΔ±nda Not
For the following code:
π€ΈββοΈ The output is
As expected, we will not see 20 π€! We got a tensor saying that the result is a tensor that does not have the shape attribute, and is of type "int32". All we did was put in the 'computation graph', but we have not run this computation yet.
π¦ Placeholders in TF
A placeholder is an object whose value you can specify only later. To specify values for a placeholder, we can pass in values by using a
feed dictionary
.Below, a placeholder has been created for x. This allows us to pass in a number later when we run the session.
π More examples
Computing sigmoid function with TF
Computing cost function with TF
Last updated
Was this helpful?