Problems importing helper_functions #94
-
Hello, friends, I'm getting an error when I run the code to import helper_functions (Chapter 2, video 71, minute 10:53:53) Using the same code from the video notebook, I get the following error: File "/content/helper_functions.py", line 8
<!DOCTYPE html>
^
SyntaxError: invalid syntax The file appears to be downloaded in the files tab, although I always got this error. Even so, I haven't been able to use any functions. Can somebody help me? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @DanteNoguez, Looks like you might be downloading the HTML version of the If you delete the file and try again but using the "raw" GitHub link:
it should work. For example, using the code from 02. PyTorch Neural Network Classification section 4: import requests
from pathlib import Path
# Download helper functions from Learn PyTorch repo (if not already downloaded)
if Path("helper_functions.py").is_file():
print("helper_functions.py already exists, skipping download")
else:
print("Downloading helper_functions.py")
request = requests.get("https://raw.githubusercontent.com/mrdbourke/pytorch-deep-learning/main/helper_functions.py")
with open("helper_functions.py", "wb") as f:
f.write(request.content)
from helper_functions import plot_predictions, plot_decision_boundary |
Beta Was this translation helpful? Give feedback.
Hi @DanteNoguez,
Looks like you might be downloading the HTML version of the
helper_functions.py
file.If you delete the file and try again but using the "raw" GitHub link:
it should work.
For example, using the code from 02. PyTorch Neural Network Classification section 4: