moskomule / anatome

Ἀνατομή is a PyTorch library to analyze representation of neural networks
MIT License
61 stars 6 forks source link

How do we run the jupyter notebook example? #17

Closed brando90 closed 2 years ago

brando90 commented 2 years ago

Got error:

FileNotFoundError: [Errno 2] No such file or directory: '/Users/brando/.torch/data/imagenet/val'

is it possible to download some data set to test anatome such that it doesn't throw an error?

Perhaps a colab example is better?

a start: https://colab.research.google.com/drive/1GrhWrWFPmlc6kmxc0TJY0Nb6qOBBgjzX?usp=sharing

moskomule commented 2 years ago

Just change the path in the following code to your favorite one.

imagenet = ImageFolder('~/.torch/data/imagenet/val', 
                       transforms.Compose([transforms.CenterCrop(224),transforms.ToTensor(),
                       transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225))]))
brando90 commented 2 years ago

Just change the path in the following code to your favorite one.

imagenet = ImageFolder('~/.torch/data/imagenet/val', 
                       transforms.Compose([transforms.CenterCrop(224),transforms.ToTensor(),
                       transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225))]))

but one has to download imagenet...this is better:

transform = transforms.Compose(
    [transforms.ToTensor(),
     transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])

batch_size = 128
num_workers = 0

trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
                                        download=True, transform=transform)
trainloader = torch.utils.data.DataLoader(trainset, batch_size=batch_size,
                                          shuffle=True, num_workers=num_workers)

testset = torchvision.datasets.CIFAR10(root='./data', train=False,
                                       download=True, transform=transform)
testloader = torch.utils.data.DataLoader(testset, batch_size=batch_size,
                                         shuffle=False, num_workers=num_workers)

classes = ('plane', 'car', 'bird', 'cat',
           'deer', 'dog', 'frog', 'horse', 'ship', 'truck')

data = next(iter(trainloader))
brando90 commented 2 years ago

reproduce with this: https://colab.research.google.com/drive/1GrhWrWFPmlc6kmxc0TJY0Nb6qOBBgjzX?usp=sharing