@staticmethod
def _layers(layer, ret_input=False):
    """Return network layers. InputLayer is returned if ret_input==True."""
    while hasattr(layer, 'input_layer'):
        yield layer
        layer = layer.input_layer
    if ret_input:
        yield layer
