Skip to content

Commit

Permalink
Add missing docstring (#1159)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanyzhu committed Jan 26, 2020
1 parent a9a834b commit a64b921
Show file tree
Hide file tree
Showing 10 changed files with 631 additions and 208 deletions.
121 changes: 111 additions & 10 deletions gluoncv/model_zoo/action_recognition/actionrec_inceptionv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,35 @@ class ActionRecInceptionV1(HybridBlock):
Parameters
----------
nclass : int, number of classes
pretrained_base : bool, load pre-trained weights or not
dropout_ratio : float, add a dropout layer to prevent overfitting on small datasets, such as UCF101
init_std : float, standard deviation value when initialize the last classification layer
feat_dim : int, feature dimension. Default is 4096 for VGG16 network
num_segments : int, number of segments used
num_crop : int, number of crops used during evaluation. Default choice is 1, 3 or 10
nclass : int
Number of classes in the training dataset.
pretrained_base : bool or str, optional, default is True.
Load pretrained base network, the extra layers are randomized. Note that
if pretrained is `True`, this has no effect.
partial_bn : bool, default False.
Freeze all batch normalization layers during training except the first layer.
dropout_ratio : float, default is 0.5.
The dropout rate of a dropout layer.
The larger the value, the more strength to prevent overfitting.
init_std : float, default is 0.001.
Standard deviation value when initialize the dense layers.
num_segments : int, default is 1.
Number of segments used to evenly divide a video.
num_crop : int, default is 1.
Number of crops used during evaluation, choices are 1, 3 or 10.
Input: a single video frame or N images from N segments when num_segments > 1
Output: a single predicted action label
"""
def __init__(self, nclass, pretrained_base=True,
partial_bn=True, dropout_ratio=0.8, init_std=0.001,
feat_dim=1024, num_segments=1, num_crop=1, **kwargs):
partial_bn=True, dropout_ratio=0.5, init_std=0.001,
num_segments=1, num_crop=1, **kwargs):
super(ActionRecInceptionV1, self).__init__()
self.dropout_ratio = dropout_ratio
self.init_std = init_std
self.num_segments = num_segments
self.num_crop = num_crop
self.feat_dim = feat_dim
self.feat_dim = 1024

pretrained_model = googlenet(pretrained=pretrained_base, partial_bn=partial_bn, **kwargs)

Expand Down Expand Up @@ -104,6 +113,29 @@ def hybrid_forward(self, F, x):
def inceptionv1_ucf101(nclass=101, pretrained=False, pretrained_base=True,
use_tsn=False, num_segments=1, num_crop=1, partial_bn=True,
ctx=mx.cpu(), root='~/.mxnet/models', **kwargs):
r"""InceptionV1 model trained on UCF101 dataset.
Parameters
----------
nclass : int.
Number of categories in the dataset.
pretrained : bool or str.
Boolean value controls whether to load the default pretrained weights for model.
String value represents the hashtag for a certain version of pretrained weights.
pretrained_base : bool or str, optional, default is True.
Load pretrained base network, the extra layers are randomized. Note that
if pretrained is `True`, this has no effect.
ctx : Context, default CPU.
The context in which to load the pretrained weights.
root : str, default $MXNET_HOME/models
Location for keeping the model parameters.
num_segments : int, default is 1.
Number of segments used to evenly divide a video.
num_crop : int, default is 1.
Number of crops used during evaluation, choices are 1, 3 or 10.
partial_bn : bool, default False.
Freeze all batch normalization layers during training except the first layer.
"""
model = ActionRecInceptionV1(nclass=nclass,
partial_bn=partial_bn,
pretrained_base=pretrained_base,
Expand All @@ -125,6 +157,29 @@ def inceptionv1_ucf101(nclass=101, pretrained=False, pretrained_base=True,
def inceptionv1_hmdb51(nclass=51, pretrained=False, pretrained_base=True,
use_tsn=False, num_segments=1, num_crop=1, partial_bn=True,
ctx=mx.cpu(), root='~/.mxnet/models', **kwargs):
r"""InceptionV1 model trained on HMDB51 dataset.
Parameters
----------
nclass : int.
Number of categories in the dataset.
pretrained : bool or str.
Boolean value controls whether to load the default pretrained weights for model.
String value represents the hashtag for a certain version of pretrained weights.
pretrained_base : bool or str, optional, default is True.
Load pretrained base network, the extra layers are randomized. Note that
if pretrained is `True`, this has no effect.
ctx : Context, default CPU.
The context in which to load the pretrained weights.
root : str, default $MXNET_HOME/models
Location for keeping the model parameters.
num_segments : int, default is 1.
Number of segments used to evenly divide a video.
num_crop : int, default is 1.
Number of crops used during evaluation, choices are 1, 3 or 10.
partial_bn : bool, default False.
Freeze all batch normalization layers during training except the first layer.
"""
model = ActionRecInceptionV1(nclass=nclass,
partial_bn=partial_bn,
pretrained_base=pretrained_base,
Expand All @@ -146,6 +201,29 @@ def inceptionv1_hmdb51(nclass=51, pretrained=False, pretrained_base=True,
def inceptionv1_kinetics400(nclass=400, pretrained=False, pretrained_base=True,
tsn=False, num_segments=1, num_crop=1, partial_bn=True,
ctx=mx.cpu(), root='~/.mxnet/models', **kwargs):
r"""InceptionV1 model trained on Kinetics400 dataset.
Parameters
----------
nclass : int.
Number of categories in the dataset.
pretrained : bool or str.
Boolean value controls whether to load the default pretrained weights for model.
String value represents the hashtag for a certain version of pretrained weights.
pretrained_base : bool or str, optional, default is True.
Load pretrained base network, the extra layers are randomized. Note that
if pretrained is `True`, this has no effect.
ctx : Context, default CPU.
The context in which to load the pretrained weights.
root : str, default $MXNET_HOME/models
Location for keeping the model parameters.
num_segments : int, default is 1.
Number of segments used to evenly divide a video.
num_crop : int, default is 1.
Number of crops used during evaluation, choices are 1, 3 or 10.
partial_bn : bool, default False.
Freeze all batch normalization layers during training except the first layer.
"""
model = ActionRecInceptionV1(nclass=nclass,
partial_bn=partial_bn,
pretrained_base=pretrained_base,
Expand All @@ -167,6 +245,29 @@ def inceptionv1_kinetics400(nclass=400, pretrained=False, pretrained_base=True,
def inceptionv1_sthsthv2(nclass=174, pretrained=False, pretrained_base=True,
tsn=False, num_segments=1, num_crop=1, partial_bn=True,
ctx=mx.cpu(), root='~/.mxnet/models', **kwargs):
r"""InceptionV1 model trained on Something-Something-V2 dataset.
Parameters
----------
nclass : int.
Number of categories in the dataset.
pretrained : bool or str.
Boolean value controls whether to load the default pretrained weights for model.
String value represents the hashtag for a certain version of pretrained weights.
pretrained_base : bool or str, optional, default is True.
Load pretrained base network, the extra layers are randomized. Note that
if pretrained is `True`, this has no effect.
ctx : Context, default CPU.
The context in which to load the pretrained weights.
root : str, default $MXNET_HOME/models
Location for keeping the model parameters.
num_segments : int, default is 1.
Number of segments used to evenly divide a video.
num_crop : int, default is 1.
Number of crops used during evaluation, choices are 1, 3 or 10.
partial_bn : bool, default False.
Freeze all batch normalization layers during training except the first layer.
"""
model = ActionRecInceptionV1(nclass=nclass,
partial_bn=partial_bn,
pretrained_base=pretrained_base,
Expand Down
121 changes: 111 additions & 10 deletions gluoncv/model_zoo/action_recognition/actionrec_inceptionv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,35 @@ class ActionRecInceptionV3(HybridBlock):
Parameters
----------
nclass : int, number of classes
pretrained_base : bool, load pre-trained weights or not
dropout_ratio : float, add a dropout layer to prevent overfitting on small datasets, such as UCF101
init_std : float, standard deviation value when initialize the last classification layer
feat_dim : int, feature dimension. Default is 4096 for VGG16 network
num_segments : int, number of segments used
num_crop : int, number of crops used during evaluation. Default choice is 1, 3 or 10
nclass : int
Number of classes in the training dataset.
pretrained_base : bool or str, optional, default is True.
Load pretrained base network, the extra layers are randomized. Note that
if pretrained is `True`, this has no effect.
partial_bn : bool, default False.
Freeze all batch normalization layers during training except the first layer.
dropout_ratio : float, default is 0.5.
The dropout rate of a dropout layer.
The larger the value, the more strength to prevent overfitting.
init_std : float, default is 0.001.
Standard deviation value when initialize the dense layers.
num_segments : int, default is 1.
Number of segments used to evenly divide a video.
num_crop : int, default is 1.
Number of crops used during evaluation, choices are 1, 3 or 10.
Input: a single video frame or N images from N segments when num_segments > 1
Output: a single predicted action label
"""
def __init__(self, nclass, pretrained_base=True,
partial_bn=True, dropout_ratio=0.8, init_std=0.001,
feat_dim=2048, num_segments=1, num_crop=1, **kwargs):
partial_bn=True, dropout_ratio=0.5, init_std=0.001,
num_segments=1, num_crop=1, **kwargs):
super(ActionRecInceptionV3, self).__init__()
self.dropout_ratio = dropout_ratio
self.init_std = init_std
self.num_segments = num_segments
self.num_crop = num_crop
self.feat_dim = feat_dim
self.feat_dim = 2048

pretrained_model = inception_v3(pretrained=pretrained_base, partial_bn=partial_bn, **kwargs)
self.features = pretrained_model.features
Expand All @@ -63,6 +72,29 @@ def hybrid_forward(self, F, x):
def inceptionv3_ucf101(nclass=101, pretrained=False, pretrained_base=True,
use_tsn=False, num_segments=1, num_crop=1, partial_bn=True,
ctx=mx.cpu(), root='~/.mxnet/models', **kwargs):
r"""InceptionV3 model trained on UCF101 dataset.
Parameters
----------
nclass : int.
Number of categories in the dataset.
pretrained : bool or str.
Boolean value controls whether to load the default pretrained weights for model.
String value represents the hashtag for a certain version of pretrained weights.
pretrained_base : bool or str, optional, default is True.
Load pretrained base network, the extra layers are randomized. Note that
if pretrained is `True`, this has no effect.
ctx : Context, default CPU.
The context in which to load the pretrained weights.
root : str, default $MXNET_HOME/models
Location for keeping the model parameters.
num_segments : int, default is 1.
Number of segments used to evenly divide a video.
num_crop : int, default is 1.
Number of crops used during evaluation, choices are 1, 3 or 10.
partial_bn : bool, default False.
Freeze all batch normalization layers during training except the first layer.
"""
model = ActionRecInceptionV3(nclass=nclass,
partial_bn=partial_bn,
pretrained_base=pretrained_base,
Expand All @@ -84,6 +116,29 @@ def inceptionv3_ucf101(nclass=101, pretrained=False, pretrained_base=True,
def inceptionv3_hmdb51(nclass=51, pretrained=False, pretrained_base=True,
use_tsn=False, num_segments=1, num_crop=1, partial_bn=True,
ctx=mx.cpu(), root='~/.mxnet/models', **kwargs):
r"""InceptionV3 model trained on HMDB51 dataset.
Parameters
----------
nclass : int.
Number of categories in the dataset.
pretrained : bool or str.
Boolean value controls whether to load the default pretrained weights for model.
String value represents the hashtag for a certain version of pretrained weights.
pretrained_base : bool or str, optional, default is True.
Load pretrained base network, the extra layers are randomized. Note that
if pretrained is `True`, this has no effect.
ctx : Context, default CPU.
The context in which to load the pretrained weights.
root : str, default $MXNET_HOME/models
Location for keeping the model parameters.
num_segments : int, default is 1.
Number of segments used to evenly divide a video.
num_crop : int, default is 1.
Number of crops used during evaluation, choices are 1, 3 or 10.
partial_bn : bool, default False.
Freeze all batch normalization layers during training except the first layer.
"""
model = ActionRecInceptionV3(nclass=nclass,
partial_bn=partial_bn,
pretrained_base=pretrained_base,
Expand All @@ -105,6 +160,29 @@ def inceptionv3_hmdb51(nclass=51, pretrained=False, pretrained_base=True,
def inceptionv3_kinetics400(nclass=400, pretrained=False, pretrained_base=True,
tsn=False, num_segments=1, num_crop=1, partial_bn=True,
ctx=mx.cpu(), root='~/.mxnet/models', **kwargs):
r"""InceptionV3 model trained on Kinetics400 dataset.
Parameters
----------
nclass : int.
Number of categories in the dataset.
pretrained : bool or str.
Boolean value controls whether to load the default pretrained weights for model.
String value represents the hashtag for a certain version of pretrained weights.
pretrained_base : bool or str, optional, default is True.
Load pretrained base network, the extra layers are randomized. Note that
if pretrained is `True`, this has no effect.
ctx : Context, default CPU.
The context in which to load the pretrained weights.
root : str, default $MXNET_HOME/models
Location for keeping the model parameters.
num_segments : int, default is 1.
Number of segments used to evenly divide a video.
num_crop : int, default is 1.
Number of crops used during evaluation, choices are 1, 3 or 10.
partial_bn : bool, default False.
Freeze all batch normalization layers during training except the first layer.
"""
model = ActionRecInceptionV3(nclass=nclass,
partial_bn=partial_bn,
pretrained_base=pretrained_base,
Expand All @@ -126,6 +204,29 @@ def inceptionv3_kinetics400(nclass=400, pretrained=False, pretrained_base=True,
def inceptionv3_sthsthv2(nclass=174, pretrained=False, pretrained_base=True,
tsn=False, num_segments=1, num_crop=1, partial_bn=True,
ctx=mx.cpu(), root='~/.mxnet/models', **kwargs):
r"""InceptionV3 model trained on Something-Something-V2 dataset.
Parameters
----------
nclass : int.
Number of categories in the dataset.
pretrained : bool or str.
Boolean value controls whether to load the default pretrained weights for model.
String value represents the hashtag for a certain version of pretrained weights.
pretrained_base : bool or str, optional, default is True.
Load pretrained base network, the extra layers are randomized. Note that
if pretrained is `True`, this has no effect.
ctx : Context, default CPU.
The context in which to load the pretrained weights.
root : str, default $MXNET_HOME/models
Location for keeping the model parameters.
num_segments : int, default is 1.
Number of segments used to evenly divide a video.
num_crop : int, default is 1.
Number of crops used during evaluation, choices are 1, 3 or 10.
partial_bn : bool, default False.
Freeze all batch normalization layers during training except the first layer.
"""
model = ActionRecInceptionV3(nclass=nclass,
partial_bn=partial_bn,
pretrained_base=pretrained_base,
Expand Down

0 comments on commit a64b921

Please sign in to comment.