YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Classifiers for MNIST and SVHN.
Snippet of code on how to load them after downloading the files in data_path.
import os
import torch
import torch.nn.functional as F
from torch import nn, optim
from torch.utils.data import DataLoader
from torchvision.datasets import MNIST, SVHN
from torchvision.transforms import ToTensor
class SVHN_Classifier(nn.Module):
def __init__(self):
super(SVHN_Classifier, self).__init__()
self.conv1 = nn.Conv2d(3, 10, kernel_size=5)
self.conv2 = nn.Conv2d(10, 20, kernel_size=5)
self.conv2_drop = nn.Dropout2d()
self.fc1 = nn.Linear(500, 50)
self.fc2 = nn.Linear(50, 10)
def forward(self, x):
x = F.relu(F.max_pool2d(self.conv1(x), 2))
x = F.relu(F.max_pool2d(self.conv2_drop(self.conv2(x)), 2))
x = x.view(-1, 500)
x = F.relu(self.fc1(x))
x = F.dropout(x, training=self.training)
x = self.fc2(x)
return F.log_softmax(x, dim=-1)
class MNIST_Classifier(nn.Module):
def __init__(self):
super(MNIST_Classifier, self).__init__()
self.conv1 = nn.Conv2d(1, 10, kernel_size=5)
self.conv2 = nn.Conv2d(10, 20, kernel_size=5)
self.conv2_drop = nn.Dropout2d()
self.fc1 = nn.Linear(320, 50)
self.fc2 = nn.Linear(50, 10)
def forward(self, x):
x = F.relu(F.max_pool2d(self.conv1(x), 2))
x = F.relu(F.max_pool2d(self.conv2_drop(self.conv2(x)), 2))
x = x.view(-1, 320)
x = F.relu(self.fc1(x))
x = F.dropout(x, training=self.training)
x = self.fc2(x)
return F.log_softmax(x, dim=-1)
def load_mnist_svhn_classifiers(data_path, device="cuda"):
c1 = MNIST_Classifier()
c1.load_state_dict(torch.load(f"{data_path}/mnist.pt", map_location=device))
c2 = SVHN_Classifier()
c2.load_state_dict(torch.load(f"{data_path}/svhn.pt", map_location=device))
return {"mnist": c1.to(device).eval(), "svhn": c2.to(device).eval()}
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support