diff --git "a/train.ipynb" "b/train.ipynb" new file mode 100644--- /dev/null +++ "b/train.ipynb" @@ -0,0 +1,2447 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Install" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%pip install uv" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "!uv pip install dagshub setuptools accelerate toml torch torchvision transformers mlflow datasets ipywidgets python-dotenv evaluate" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Setup" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
Initialized MLflow to track repo \"amaye15/CanineNet\"\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "Initialized MLflow to track repo \u001b[32m\"amaye15/CanineNet\"\u001b[0m\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/html": [
+ "Repository amaye15/CanineNet initialized!\n", + "\n" + ], + "text/plain": [ + "Repository amaye15/CanineNet initialized!\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import os\n", + "import toml\n", + "import torch\n", + "import mlflow\n", + "import dagshub\n", + "import datasets\n", + "import evaluate\n", + "from dotenv import load_dotenv\n", + "from torchvision.transforms import v2\n", + "from transformers import AutoImageProcessor, AutoModelForImageClassification, TrainingArguments, Trainer\n", + "\n", + "ENV_PATH = \"/Users/andrewmayes/Openclassroom/CanineNet/.env\"\n", + "CONFIG_PATH = \"/Users/andrewmayes/Openclassroom/CanineNet/code/config.toml\"\n", + "CONFIG = toml.load(CONFIG_PATH)\n", + "\n", + "load_dotenv(ENV_PATH)\n", + "\n", + "dagshub.init(repo_name=os.environ['MLFLOW_TRACKING_PROJECTNAME'], repo_owner=os.environ['MLFLOW_TRACKING_USERNAME'], mlflow=True, dvc=True)\n", + "\n", + "os.environ['MLFLOW_TRACKING_USERNAME'] = \"amaye15\"\n", + "\n", + "mlflow.set_tracking_uri(f'https://dagshub.com/' + os.environ['MLFLOW_TRACKING_USERNAME']\n", + " + '/' + os.environ['MLFLOW_TRACKING_PROJECTNAME'] + '.mlflow')\n", + "\n", + "CREATE_DATASET = True\n", + "ORIGINAL_DATASET = \"Alanox/stanford-dogs\"\n", + "MODIFIED_DATASET = \"amaye15/stanford-dogs\"\n", + "REMOVE_COLUMNS = [\"name\", \"annotations\"]\n", + "RENAME_COLUMNS = {\"image\":\"pixel_values\", \"target\":\"label\"}\n", + "SPLIT = 0.2\n", + "\n", + "METRICS = [\"accuracy\", \"f1\", \"precision\", \"recall\"]\n", + "# MODELS = 'google/vit-base-patch16-224'\n", + "# MODELS = \"google/siglip-base-patch16-224\"\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Dataset" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Affenpinscher: 0\n", + "Afghan Hound: 1\n", + "African Hunting Dog: 2\n", + "Airedale: 3\n", + "American Staffordshire Terrier: 4\n", + "Appenzeller: 5\n", + "Australian Terrier: 6\n", + "Basenji: 7\n", + "Basset: 8\n", + "Beagle: 9\n", + "Bedlington Terrier: 10\n", + "Bernese Mountain Dog: 11\n", + "Black And Tan Coonhound: 12\n", + "Blenheim Spaniel: 13\n", + "Bloodhound: 14\n", + "Bluetick: 15\n", + "Border Collie: 16\n", + "Border Terrier: 17\n", + "Borzoi: 18\n", + "Boston Bull: 19\n", + "Bouvier Des Flandres: 20\n", + "Boxer: 21\n", + "Brabancon Griffon: 22\n", + "Briard: 23\n", + "Brittany Spaniel: 24\n", + "Bull Mastiff: 25\n", + "Cairn: 26\n", + "Cardigan: 27\n", + "Chesapeake Bay Retriever: 28\n", + "Chihuahua: 29\n", + "Chow: 30\n", + "Clumber: 31\n", + "Cocker Spaniel: 32\n", + "Collie: 33\n", + "Curly Coated Retriever: 34\n", + "Dandie Dinmont: 35\n", + "Dhole: 36\n", + "Dingo: 37\n", + "Doberman: 38\n", + "English Foxhound: 39\n", + "English Setter: 40\n", + "English Springer: 41\n", + "Entlebucher: 42\n", + "Eskimo Dog: 43\n", + "Flat Coated Retriever: 44\n", + "French Bulldog: 45\n", + "German Shepherd: 46\n", + "German Short Haired Pointer: 47\n", + "Giant Schnauzer: 48\n", + "Golden Retriever: 49\n", + "Gordon Setter: 50\n", + "Great Dane: 51\n", + "Great Pyrenees: 52\n", + "Greater Swiss Mountain Dog: 53\n", + "Groenendael: 54\n", + "Ibizan Hound: 55\n", + "Irish Setter: 56\n", + "Irish Terrier: 57\n", + "Irish Water Spaniel: 58\n", + "Irish Wolfhound: 59\n", + "Italian Greyhound: 60\n", + "Japanese Spaniel: 61\n", + "Keeshond: 62\n", + "Kelpie: 63\n", + "Kerry Blue Terrier: 64\n", + "Komondor: 65\n", + "Kuvasz: 66\n", + "Labrador Retriever: 67\n", + "Lakeland Terrier: 68\n", + "Leonberg: 69\n", + "Lhasa: 70\n", + "Malamute: 71\n", + "Malinois: 72\n", + "Maltese Dog: 73\n", + "Mexican Hairless: 74\n", + "Miniature Pinscher: 75\n", + "Miniature Poodle: 76\n", + "Miniature Schnauzer: 77\n", + "Newfoundland: 78\n", + "Norfolk Terrier: 79\n", + "Norwegian Elkhound: 80\n", + "Norwich Terrier: 81\n", + "Old English Sheepdog: 82\n", + "Otterhound: 83\n", + "Papillon: 84\n", + "Pekinese: 85\n", + "Pembroke: 86\n", + "Pomeranian: 87\n", + "Pug: 88\n", + "Redbone: 89\n", + "Rhodesian Ridgeback: 90\n", + "Rottweiler: 91\n", + "Saint Bernard: 92\n", + "Saluki: 93\n", + "Samoyed: 94\n", + "Schipperke: 95\n", + "Scotch Terrier: 96\n", + "Scottish Deerhound: 97\n", + "Sealyham Terrier: 98\n", + "Shetland Sheepdog: 99\n", + "Shih Tzu: 100\n", + "Siberian Husky: 101\n", + "Silky Terrier: 102\n", + "Soft Coated Wheaten Terrier: 103\n", + "Staffordshire Bullterrier: 104\n", + "Standard Poodle: 105\n", + "Standard Schnauzer: 106\n", + "Sussex Spaniel: 107\n", + "Tibetan Mastiff: 108\n", + "Tibetan Terrier: 109\n", + "Toy Poodle: 110\n", + "Toy Terrier: 111\n", + "Vizsla: 112\n", + "Walker Hound: 113\n", + "Weimaraner: 114\n", + "Welsh Springer Spaniel: 115\n", + "West Highland White Terrier: 116\n", + "Whippet: 117\n", + "Wire Haired Fox Terrier: 118\n", + "Yorkshire Terrier: 119\n" + ] + } + ], + "source": [ + "if CREATE_DATASET:\n", + " ds = datasets.load_dataset(ORIGINAL_DATASET, token=os.getenv(\"HF_TOKEN\"), split=\"full\", trust_remote_code=True)\n", + " ds = ds.remove_columns(REMOVE_COLUMNS).rename_columns(RENAME_COLUMNS)\n", + "\n", + " labels = ds.select_columns(\"label\").to_pandas().sort_values(\"label\").get(\"label\").unique().tolist()\n", + " numbers = range(len(labels))\n", + " label2int = dict(zip(labels, numbers))\n", + " int2label = dict(zip(numbers, labels))\n", + "\n", + " for key, val in label2int.items():\n", + " print(f\"{key}: {val}\")\n", + "\n", + " ds = ds.class_encode_column(\"label\")\n", + " ds = ds.align_labels_with_mapping(label2int, \"label\")\n", + "\n", + " ds = ds.train_test_split(test_size=SPLIT, stratify_by_column = \"label\")\n", + " #ds.push_to_hub(MODIFIED_DATASET, token=os.getenv(\"HF_TOKEN\"))\n", + "\n", + " CONFIG[\"label2int\"] = str(label2int)\n", + " CONFIG[\"int2label\"] = str(int2label)\n", + "\n", + " # with open(\"output.toml\", \"w\") as toml_file:\n", + " # toml.dump(toml.dumps(CONFIG), toml_file)\n", + "\n", + " #ds = datasets.load_dataset(MODIFIED_DATASET, token=os.getenv(\"HF_TOKEN\"), trust_remote_code=True, streaming=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n", + " warnings.warn(\n", + "Some weights of ViTForImageClassification were not initialized from the model checkpoint at google/vit-base-patch16-224 and are newly initialized because the shapes did not match:\n", + "- classifier.bias: found shape torch.Size([1000]) in the checkpoint and torch.Size([120]) in the model instantiated\n", + "- classifier.weight: found shape torch.Size([1000, 768]) in the checkpoint and torch.Size([120, 768]) in the model instantiated\n", + "You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n", + "max_steps is given, it will override any value given in num_train_epochs\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "8956098b0d16497b98dd963b5ee39e30", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/1000 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 4.7916, 'grad_norm': 3.3211498260498047, 'learning_rate': 4.9500000000000004e-05, 'epoch': 0.08}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "4d3ec8db90b042fe8ab52c70ed268cdb", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", + " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 4.59041690826416, 'eval_accuracy': 0.03279883381924198, 'eval_f1': 0.023986707967293786, 'eval_precision': 0.03211887676779008, 'eval_recall': 0.03425192381347505, 'eval_runtime': 53.2348, 'eval_samples_per_second': 77.318, 'eval_steps_per_second': 2.423, 'epoch': 0.08}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 4.5526, 'grad_norm': 3.224865674972534, 'learning_rate': 4.9e-05, 'epoch': 0.16}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "541a4549237f4d45aee95f908359226d", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", + " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 4.290071964263916, 'eval_accuracy': 0.11175898931000972, 'eval_f1': 0.08908255823524142, 'eval_precision': 0.1067771345006905, 'eval_recall': 0.11339877341742725, 'eval_runtime': 51.1812, 'eval_samples_per_second': 80.42, 'eval_steps_per_second': 2.52, 'epoch': 0.16}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 4.2946, 'grad_norm': 3.2911369800567627, 'learning_rate': 4.85e-05, 'epoch': 0.23}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "c265874044c143fd86a10d1bd307cd1b", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", + " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 3.9658701419830322, 'eval_accuracy': 0.2602040816326531, 'eval_f1': 0.21239451127524447, 'eval_precision': 0.22870350842966575, 'eval_recall': 0.25221809426784864, 'eval_runtime': 51.739, 'eval_samples_per_second': 79.553, 'eval_steps_per_second': 2.493, 'epoch': 0.23}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 3.9673, 'grad_norm': 3.175402879714966, 'learning_rate': 4.8e-05, 'epoch': 0.31}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "035e3ab4d5694db1a427ad6e9bfc4281", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", + " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 3.6288135051727295, 'eval_accuracy': 0.43513119533527694, 'eval_f1': 0.366602546469618, 'eval_precision': 0.4093361027943531, 'eval_recall': 0.4188864319436577, 'eval_runtime': 51.7563, 'eval_samples_per_second': 79.527, 'eval_steps_per_second': 2.492, 'epoch': 0.31}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 3.69, 'grad_norm': 3.415304660797119, 'learning_rate': 4.75e-05, 'epoch': 0.39}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d1fdf4404e6f4758bd063a8409038424", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", + " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 3.322521924972534, 'eval_accuracy': 0.5393586005830904, 'eval_f1': 0.4751230002672551, 'eval_precision': 0.5231645895485272, 'eval_recall': 0.5244474872029307, 'eval_runtime': 50.7169, 'eval_samples_per_second': 81.156, 'eval_steps_per_second': 2.544, 'epoch': 0.39}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 3.4705, 'grad_norm': 3.415445566177368, 'learning_rate': 4.7e-05, 'epoch': 0.47}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "5540b71488024283bf9abe62b6fb2e46", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", + " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 3.0343177318573, 'eval_accuracy': 0.6260932944606414, 'eval_f1': 0.5750032173775251, 'eval_precision': 0.6562784639124888, 'eval_recall': 0.6139453832484347, 'eval_runtime': 50.3389, 'eval_samples_per_second': 81.766, 'eval_steps_per_second': 2.563, 'epoch': 0.47}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 3.2239, 'grad_norm': 3.506593942642212, 'learning_rate': 4.6500000000000005e-05, 'epoch': 0.54}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "33928c85262a4b5eb877a4886826afe2", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", + " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 2.767138957977295, 'eval_accuracy': 0.6841593780369291, 'eval_f1': 0.6502714331646734, 'eval_precision': 0.7271627219700082, 'eval_recall': 0.6742837030131856, 'eval_runtime': 50.2969, 'eval_samples_per_second': 81.834, 'eval_steps_per_second': 2.565, 'epoch': 0.54}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 2.9986, 'grad_norm': 3.5921738147735596, 'learning_rate': 4.600000000000001e-05, 'epoch': 0.62}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "5d0cf65f2e154356b2b7b998e88db7e2", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", + " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 2.5190885066986084, 'eval_accuracy': 0.7261904761904762, 'eval_f1': 0.6971327484544173, 'eval_precision': 0.7600606189621968, 'eval_recall': 0.7160788289205049, 'eval_runtime': 52.0391, 'eval_samples_per_second': 79.094, 'eval_steps_per_second': 2.479, 'epoch': 0.62}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 2.7575, 'grad_norm': 3.5415148735046387, 'learning_rate': 4.55e-05, 'epoch': 0.7}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "b5bb593385c646d0aaf3e63f9fab6536", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", + " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 2.2952561378479004, 'eval_accuracy': 0.7429543245869776, 'eval_f1': 0.7161776971625036, 'eval_precision': 0.7734898436175475, 'eval_recall': 0.7333011075004312, 'eval_runtime': 51.2239, 'eval_samples_per_second': 80.353, 'eval_steps_per_second': 2.518, 'epoch': 0.7}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 2.5923, 'grad_norm': 3.779869794845581, 'learning_rate': 4.5e-05, 'epoch': 0.78}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "5a24a393d40e43a5a3f0120f56012ea7", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", + " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 2.1008450984954834, 'eval_accuracy': 0.7694363459669582, 'eval_f1': 0.7470022460097115, 'eval_precision': 0.7956268510731889, 'eval_recall': 0.7600407392219083, 'eval_runtime': 50.3149, 'eval_samples_per_second': 81.805, 'eval_steps_per_second': 2.564, 'epoch': 0.78}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 2.4265, 'grad_norm': 3.7507710456848145, 'learning_rate': 4.4500000000000004e-05, 'epoch': 0.85}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "995ddb483b3847febd446b948427b37f", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", + " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 1.9249824285507202, 'eval_accuracy': 0.7949465500485908, 'eval_f1': 0.7762138418275039, 'eval_precision': 0.8093930866629951, 'eval_recall': 0.7862772151206487, 'eval_runtime': 50.8948, 'eval_samples_per_second': 80.873, 'eval_steps_per_second': 2.535, 'epoch': 0.85}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 2.3049, 'grad_norm': 3.863125801086426, 'learning_rate': 4.4000000000000006e-05, 'epoch': 0.93}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "f55f9ebccf3d4c8faec7756fc4792b1d", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", + " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 1.76363205909729, 'eval_accuracy': 0.8053935860058309, 'eval_f1': 0.7860648379315559, 'eval_precision': 0.817345808479714, 'eval_recall': 0.7971126094314006, 'eval_runtime': 51.1375, 'eval_samples_per_second': 80.489, 'eval_steps_per_second': 2.523, 'epoch': 0.93}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 2.1243, 'grad_norm': 3.8729865550994873, 'learning_rate': 4.35e-05, 'epoch': 1.01}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "f0177ad8d7bf4b22ab94ed7f7a473667", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 1.628955602645874, 'eval_accuracy': 0.8199708454810496, 'eval_f1': 0.8055584922683607, 'eval_precision': 0.8382041042207944, 'eval_recall': 0.8125001888793706, 'eval_runtime': 51.6685, 'eval_samples_per_second': 79.662, 'eval_steps_per_second': 2.497, 'epoch': 1.01}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.9721, 'grad_norm': 3.5856685638427734, 'learning_rate': 4.3e-05, 'epoch': 1.09}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d2473f9fa5dc478aaee5ed0c7709ca35", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 1.512076735496521, 'eval_accuracy': 0.8226433430515063, 'eval_f1': 0.8083553747667891, 'eval_precision': 0.8395653312645351, 'eval_recall': 0.8148619684962682, 'eval_runtime': 50.6254, 'eval_samples_per_second': 81.303, 'eval_steps_per_second': 2.548, 'epoch': 1.09}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.848, 'grad_norm': 4.045370101928711, 'learning_rate': 4.25e-05, 'epoch': 1.17}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "b27852ca41894ef3acd4e9e2ec0f17f3", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 1.4282456636428833, 'eval_accuracy': 0.8163265306122449, 'eval_f1': 0.8001792733933139, 'eval_precision': 0.8361965629071254, 'eval_recall': 0.8083324752834017, 'eval_runtime': 50.3907, 'eval_samples_per_second': 81.682, 'eval_steps_per_second': 2.56, 'epoch': 1.17}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.775, 'grad_norm': 3.4402902126312256, 'learning_rate': 4.2e-05, 'epoch': 1.24}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "4c75e873d1c94e41939341a2cc7504cf", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 1.3034026622772217, 'eval_accuracy': 0.8304178814382897, 'eval_f1': 0.8171290590037299, 'eval_precision': 0.8438375495033491, 'eval_recall': 0.8237879661733023, 'eval_runtime': 50.5312, 'eval_samples_per_second': 81.455, 'eval_steps_per_second': 2.553, 'epoch': 1.24}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.717, 'grad_norm': 4.508427619934082, 'learning_rate': 4.15e-05, 'epoch': 1.32}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d59d77b5e69148e08f58ced7b363923f", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 1.234329104423523, 'eval_accuracy': 0.8275024295432458, 'eval_f1': 0.8125876753602064, 'eval_precision': 0.8459897625417544, 'eval_recall': 0.8207423193935024, 'eval_runtime': 51.6023, 'eval_samples_per_second': 79.764, 'eval_steps_per_second': 2.5, 'epoch': 1.32}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.6203, 'grad_norm': 4.164703369140625, 'learning_rate': 4.1e-05, 'epoch': 1.4}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "36e0ea06d99945d8a8f507cc392eb4f6", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 1.155371904373169, 'eval_accuracy': 0.8386783284742468, 'eval_f1': 0.8259221837965353, 'eval_precision': 0.8551546811719654, 'eval_recall': 0.8323141238003131, 'eval_runtime': 49.4169, 'eval_samples_per_second': 83.291, 'eval_steps_per_second': 2.61, 'epoch': 1.4}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.5739, 'grad_norm': 4.294710159301758, 'learning_rate': 4.05e-05, 'epoch': 1.48}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "02a63d0cfa5e41d5b6adebcca196c94f", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 1.0944122076034546, 'eval_accuracy': 0.8483965014577259, 'eval_f1': 0.8383859995600991, 'eval_precision': 0.8593382274020727, 'eval_recall': 0.8419989464963109, 'eval_runtime': 49.3074, 'eval_samples_per_second': 83.476, 'eval_steps_per_second': 2.616, 'epoch': 1.48}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.5508, 'grad_norm': 4.421907424926758, 'learning_rate': 4e-05, 'epoch': 1.55}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "343317e28f9444e99662abe768fb2eef", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 1.0399514436721802, 'eval_accuracy': 0.8483965014577259, 'eval_f1': 0.8393761386325121, 'eval_precision': 0.8573655692947703, 'eval_recall': 0.8430633117926871, 'eval_runtime': 50.9197, 'eval_samples_per_second': 80.833, 'eval_steps_per_second': 2.533, 'epoch': 1.55}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.4549, 'grad_norm': 3.6883435249328613, 'learning_rate': 3.9500000000000005e-05, 'epoch': 1.63}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "fbf592fb64054d509ba66761f573b310", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.9943499565124512, 'eval_accuracy': 0.8452380952380952, 'eval_f1': 0.8340415998210869, 'eval_precision': 0.8496642201346286, 'eval_recall': 0.839884001710882, 'eval_runtime': 52.2229, 'eval_samples_per_second': 78.816, 'eval_steps_per_second': 2.47, 'epoch': 1.63}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.3907, 'grad_norm': 4.171701908111572, 'learning_rate': 3.9000000000000006e-05, 'epoch': 1.71}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "e739c4344d884d44980e0d86b892fd3a", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.94267338514328, 'eval_accuracy': 0.859572400388727, 'eval_f1': 0.8479519223569636, 'eval_precision': 0.8627294484486137, 'eval_recall': 0.8542068898560096, 'eval_runtime': 51.0776, 'eval_samples_per_second': 80.583, 'eval_steps_per_second': 2.526, 'epoch': 1.71}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.3497, 'grad_norm': 4.337088584899902, 'learning_rate': 3.85e-05, 'epoch': 1.79}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "3657fd3978b447978fb7b1ce31b56527", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.8935672640800476, 'eval_accuracy': 0.8568999028182702, 'eval_f1': 0.8460929854549794, 'eval_precision': 0.8647196461364844, 'eval_recall': 0.8516295924782159, 'eval_runtime': 50.5744, 'eval_samples_per_second': 81.385, 'eval_steps_per_second': 2.551, 'epoch': 1.79}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.2618, 'grad_norm': 5.071542263031006, 'learning_rate': 3.8e-05, 'epoch': 1.86}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "94c0c390d92e457cbf7c988b58d2d354", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.8619340658187866, 'eval_accuracy': 0.8612730806608357, 'eval_f1': 0.8502671935975802, 'eval_precision': 0.8670524464371693, 'eval_recall': 0.8559731514388853, 'eval_runtime': 50.4579, 'eval_samples_per_second': 81.573, 'eval_steps_per_second': 2.557, 'epoch': 1.86}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.3014, 'grad_norm': 4.787931442260742, 'learning_rate': 3.7500000000000003e-05, 'epoch': 1.94}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "84ab179fc74749209c3bc54d9d9ca055", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.8324140906333923, 'eval_accuracy': 0.8603012633624878, 'eval_f1': 0.8508223443739876, 'eval_precision': 0.873686930071698, 'eval_recall': 0.8552822096629503, 'eval_runtime': 49.9525, 'eval_samples_per_second': 82.398, 'eval_steps_per_second': 2.582, 'epoch': 1.94}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.2209, 'grad_norm': 3.798623561859131, 'learning_rate': 3.7e-05, 'epoch': 2.02}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "f4a3238fe41845cf92ea2e8ee78d7508", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.8015190362930298, 'eval_accuracy': 0.859086491739553, 'eval_f1': 0.8503497319465885, 'eval_precision': 0.8645245561175217, 'eval_recall': 0.8536939181164537, 'eval_runtime': 49.8992, 'eval_samples_per_second': 82.486, 'eval_steps_per_second': 2.585, 'epoch': 2.02}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.2139, 'grad_norm': 4.351296901702881, 'learning_rate': 3.65e-05, 'epoch': 2.1}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "a1e23083a5d74c2a974113ec103af4a8", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.782394289970398, 'eval_accuracy': 0.859572400388727, 'eval_f1': 0.8516954841913884, 'eval_precision': 0.8655586585671634, 'eval_recall': 0.8543517201403624, 'eval_runtime': 49.879, 'eval_samples_per_second': 82.52, 'eval_steps_per_second': 2.586, 'epoch': 2.1}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.1364, 'grad_norm': 4.9539899826049805, 'learning_rate': 3.6e-05, 'epoch': 2.17}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "74a9101c3c464d36b84566f47ac0b9f4", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.7543724775314331, 'eval_accuracy': 0.8603012633624878, 'eval_f1': 0.851262935474796, 'eval_precision': 0.8611333141388174, 'eval_recall': 0.8555708075005329, 'eval_runtime': 53.5735, 'eval_samples_per_second': 76.829, 'eval_steps_per_second': 2.408, 'epoch': 2.17}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.1811, 'grad_norm': 4.293638229370117, 'learning_rate': 3.55e-05, 'epoch': 2.25}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "1f4df39ce51c49fcbaa296eb2a50ae07", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.7282825112342834, 'eval_accuracy': 0.8683187560738581, 'eval_f1': 0.8604884217835308, 'eval_precision': 0.8785234062020453, 'eval_recall': 0.8636616651541331, 'eval_runtime': 51.3447, 'eval_samples_per_second': 80.164, 'eval_steps_per_second': 2.512, 'epoch': 2.25}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.1316, 'grad_norm': 4.308586120605469, 'learning_rate': 3.5e-05, 'epoch': 2.33}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "847d960f73de4a31a0a502f54b720b54", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/sklearn/metrics/_classification.py:1509: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 in labels with no predicted samples. Use `zero_division` parameter to control this behavior.\n", + " _warn_prf(average, modifier, f\"{metric.capitalize()} is\", len(result))\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.7169475555419922, 'eval_accuracy': 0.8634596695821186, 'eval_f1': 0.8549726282933512, 'eval_precision': 0.8653217849672211, 'eval_recall': 0.8590424939111163, 'eval_runtime': 52.5897, 'eval_samples_per_second': 78.266, 'eval_steps_per_second': 2.453, 'epoch': 2.33}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.1246, 'grad_norm': 5.067152500152588, 'learning_rate': 3.45e-05, 'epoch': 2.41}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "90afcaa4c24f44c195232b19ce027dd2", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.6899862289428711, 'eval_accuracy': 0.8685617103984451, 'eval_f1': 0.8609562665671713, 'eval_precision': 0.873891468047725, 'eval_recall': 0.8645486428095622, 'eval_runtime': 51.0593, 'eval_samples_per_second': 80.612, 'eval_steps_per_second': 2.526, 'epoch': 2.41}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.1027, 'grad_norm': 4.583244323730469, 'learning_rate': 3.4000000000000007e-05, 'epoch': 2.49}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "e6e03674cdc04704bc08ecabc58c8634", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.6861591339111328, 'eval_accuracy': 0.8627308066083577, 'eval_f1': 0.8547566267077581, 'eval_precision': 0.8729627008920142, 'eval_recall': 0.85819312627202, 'eval_runtime': 50.9633, 'eval_samples_per_second': 80.764, 'eval_steps_per_second': 2.531, 'epoch': 2.49}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.0911, 'grad_norm': 5.299077033996582, 'learning_rate': 3.35e-05, 'epoch': 2.56}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "c6887b7315cc4e2f834e7f6ce8b73436", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.6666666865348816, 'eval_accuracy': 0.869290573372206, 'eval_f1': 0.863175811291841, 'eval_precision': 0.8730203986353282, 'eval_recall': 0.8652590704733508, 'eval_runtime': 50.1828, 'eval_samples_per_second': 82.02, 'eval_steps_per_second': 2.571, 'epoch': 2.56}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.0158, 'grad_norm': 4.278907299041748, 'learning_rate': 3.3e-05, 'epoch': 2.64}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "0927b5a320ae4087848d4d3ff4a4aad2", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.6544042825698853, 'eval_accuracy': 0.869533527696793, 'eval_f1': 0.8627614739793023, 'eval_precision': 0.8751009259523854, 'eval_recall': 0.8651077351889115, 'eval_runtime': 51.3202, 'eval_samples_per_second': 80.202, 'eval_steps_per_second': 2.514, 'epoch': 2.64}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.0805, 'grad_norm': 4.947147846221924, 'learning_rate': 3.2500000000000004e-05, 'epoch': 2.72}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "35e689547c3d46d8806ede3fd9cad7ae", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.6342029571533203, 'eval_accuracy': 0.8702623906705539, 'eval_f1': 0.8634235186066931, 'eval_precision': 0.8732936493763793, 'eval_recall': 0.8663165299277578, 'eval_runtime': 50.3866, 'eval_samples_per_second': 81.688, 'eval_steps_per_second': 2.56, 'epoch': 2.72}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.0679, 'grad_norm': 4.278728485107422, 'learning_rate': 3.2000000000000005e-05, 'epoch': 2.8}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "3345b82a053441f492b8fdcd060d8c7b", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.6275651454925537, 'eval_accuracy': 0.8753644314868805, 'eval_f1': 0.8689471024811166, 'eval_precision': 0.879685192995849, 'eval_recall': 0.8713243652075321, 'eval_runtime': 51.949, 'eval_samples_per_second': 79.232, 'eval_steps_per_second': 2.483, 'epoch': 2.8}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.0611, 'grad_norm': 4.940574645996094, 'learning_rate': 3.15e-05, 'epoch': 2.87}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "135dcb807e07423c9c4a3586d937e2ab", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.6223117113113403, 'eval_accuracy': 0.8746355685131195, 'eval_f1': 0.8692406162201597, 'eval_precision': 0.8806579158569162, 'eval_recall': 0.870532202424671, 'eval_runtime': 52.9118, 'eval_samples_per_second': 77.79, 'eval_steps_per_second': 2.438, 'epoch': 2.87}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 0.9996, 'grad_norm': 4.699158191680908, 'learning_rate': 3.1e-05, 'epoch': 2.95}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "06ffe89be74746c595723dab8454e50f", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.6055032014846802, 'eval_accuracy': 0.8724489795918368, 'eval_f1': 0.866110202239798, 'eval_precision': 0.8758324699115112, 'eval_recall': 0.8682737253565844, 'eval_runtime': 54.0895, 'eval_samples_per_second': 76.096, 'eval_steps_per_second': 2.385, 'epoch': 2.95}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 1.0838, 'grad_norm': 5.070742607116699, 'learning_rate': 3.05e-05, 'epoch': 3.03}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "1554352291aa4fe8a7b70d7e6b669993", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.6039470434188843, 'eval_accuracy': 0.8714771622934888, 'eval_f1': 0.8652108509442547, 'eval_precision': 0.8769133958916836, 'eval_recall': 0.8676869526047258, 'eval_runtime': 52.8001, 'eval_samples_per_second': 77.954, 'eval_steps_per_second': 2.443, 'epoch': 3.03}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 0.9396, 'grad_norm': 4.173382759094238, 'learning_rate': 3e-05, 'epoch': 3.11}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "1bf0ac65d1264a0ea511186ea2f26fc2", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.5945668816566467, 'eval_accuracy': 0.8736637512147716, 'eval_f1': 0.8676393211803758, 'eval_precision': 0.8790815570100037, 'eval_recall': 0.8699155844793023, 'eval_runtime': 52.0844, 'eval_samples_per_second': 79.026, 'eval_steps_per_second': 2.477, 'epoch': 3.11}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 0.8466, 'grad_norm': 3.887993574142456, 'learning_rate': 2.95e-05, 'epoch': 3.18}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "0772650c569d45a58807366fe0674b66", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.5809826850891113, 'eval_accuracy': 0.8717201166180758, 'eval_f1': 0.8652831106398223, 'eval_precision': 0.8775108148332962, 'eval_recall': 0.8673374594743511, 'eval_runtime': 51.6825, 'eval_samples_per_second': 79.64, 'eval_steps_per_second': 2.496, 'epoch': 3.18}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 0.9588, 'grad_norm': 4.710897445678711, 'learning_rate': 2.9e-05, 'epoch': 3.26}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "5079d0e589a04f1abd79cc3379970a53", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.5819315910339355, 'eval_accuracy': 0.8709912536443148, 'eval_f1': 0.8651293112219904, 'eval_precision': 0.8765510323397824, 'eval_recall': 0.8671133714398253, 'eval_runtime': 52.044, 'eval_samples_per_second': 79.087, 'eval_steps_per_second': 2.479, 'epoch': 3.26}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 0.9784, 'grad_norm': 4.351672172546387, 'learning_rate': 2.8499999999999998e-05, 'epoch': 3.34}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "0bb2253aa55b4d98a6ab71a3ceb708c2", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.5742390155792236, 'eval_accuracy': 0.8753644314868805, 'eval_f1': 0.8684385629612047, 'eval_precision': 0.8788313458944916, 'eval_recall': 0.8715573206215157, 'eval_runtime': 51.4937, 'eval_samples_per_second': 79.932, 'eval_steps_per_second': 2.505, 'epoch': 3.34}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 0.9289, 'grad_norm': 3.955735445022583, 'learning_rate': 2.8000000000000003e-05, 'epoch': 3.42}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "8f6105f5356147a5acf18b735bb315ef", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.5666605830192566, 'eval_accuracy': 0.8768221574344023, 'eval_f1': 0.8703081475674864, 'eval_precision': 0.8791546588398214, 'eval_recall': 0.8730635885436284, 'eval_runtime': 52.0695, 'eval_samples_per_second': 79.048, 'eval_steps_per_second': 2.477, 'epoch': 3.42}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 0.8917, 'grad_norm': 5.534939289093018, 'learning_rate': 2.7500000000000004e-05, 'epoch': 3.5}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "6bc0ef501ddd4dc5b6e5791b215bed79", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.5615334510803223, 'eval_accuracy': 0.8724489795918368, 'eval_f1': 0.8671806190741914, 'eval_precision': 0.8761653506025291, 'eval_recall': 0.8689939069337426, 'eval_runtime': 49.0092, 'eval_samples_per_second': 83.984, 'eval_steps_per_second': 2.632, 'epoch': 3.5}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 0.8646, 'grad_norm': 4.613251686096191, 'learning_rate': 2.7000000000000002e-05, 'epoch': 3.57}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "b502bb29162a42dda8e6e2191d62dd30", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.553726851940155, 'eval_accuracy': 0.8736637512147716, 'eval_f1': 0.8680915711504643, 'eval_precision': 0.876113415625243, 'eval_recall': 0.8701837731835593, 'eval_runtime': 50.6735, 'eval_samples_per_second': 81.226, 'eval_steps_per_second': 2.546, 'epoch': 3.57}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 0.9029, 'grad_norm': 4.512484550476074, 'learning_rate': 2.6500000000000004e-05, 'epoch': 3.65}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "fda49c67a72c4b58a0eb59a0b9c02bfd", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.5537687540054321, 'eval_accuracy': 0.8731778425655977, 'eval_f1': 0.8693973752455058, 'eval_precision': 0.8770822816897138, 'eval_recall': 0.8698390866136516, 'eval_runtime': 48.9555, 'eval_samples_per_second': 84.076, 'eval_steps_per_second': 2.635, 'epoch': 3.65}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 0.9551, 'grad_norm': 5.1214070320129395, 'learning_rate': 2.6000000000000002e-05, 'epoch': 3.73}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "a35540f0dbca4cbfad64245a184666a9", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.5439913868904114, 'eval_accuracy': 0.8765792031098154, 'eval_f1': 0.871965579787482, 'eval_precision': 0.8809148637967384, 'eval_recall': 0.8735359583321627, 'eval_runtime': 49.737, 'eval_samples_per_second': 82.755, 'eval_steps_per_second': 2.594, 'epoch': 3.73}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 0.8787, 'grad_norm': 5.106933116912842, 'learning_rate': 2.5500000000000003e-05, 'epoch': 3.81}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "7277076ca4a64bcc86bb9824fabe85ab", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.5448131561279297, 'eval_accuracy': 0.8751214771622935, 'eval_f1': 0.870431998571916, 'eval_precision': 0.8790974083015579, 'eval_recall': 0.871176099630073, 'eval_runtime': 50.3369, 'eval_samples_per_second': 81.769, 'eval_steps_per_second': 2.563, 'epoch': 3.81}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 0.9128, 'grad_norm': 3.737730026245117, 'learning_rate': 2.5e-05, 'epoch': 3.88}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "1258ae6be2724b53ba883bf6889930ac", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.5354462265968323, 'eval_accuracy': 0.8751214771622935, 'eval_f1': 0.8700851753661716, 'eval_precision': 0.8798565924694164, 'eval_recall': 0.8711981894305025, 'eval_runtime': 52.2403, 'eval_samples_per_second': 78.79, 'eval_steps_per_second': 2.469, 'epoch': 3.88}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'loss': 0.8566, 'grad_norm': 5.4926605224609375, 'learning_rate': 2.45e-05, 'epoch': 3.96}\n" + ] + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "4daeb4a92adf4136810ffd6d38a743a3", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0/129 [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'eval_loss': 0.5262439250946045, 'eval_accuracy': 0.8775510204081632, 'eval_f1': 0.8715380279278444, 'eval_precision': 0.884592471549905, 'eval_recall': 0.8738306977142041, 'eval_runtime': 51.4152, 'eval_samples_per_second': 80.054, 'eval_steps_per_second': 2.509, 'epoch': 3.96}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/andrewmayes/Openclassroom/CanineNet/env/lib/python3.12/site-packages/torch/utils/checkpoint.py:464: UserWarning: torch.utils.checkpoint: the use_reentrant parameter should be passed explicitly. In version 2.4 we will raise an exception if use_reentrant is not passed. use_reentrant=False is recommended, but if you need to preserve the current default behavior, you can pass use_reentrant=True. Refer to docs for more details on the differences between the two variants.\n", + " warnings.warn(\n" + ] + } + ], + "source": [ + "metrics = {metric: evaluate.load(metric) for metric in METRICS}\n", + "\n", + "\n", + "# for lr in [5e-3, 5e-4, 5e-5]: # 5e-5\n", + "# for batch in [64]: # 32\n", + "# for model_name in [\"google/vit-base-patch16-224\", \"microsoft/swinv2-base-patch4-window16-256\", \"google/siglip-base-patch16-224\"]: # \"facebook/dinov2-base\"\n", + "\n", + "lr = 5e-5\n", + "batch = 32\n", + "model_name = \"google/vit-base-patch16-224\"\n", + "\n", + "image_processor = AutoImageProcessor.from_pretrained(model_name)\n", + "model = AutoModelForImageClassification.from_pretrained(\n", + "model_name,\n", + "num_labels=len(label2int),\n", + "id2label=int2label,\n", + "label2id=label2int,\n", + "ignore_mismatched_sizes=True,\n", + ")\n", + "\n", + "# Then, in your transformations:\n", + "def train_transform(examples, num_ops=10, magnitude=9, num_magnitude_bins=31):\n", + "\n", + " transformation = v2.Compose(\n", + " [\n", + " v2.RandAugment(\n", + " num_ops=num_ops,\n", + " magnitude=magnitude,\n", + " num_magnitude_bins=num_magnitude_bins,\n", + " )\n", + " ]\n", + " )\n", + " # Ensure each image has three dimensions (in this case, ensure it's RGB)\n", + " examples[\"pixel_values\"] = [\n", + " image.convert(\"RGB\") for image in examples[\"pixel_values\"]\n", + " ]\n", + " # Apply transformations\n", + " examples[\"pixel_values\"] = [\n", + " image_processor(transformation(image), return_tensors=\"pt\")[\n", + " \"pixel_values\"\n", + " ].squeeze()\n", + " for image in examples[\"pixel_values\"]\n", + " ]\n", + " return examples\n", + "\n", + "\n", + "def test_transform(examples):\n", + " # Ensure each image is RGB\n", + " examples[\"pixel_values\"] = [\n", + " image.convert(\"RGB\") for image in examples[\"pixel_values\"]\n", + " ]\n", + " # Apply processing\n", + " examples[\"pixel_values\"] = [\n", + " image_processor(image, return_tensors=\"pt\")[\"pixel_values\"].squeeze()\n", + " for image in examples[\"pixel_values\"]\n", + " ]\n", + " return examples\n", + "\n", + "\n", + "def compute_metrics(eval_pred):\n", + " predictions, labels = eval_pred\n", + " # predictions = np.argmax(logits, axis=-1)\n", + " results = {}\n", + " for key, val in metrics.items():\n", + " if \"accuracy\" == key:\n", + " result = next(\n", + " iter(val.compute(predictions=predictions, references=labels).items())\n", + " )\n", + " if \"accuracy\" != key:\n", + " result = next(\n", + " iter(\n", + " val.compute(\n", + " predictions=predictions, references=labels, average=\"macro\"\n", + " ).items()\n", + " )\n", + " )\n", + " results[result[0]] = result[1]\n", + " return results\n", + "\n", + "\n", + "def collate_fn(examples):\n", + " pixel_values = torch.stack([example[\"pixel_values\"] for example in examples])\n", + " labels = torch.tensor([example[\"label\"] for example in examples])\n", + " return {\"pixel_values\": pixel_values, \"labels\": labels}\n", + "\n", + "\n", + "def preprocess_logits_for_metrics(logits, labels):\n", + " \"\"\"\n", + " Original Trainer may have a memory leak.\n", + " This is a workaround to avoid storing too many tensors that are not needed.\n", + " \"\"\"\n", + " pred_ids = torch.argmax(logits, dim=-1)\n", + " return pred_ids\n", + "\n", + "ds[\"train\"].set_transform(train_transform)\n", + "ds[\"test\"].set_transform(test_transform)\n", + "\n", + "training_args = TrainingArguments(**CONFIG[\"training_args\"])\n", + "training_args.per_device_train_batch_size = batch\n", + "training_args.per_device_eval_batch_size = batch\n", + "training_args.hub_model_id = f\"amaye15/{model_name.replace('/','-')}-batch{batch}-lr{lr}-standford-dogs\"\n", + "\n", + "mlflow.start_run(run_name=f\"{model_name.replace('/','-')}-batch{batch}-lr{lr}\")\n", + "\n", + "trainer = Trainer(\n", + " model=model,\n", + " args=training_args,\n", + " train_dataset=ds[\"train\"],\n", + " eval_dataset=ds[\"test\"],\n", + " tokenizer=image_processor,\n", + " data_collator=collate_fn,\n", + " compute_metrics=compute_metrics,\n", + " # callbacks=[early_stopping_callback],\n", + " preprocess_logits_for_metrics=preprocess_logits_for_metrics,\n", + ")\n", + "\n", + "# Train the model\n", + "trainer.train()\n", + "\n", + "trainer.push_to_hub()\n", + "\n", + "mlflow.end_run()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mlflow.end_run()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# training_args = TrainingArguments(**CONFIG[\"training_args\"])\n", + "\n", + "# image_processor = AutoImageProcessor.from_pretrained(MODELS)\n", + "# model = AutoModelForImageClassification.from_pretrained(\n", + "# MODELS,\n", + "# num_labels=len(CONFIG[\"label2int\"]),\n", + "# id2label=CONFIG[\"label2int\"],\n", + "# label2id=CONFIG[\"int2label\"],\n", + "# ignore_mismatched_sizes=True,\n", + "# )\n", + "\n", + "\n", + "# training_args = TrainingArguments(**CONFIG[\"training_args\"])\n", + "\n", + "# trainer = Trainer(\n", + "# model=model,\n", + "# args=training_args,\n", + "# train_dataset=ds[\"train\"],\n", + "# eval_dataset=ds[\"test\"],\n", + "# tokenizer=image_processor,\n", + "# data_collator=collate_fn,\n", + "# compute_metrics=compute_metrics,\n", + "# # callbacks=[early_stopping_callback],\n", + "# preprocess_logits_for_metrics=preprocess_logits_for_metrics,\n", + "# )\n", + "\n", + "# # Train the model\n", + "# trainer.train()\n", + "\n", + "# mlflow.end_run()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "env", + "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.12.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}