1"""Pycharm: https://www.jetbrains.com/pycharm/
2
3...or if you are willing to go the better,
4more painful, but yet better way, you should NOT use an IDE.
5The solution is a text editor.
6
7Good Text Editors (ranked):
8 - Atom : https://atom.io/
9 - VS Code : https://code.visualstudio.com/
10 - Sublime Text : https://www.sublimetext.com/
11"""
1<pre id="3346" class="graf graf--pre graf-after--p">%matplotlib inline
2import numpy as np
3import matplotlib.pyplot as plt
4fig = plt.figure()
5ax = plt.axes(projection=’3d’)</pre>
6
1theta = 2 * np.pi * np.random.random(1000)
2r = 6 * np.random.random(1000)
3x = np.ravel(r * np.sin(theta))
4y = np.ravel(r * np.cos(theta))
5z = f(x, y)
6ax = plt.axes(projection=’3d’)
7ax.plot_trisurf(x, y, z,cmap=’viridis’, edgecolor=’none’);
8
1import numpy as np
2
3import tensorflow as tf
4
5
6
7from include.data import get_data_set
8
9from include.model import model
10
11
12
13
14
15test_x, test_y = get_data_set("test")
16
17x, y, output, y_pred_cls, global_step, learning_rate = model()
18
19
20
21
22
23_BATCH_SIZE = 128
24
25_CLASS_SIZE = 10
26
27_SAVE_PATH = "./tensorboard/cifar-10-v1.0.0/"
28
29
30
31
32
33saver = tf.train.Saver()
34
35sess = tf.Session()
36
37
38
39
40
41try:
42
43 print("
44Trying to restore last checkpoint ...")
45
46 last_chk_path = tf.train.latest_checkpoint(checkpoint_dir=_SAVE_PATH)
47
48 saver.restore(sess, save_path=last_chk_path)
49
50 print("Restored checkpoint from:", last_chk_path)
51
52except ValueError:
53
54 print("
55Failed to restore checkpoint. Initializing variables instead.")
56
57 sess.run(tf.global_variables_initializer())
58
59
60
61
62
63def main():
64
65 i = 0
66
67 predicted_class = np.zeros(shape=len(test_x), dtype=np.int)
68
69 while i < len(test_x):
70
71 j = min(i + _BATCH_SIZE, len(test_x))
72
73 batch_xs = test_x[i:j, :]
74
75 batch_ys = test_y[i:j, :]
76
77 predicted_class[i:j] = sess.run(y_pred_cls, feed_dict={x: batch_xs, y: batch_ys})
78
79 i = j
80
81
82
83 correct = (np.argmax(test_y, axis=1) == predicted_class)
84
85 acc = correct.mean() * 100
86
87 correct_numbers = correct.sum()
88
89 print()
90
91 print("Accuracy on Test-Set: {0:.2f}% ({1} / {2})".format(acc, correct_numbers, len(test_x)))
92
93if __name__ == "__main__":
94
95 main()
96
97sess.close()
98
1ax = plt.axes(projection=’3d’)# Data for a three-dimensional line
2zline = np.linspace(0, 15, 1000)
3xline = np.sin(zline)
4yline = np.cos(zline)
5ax.plot3D(xline, yline, zline, ‘gray’)# Data for three-dimensional scattered points
6zdata = 15 * np.random.random(100)
7xdata = np.sin(zdata) + 0.1 * np.random.randn(100)
8ydata = np.cos(zdata) + 0.1 * np.random.randn(100)
9ax.scatter3D(xdata, ydata, zdata, c=zdata, cmap=’Greens’);
10
1def f(x, y):
2 return np.sin(np.sqrt(x ** 2 + y ** 2))
3
4x = np.linspace(-6, 6, 30)
5y = np.linspace(-6, 6, 30)
6
7X, Y = np.meshgrid(x, y)
8Z = f(X, Y)fig = plt.figure()
9ax = plt.axes(projection='3d')
10ax.contour3D(X, Y, Z, 50, cmap='binary')
11ax.set_xlabel('x')
12ax.set_ylabel('y')
13ax.set_zlabel('z');
14