|
8 | 8 | }, |
9 | 9 | "outputs": [], |
10 | 10 | "source": [ |
11 | | - "!pip install autokeras\n" |
| 11 | + "!pip install autokeras" |
12 | 12 | ] |
13 | 13 | }, |
14 | 14 | { |
|
23 | 23 | "import tensorflow as tf\n", |
24 | 24 | "from tensorflow.keras.datasets import mnist\n", |
25 | 25 | "\n", |
26 | | - "import autokeras as ak\n" |
| 26 | + "import autokeras as ak" |
27 | 27 | ] |
28 | 28 | }, |
29 | 29 | { |
|
47 | 47 | "(x_train, y_train), (x_test, y_test) = mnist.load_data()\n", |
48 | 48 | "print(x_train.shape) # (60000, 28, 28)\n", |
49 | 49 | "print(y_train.shape) # (60000,)\n", |
50 | | - "print(y_train[:3]) # array([7, 2, 1], dtype=uint8)\n" |
| 50 | + "print(y_train[:3]) # array([7, 2, 1], dtype=uint8)" |
51 | 51 | ] |
52 | 52 | }, |
53 | 53 | { |
|
83 | 83 | "\n", |
84 | 84 | "\n", |
85 | 85 | "# Evaluate the best model with testing data.\n", |
86 | | - "print(clf.evaluate(x_test, y_test))\n" |
| 86 | + "print(clf.evaluate(x_test, y_test))" |
87 | 87 | ] |
88 | 88 | }, |
89 | 89 | { |
|
112 | 112 | " # Split the training data and use the last 15% as validation data.\n", |
113 | 113 | " validation_split=0.15,\n", |
114 | 114 | " epochs=10,\n", |
115 | | - ")\n" |
| 115 | + ")" |
116 | 116 | ] |
117 | 117 | }, |
118 | 118 | { |
|
144 | 144 | " # Use your own validation set.\n", |
145 | 145 | " validation_data=(x_val, y_val),\n", |
146 | 146 | " epochs=10,\n", |
147 | | - ")\n" |
| 147 | + ")" |
148 | 148 | ] |
149 | 149 | }, |
150 | 150 | { |
|
184 | 184 | "clf = ak.AutoModel(\n", |
185 | 185 | " inputs=input_node, outputs=output_node, overwrite=True, max_trials=1\n", |
186 | 186 | ")\n", |
187 | | - "clf.fit(x_train, y_train, epochs=10)\n" |
| 187 | + "clf.fit(x_train, y_train, epochs=10)" |
188 | 188 | ] |
189 | 189 | }, |
190 | 190 | { |
|
218 | 218 | "clf = ak.AutoModel(\n", |
219 | 219 | " inputs=input_node, outputs=output_node, overwrite=True, max_trials=1\n", |
220 | 220 | ")\n", |
221 | | - "clf.fit(x_train, y_train, epochs=10)\n" |
| 221 | + "clf.fit(x_train, y_train, epochs=10)" |
222 | 222 | ] |
223 | 223 | }, |
224 | 224 | { |
|
268 | 268 | "print(y_train[:3])\n", |
269 | 269 | "# array([[0., 0., 0., 0., 0., 1., 0., 0., 0., 0.],\n", |
270 | 270 | "# [1., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n", |
271 | | - "# [0., 0., 0., 0., 1., 0., 0., 0., 0., 0.]])\n" |
| 271 | + "# [0., 0., 0., 0., 1., 0., 0., 0., 0., 0.]])" |
272 | 272 | ] |
273 | 273 | }, |
274 | 274 | { |
|
297 | 297 | "# Predict with the best model.\n", |
298 | 298 | "predicted_y = clf.predict(test_set)\n", |
299 | 299 | "# Evaluate the best model with testing data.\n", |
300 | | - "print(clf.evaluate(test_set))\n" |
| 300 | + "print(clf.evaluate(test_set))" |
301 | 301 | ] |
302 | 302 | }, |
303 | 303 | { |
|
0 commit comments