Skip to content

Commit

Permalink
Correcting percentage string
Browse files Browse the repository at this point in the history
  • Loading branch information
phlippe committed Aug 27, 2021
1 parent b89843e commit 674c5f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2766,7 +2766,7 @@
" num_preds += data_labels.shape[0]\n",
" \n",
" acc = true_preds / num_preds\n",
" print(f\"Accuracy of the model: {100.0*acc:4.2f}%%\")"
" print(f\"Accuracy of the model: {100.0*acc:4.2f}%\")"
]
},
{
Expand Down
20 changes: 10 additions & 10 deletions docs/tutorial_notebooks/tutorial3/Activation_Functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
" file_path = os.path.join(CHECKPOINT_PATH, file_name)\n",
" if not os.path.isfile(file_path):\n",
" file_url = base_url + file_name\n",
" print(\"Downloading %s...\" % file_url)\n",
" print(f\"Downloading {file_url}...\")\n",
" try:\n",
" urllib.request.urlretrieve(file_url, file_path)\n",
" except HTTPError as e:\n",
Expand Down Expand Up @@ -3085,8 +3085,8 @@
" net - (Optional) If given, the state dict is loaded into this model. Otherwise, a new model is created.\n",
" \"\"\"\n",
" config_file, model_file = _get_config_file(model_path, model_name), _get_model_file(model_path, model_name)\n",
" assert os.path.isfile(config_file), \"Could not find the config file \\\"%s\\\". Are you sure this is the correct path and you have your model config stored here?\" % (config_file)\n",
" assert os.path.isfile(model_file), \"Could not find the model file \\\"%s\\\". Are you sure this is the correct path and you have your model stored here?\" % (model_file)\n",
" assert os.path.isfile(config_file), f\"Could not find the config file \\\"{config_file}\\\". Are you sure this is the correct path and you have your model config stored here?\"\n",
" assert os.path.isfile(model_file), f\"Could not find the model file \\\"{model_file}\\\". Are you sure this is the correct path and you have your model stored here?\"\n",
" with open(config_file, \"r\") as f:\n",
" config_dict = json.load(f)\n",
" if net is None:\n",
Expand Down Expand Up @@ -24170,7 +24170,7 @@
" set_seed(42) # Setting the seed ensures that we have the same weight initialization for each activation function\n",
" act_fn = act_fn_by_name[act_fn_name]()\n",
" net_actfn = BaseNetwork(act_fn=act_fn).to(device)\n",
" visualize_gradients(net_actfn, color=\"C%i\"%i)"
" visualize_gradients(net_actfn, color=f\"C{i}\")"
]
},
{
Expand Down Expand Up @@ -24250,7 +24250,7 @@
" ################\n",
" val_acc = test_model(net, val_loader)\n",
" val_scores.append(val_acc)\n",
" print(f\"[Epoch {epoch+1:2i}] Training accuracy: {train_acc*100.0:05.2f}%%, Validation accuracy: {val_acc*100.0:05.2f}%%\")\n",
" print(f\"[Epoch {epoch+1:2i}] Training accuracy: {train_acc*100.0:05.2f}%, Validation accuracy: {val_acc*100.0:05.2f}%\")\n",
"\n",
" if len(val_scores) == 1 or val_acc > val_scores[best_val_epoch]:\n",
" print(\"\\t (New best performance, saving model...)\")\n",
Expand All @@ -24270,7 +24270,7 @@
" \n",
" load_model(CHECKPOINT_PATH, model_name, net=net)\n",
" test_acc = test_model(net, test_loader)\n",
" print((f\" Test accuracy: {test_acc*100.0:4.2f}%% \").center(50, \"=\")+\"\\n\")\n",
" print((f\" Test accuracy: {test_acc*100.0:4.2f}% \").center(50, \"=\")+\"\\n\")\n",
" return test_acc\n",
" \n",
"\n",
Expand Down Expand Up @@ -24345,7 +24345,7 @@
" set_seed(42)\n",
" act_fn = act_fn_by_name[act_fn_name]()\n",
" net_actfn = BaseNetwork(act_fn=act_fn).to(device)\n",
" train_model(net_actfn, \"FashionMNIST_%s\" % act_fn_name, overwrite=False)"
" train_model(net_actfn, f\"FashionMNIST_{act_fn_name}\", overwrite=False)"
]
},
{
Expand Down Expand Up @@ -59193,8 +59193,8 @@
],
"source": [
"for i, act_fn_name in enumerate(act_fn_by_name):\n",
" net_actfn = load_model(model_path=CHECKPOINT_PATH, model_name=\"FashionMNIST_%s\" % act_fn_name).to(device)\n",
" visualize_activations(net_actfn, color=\"C%i\" % i)"
" net_actfn = load_model(model_path=CHECKPOINT_PATH, model_name=f\"FashionMNIST_{act_fn_name}\").to(device)\n",
" visualize_activations(net_actfn, color=f\"C{i}\")"
]
},
{
Expand Down Expand Up @@ -59261,7 +59261,7 @@
" layer_index += 1\n",
" number_neurons_dead = [t.sum().item() for t in neurons_dead]\n",
" print(\"Number of dead neurons:\", number_neurons_dead)\n",
" print(\"In percentage:\", \", \".join([f\"{(100.0 * num_dead / tens.shape[0]):4.2f}%%\" for tens, num_dead in zip(neurons_dead, number_neurons_dead)]))"
" print(\"In percentage:\", \", \".join([f\"{(100.0 * num_dead / tens.shape[0]):4.2f}%\" for tens, num_dead in zip(neurons_dead, number_neurons_dead)]))"
]
},
{
Expand Down

0 comments on commit 674c5f5

Please sign in to comment.