If you're running the demos from this repo on Google Colab, you may try this workflow below. It uses the first module 1_linear_classifier.ipynb as an example.
- On colab main page, select File -> New Notebook in Drive
- Clone the repo and enter the workspace
!git clone https://github.com/williamqwu/ml-tutorials-suite ml_tutorials
%cd ml_tutorials
!pwd
!ls- Import the local libraries via this block below, instead of
import lib.linear_classifier as LCandimport infra.plot as plotas written in the original notebook:
import importlib.util
import os
module_path = os.path.join(os.getcwd(), "lib", "linear_classifier.py")
spec = importlib.util.spec_from_file_location("linear_classifier", module_path)
LC = importlib.util.module_from_spec(spec)
spec.loader.exec_module(LC)
module_path = os.path.join(os.getcwd(), "infra", "plot.py")
spec = importlib.util.spec_from_file_location("plot", module_path)
plot = importlib.util.module_from_spec(spec)
spec.loader.exec_module(plot)