MCPcopy
hub / github.com/tensorlayer/TensorLayer / identity_block

Function identity_block

tensorlayer/models/resnet.py:25–61  ·  view source on GitHub ↗

The identity block where there is no conv layer at shortcut. Parameters ---------- input : tf tensor Input tensor from above layer. kernel_size : int The kernel size of middle conv layer at main path. n_filters : list of integers The numbers of filters fo

(input, kernel_size, n_filters, stage, block)

Source from the content-addressed store, hash-verified

23
24
25def identity_block(input, kernel_size, n_filters, stage, block):
26 """The identity block where there is no conv layer at shortcut.
27
28 Parameters
29 ----------
30 input : tf tensor
31 Input tensor from above layer.
32 kernel_size : int
33 The kernel size of middle conv layer at main path.
34 n_filters : list of integers
35 The numbers of filters for 3 conv layer at main path.
36 stage : int
37 Current stage label.
38 block : str
39 Current block label.
40
41 Returns
42 -------
43 Output tensor of this block.
44
45 """
46 filters1, filters2, filters3 = n_filters
47 conv_name_base = 'res' + str(stage) + block + '_branch'
48 bn_name_base = 'bn' + str(stage) + block + '_branch'
49
50 x = Conv2d(filters1, (1, 1), W_init=tf.initializers.he_normal(), name=conv_name_base + '2a')(input)
51 x = BatchNorm(name=bn_name_base + '2a', act='relu')(x)
52
53 ks = (kernel_size, kernel_size)
54 x = Conv2d(filters2, ks, padding='SAME', W_init=tf.initializers.he_normal(), name=conv_name_base + '2b')(x)
55 x = BatchNorm(name=bn_name_base + '2b', act='relu')(x)
56
57 x = Conv2d(filters3, (1, 1), W_init=tf.initializers.he_normal(), name=conv_name_base + '2c')(x)
58 x = BatchNorm(name=bn_name_base + '2c')(x)
59
60 x = Elementwise(tf.add, act='relu')([x, input])
61 return x
62
63
64def conv_block(input, kernel_size, n_filters, stage, block, strides=(2, 2)):

Callers 1

ResNet50Function · 0.85

Calls 3

Conv2dClass · 0.90
BatchNormClass · 0.90
ElementwiseClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…