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

Class Dense

tensorlayer/layers/dense/base_dense.py:19–111  ·  view source on GitHub ↗

The :class:`Dense` class is a fully connected layer. Parameters ---------- n_units : int The number of units of this layer. act : activation function The activation function of this layer. W_init : initializer The initializer for the weight matrix. b_

Source from the content-addressed store, hash-verified

17
18
19class Dense(Layer):
20 """The :class:`Dense` class is a fully connected layer.
21
22 Parameters
23 ----------
24 n_units : int
25 The number of units of this layer.
26 act : activation function
27 The activation function of this layer.
28 W_init : initializer
29 The initializer for the weight matrix.
30 b_init : initializer or None
31 The initializer for the bias vector. If None, skip biases.
32 in_channels: int
33 The number of channels of the previous layer.
34 If None, it will be automatically detected when the layer is forwarded for the first time.
35 name : None or str
36 A unique layer name. If None, a unique name will be automatically generated.
37
38 Examples
39 --------
40 With TensorLayer
41
42 >>> net = tl.layers.Input([100, 50], name='input')
43 >>> dense = tl.layers.Dense(n_units=800, act=tf.nn.relu, in_channels=50, name='dense_1')
44 >>> print(dense)
45 Dense(n_units=800, relu, in_channels='50', name='dense_1')
46 >>> tensor = tl.layers.Dense(n_units=800, act=tf.nn.relu, name='dense_2')(net)
47 >>> print(tensor)
48 tf.Tensor([...], shape=(100, 800), dtype=float32)
49
50 Notes
51 -----
52 If the layer input has more than two axes, it needs to be flatten by using :class:`Flatten`.
53
54 """
55
56 def __init__(
57 self,
58 n_units,
59 act=None,
60 W_init=tl.initializers.truncated_normal(stddev=0.05),
61 b_init=tl.initializers.constant(value=0.0),
62 in_channels=None,
63 name=None, # 'dense',
64 ):
65
66 super(Dense, self).__init__(name, act=act)
67
68 self.n_units = n_units
69 self.W_init = W_init
70 self.b_init = b_init
71 self.in_channels = in_channels
72
73 if self.in_channels is not None:
74 self.build(self.in_channels)
75 self._built = True
76

Callers 15

make_layersFunction · 0.90
ResNet50Function · 0.90
get_modelFunction · 0.90
get_model_batchnormFunction · 0.90
create_base_networkFunction · 0.90
hidden_modelFunction · 0.90
get_modelFunction · 0.90
__init__Method · 0.90
__init__Method · 0.90
get_modelFunction · 0.90
__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by 15

basic_static_modelFunction · 0.68
__init__Method · 0.68
setUpClassMethod · 0.68
setUpClassMethod · 0.68
__init__Method · 0.68
setUpClassMethod · 0.68
setUpClassMethod · 0.68
test_special_casesMethod · 0.68
test_layerlistMethod · 0.68
get_unstack_modelMethod · 0.68
__init__Method · 0.68
MyModelMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…