greydanus / mnist1d

A 1D analogue of the MNIST dataset for measuring spatial biases and answering Science of Deep Learning questions.
Apache License 2.0
199 stars 33 forks source link

Error when importing mnist1d.data and mnist1d.utils in Colab notebook #16

Open Lorenzo-Sibi opened 1 month ago

Lorenzo-Sibi commented 1 month ago

When trying to use the repo in a Colab notebook, in the import section:

# Setup
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.utils.data import TensorDataset, DataLoader
from torch.utils.tensorboard import SummaryWriter
from torchvision import datasets, transforms

import math
from torchsummary import summary
from tqdm import tqdm
import numpy as np
import matplotlib.pyplot as plt

# Additional Setup for MNIST-1D
!git clone https://github.com/greydanus/mnist1d
import mnist1d
from mnist1d.data import get_templates, get_dataset_args, get_dataset
from mnist1d.utils import set_seed, plot_signals, ObjectView, from_pickle

# Additional Setup to use Tensorboard
!pip install -q tensorflow
%load_ext tensorboard

I obtain the following error:

Cloning into 'mnist1d'...
remote: Enumerating objects: 537, done.
remote: Counting objects: 100% (156/156), done.
remote: Compressing objects: 100% (86/86), done.
remote: Total 537 (delta 96), reused 108 (delta 67), pack-reused 381 (from 1)
Receiving objects: 100% (537/537), 14.92 MiB | 15.39 MiB/s, done.
Resolving deltas: 100% (249/249), done.
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
[<ipython-input-1-33e438737ccd>](https://localhost:8080/#) in <cell line: 19>()
     17 get_ipython().system('git clone https://github.com/greydanus/mnist1d')
     18 import mnist1d
---> 19 from mnist1d.data import get_templates, get_dataset_args, get_dataset
     20 from mnist1d.utils import set_seed, plot_signals, ObjectView, from_pickle
     21 

ModuleNotFoundError: No module named 'mnist1d.data'

I solved it by editing the data.py and utils.py files on lines 8, 9 (data.py) and 8 (utilis.py):

greydanus commented 1 month ago

Sorry about that - I think I pushed a breaking change earlier today. I just made the relevant fix. Are you still seeing this error?