smash.factory.Net.add_flatten#

Net.add_flatten()[source]#

Add a flatten layer to reshape the input from 2D layer into 1D layer.

Examples

>>> from smash.factory import Net
>>> net = Net()
>>> net.add_conv2d(64, filter_shape=5, input_shape=(30, 32, 6))
>>> net.add_flatten()
>>> net.add_dense(16)
>>> net
+------------------------------------------------------+
| Layer Type  Input/Output Shape        Num Parameters |
+------------------------------------------------------+
| Conv2D      (30, 32, 6)/(30, 32, 64)  9664           |
| Flatten     (30, 32, 64)/(960, 64)    0              |
| Dense       (960, 64)/(960, 16)       1040           |
+------------------------------------------------------+
Total parameters: 10704
Trainable parameters: 10704