MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / argscope

Function argscope

tensorpack/tfutils/argscope.py:23–53  ·  view source on GitHub ↗

Args: layers (list or layer): layer or list of layers to apply the arguments. Returns: a context where all appearance of these layer will by default have the arguments specified by kwargs. Example: .. code-block:: python with argscope(Conv2

(layers, **kwargs)

Source from the content-addressed store, hash-verified

21
22@contextmanager
23def argscope(layers, **kwargs):
24 """
25 Args:
26 layers (list or layer): layer or list of layers to apply the arguments.
27
28 Returns:
29 a context where all appearance of these layer will by default have the
30 arguments specified by kwargs.
31
32 Example:
33 .. code-block:: python
34
35 with argscope(Conv2D, kernel_shape=3, nl=tf.nn.relu, out_channel=32):
36 x = Conv2D('conv0', x)
37 x = Conv2D('conv1', x)
38 x = Conv2D('conv2', x, out_channel=64) # override argscope
39
40 """
41 if not isinstance(layers, list):
42 layers = [layers]
43
44 for l in layers:
45 assert hasattr(l, '__argscope_enabled__'), "Argscope not supported for {}".format(l)
46
47 # need to deepcopy so that changes to new_scope does not affect outer scope
48 new_scope = copy.deepcopy(get_arg_scope())
49 for l in layers:
50 new_scope[l.__name__].update(kwargs)
51 _ArgScopeStack.append(new_scope)
52 yield
53 del _ArgScopeStack[-1]
54
55
56def get_arg_scope():

Callers 15

__init__Method · 0.90
get_logitsMethod · 0.90
resnet_backboneFunction · 0.90
resnet_backboneFunction · 0.90
flownet2_fusionMethod · 0.90
flownet2_sdMethod · 0.90
graph_structureMethod · 0.90
graph_structureMethod · 0.90
fastrcnn_Xconv1fc_headFunction · 0.90
rpn_headFunction · 0.90
backbone_scopeFunction · 0.90
fpn_modelFunction · 0.90

Calls 4

get_arg_scopeFunction · 0.85
formatMethod · 0.80
updateMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected