-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ResNet, AlexNet, and VGG model definitions and model zoo #23
Conversation
236d645
to
c96e794
Compare
def __init__(self, num_classes=1000): | ||
super(AlexNet, self).__init__() | ||
self.features = nn.Sequential( | ||
nn.Conv2d(3, 64, kernel_size=11, stride=4, padding=2), |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
About the padding in |
I'm wondering, it might be better at some point to move the |
good idea. torch.utils? |
|
I also think the model zoo is a work-in-progress. There's still some unanswered questions and things I'd like to have:
|
I love the idea of using github names! I think github supports git lfs, so we only need to standardize the structure of the repo and it should be good. We could just clone the repo in some local directory where it would be cached, and then load it from there. |
|
||
def load_url(url, model_dir=None): | ||
if model_dir is None: | ||
model_dir = os.getenv('TORCH_MODEL_ZOO', DEFAULT_MODEL_DIR) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
else: | ||
file_size = int(meta.get_all("Content-Length")[0]) | ||
|
||
with tempfile.NamedTemporaryFile(delete=False) as f, tqdm(total=file_size) as pbar: |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
return VGG(make_layers(cfg['A'])) | ||
|
||
|
||
def vgg11_bn(): |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
8ef76ff
to
5d69981
Compare
Updated to use |
def resnet18(pretrained=False): | ||
model = ResNet(BasicBlock, [2, 2, 2, 2]) | ||
if pretrained: | ||
model.load_state_dict(model_zoo.load_url('https://s3.amazonaws.com/pytorch/models/resnet18-5c106cde.pth')) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Hi @colesbury, do you remember any more details on how these models (specifically resnet18) were trained? i.e. which year of ImageNet, final train/val accuracy, batch size. Thank you! |
The ResNet models were trained on ILSVRC2012. They were trained with the default options using https://github.com/pytorch/examples/tree/master/imagenet. (batch size 256, 90 epochs, lr=0.1 decay by 10 every 30 epochs). I think I used 4 GPUs, but it might have been 8. Accuracy on the validation set is in the table here: You can verify the accuracy on the validation set by running the example imagenet script with:
You can compute the accuracy on the training set by swapping your train and val directories and running the above command. |
You can create a ResNet-18 model pre-trained on ImageNet with: