First try to solve Polynomial equations by Tensorflow
First try to solve polynomial equations y=3x^2+2x-5 using Tensorflow Output with 100000 looptimes: A: [ 2.99184537] B: [ 2.0156281] C: [-5.00763798] D: [ 2.00114322] loss: 4.62821e-07 from __future__ import print_function import tensorflow as tf sess = tf.Session(); #Model Parameters A = tf.Variable([ 1. ], dtype =tf.float32) B = tf.Variable([ 1. ], dtype =tf.float32) C = tf.Variable([- 1. ], dtype =tf.float32) D = tf.Variable([ 1. ], dtype =tf.float32) #Model Input and Output x = tf.placeholder(tf.float32) y = tf.placeholder(tf.float32) unknown_model = A * x ** D + B * x + C #Loss loss = tf.reduce_sum(tf.square(unknown_model - y)) #Optimizer optimizer = tf.train.AdamOptimizer( 0.01 ) train = optimizer.minimize(loss) #Training Data x_train = [ 1 , 2 , 3 , 4 ] y_train = [ 0 , 11 , 28 , 51 ] #Training Loop init = tf.global_variables_initializer() sess.run(init) for i in range ( 100000 ): sess.run(train, {x:x_train, y:y_train}) #evaluate training accuracy curr_A, curr_B, c...