Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions docs/ipynb/customized.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"outputs": [],
"source": [
"!pip install autokeras\n"
"!pip install autokeras"
]
},
{
Expand All @@ -23,7 +23,7 @@
"import tensorflow as tf\n",
"from tensorflow.keras.datasets import mnist\n",
"\n",
"import autokeras as ak\n"
"import autokeras as ak"
]
},
{
Expand Down Expand Up @@ -67,7 +67,6 @@
},
"outputs": [],
"source": [
"\n",
"input_node = ak.ImageInput()\n",
"output_node = ak.Normalization()(input_node)\n",
"output_node1 = ak.ConvBlock()(output_node)\n",
Expand All @@ -77,7 +76,7 @@
"\n",
"auto_model = ak.AutoModel(\n",
" inputs=input_node, outputs=output_node, overwrite=True, max_trials=1\n",
")\n"
")"
]
},
{
Expand Down Expand Up @@ -108,7 +107,6 @@
},
"outputs": [],
"source": [
"\n",
"(x_train, y_train), (x_test, y_test) = mnist.load_data()\n",
"print(x_train.shape) # (60000, 28, 28)\n",
"print(y_train.shape) # (60000,)\n",
Expand All @@ -119,7 +117,7 @@
"# Predict with the best model.\n",
"predicted_y = auto_model.predict(x_test)\n",
"# Evaluate the best model with testing data.\n",
"print(auto_model.evaluate(x_test, y_test))\n"
"print(auto_model.evaluate(x_test, y_test))"
]
},
{
Expand Down Expand Up @@ -176,7 +174,6 @@
},
"outputs": [],
"source": [
"\n",
"class SingleDenseLayerBlock(ak.Block):\n",
" def build(self, hp, inputs=None):\n",
" # Get the input_node from inputs.\n",
Expand All @@ -185,8 +182,7 @@
" hp.Int(\"num_units\", min_value=32, max_value=512, step=32)\n",
" )\n",
" output_node = layer(input_node)\n",
" return output_node\n",
"\n"
" return output_node"
]
},
{
Expand Down Expand Up @@ -220,7 +216,7 @@
"y_test = np.random.rand(num_instances, 1).astype(np.float32)\n",
"# Train the model\n",
"auto_model.fit(x_train, y_train, epochs=1)\n",
"print(auto_model.evaluate(x_test, y_test))\n"
"print(auto_model.evaluate(x_test, y_test))"
]
},
{
Expand Down
7 changes: 3 additions & 4 deletions docs/ipynb/export.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"outputs": [],
"source": [
"!pip install autokeras\n"
"!pip install autokeras"
]
},
{
Expand All @@ -23,7 +23,7 @@
"from tensorflow.keras.datasets import mnist\n",
"from tensorflow.keras.models import load_model\n",
"\n",
"import autokeras as ak\n"
"import autokeras as ak"
]
},
{
Expand All @@ -47,7 +47,6 @@
},
"outputs": [],
"source": [
"\n",
"print(tf.__version__)\n",
"(x_train, y_train), (x_test, y_test) = mnist.load_data()\n",
"\n",
Expand All @@ -71,7 +70,7 @@
"loaded_model = load_model(\"model_autokeras\", custom_objects=ak.CUSTOM_OBJECTS)\n",
"\n",
"predicted_y = loaded_model.predict(tf.expand_dims(x_test, -1))\n",
"print(predicted_y)\n"
"print(predicted_y)"
]
}
],
Expand Down
20 changes: 10 additions & 10 deletions docs/ipynb/image_classification.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"outputs": [],
"source": [
"!pip install autokeras\n"
"!pip install autokeras"
]
},
{
Expand All @@ -23,7 +23,7 @@
"import tensorflow as tf\n",
"from tensorflow.keras.datasets import mnist\n",
"\n",
"import autokeras as ak\n"
"import autokeras as ak"
]
},
{
Expand All @@ -47,7 +47,7 @@
"(x_train, y_train), (x_test, y_test) = mnist.load_data()\n",
"print(x_train.shape) # (60000, 28, 28)\n",
"print(y_train.shape) # (60000,)\n",
"print(y_train[:3]) # array([7, 2, 1], dtype=uint8)\n"
"print(y_train[:3]) # array([7, 2, 1], dtype=uint8)"
]
},
{
Expand Down Expand Up @@ -83,7 +83,7 @@
"\n",
"\n",
"# Evaluate the best model with testing data.\n",
"print(clf.evaluate(x_test, y_test))\n"
"print(clf.evaluate(x_test, y_test))"
]
},
{
Expand Down Expand Up @@ -112,7 +112,7 @@
" # Split the training data and use the last 15% as validation data.\n",
" validation_split=0.15,\n",
" epochs=10,\n",
")\n"
")"
]
},
{
Expand Down Expand Up @@ -144,7 +144,7 @@
" # Use your own validation set.\n",
" validation_data=(x_val, y_val),\n",
" epochs=10,\n",
")\n"
")"
]
},
{
Expand Down Expand Up @@ -184,7 +184,7 @@
"clf = ak.AutoModel(\n",
" inputs=input_node, outputs=output_node, overwrite=True, max_trials=1\n",
")\n",
"clf.fit(x_train, y_train, epochs=10)\n"
"clf.fit(x_train, y_train, epochs=10)"
]
},
{
Expand Down Expand Up @@ -218,7 +218,7 @@
"clf = ak.AutoModel(\n",
" inputs=input_node, outputs=output_node, overwrite=True, max_trials=1\n",
")\n",
"clf.fit(x_train, y_train, epochs=10)\n"
"clf.fit(x_train, y_train, epochs=10)"
]
},
{
Expand Down Expand Up @@ -268,7 +268,7 @@
"print(y_train[:3])\n",
"# array([[0., 0., 0., 0., 0., 1., 0., 0., 0., 0.],\n",
"# [1., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
"# [0., 0., 0., 0., 1., 0., 0., 0., 0., 0.]])\n"
"# [0., 0., 0., 0., 1., 0., 0., 0., 0., 0.]])"
]
},
{
Expand Down Expand Up @@ -297,7 +297,7 @@
"# Predict with the best model.\n",
"predicted_y = clf.predict(test_set)\n",
"# Evaluate the best model with testing data.\n",
"print(clf.evaluate(test_set))\n"
"print(clf.evaluate(test_set))"
]
},
{
Expand Down
19 changes: 9 additions & 10 deletions docs/ipynb/image_regression.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"outputs": [],
"source": [
"!pip install autokeras\n"
"!pip install autokeras"
]
},
{
Expand All @@ -22,7 +22,7 @@
"import tensorflow as tf\n",
"from tensorflow.keras.datasets import mnist\n",
"\n",
"import autokeras as ak\n"
"import autokeras as ak"
]
},
{
Expand All @@ -49,13 +49,12 @@
},
"outputs": [],
"source": [
"\n",
"(x_train, y_train), (x_test, y_test) = mnist.load_data()\n",
"x_train = x_train[:100]\n",
"y_train = y_train[:100]\n",
"print(x_train.shape) # (60000, 28, 28)\n",
"print(y_train.shape) # (60000,)\n",
"print(y_train[:3]) # array([7, 2, 1], dtype=uint8)\n"
"print(y_train[:3]) # array([7, 2, 1], dtype=uint8)"
]
},
{
Expand Down Expand Up @@ -90,7 +89,7 @@
"\n",
"\n",
"# Evaluate the best model with testing data.\n",
"print(reg.evaluate(x_test, y_test))\n"
"print(reg.evaluate(x_test, y_test))"
]
},
{
Expand Down Expand Up @@ -119,7 +118,7 @@
" # Split the training data and use the last 15% as validation data.\n",
" validation_split=0.15,\n",
" epochs=2,\n",
")\n"
")"
]
},
{
Expand Down Expand Up @@ -151,7 +150,7 @@
" # Use your own validation set.\n",
" validation_data=(x_val, y_val),\n",
" epochs=2,\n",
")\n"
")"
]
},
{
Expand Down Expand Up @@ -191,7 +190,7 @@
"reg = ak.AutoModel(\n",
" inputs=input_node, outputs=output_node, overwrite=True, max_trials=1\n",
")\n",
"reg.fit(x_train, y_train, epochs=2)\n"
"reg.fit(x_train, y_train, epochs=2)"
]
},
{
Expand Down Expand Up @@ -225,7 +224,7 @@
"reg = ak.AutoModel(\n",
" inputs=input_node, outputs=output_node, overwrite=True, max_trials=1\n",
")\n",
"reg.fit(x_train, y_train, epochs=2)\n"
"reg.fit(x_train, y_train, epochs=2)"
]
},
{
Expand Down Expand Up @@ -278,7 +277,7 @@
"# Predict with the best model.\n",
"predicted_y = reg.predict(test_set)\n",
"# Evaluate the best model with testing data.\n",
"print(reg.evaluate(test_set))\n"
"print(reg.evaluate(test_set))"
]
},
{
Expand Down
19 changes: 8 additions & 11 deletions docs/ipynb/load.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"outputs": [],
"source": [
"!pip install autokeras\n"
"!pip install autokeras"
]
},
{
Expand All @@ -25,7 +25,7 @@
"import numpy as np\n",
"import tensorflow as tf\n",
"\n",
"import autokeras as ak\n"
"import autokeras as ak"
]
},
{
Expand Down Expand Up @@ -61,7 +61,7 @@
"local_dir_path = os.path.dirname(local_file_path)\n",
"# After check mannually, we know the extracted data is in 'flower_photos'.\n",
"data_dir = os.path.join(local_dir_path, \"flower_photos\")\n",
"print(data_dir)\n"
"print(data_dir)"
]
},
{
Expand Down Expand Up @@ -115,7 +115,7 @@
" seed=123,\n",
" image_size=(img_height, img_width),\n",
" batch_size=batch_size,\n",
")\n"
")"
]
},
{
Expand All @@ -137,7 +137,7 @@
"source": [
"clf = ak.ImageClassifier(overwrite=True, max_trials=1)\n",
"clf.fit(train_data, epochs=1)\n",
"print(clf.evaluate(test_data))\n"
"print(clf.evaluate(test_data))"
]
},
{
Expand Down Expand Up @@ -171,8 +171,7 @@
"data_dir = os.path.join(local_dir_path, \"aclImdb\")\n",
"# Remove the unused data folder.\n",
"\n",
"shutil.rmtree(os.path.join(data_dir, \"train/unsup\"))\n",
"\n"
"shutil.rmtree(os.path.join(data_dir, \"train/unsup\"))"
]
},
{
Expand Down Expand Up @@ -204,8 +203,7 @@
"\n",
"clf = ak.TextClassifier(overwrite=True, max_trials=1)\n",
"clf.fit(train_data, epochs=2)\n",
"print(clf.evaluate(test_data))\n",
"\n"
"print(clf.evaluate(test_data))"
]
},
{
Expand All @@ -226,7 +224,6 @@
},
"outputs": [],
"source": [
"\n",
"N_BATCHES = 30\n",
"BATCH_SIZE = 100\n",
"N_FEATURES = 10\n",
Expand Down Expand Up @@ -255,7 +252,7 @@
"\n",
"clf = ak.StructuredDataClassifier(overwrite=True, max_trials=1, seed=5)\n",
"clf.fit(x=dataset, validation_data=dataset, batch_size=BATCH_SIZE)\n",
"print(clf.evaluate(dataset))\n"
"print(clf.evaluate(dataset))"
]
},
{
Expand Down
Loading