Mobilenetv2¶
-
class
olympus.models.mobilenetv2.Block(in_planes, out_planes, expansion, stride)[source]¶ Bases:
torch.nn.modules.module.Moduleexpand + depthwise + pointwise
See :class`.MobileNetV2` for license and references`
Methods
__call__(self, \*input, \*\*kwargs)Call self as a function. add_module(self, name, module)Adds a child module to the current module. apply(self, fn)Applies fnrecursively to every submodule (as returned by.children()) as well as self.buffers(self[, recurse])Returns an iterator over module buffers. children(self)Returns an iterator over immediate children modules. cpu(self)Moves all model parameters and buffers to the CPU. cuda(self[, device])Moves all model parameters and buffers to the GPU. double(self)Casts all floating point parameters and buffers to doubledatatype.eval(self)Sets the module in evaluation mode. extra_repr(self)Set the extra representation of the module float(self)Casts all floating point parameters and buffers to float datatype. forward(self, x)Defines the computation performed at every call. half(self)Casts all floating point parameters and buffers to halfdatatype.load_state_dict(self, state_dict[, strict])Copies parameters and buffers from state_dictinto this module and its descendants.modules(self)Returns an iterator over all modules in the network. named_buffers(self[, prefix, recurse])Returns an iterator over module buffers, yielding both the name of the buffer as well as the buffer itself. named_children(self)Returns an iterator over immediate children modules, yielding both the name of the module as well as the module itself. named_modules(self[, memo, prefix])Returns an iterator over all modules in the network, yielding both the name of the module as well as the module itself. named_parameters(self[, prefix, recurse])Returns an iterator over module parameters, yielding both the name of the parameter as well as the parameter itself. parameters(self[, recurse])Returns an iterator over module parameters. register_backward_hook(self, hook)Registers a backward hook on the module. register_buffer(self, name, tensor)Adds a persistent buffer to the module. register_forward_hook(self, hook)Registers a forward hook on the module. register_forward_pre_hook(self, hook)Registers a forward pre-hook on the module. register_parameter(self, name, param)Adds a parameter to the module. requires_grad_(self[, requires_grad])Change if autograd should record operations on parameters in this module. state_dict(self[, destination, prefix, …])Returns a dictionary containing a whole state of the module. to(self, \*args, \*\*kwargs)Moves and/or casts the parameters and buffers. train(self[, mode])Sets the module in training mode. type(self, dst_type)Casts all parameters and buffers to dst_type.zero_grad(self)Sets gradients of all model parameters to zero. share_memory -
forward(self, x)[source]¶ Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
-
-
class
olympus.models.mobilenetv2.MobileNetV2(cfg, input_size, conv, avgpool, num_classes=(10, ))[source]¶ Bases:
torch.nn.modules.module.ModuleDetails on arxiv.
Original source github.
Notes
MIT License
Copyright (c) 2017 liukuang
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
References
[Re20c01034061-1] Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, Liang-Chieh Chen. “MobileNetV2: Inverted Residuals and Linear Bottlenecks” Mar 2019 Attributes: - input_size: (1, 28, 28), (3, 32, 32), (3, 64, 64)
Methods
__call__(self, \*input, \*\*kwargs)Call self as a function. add_module(self, name, module)Adds a child module to the current module. apply(self, fn)Applies fnrecursively to every submodule (as returned by.children()) as well as self.buffers(self[, recurse])Returns an iterator over module buffers. children(self)Returns an iterator over immediate children modules. cpu(self)Moves all model parameters and buffers to the CPU. cuda(self[, device])Moves all model parameters and buffers to the GPU. double(self)Casts all floating point parameters and buffers to doubledatatype.eval(self)Sets the module in evaluation mode. extra_repr(self)Set the extra representation of the module float(self)Casts all floating point parameters and buffers to float datatype. forward(self, x)Defines the computation performed at every call. half(self)Casts all floating point parameters and buffers to halfdatatype.load_state_dict(self, state_dict[, strict])Copies parameters and buffers from state_dictinto this module and its descendants.modules(self)Returns an iterator over all modules in the network. named_buffers(self[, prefix, recurse])Returns an iterator over module buffers, yielding both the name of the buffer as well as the buffer itself. named_children(self)Returns an iterator over immediate children modules, yielding both the name of the module as well as the module itself. named_modules(self[, memo, prefix])Returns an iterator over all modules in the network, yielding both the name of the module as well as the module itself. named_parameters(self[, prefix, recurse])Returns an iterator over module parameters, yielding both the name of the parameter as well as the parameter itself. parameters(self[, recurse])Returns an iterator over module parameters. register_backward_hook(self, hook)Registers a backward hook on the module. register_buffer(self, name, tensor)Adds a persistent buffer to the module. register_forward_hook(self, hook)Registers a forward hook on the module. register_forward_pre_hook(self, hook)Registers a forward pre-hook on the module. register_parameter(self, name, param)Adds a parameter to the module. requires_grad_(self[, requires_grad])Change if autograd should record operations on parameters in this module. state_dict(self[, destination, prefix, …])Returns a dictionary containing a whole state of the module. to(self, \*args, \*\*kwargs)Moves and/or casts the parameters and buffers. train(self[, mode])Sets the module in training mode. type(self, dst_type)Casts all parameters and buffers to dst_type.zero_grad(self)Sets gradients of all model parameters to zero. share_memory -
forward(self, x)[source]¶ Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.