diff --git a/_sources/notebooks/2.1-dense-keras.ipynb b/_sources/notebooks/2.1-dense-keras.ipynb index c873a2b..32b5180 100644 --- a/_sources/notebooks/2.1-dense-keras.ipynb +++ b/_sources/notebooks/2.1-dense-keras.ipynb @@ -198,7 +198,9 @@ "\n", "NDIM = len(VARS)\n", "inputs = Input(shape=(NDIM,), name=\"input\")\n", - "outputs = Dense(1, name=\"output\", kernel_initializer=\"normal\", activation=\"sigmoid\")(inputs)\n", + "outputs = Dense(1, name=\"output\", kernel_initializer=\"normal\", activation=\"sigmoid\")(\n", + " inputs\n", + ")\n", "\n", "# creae the model\n", "model = Model(inputs=inputs, outputs=outputs)\n", @@ -242,7 +244,9 @@ "\n", "from sklearn.model_selection import train_test_split\n", "\n", - "X_train_val, X_test, Y_train_val, Y_test = train_test_split(X, Y, test_size=0.2, random_state=7)\n", + "X_train_val, X_test, Y_train_val, Y_test = train_test_split(\n", + " X, Y, test_size=0.2, random_state=7\n", + ")\n", "\n", "# preprocessing: standard scalar\n", "from sklearn.preprocessing import StandardScaler\n", diff --git a/_sources/notebooks/3-conv2d.ipynb b/_sources/notebooks/3-conv2d.ipynb index 551c399..c20f62d 100644 --- a/_sources/notebooks/3-conv2d.ipynb +++ b/_sources/notebooks/3-conv2d.ipynb @@ -448,7 +448,7 @@ " save_best_only=True,\n", " save_weights_only=False,\n", " mode=\"auto\",\n", - " save_freq=\"epoch\",\n", + " save_freq=\"epoch\"\n", ")" ] }, diff --git a/_sources/notebooks/4-gnn-cora.ipynb b/_sources/notebooks/4-gnn-cora.ipynb index 180f253..a7bed93 100644 --- a/_sources/notebooks/4-gnn-cora.ipynb +++ b/_sources/notebooks/4-gnn-cora.ipynb @@ -184,7 +184,7 @@ ], "source": [ "# Load Cora dataset\n", - "dataset = Planetoid(root=\"/tmp/Cora\", name=\"Cora\")\n", + "dataset = Planetoid(root='/tmp/Cora', name='Cora')\n", "data = dataset[0]" ] }, @@ -269,13 +269,13 @@ } ], "source": [ - "print(\"node vectors: \\n\", data.x, \"\\n\")\n", - "print(\"node classes: \\n\", data.y, \"\\n\")\n", - "print(\"edge indeces: \\n\", data.edge_index, \"\\n\\n\\n\")\n", + "print(\"node vectors: \\n\", data.x, '\\n')\n", + "print(\"node classes: \\n\", data.y, '\\n')\n", + "print(\"edge indeces: \\n\", data.edge_index, '\\n\\n\\n')\n", "\n", - "print(\"train_mask: \\n\", data.train_mask, \"\\n\")\n", - "print(\"val_mask: \\n\", data.val_mask, \"\\n\")\n", - "print(\"test_mask: \\n\", data.test_mask, \"\\n\")" + "print(\"train_mask: \\n\", data.train_mask, '\\n')\n", + "print(\"val_mask: \\n\", data.val_mask, '\\n')\n", + "print(\"test_mask: \\n\", data.test_mask, '\\n')" ] }, { @@ -316,8 +316,8 @@ "\n", "plt.figure(figsize=(12, 12))\n", "nx.draw(subset_graph, with_labels=False, node_size=10)\n", - "plt.title(\"Visualization of a Subset of the Cora Graph\")\n", - "plt.show()" + "plt.title('Visualization of a Subset of the Cora Graph')\n", + "plt.show()\n" ] }, { @@ -374,7 +374,7 @@ "outputs": [], "source": [ "# Training and evaluation\n", - "device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n", + "device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n", "model = GNN(hidden_channels=16).to(device)\n", "data = data.to(device)\n", "optimizer = torch.optim.Adam(model.parameters(), lr=0.01, weight_decay=5e-4)" @@ -437,7 +437,6 @@ "train_loss_history = []\n", "test_accuracy_history = []\n", "\n", - "\n", "def train():\n", " model.train()\n", " optimizer.zero_grad()\n", @@ -447,7 +446,6 @@ " optimizer.step()\n", " return loss.item()\n", "\n", - "\n", "def test():\n", " model.eval()\n", " out = model(data.x, data.edge_index)\n", @@ -456,14 +454,13 @@ " acc = int(correct.sum()) / int(data.test_mask.sum())\n", " return acc\n", "\n", - "\n", "for epoch in range(300):\n", " loss = train()\n", " train_loss_history.append(loss)\n", " accuracy = test()\n", " test_accuracy_history.append(accuracy)\n", " if epoch % 10 == 0:\n", - " print(f\"Epoch: {epoch:03d}, Loss: {loss:.4f}, Accuracy: {accuracy:.4f}\")\n", + " print(f'Epoch: {epoch:03d}, Loss: {loss:.4f}, Accuracy: {accuracy:.4f}')\n", "\n", "print(\"Test Accuracy:\", test())" ] diff --git a/_sources/notebooks/6-gan-mnist.ipynb b/_sources/notebooks/6-gan-mnist.ipynb index a327ba1..25b1cfc 100644 --- a/_sources/notebooks/6-gan-mnist.ipynb +++ b/_sources/notebooks/6-gan-mnist.ipynb @@ -98,8 +98,7 @@ "from tensorflow.keras.layers import Input, Reshape, Dense, Dropout, LeakyReLU\n", "from tensorflow.keras.models import Model, Sequential\n", "from tensorflow.keras.datasets import mnist\n", - "\n", - "# temporarily importing legacy optimizer because of\n", + "# temporarily importing legacy optimizer because of \n", "# https://github.com/keras-team/keras-io/issues/1241#issuecomment-1442383703\n", "from tensorflow.keras.optimizers.legacy import Adam\n", "from tensorflow.keras import backend as K\n", @@ -311,7 +310,7 @@ " )\n", " plt.text(5, 37, val, fontsize=12)\n", " plt.axis(\"off\")\n", - "\n", + " \n", " plt.show()" ] }, diff --git a/notebooks/2.1-dense-keras.html b/notebooks/2.1-dense-keras.html index fdfdebe..2602e4c 100644 --- a/notebooks/2.1-dense-keras.html +++ b/notebooks/2.1-dense-keras.html @@ -549,7 +549,9 @@

2.1.2. Define the modelNDIM = len(VARS) inputs = Input(shape=(NDIM,), name="input") -outputs = Dense(1, name="output", kernel_initializer="normal", activation="sigmoid")(inputs) +outputs = Dense(1, name="output", kernel_initializer="normal", activation="sigmoid")( + inputs +) # creae the model model = Model(inputs=inputs, outputs=outputs) @@ -593,7 +595,9 @@

2.1.3. Dividing the data into testing an from sklearn.model_selection import train_test_split -X_train_val, X_test, Y_train_val, Y_test = train_test_split(X, Y, test_size=0.2, random_state=7) +X_train_val, X_test, Y_train_val, Y_test = train_test_split( + X, Y, test_size=0.2, random_state=7 +) # preprocessing: standard scalar from sklearn.preprocessing import StandardScaler diff --git a/notebooks/3-conv2d.html b/notebooks/3-conv2d.html index df8f57a..a5a5214 100644 --- a/notebooks/3-conv2d.html +++ b/notebooks/3-conv2d.html @@ -718,7 +718,7 @@

3.5. Dividing the data into testing and save_best_only=True, save_weights_only=False, mode="auto", - save_freq="epoch", + save_freq="epoch" ) diff --git a/notebooks/4-gnn-cora.html b/notebooks/4-gnn-cora.html index 518cc0c..26427cb 100644 --- a/notebooks/4-gnn-cora.html +++ b/notebooks/4-gnn-cora.html @@ -541,7 +541,7 @@

4.2. Step 2: Import Libraries and Load C
# Load Cora dataset
-dataset = Planetoid(root="/tmp/Cora", name="Cora")
+dataset = Planetoid(root='/tmp/Cora', name='Cora')
 data = dataset[0]
 
@@ -576,13 +576,13 @@

4.2. Step 2: Import Libraries and Load C

-
print("node vectors: \n", data.x, "\n")
-print("node classes:  \n", data.y, "\n")
-print("edge indeces: \n", data.edge_index, "\n\n\n")
+
print("node vectors: \n", data.x,          '\n')
+print("node classes:  \n", data.y,          '\n')
+print("edge indeces: \n", data.edge_index, '\n\n\n')
 
-print("train_mask: \n", data.train_mask, "\n")
-print("val_mask: \n", data.val_mask, "\n")
-print("test_mask: \n", data.test_mask, "\n")
+print("train_mask: \n", data.train_mask, '\n')
+print("val_mask: \n", data.val_mask, '\n')
+print("test_mask: \n", data.test_mask, '\n')
 
@@ -634,7 +634,7 @@

4.2. Step 2: Import Libraries and Load C plt.figure(figsize=(12, 12)) nx.draw(subset_graph, with_labels=False, node_size=10) -plt.title("Visualization of a Subset of the Cora Graph") +plt.title('Visualization of a Subset of the Cora Graph') plt.show()

@@ -673,7 +673,7 @@

4.4. Step 4: Training and Evaluation
diff --git a/notebooks/6-gan-mnist.html b/notebooks/6-gan-mnist.html index f4ef99c..7ad9e61 100644 --- a/notebooks/6-gan-mnist.html +++ b/notebooks/6-gan-mnist.html @@ -456,8 +456,7 @@

7.1.1. Importing and preprocessing our d from tensorflow.keras.layers import Input, Reshape, Dense, Dropout, LeakyReLU from tensorflow.keras.models import Model, Sequential from tensorflow.keras.datasets import mnist - -# temporarily importing legacy optimizer because of +# temporarily importing legacy optimizer because of # https://github.com/keras-team/keras-io/issues/1241#issuecomment-1442383703 from tensorflow.keras.optimizers.legacy import Adam from tensorflow.keras import backend as K @@ -581,7 +580,7 @@

7.1.2. Defining our model) plt.text(5, 37, val, fontsize=12) plt.axis("off") - + plt.show()