示例#1
0
def get(identifier):
    """Return the loss callable by identifier.

    Parameters
    ----------
    identifier : Union[callable, str]
        The identifier.

    Returns
    -------
    callable
        The loss callable.

    """
    if identifier is None:
        return None
    elif callable(identifier):
        return identifier
    elif isinstance(identifier, six.string_types):
        return generic_utils.deserialize_keras_object(
            identifier, globals(), 'loss')
    else:
        raise TypeError(
            'Could not interpret the loss identifier: {}.'
            .format(identifier))
示例#2
0
def get(identifier):
    """Return the regularizer callable by identifier.

    Parameters
    ----------
    identifier : Union[callable, str]
        The identifier.

    Returns
    -------
    callable
        The activation callable.

    """
    if identifier is None:
        return None
    elif callable(identifier):
        return identifier
    elif isinstance(identifier, six.string_types):
        if identifier == 'l1_l2':
            return L1L2(l1=0.01, l2=0.01)
        return generic_utils.deserialize_keras_object(identifier, globals(),
                                                      'regularizer')
    else:
        raise TypeError(
            'Could not interpret the regularizer identifier: {}.'.format(
                identifier))