Skip to content

is the mse layer really divide by the number of size ?  #2246

@pengwangucla

Description

@pengwangucla

In the mse_cost in Layers.py. We see the description is $\frac{1}{N}\sum_{i=1}^N(t _i- y_i)^2$, I think N is the size of each item

However, when I check the implementation it calls sumofsquarediff, which does not do a normalization of layer size N. I think it is a wrong description of the mse_cost layer ?

@wrap_name_default()
@layer_support()
def mse_cost(input, label, weight=None, name=None, layer_attr=None):
    """
    mean squared error cost:

    ..  math::
       $\frac{1}{N}\sum_{i=1}^N(t _i- y_i)^2$

    :param name: layer name.
    :type name: basestring
    :param input: Network prediction.
    :type input: LayerOutput
    :param label: Data label.
    :type label: LayerOutput
    :param weight: The weight affects the cost, namely the scale of cost.
                   It is an optional argument.
    :type weight: LayerOutput
    :param layer_attr: layer's extra attribute.
    :type layer_attr: ExtraLayerAttribute
    :return: LayerOutput object.
    :rtype: LayerOutput
    """
    ipts, parents = __cost_input__(input, label, weight)

    Layer(
        inputs=ipts,
        type="square_error",
        name=name,
        **ExtraLayerAttribute.to_kwargs(layer_attr))
    return LayerOutput(name, LayerType.COST, parents=parents, size=1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions