def layer_description_builder(layer_information, id_to_node):
    '''build layer from description.
    '''
    # pylint: disable=W0123
    layer_type = layer_information[0]

    layer_input_ids = layer_information[1]
    if isinstance(layer_input_ids, Iterable):
        layer_input = list(map(lambda x: id_to_node[x], layer_input_ids))
    else:
        layer_input = id_to_node[layer_input_ids]
    layer_output = id_to_node[layer_information[2]]
    if layer_type.startswith("StubConv"):
        input_channel = layer_information[3]
        filters = layer_information[4]
        kernel_size = layer_information[5]
        stride = layer_information[6]
        return eval(layer_type)(
            input_channel, filters, kernel_size, stride, layer_input, layer_output
        )
    elif layer_type.startswith("StubDense"):
        input_units = layer_information[3]
        units = layer_information[4]
        return eval(layer_type)(input_units, units, layer_input, layer_output)
    elif layer_type.startswith("StubBatchNormalization"):
        num_features = layer_information[3]
        return eval(layer_type)(num_features, layer_input, layer_output)
    elif layer_type.startswith("StubDropout"):
        rate = layer_information[3]
        return eval(layer_type)(rate, layer_input, layer_output)
    elif layer_type.startswith("StubPooling"):
        kernel_size = layer_information[3]
        stride = layer_information[4]
        padding = layer_information[5]
        return eval(layer_type)(kernel_size, stride, padding, layer_input, layer_output)
    else:
        return eval(layer_type)(layer_input, layer_output)
def layer_description_builder ( layer_information , id_to_node ) : layer_type = layer_information [ 0 ] layer_input_ids = layer_information [ 1 ] if isinstance ( layer_input_ids , Iterable ) : layer_input = list ( map ( lambda x : id_to_node [ x ] , layer_input_ids ) ) else : layer_input = id_to_node [ layer_input_ids ] layer_output = id_to_node [ layer_information [ 2 ] ] if layer_type . startswith ( "StubConv" ) : input_channel = layer_information [ 3 ] filters = layer_information [ 4 ] kernel_size = layer_information [ 5 ] stride = layer_information [ 6 ] return eval ( layer_type ) ( input_channel , filters , kernel_size , stride , layer_input , layer_output ) elif layer_type . startswith ( "StubDense" ) : input_units = layer_information [ 3 ] units = layer_information [ 4 ] return eval ( layer_type ) ( input_units , units , layer_input , layer_output ) elif layer_type . startswith ( "StubBatchNormalization" ) : num_features = layer_information [ 3 ] return eval ( layer_type ) ( num_features , layer_input , layer_output ) elif layer_type . startswith ( "StubDropout" ) : rate = layer_information [ 3 ] return eval ( layer_type ) ( rate , layer_input , layer_output ) elif layer_type . startswith ( "StubPooling" ) : kernel_size = layer_information [ 3 ] stride = layer_information [ 4 ] padding = layer_information [ 5 ] return eval ( layer_type ) ( kernel_size , stride , padding , layer_input , layer_output ) else : return eval ( layer_type ) ( layer_input , layer_output )
build layer from description.