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 ParametersA = 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 Outputx = tf.placeholder(tf.float32)
y = tf.placeholder(tf.float32)
unknown_model = A * x ** D + B * x + C

#Lossloss = tf.reduce_sum(tf.square(unknown_model - y))

#Optimizeroptimizer = tf.train.AdamOptimizer(0.01)
train = optimizer.minimize(loss)

#Training Datax_train = [1,2,3,4]
y_train = [0,11,28,51]

#Training Loopinit = tf.global_variables_initializer()
sess.run(init)
for i in range(100000):
    sess.run(train, {x:x_train, y:y_train})

#evaluate training accuracycurr_A, curr_B, curr_C, curr_D, curr_loss = sess.run([A, B, C, D, loss], {x: x_train, y: y_train})
print("A: %s B: %s C: %s D: %s loss: %s"%(curr_A, curr_B, curr_C, curr_D, curr_loss))

Popular posts from this blog

Accuracy for Logistic Regression model is always lower than using Convolutional neural network

96.24% accuracy with higher epoch numbers for Convolutional Neural Network

Tower Defense (Endless TD Beta)

Using mini batch SGD Neural Network in Alphabet recognition!

Simple data curation practices using Numpy (Udacity Deep Learning Assignment 1)

Endless Falling

Python to read and record SQM-LE data, search saved data and find IP address..

Accuracy 96% with Simple Deep NN using Keras Theano backend for nonMNist alphabet recognition

Mine Sweeper C#

First try coding for Sudoku