Caffe2 - Python API
A deep learning, cross platform ML framework
Packages
Classes
Files
C++ API
Python API
GitHub
File List
caffe2
python
regularizer_context.py
1
# @package regularizer_context
2
# Module caffe2.python.regularizer_context
3
from
__future__
import
absolute_import
4
from
__future__
import
division
5
from
__future__
import
print_function
6
from
__future__
import
unicode_literals
7
8
from
caffe2.python
import
context
9
from
caffe2.python.modifier_context
import
(
10
ModifierContext, UseModifierBase)
11
12
13
@context.define_context(allow_default=
True
)
14
class
RegularizerContext
(ModifierContext):
15
"""
16
provide context to allow param_info to have different regularizers
17
"""
18
19
def
has_regularizer(self, name):
20
return
self._has_modifier(name)
21
22
def
get_regularizer(self, name):
23
assert
self.
has_regularizer
(name), (
24
"{} regularizer is not provided!"
.format(name))
25
return
self._get_modifier(name)
26
27
28
class
UseRegularizer
(UseModifierBase):
29
'''
30
context class to allow setting the current context.
31
Example useage with layer:
32
regularizers = {'reg1': reg1, 'reg2': reg2}
33
with UseRegularizer(regularizers):
34
reg = RegularizerContext.current().get_regularizer('reg1')
35
layer(reg=reg)
36
'''
37
def
_context_class(self):
38
return
RegularizerContext
caffe2.python.regularizer_context.RegularizerContext
Definition:
regularizer_context.py:14
caffe2.python
Definition:
__init__.py:1
caffe2.python.regularizer_context.RegularizerContext.has_regularizer
def has_regularizer(self, name)
Definition:
regularizer_context.py:19
caffe2.python.regularizer_context.UseRegularizer
Definition:
regularizer_context.py:28
caffe2.python.modifier_context
Definition:
modifier_context.py:1
Generated on Thu Mar 21 2019 13:06:36 for Caffe2 - Python API by
1.8.11