def convert_leakyrelu(net, node, module, builder):
    """Convert a leakyrelu layer from mxnet to coreml.

    Parameters
    ----------
    network: net
        A mxnet network object.

    layer: node
        Node to convert.

    module: module
        An module for MXNet

    builder: NeuralNetworkBuilder
        A neural network builder object.
    """

    input_name, output_name = _get_input_output_name(net, node)
    name = node['name']
    inputs = node['inputs']
    args, _ = module.get_params()
    mx_non_linearity = _get_attrs(node)['act_type']
    if mx_non_linearity == 'elu':
        non_linearity = 'ELU'
        slope = _get_attrs(node)['slope'] if 'slope' in _get_attrs(node) else 0.25
        params = slope
    elif mx_non_linearity == 'leaky':
        non_linearity = 'LEAKYRELU'
        slope = _get_attrs(node)['slope'] if 'slope' in _get_attrs(node) else 0.25
        params = [slope]
    elif mx_non_linearity == 'prelu':
        non_linearity = 'PRELU'
        params = args[_get_node_name(net, inputs[1][0])].asnumpy()
    else:
        raise TypeError('Unknown activation type %s' % mx_non_linearity)
    builder.add_activation(name = name,
                           non_linearity = non_linearity,
                           input_name = input_name,
                           output_name = output_name,
                           params = params)
def convert_leakyrelu ( net , node , module , builder ) : input_name , output_name = _get_input_output_name ( net , node ) name = node [ 'name' ] inputs = node [ 'inputs' ] args , _ = module . get_params ( ) mx_non_linearity = _get_attrs ( node ) [ 'act_type' ] if mx_non_linearity == 'elu' : non_linearity = 'ELU' slope = _get_attrs ( node ) [ 'slope' ] if 'slope' in _get_attrs ( node ) else 0.25 params = slope elif mx_non_linearity == 'leaky' : non_linearity = 'LEAKYRELU' slope = _get_attrs ( node ) [ 'slope' ] if 'slope' in _get_attrs ( node ) else 0.25 params = [ slope ] elif mx_non_linearity == 'prelu' : non_linearity = 'PRELU' params = args [ _get_node_name ( net , inputs [ 1 ] [ 0 ] ) ] . asnumpy ( ) else : raise TypeError ( 'Unknown activation type %s' % mx_non_linearity ) builder . add_activation ( name = name , non_linearity = non_linearity , input_name = input_name , output_name = output_name , params = params )
Convert a leakyrelu layer from mxnet to coreml.

    Parameters
    ----------
    network: net
        A mxnet network object.

    layer: node
        Node to convert.

    module: module
        An module for MXNet

    builder: NeuralNetworkBuilder
        A neural network builder object.