#!/usr/bin/env python3
import tensorflow as tf
import numpy as np
"""Basic usage of tensorflow
solve eqation Ax = y
A = [1, 2]
    [3, 4]
y = [10]
    [22]
so x = ?
"""

if __name__ == '__main__':
    A = tf.constant( [[1., 2.], [3., 4.]])
    y = tf.constant([[10.], [22.]])
    x = tf.Variable(tf.zeros([2, 1])) # x is unkown, so set it a Variable
    y_ = tf.matmul(A, x)
    """ y is the target value
        y_ is current value
        so, less (y_ - y) indicates more accurate x
    """

    deviation = tf.reduce_sum(tf.square(y - y_))
    train_step = tf.train.GradientDescentOptimizer(0.01).minimize(deviation)

    init = tf.initialize_all_variables()
    sess = tf.Session()
    sess.run(init)
    for i in range(10000):
        sess.run(train_step)
    print(sess.run(x))

@@ -108,16 +108,39 @@
 n Ax = y
+ with interation method
 %0AA = %5B1,
@@ -371,17 +371,17 @@
 le%0A    y
-_
+y
  = tf.ma
@@ -430,17 +430,17 @@
        y
-_
+y
  is curr
@@ -472,14 +472,16 @@
 s (y
-_
+y
  - y)
+%5E2
  ind
@@ -532,22 +532,8 @@
 n = 
-tf.reduce_sum(
 tf.s
@@ -547,10 +547,9 @@
  - y
-_)
+y
 )%0A  
@@ -708,16 +708,47 @@
 n(init)%0A
+    %22%22%22iterate 10000 times %22%22%22%0A
     for 

rename y_ to yy, change deviation from tf.reduce_sum(tf.square(y - yy)) to tf.square(y - yy)