Last active
July 3, 2018 02:22
-
-
Save keiji/c8fdc405f21d51426ceaa66a597e4de0 to your computer and use it in GitHub Desktop.
Twitterで流れていた問題のアレ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://twitter.com/kaityo256/status/904279527353749509 | |
| import tensorflow as tf | |
| a = tf.Variable(0.1) | |
| b = tf.Variable(0.2) | |
| c = tf.Variable(0.3) | |
| result = a / (b + c) + b / (c + a) + c / (a + b) | |
| groundtruth = tf.constant(4.0) | |
| loss = tf.squared_difference(result, groundtruth) | |
| global_step = tf.Variable(0, trainable=False) | |
| opt = tf.train.GradientDescentOptimizer(0.0001) | |
| train_op = opt.minimize(loss, global_step=global_step) | |
| with tf.Session() as sess: | |
| sess.run(tf.global_variables_initializer()) | |
| while True: | |
| _, step, value, a_value, b_value, c_value = sess.run([train_op, global_step, result, a, b, c]) | |
| print('%d - a:%f, b:%f, c:%f, result:%f' % (step, a_value, b_value, c_value, value)) | |
| if value == 4.0: | |
| break |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
自然数の解はないと思ったらちゃんとあった。
https://twitter.com/kaityo256/status/904279898507771905