# sinxeqn_regression_01.py
import tensorflow as tf
x_train = [-2.0, -0.7, 0.4, 2.0]
y_train = [-0.7518,-0.2674, 0.05905, 0.7518]
W1 = tf.Variable(tf.random_uniform([1],-3.2, -3.0, dtype = tf.float32, name='weight1'))
W2 = tf.Variable(tf.random_uniform([1],-0.5, +0.5, dtype = tf.float32, name='weight2'))
W3 = tf.Variable(tf.random_uniform([1], 3.0, 3.2, dtype = tf.float32, name='weight3'))
hypothesis = (tf.sin(x_train) - tf.sin(W1))*(tf.sin(x_train) - tf.sin(W2))*(tf.sin(x_train) - tf.sin(W3))
cost = tf.reduce_mean(tf.square(hypothesis - y_train))
optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.6)
train = optimizer.minimize(cost)
sess = tf.Session()
sess.run(tf.global_variables_initializer())
for step in range(5001):
sess.run(train)
if step % 1000 == 0:
print(step, sess.run(cost), sess.run(W1), sess.run(W2), sess.run(W3))
'머신러닝' 카테고리의 다른 글
x**(1/3)=0 TensorFlow 수치해 파이선 코드 (0) | 2018.11.25 |
---|---|
x-2sin(x)=0 TensorFlow 수치해 (0) | 2018.11.25 |
3차방정식의 근 구하기 텐서플로우 파이선 코드 (0) | 2018.11.25 |
머신러닝 TensorFlow 응용 2차 방정식의 중근 구하기 (0) | 2018.11.25 |
Rosenblatt Perceptron N = 1 조도센서 예제 Fermi-Diradc 확률분포를 사용하는 Sigmoid 확률분포 계산 (0) | 2018.09.06 |