Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sergio #1091

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open

Sergio #1091

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
4564065
Modified using Colab
sergio-sanz-rodriguez Jul 13, 2024
9298eec
update notebook
sergio-sanz-rodriguez Jul 13, 2024
99164b0
update notebook
sergio-sanz-rodriguez Jul 13, 2024
0142056
Created using Colab
sergio-sanz-rodriguez Jul 16, 2024
3dbd1ce
done exercise 00_pytorch_fundamentals_exercises.ipynb
sergio-sanz-rodriguez Jul 16, 2024
d55a2dd
modifed 01 notebook
sergio-sanz-rodriguez Jul 22, 2024
20b99b7
modifed 01 notebook
sergio-sanz-rodriguez Jul 22, 2024
77b9e67
modified notebook 01 with additional notes
sergio-sanz-rodriguez Jul 23, 2024
568de11
Created using Colab
sergio-sanz-rodriguez Jul 23, 2024
3ef4093
modified learning rate to 0.01 in 01
sergio-sanz-rodriguez Jul 23, 2024
de7ff84
Merge pull request #1 from sergio-sanz-rodriguez/sergio
sergio-sanz-rodriguez Jul 23, 2024
826d297
completed notebook 01 except exercises
sergio-sanz-rodriguez Jul 24, 2024
df2c162
Merge pull request #2 from sergio-sanz-rodriguez/sergio
sergio-sanz-rodriguez Jul 24, 2024
8cecf2a
started exercise 01
sergio-sanz-rodriguez Jul 24, 2024
17b0fa3
Merge branch 'main' of github.com:sergio-sanz-rodriguez/pytorch-deep-…
sergio-sanz-rodriguez Jul 24, 2024
a2abb32
fix typo error in exercise 01
sergio-sanz-rodriguez Jul 24, 2024
ba5ecf7
Merge pull request #3 from sergio-sanz-rodriguez/sergio
sergio-sanz-rodriguez Jul 24, 2024
668d4ab
completed exercise 01
sergio-sanz-rodriguez Jul 25, 2024
81d538a
Merge branch 'sergio'
sergio-sanz-rodriguez Jul 25, 2024
1dc216e
Merge pull request #4 from sergio-sanz-rodriguez/sergio
sergio-sanz-rodriguez Jul 25, 2024
71eb85f
Merge branch 'main' of github.com:sergio-sanz-rodriguez/pytorch-deep-…
sergio-sanz-rodriguez Jul 25, 2024
c486f7f
added commands for saving the whole model
sergio-sanz-rodriguez Jul 25, 2024
027363b
Merge branch 'sergio'
sergio-sanz-rodriguez Jul 25, 2024
fee7cd6
added an alternative model to notebook 02 consisting of 5 inputs and …
sergio-sanz-rodriguez Jul 29, 2024
a1eb119
Merge pull request #5 from sergio-sanz-rodriguez/sergio
sergio-sanz-rodriguez Jul 29, 2024
0597828
modified notebook 02 with an alterantative model (model_1)
sergio-sanz-rodriguez Aug 2, 2024
1590892
Merge pull request #6 from sergio-sanz-rodriguez/sergio
sergio-sanz-rodriguez Aug 2, 2024
71d9659
updated notebooks with own tests and comments
sergio-sanz-rodriguez Sep 13, 2024
53222f2
Merge branch 'sergio'
sergio-sanz-rodriguez Sep 13, 2024
13c7ef7
completed notebook 2
sergio-sanz-rodriguez Sep 17, 2024
8e04cdd
Merge pull request #7 from sergio-sanz-rodriguez/sergio
sergio-sanz-rodriguez Sep 17, 2024
70a9da1
modified notebook 03_
sergio-sanz-rodriguez Sep 28, 2024
a77faf1
Merge pull request #8 from sergio-sanz-rodriguez/sergio
sergio-sanz-rodriguez Sep 28, 2024
ec93605
updated 03 notebook
sergio-sanz-rodriguez Oct 13, 2024
286772a
updated notebooks
sergio-sanz-rodriguez Oct 14, 2024
c314ec8
updated notebooks
sergio-sanz-rodriguez Oct 14, 2024
d2c01c5
updated notebooks 2 and 3
sergio-sanz-rodriguez Oct 30, 2024
f6e844a
updated notebook 04
sergio-sanz-rodriguez Oct 31, 2024
710196d
updated notebook 04
sergio-sanz-rodriguez Oct 31, 2024
d739408
updated notebook 04
sergio-sanz-rodriguez Oct 31, 2024
4664705
updated notebook 04
sergio-sanz-rodriguez Nov 1, 2024
b477696
completed section 4
sergio-sanz-rodriguez Nov 1, 2024
ef345bd
Merge pull request #9 from sergio-sanz-rodriguez/sergio
sergio-sanz-rodriguez Nov 1, 2024
30d70fb
complete section 05
sergio-sanz-rodriguez Nov 1, 2024
fbe3be0
added py scripts generated in section 05
sergio-sanz-rodriguez Nov 1, 2024
2b7c7dd
Merge branch 'sergio'
sergio-sanz-rodriguez Nov 1, 2024
d55d7e5
changes in some py scripts of section 05
sergio-sanz-rodriguez Nov 1, 2024
0e13def
completed section 06
sergio-sanz-rodriguez Nov 3, 2024
ef565ba
completed module 7
sergio-sanz-rodriguez Nov 17, 2024
8c48c70
updated files for section 8
sergio-sanz-rodriguez Nov 20, 2024
4353a72
added papers ViT
sergio-sanz-rodriguez Nov 20, 2024
793fd3f
update section 8
sergio-sanz-rodriguez Nov 21, 2024
071aa04
added paper 'attention is all you need'
sergio-sanz-rodriguez Nov 21, 2024
cf11472
finished section 08 execpt extra exercises
sergio-sanz-rodriguez Nov 22, 2024
d8c1c4d
finished module 8
sergio-sanz-rodriguez Nov 24, 2024
6a2a81c
finished section 08
sergio-sanz-rodriguez Dec 2, 2024
efdad71
remove database foodvision mini
sergio-sanz-rodriguez Dec 2, 2024
683a2f3
pytorch 2.0
sergio-sanz-rodriguez Dec 4, 2024
993dd92
small change in notebook 08
sergio-sanz-rodriguez Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7,652 changes: 3,948 additions & 3,704 deletions 00_pytorch_fundamentals.ipynb

Large diffs are not rendered by default.

573 changes: 375 additions & 198 deletions 01_pytorch_workflow.ipynb

Large diffs are not rendered by default.

1,149 changes: 805 additions & 344 deletions 02_pytorch_classification.ipynb

Large diffs are not rendered by default.

5,024 changes: 4,379 additions & 645 deletions 03_pytorch_computer_vision.ipynb

Large diffs are not rendered by default.

1,061 changes: 728 additions & 333 deletions 04_pytorch_custom_datasets.ipynb

Large diffs are not rendered by default.

519 changes: 382 additions & 137 deletions 06_pytorch_transfer_learning.ipynb

Large diffs are not rendered by default.

2,163 changes: 1,941 additions & 222 deletions 07_pytorch_experiment_tracking.ipynb

Large diffs are not rendered by default.

10,560 changes: 5,712 additions & 4,848 deletions 08_pytorch_paper_replicating.ipynb

Large diffs are not rendered by default.

1,278 changes: 803 additions & 475 deletions 09_pytorch_model_deployment.ipynb

Large diffs are not rendered by default.

Binary file added AttentionIsAllYouNeed.pdf
Binary file not shown.
Binary file added VisionTransformerPaper.pdf
Binary file not shown.
Binary file removed data/pizza_steak_sushi_20_percent.zip
Binary file not shown.
Binary file removed demos/foodvision_mini.zip
Binary file not shown.
416 changes: 288 additions & 128 deletions extras/exercises/00_pytorch_fundamentals_exercises.ipynb

Large diffs are not rendered by default.

591 changes: 450 additions & 141 deletions extras/exercises/01_pytorch_workflow_exercises.ipynb

Large diffs are not rendered by default.

1,598 changes: 972 additions & 626 deletions extras/exercises/02_pytorch_classification_exercises.ipynb

Large diffs are not rendered by default.

1,035 changes: 843 additions & 192 deletions extras/exercises/03_pytorch_computer_vision_exercises.ipynb

Large diffs are not rendered by default.

2,441 changes: 1,664 additions & 777 deletions extras/exercises/04_pytorch_custom_datasets_exercises.ipynb

Large diffs are not rendered by default.

3,408 changes: 1,888 additions & 1,520 deletions extras/exercises/06_pytorch_transfer_learning_exercises.ipynb

Large diffs are not rendered by default.

3,059 changes: 2,352 additions & 707 deletions extras/exercises/07_pytorch_experiment_tracking_exercise_template.ipynb

Large diffs are not rendered by default.

1,711 changes: 1,241 additions & 470 deletions extras/exercises/08_pytorch_paper_replicating_exercises.ipynb

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions extras/exercises/going_modular/sergio/pytorch/data_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"""
Contains functionality for creating PyTorch DataLoaders for
image classification data.
"""
import os

from torch.utils.data import DataLoader
from torchvision import datasets, transforms

NUM_WORKERS = os.cpu_count()

def create_dataloaders(
train_dir: str,
test_dir: str,
train_transform: transforms.Compose,
test_transform: transforms.Compose,
batch_size: int,
num_workers: int=NUM_WORKERS
):
"""Creates training and testing DataLoaders.

Takes in a training directory and testing directory path and turns
them into PyTorch Datasets and then into PyTorch DataLoaders.

Args:
train_dir: Path to training directory.
test_dir: Path to testing directory.
train_transform: torchvision transforms to perform on training data.
test_transform: torchvision transforms to perform on test data.
batch_size: Number of samples per batch in each of the DataLoaders.
num_workers: An integer for number of workers per DataLoader.

Returns:
A tuple of (train_dataloader, test_dataloader, class_names).
Where class_names is a list of the target classes.
Example usage:
train_dataloader, test_dataloader, class_names = \
= create_dataloaders(train_dir=path/to/train_dir,
test_dir=path/to/test_dir,
transform=some_transform,
batch_size=32,
num_workers=4)
"""
# Use ImageFolder to create dataset(s)
train_data = datasets.ImageFolder(train_dir, transform=train_transform)
test_data = datasets.ImageFolder(test_dir, transform=test_transform)

# Get class names
class_names = train_data.classes

# Turn images into data loaders
train_dataloader = DataLoader(
train_data,
batch_size=batch_size,
shuffle=True,
num_workers=num_workers,
pin_memory=True, #enables fast data transfre to CUDA-enable GPU
)
test_dataloader = DataLoader(
test_data,
batch_size=batch_size,
shuffle=False,
num_workers=num_workers,
pin_memory=True, #enables fast data transfre to CUDA-enable GPU
)

return train_dataloader, test_dataloader, class_names
Loading