mirror of
https://github.com/mrdbourke/pytorch-deep-learning.git
synced 2026-11-27 06:07:09 +00:00
Update helper_functions.py
This commit is contained in:
1 parent
5e340d4e0b
commit
cfdda5e4b7
1 file changed
+19
-1
+19
-1
@@ -16,6 +16,24 @@ from pathlib import Path
|
||||
|
||||
import requests
|
||||
|
||||
# Walk through an image classification directory and find out how many files (images)
|
||||
# are in each subdirectory.
|
||||
import os
|
||||
|
||||
def walk_through_dir(dir_path):
|
||||
"""
|
||||
Walks through dir_path returning its contents.
|
||||
Args:
|
||||
dir_path (str): target directory
|
||||
|
||||
Returns:
|
||||
A print out of:
|
||||
number of subdiretories in dir_path
|
||||
number of images (files) in each subdirectory
|
||||
name of each subdirectory
|
||||
"""
|
||||
for dirpath, dirnames, filenames in os.walk(dir_path):
|
||||
print(f"There are {len(dirnames)} directories and {len(filenames)} images in '{dirpath}'.")
|
||||
|
||||
def plot_decision_boundary(model: torch.nn.Module, X: torch.Tensor, y: torch.Tensor):
|
||||
"""Plots decision boundaries of model predicting on X in comparison to y.
|
||||
@@ -273,4 +291,4 @@ def download_data(source: str,
|
||||
if remove_source:
|
||||
os.remove(data_path / target_file)
|
||||
|
||||
return image_path
|
||||
return image_path
|
||||
Reference in new issue
Block a user