-
Notifications
You must be signed in to change notification settings - Fork 31.2k
Resnet #15770
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
Merged
Merged
Resnet #15770
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
f2593f3
first commit
FrancescoSaverioZuppichini cc1d1c2
ResNet model correctly implemented.
FrancescoSaverioZuppichini 1a6d045
minor changes
FrancescoSaverioZuppichini b0089cf
Apply suggestions from code review
FrancescoSaverioZuppichini c55e5fc
new test format
FrancescoSaverioZuppichini 9a9e3c7
minor changes from conversations
FrancescoSaverioZuppichini b54dc28
minor changes from conversations
FrancescoSaverioZuppichini d95c607
make style + quality
FrancescoSaverioZuppichini c30f3e9
readded the tests
FrancescoSaverioZuppichini c5489df
test + README
FrancescoSaverioZuppichini ca2fbbb
minor changes from conversations
FrancescoSaverioZuppichini 9a17143
error in README
FrancescoSaverioZuppichini bc26ea3
make fix-copies
FrancescoSaverioZuppichini a60983a
removed regression for classification head
FrancescoSaverioZuppichini 5c05428
make quality
FrancescoSaverioZuppichini 4accbd7
fixed loss control flow
FrancescoSaverioZuppichini 7eedf7f
fixed loss control flow
FrancescoSaverioZuppichini db8c38c
resolved conversations
FrancescoSaverioZuppichini 3e2b79c
Apply suggestions from code review
FrancescoSaverioZuppichini 1c6885d
READMEs
FrancescoSaverioZuppichini 79b2ba0
index.mdx
FrancescoSaverioZuppichini eae2cef
minor changes
FrancescoSaverioZuppichini 717cfd5
updated tests and models
FrancescoSaverioZuppichini 69240c4
unused import
FrancescoSaverioZuppichini 45db40c
outputs
FrancescoSaverioZuppichini a0597a5
Update docs/source/model_doc/resnet.mdx
FrancescoSaverioZuppichini d37ea95
added embeddings_size
FrancescoSaverioZuppichini 2c4034f
Apply suggestions from code review
FrancescoSaverioZuppichini d793bb7
conversation
FrancescoSaverioZuppichini e18d9da
added push to hub
FrancescoSaverioZuppichini 398642f
test
FrancescoSaverioZuppichini b4b8c83
embedding_size
FrancescoSaverioZuppichini 5c89040
make fix-copies
FrancescoSaverioZuppichini ee8783b
resolved conversations
FrancescoSaverioZuppichini 7a6febf
CI
FrancescoSaverioZuppichini 974337c
changed organization
FrancescoSaverioZuppichini 8a8ca31
minor changes
FrancescoSaverioZuppichini 8517727
CI
FrancescoSaverioZuppichini 367e886
minor changes
FrancescoSaverioZuppichini 73d3a66
conversations
FrancescoSaverioZuppichini a5d9f29
conversation
FrancescoSaverioZuppichini 7e08499
doc
FrancescoSaverioZuppichini d8553c3
tests
FrancescoSaverioZuppichini 1a4521c
removed unused docstring
FrancescoSaverioZuppichini 3a3ae6d
conversation
FrancescoSaverioZuppichini 8708d65
removed unused outputs
FrancescoSaverioZuppichini 2b4c8bc
CI
FrancescoSaverioZuppichini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| <!--Copyright 2022 The HuggingFace Team. All rights reserved. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
| the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations under the License. | ||
| --> | ||
|
|
||
| # ResNet | ||
|
|
||
| ## Overview | ||
|
|
||
| The ResNet model was proposed in [Deep Residual Learning for Image Recognition](https://arxiv.org/abs/1512.03385) by Kaiming He, Xiangyu Zhang, Shaoqing Ren and Jian Sun. Our implementation follows the small changes made by [Nvidia](https://catalog.ngc.nvidia.com/orgs/nvidia/resources/resnet_50_v1_5_for_pytorch), we apply the `stride=2` for downsampling in bottleneck's `3x3` conv and not in the first `1x1`. This is generally known as "ResNet v1.5". | ||
|
|
||
| ResNet introduced residual connections, they allow to train networks with an unseen number of layers (up to 1000). ResNet won the 2015 ILSVRC & COCO competition, one important milestone in deep computer vision. | ||
|
|
||
| The abstract from the paper is the following: | ||
|
|
||
| *Deeper neural networks are more difficult to train. We present a residual learning framework to ease the training of networks that are substantially deeper than those used previously. We explicitly reformulate the layers as learning residual functions with reference to the layer inputs, instead of learning unreferenced functions. We provide comprehensive empirical evidence showing that these residual networks are easier to optimize, and can gain accuracy from considerably increased depth. On the ImageNet dataset we evaluate residual nets with a depth of up to 152 layers---8x deeper than VGG nets but still having lower complexity. An ensemble of these residual nets achieves 3.57% error on the ImageNet test set. This result won the 1st place on the ILSVRC 2015 classification task. We also present analysis on CIFAR-10 with 100 and 1000 layers. | ||
| The depth of representations is of central importance for many visual recognition tasks. Solely due to our extremely deep representations, we obtain a 28% relative improvement on the COCO object detection dataset. Deep residual nets are foundations of our submissions to ILSVRC & COCO 2015 competitions, where we also won the 1st places on the tasks of ImageNet detection, ImageNet localization, COCO detection, and COCO segmentation.* | ||
|
|
||
| Tips: | ||
|
|
||
| - One can use [`AutoFeatureExtractor`] to prepare images for the model. | ||
|
|
||
| The figure below illustrates the architecture of ResNet. Taken from the [original paper](https://arxiv.org/abs/1512.03385). | ||
|
|
||
| <img width="600" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/resnet_architecture.png"/> | ||
|
|
||
| This model was contributed by [Francesco](https://huggingface.co/Francesco). The original code can be found [here](https://github.com/KaimingHe/deep-residual-networks). | ||
|
|
||
| ## ResNetConfig | ||
|
|
||
| [[autodoc]] ResNetConfig | ||
|
|
||
|
|
||
| ## ResNetModel | ||
|
|
||
| [[autodoc]] ResNetModel | ||
| - forward | ||
|
|
||
|
|
||
| ## ResNetForImageClassification | ||
|
|
||
| [[autodoc]] ResNetForImageClassification | ||
| - forward | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,6 +94,7 @@ | |
| realm, | ||
| reformer, | ||
| rembert, | ||
| resnet, | ||
| retribert, | ||
| roberta, | ||
| roformer, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.