|
8 | 8 | y_data = xy[:, [-1]]
|
9 | 9 |
|
10 | 10 | # Make sure the shape and data are OK
|
11 |
| -print(x_data.shape, x_data, len(x_data)) |
12 |
| -print(y_data.shape, y_data) |
| 11 | +print(x_data, "\nx_data shape:", x_data.shape) |
| 12 | +print(y_data, "\ny_data shape:", y_data.shape) |
| 13 | + |
| 14 | +# data output |
| 15 | +''' |
| 16 | +[[ 73. 80. 75.] |
| 17 | + [ 93. 88. 93.] |
| 18 | + ... |
| 19 | + [ 76. 83. 71.] |
| 20 | + [ 96. 93. 95.]] |
| 21 | +x_data shape: (25, 3) |
| 22 | +[[152.] |
| 23 | + [185.] |
| 24 | + ... |
| 25 | + [149.] |
| 26 | + [192.]] |
| 27 | +y_data shape: (25, 1) |
| 28 | +''' |
13 | 29 |
|
14 | 30 | # placeholders for a tensor that will be always fed.
|
15 | 31 | X = tf.placeholder(tf.float32, shape=[None, 3])
|
|
34 | 50 | sess.run(tf.global_variables_initializer())
|
35 | 51 |
|
36 | 52 | for step in range(2001):
|
37 |
| - cost_val, hy_val, _ = sess.run( |
38 |
| - [cost, hypothesis, train], feed_dict={X: x_data, Y: y_data}) |
| 53 | + cost_val, hy_val, _ = sess.run([cost, hypothesis, train], |
| 54 | + feed_dict={X: x_data, Y: y_data}) |
39 | 55 | if step % 10 == 0:
|
40 |
| - print(step, "Cost: ", cost_val, "\nPrediction:\n", hy_val) |
| 56 | + print(step, "Cost:", cost_val, "\nPrediction:\n", hy_val) |
| 57 | + |
| 58 | +# train output |
| 59 | +''' |
| 60 | +0 Cost: 21027.0 |
| 61 | +Prediction: |
| 62 | + [[22.048063 ] |
| 63 | + [21.619772 ] |
| 64 | + ... |
| 65 | + [31.36112 ] |
| 66 | + [24.986364 ]] |
| 67 | +10 Cost: 95.976326 |
| 68 | +Prediction: |
| 69 | + [[157.11063 ] |
| 70 | + [183.99283 ] |
| 71 | + ... |
| 72 | + [167.48862 ] |
| 73 | + [193.25117 ]] |
| 74 | + 1990 Cost: 24.863274 |
| 75 | +Prediction: |
| 76 | + [[154.4393 ] |
| 77 | + [185.5584 ] |
| 78 | + ... |
| 79 | + [158.27443 ] |
| 80 | + [192.79778 ]] |
| 81 | +2000 Cost: 24.722485 |
| 82 | +Prediction: |
| 83 | + [[154.42894 ] |
| 84 | + [185.5586 ] |
| 85 | + ... |
| 86 | + [158.24257 ] |
| 87 | + [192.79166 ]] |
| 88 | +''' |
41 | 89 |
|
42 | 90 | # Ask my score
|
43 |
| -print("Your score will be ", sess.run( |
44 |
| - hypothesis, feed_dict={X: [[100, 70, 101]]})) |
| 91 | +print("Your score will be ", sess.run(hypothesis, |
| 92 | + feed_dict={X: [[100, 70, 101]]})) |
45 | 93 |
|
46 | 94 | print("Other scores will be ", sess.run(hypothesis,
|
47 | 95 | feed_dict={X: [[60, 70, 110], [90, 100, 80]]}))
|
|
0 commit comments