Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
98146a1a
Unverified
Commit
98146a1a
authored
Oct 22, 2020
by
F-G Fernandez
Committed by
GitHub
Oct 22, 2020
Browse files
style: Added annotation typing for alexnet (#2859)
parent
3756b607
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
torchvision/models/alexnet.py
torchvision/models/alexnet.py
+4
-3
No files found.
torchvision/models/alexnet.py
View file @
98146a1a
import
torch
import
torch
import
torch.nn
as
nn
import
torch.nn
as
nn
from
.utils
import
load_state_dict_from_url
from
.utils
import
load_state_dict_from_url
from
typing
import
Any
__all__
=
[
'AlexNet'
,
'alexnet'
]
__all__
=
[
'AlexNet'
,
'alexnet'
]
...
@@ -13,7 +14,7 @@ model_urls = {
...
@@ -13,7 +14,7 @@ model_urls = {
class
AlexNet
(
nn
.
Module
):
class
AlexNet
(
nn
.
Module
):
def
__init__
(
self
,
num_classes
=
1000
):
def
__init__
(
self
,
num_classes
:
int
=
1000
):
super
(
AlexNet
,
self
).
__init__
()
super
(
AlexNet
,
self
).
__init__
()
self
.
features
=
nn
.
Sequential
(
self
.
features
=
nn
.
Sequential
(
nn
.
Conv2d
(
3
,
64
,
kernel_size
=
11
,
stride
=
4
,
padding
=
2
),
nn
.
Conv2d
(
3
,
64
,
kernel_size
=
11
,
stride
=
4
,
padding
=
2
),
...
@@ -41,7 +42,7 @@ class AlexNet(nn.Module):
...
@@ -41,7 +42,7 @@ class AlexNet(nn.Module):
nn
.
Linear
(
4096
,
num_classes
),
nn
.
Linear
(
4096
,
num_classes
),
)
)
def
forward
(
self
,
x
)
:
def
forward
(
self
,
x
:
torch
.
Tensor
)
->
torch
.
Tensor
:
x
=
self
.
features
(
x
)
x
=
self
.
features
(
x
)
x
=
self
.
avgpool
(
x
)
x
=
self
.
avgpool
(
x
)
x
=
torch
.
flatten
(
x
,
1
)
x
=
torch
.
flatten
(
x
,
1
)
...
@@ -49,7 +50,7 @@ class AlexNet(nn.Module):
...
@@ -49,7 +50,7 @@ class AlexNet(nn.Module):
return
x
return
x
def
alexnet
(
pretrained
=
False
,
progress
=
True
,
**
kwargs
)
:
def
alexnet
(
pretrained
:
bool
=
False
,
progress
:
bool
=
True
,
**
kwargs
:
Any
)
->
AlexNet
:
r
"""AlexNet model architecture from the
r
"""AlexNet model architecture from the
`"One weird trick..." <https://arxiv.org/abs/1404.5997>`_ paper.
`"One weird trick..." <https://arxiv.org/abs/1404.5997>`_ paper.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment