deeplabcut.pose_estimation_tensorflow.backbones.mobilenet
Classes:
| Name | Description |
|---|---|
NoOpScope |
No-op context manager. |
Functions:
| Name | Description |
|---|---|
global_pool |
Applies avg pool to produce 1x1 output. |
mobilenet |
Mobilenet model for classification, supports both V1 and V2. |
mobilenet_base |
Mobilenet base network. |
safe_arg_scope |
Returns |
training_scope |
Defines Mobilenet training scope. |
NoOpScope
global_pool
Applies avg pool to produce 1x1 output.
NOTE: This function is functionally equivalent to reduce_mean, but it has baked in average pool which has better support across hardware.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
input tensor |
required | |
|
pooling op (avg pool is default) |
avg_pool2d
|
Returns: a tensor batch_size x 1 x 1 x depth.
Source code in deeplabcut/pose_estimation_tensorflow/backbones/mobilenet.py
mobilenet
mobilenet(
inputs,
num_classes=1001,
prediction_fn=slim.softmax,
reuse=None,
scope="Mobilenet",
base_only=False,
**mobilenet_args
)
Mobilenet model for classification, supports both V1 and V2.
Note: default mode is inference, use mobilenet.training_scope to create training network.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
a tensor of shape [batch_size, height, width, channels]. |
required | |
|
number of predicted classes. If 0 or None, the logits layer is omitted and the input features to the logits layer (before dropout) are returned instead. |
1001
|
|
|
a function to get predictions out of logits (default softmax). |
softmax
|
|
|
whether or not the network and its variables should be reused. To be able to reuse 'scope' must be given. |
None
|
|
|
Optional variable_scope. |
'Mobilenet'
|
|
|
if True will only create the base of the network (no pooling |
False
|
|
|
passed to mobilenet_base verbatim. - conv_defs: list of conv defs - multiplier: Float multiplier for the depth (number of channels) for all convolution ops. The value must be greater than zero. Typical usage will be to set this value in (0, 1) to reduce the number of parameters or computation cost of the model. - output_stride: will ensure that the last layer has at most total stride. If the architecture calls for more stride than that provided (e.g. output_stride=16, but the architecture has 5 stride=2 operators), it will replace output_stride with fractional convolutions using Atrous Convolutions. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
logits |
the pre-softmax activations, a tensor of size [batch_size, num_classes] end_points: a dictionary from components of the network to the corresponding activation tensor. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Input rank is invalid. |
Source code in deeplabcut/pose_estimation_tensorflow/backbones/mobilenet.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
mobilenet_base
mobilenet_base(
inputs,
conv_defs,
multiplier=1.0,
final_endpoint=None,
output_stride=None,
use_explicit_padding=False,
scope=None,
is_training=False,
)
Mobilenet base network.
Constructs a network from inputs to the given final endpoint. By default the network is constructed in inference mode. To create network in training mode use:
with slim.arg_scope(mobilenet.training_scope()): logits, endpoints = mobilenet_base(...)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
a tensor of shape [batch_size, height, width, channels]. |
required | |
|
A list of op(...) layers specifying the net architecture. |
required | |
|
Float multiplier for the depth (number of channels) for all convolution ops. The value must be greater than zero. Typical usage will be to set this value in (0, 1) to reduce the number of parameters or computation cost of the model. |
1.0
|
|
|
The name of last layer, for early termination for |
None
|
|
|
last layer is "layer_14", for V2: "layer_20" |
required | |
|
An integer that specifies the requested ratio of input to output spatial resolution. If not None, then we invoke atrous convolution if necessary to prevent the network from reducing the spatial resolution of the activation maps. Allowed values are 1 or any even number, excluding zero. Typical values are 8 (accurate fully convolutional mode), 16 (fast fully convolutional mode), and 32 (classification mode). NOTE- output_stride relies on all consequent operators to support dilated operators via "rate" parameter. This might require wrapping non-conv operators to operate properly. |
None
|
|
|
Use 'VALID' padding for convolutions, but prepad inputs so that the output dimensions are the same as if 'SAME' padding were used. |
False
|
|
|
optional variable scope. |
None
|
|
|
How to setup batch_norm and other ops. Note: most of the time this does not need be set directly. Use mobilenet.training_scope() to set up training instead. This parameter is here for backward compatibility only. It is safe to set it to the value matching training_scope(is_training=...). It is also safe to explicitly set it to False, even if there is outer training_scope set to to training. (The network will be built in inference mode). If this is set to None, no arg_scope is added for slim.batch_norm's is_training parameter. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
tensor_out |
output tensor. end_points: a set of activations for external use, for example summaries or losses. |
Raises:
| Type | Description |
|---|---|
ValueError
|
depth_multiplier <= 0, or the target output_stride is not allowed. |
Source code in deeplabcut/pose_estimation_tensorflow/backbones/mobilenet.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
safe_arg_scope
Returns slim.arg_scope with all None arguments removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Functions to pass to |
required | |
|
Arguments to pass to |
{}
|
Returns:
| Type | Description |
|---|---|
|
arg_scope or No-op context manager. |
can be useful if None value should be interpreted as "do not overwrite
this parameter value".
Source code in deeplabcut/pose_estimation_tensorflow/backbones/mobilenet.py
training_scope
training_scope(is_training=True, weight_decay=4e-05, stddev=0.09, dropout_keep_prob=0.8, bn_decay=0.997)
Defines Mobilenet training scope.
Usage
with tf.contrib.slim.arg_scope(mobilenet.training_scope()): logits, endpoints = mobilenet_v2.mobilenet(input_tensor)
the network created will be trainble with dropout/batch norm
initialized appropriately.
Args: is_training: if set to False this will ensure that all customizations are set to non-training mode. This might be helpful for code that is reused across both training/evaluation, but most of the time training_scope with value False is not needed. If this is set to None, the parameters is not added to the batch_norm arg_scope.
weight_decay: The weight decay to use for regularizing the model. stddev: Standard deviation for initialization, if negative uses xavier. dropout_keep_prob: dropout keep probability (not set if equals to None). bn_decay: decay for the batch norm moving averages (not set if equals to None).
Returns:
| Type | Description |
|---|---|
|
An argument scope to use via arg_scope. |