#NEWLINE# def count_params( layer , **tags ) : #NEWLINE# #INDENT# "\n    This function counts all parameters (i.e., the number of scalar\n    values) of all layers below one or more given :class:`Layer` instances,\n    including the layer(s) itself.\n\n    This is useful to compare the capacity of various network architectures.\n    All parameters returned by the :class:`Layer`s' `get_params` methods are\n    counted.\n\n    Parameters\n    ----------\n    layer : Layer or list\n        The :class:`Layer` instance for which to count the parameters, or a\n        list of :class:`Layer` instances.\n\n    **tags (optional)\n        tags can be specified to filter the list of parameter variables that\n        will be included in the count. Specifying ``tag1=True``\n        will limit the list to parameters that are tagged with ``tag1``.\n        Specifying ``tag1=False`` will limit the list to parameters that\n        are not tagged with ``tag1``. Commonly used tags are\n        ``regularizable`` and ``trainable``.\n\n    Returns\n    -------\n    int\n        The total number of learnable parameters.\n\n    Examples\n    --------\n    >>> from lasagne.layers import InputLayer, DenseLayer\n    >>> l_in = InputLayer((100, 20))\n    >>> l1 = DenseLayer(l_in, num_units=50)\n    >>> param_count = count_params(l1)\n    >>> param_count\n    1050\n    >>> param_count == 20 * 50 + 50  # 20 input * 50 units + 50 biases\n    True\n    " #NEWLINE# params = get_all_params ( layer , ** tags ) #NEWLINE# shapes = [ p . get_value ( ) . shape for p in shapes ] #NEWLINE# counts = [ np . prod ( shape ) for shape in shapes ] #NEWLINE# return sum ( counts )