MCPcopy Index your code
hub / github.com/tensorlayer/TensorLayer / UnStack

Class UnStack

tensorlayer/layers/stack.py:67–116  ·  view source on GitHub ↗

The :class:`UnStack` class is a layer for unstacking the given dimension of a rank-R tensor into rank-(R-1) tensors., see `tf.unstack() `__. Parameters ---------- num : int or None The length of the dimension axis. Auto

Source from the content-addressed store, hash-verified

65
66
67class UnStack(Layer):
68 """
69 The :class:`UnStack` class is a layer for unstacking the given dimension of a rank-R tensor into rank-(R-1) tensors., see `tf.unstack() <https://www.tensorflow.org/api_docs/python/tf/unstack>`__.
70
71 Parameters
72 ----------
73 num : int or None
74 The length of the dimension axis. Automatically inferred if None (the default).
75 axis : int
76 Dimension along which axis to concatenate.
77 name : str
78 A unique layer name.
79
80 Returns
81 -------
82 list of :class:`Layer`
83 The list of layer objects unstacked from the input.
84
85 Examples
86 --------
87 >>> ni = Input([4, 10], name='input')
88 >>> nn = Dense(n_units=5)(ni)
89 >>> nn = UnStack(axis=1)(nn) # unstack in channel axis
90 >>> len(nn) # 5
91 >>> nn[0].shape # (4,)
92
93 """
94
95 def __init__(self, num=None, axis=0, name=None): #'unstack'):
96 super().__init__(name)
97 self.num = num
98 self.axis = axis
99
100 self.build(None)
101 self._built = True
102 logging.info("UnStack %s: num: %s axis: %d" % (self.name, self.num, self.axis))
103
104 def __repr__(self):
105 s = '{classname}(num={num}, axis={axis}'
106 if self.name is not None:
107 s += ', name=\'{name}\''
108 s += ')'
109 return s.format(classname=self.__class__.__name__, **self.__dict__)
110
111 def build(self, inputs_shape):
112 pass
113
114 def forward(self, inputs):
115 outputs = tf.unstack(inputs, num=self.num, axis=self.axis, name=self.name)
116 return outputs

Callers 2

setUpClassMethod · 0.85
get_unstack_modelMethod · 0.85

Calls

no outgoing calls

Tested by 2

setUpClassMethod · 0.68
get_unstack_modelMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…