A layer that reshapes high-dimension input into a vector. Then we often apply Dense, RNN, Concat and etc on the top of a flatten layer. [batch_size, mask_row, mask_col, n_mask] ---> [batch_size, mask_row * mask_col * n_mask] Parameters ---------- name : None or str A un
| 17 | |
| 18 | |
| 19 | class Flatten(Layer): |
| 20 | """A layer that reshapes high-dimension input into a vector. |
| 21 | |
| 22 | Then we often apply Dense, RNN, Concat and etc on the top of a flatten layer. |
| 23 | [batch_size, mask_row, mask_col, n_mask] ---> [batch_size, mask_row * mask_col * n_mask] |
| 24 | |
| 25 | Parameters |
| 26 | ---------- |
| 27 | name : None or str |
| 28 | A unique layer name. |
| 29 | |
| 30 | Examples |
| 31 | -------- |
| 32 | >>> x = tl.layers.Input([8, 4, 3], name='input') |
| 33 | >>> y = tl.layers.Flatten(name='flatten')(x) |
| 34 | [8, 12] |
| 35 | |
| 36 | """ |
| 37 | |
| 38 | def __init__(self, name=None): #'flatten'): |
| 39 | super(Flatten, self).__init__(name) |
| 40 | |
| 41 | self.build() |
| 42 | self._built = True |
| 43 | |
| 44 | logging.info("Flatten %s:" % (self.name)) |
| 45 | |
| 46 | def __repr__(self): |
| 47 | s = '{classname}(' |
| 48 | s += 'name=\'{name}\'' |
| 49 | s += ')' |
| 50 | return s.format(classname=self.__class__.__name__, **self.__dict__) |
| 51 | |
| 52 | def build(self, inputs_shape=None): |
| 53 | pass |
| 54 | |
| 55 | # @tf.function |
| 56 | def forward(self, inputs): |
| 57 | outputs = flatten_reshape(inputs, name=self.name) |
| 58 | return outputs |
| 59 | |
| 60 | |
| 61 | class Reshape(Layer): |
no outgoing calls
searching dependent graphs…