-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
1 changed file
with
74 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"The following code trains a model on the XOR dataset using the CPU and then using the GPU to train, and then outputs the training time taken." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"CPU Training Time: 160.45\n", | ||
"GPU Training Time: 42.58\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import os\n", | ||
"\n", | ||
"from school_project.models.cpu.cat_recognition import CatRecognitionModel as CPUModel\n", | ||
"from school_project.models.gpu.cat_recognition import CatRecognitionModel as GPUModel\n", | ||
"\n", | ||
"# Change to root directory of project\n", | ||
"os.chdir(os.getcwd())\n", | ||
"\n", | ||
"model = CPUModel(hidden_layers_shape=[100, 100],\n", | ||
" train_dataset_size=209,\n", | ||
" learning_rate=0.1,\n", | ||
" use_relu=True)\n", | ||
"model.create_model_values()\n", | ||
"model.train(epoch_count=3_500)\n", | ||
"\n", | ||
"print(f\"CPU Training Time: {model.training_time}\")\n", | ||
"\n", | ||
"model = GPUModel(hidden_layers_shape=[100, 100],\n", | ||
" train_dataset_size=209,\n", | ||
" learning_rate=0.1,\n", | ||
" use_relu=True)\n", | ||
"model.create_model_values()\n", | ||
"model.train(epoch_count=3_500)\n", | ||
"\n", | ||
"print(f\"GPU Training Time: {model.training_time}\")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "venv", | ||
"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.10.11" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |