-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4885ce
commit af9d89b
Showing
13 changed files
with
762 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
scripts/wandb/* | ||
scripts/images/* |
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Install and Import Required Libraries\n", | ||
"Install wandb using pip and import the necessary libraries." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Import the necessary ibraries\n", | ||
"import wandb\n", | ||
"import numpy as np\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"from PIL import Image\n", | ||
"import os" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Initialize wandb Project\n", | ||
"Initialize a new wandb project and configure the settings." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Initialize wandb Project\n", | ||
"wandb.init(project=\"plr-exercise\", config={\n", | ||
" \"learning_rate\": 0.001,\n", | ||
" \"epochs\": 10,\n", | ||
" \"batch_size\": 32\n", | ||
"})\n", | ||
"\n", | ||
"# Access the configuration\n", | ||
"config = wandb.config\n", | ||
"\n", | ||
"# Log the configuration\n", | ||
"wandb.config.update({\n", | ||
" \"optimizer\": \"adam\",\n", | ||
" \"loss_function\": \"categorical_crossentropy\"\n", | ||
"})" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Log Random Curves\n", | ||
"Generate random curves and log them to wandb." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Generate random curves and log them to wandb\n", | ||
"x = np.linspace(0, 10, 100)\n", | ||
"y1 = np.sin(x) + np.random.normal(0, 0.1, 100)\n", | ||
"y2 = np.cos(x) + np.random.normal(0, 0.1, 100)\n", | ||
"\n", | ||
"plt.figure()\n", | ||
"plt.plot(x, y1, label='Random Sine Curve')\n", | ||
"plt.plot(x, y2, label='Random Cosine Curve')\n", | ||
"\n", | ||
"plt.legend()\n", | ||
"plt.title('Random Curves')\n", | ||
"plt.xlabel('X-axis')\n", | ||
"plt.ylabel('Y-axis')\n", | ||
"\n", | ||
"# Save the plot as an image file\n", | ||
"plt.savefig('random_curves.png')\n", | ||
"\n", | ||
"# Log the plot image to wandb\n", | ||
"wandb.log({\"random_curves\": wandb.Image('random_curves.png')})\n", | ||
"\n", | ||
"# Optionally, log the data points as well\n", | ||
"wandb.log({\"x\": x, \"y1\": y1, \"y2\": y2})" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Upload Images of Dogs and Cats\n", | ||
"Upload images of dogs and cats to wandb." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Upload Images of Dogs and Cats\n", | ||
"\n", | ||
"# Create a directory to store images\n", | ||
"os.makedirs('images', exist_ok=True)\n", | ||
"\n", | ||
"# Download sample images of dogs and cats\n", | ||
"!wget -O images/dog.jpg https://images.unsplash.com/photo-1560807707-8cc77767d783\n", | ||
"!wget -O images/cat.jpg https://images.unsplash.com/photo-1518791841217-8f162f1e1131\n", | ||
"\n", | ||
"# Load the images using PIL\n", | ||
"dog_image = Image.open('images/dog.jpg')\n", | ||
"cat_image = Image.open('images/cat.jpg')\n", | ||
"\n", | ||
"# Log the images to wandb\n", | ||
"wandb.log({\"dog_image\": wandb.Image(dog_image, caption=\"Dog\")})\n", | ||
"wandb.log({\"cat_image\": wandb.Image(cat_image, caption=\"Cat\")})" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Create a new artifact\n", | ||
"artifact = wandb.Artifact('source_code', type='code')\n", | ||
"\n", | ||
"# Add files to the artifact\n", | ||
"artifact.add_file('./03_wandb.ipynb')\n", | ||
"\n", | ||
"# Log the artifact\n", | ||
"wandb.log_artifact(artifact)\n", | ||
"wandb.finish()\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.10" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |