converters.keras._topology2

Module Contents

Classes

NetGraph(self,model) Attributes:

Functions

_to_list(x)
_insert_to_dict(d,key,e)
_is_merge_layer(layer)
_to_list(x)
_insert_to_dict(d, key, e)
_is_merge_layer(layer)
class NetGraph(model)

Attributes: layer_list - a list of layer names in the Keras model connection_map - a map where the key is a layer, the value is a list of its successors reverse_connection_map - a map where the key is a layer, the value is a list of its predecessors keras_layer_map - a map where the key is a layer name, the value is Keras layer model - a reference of the keras model. blob_names - blob names for each one of the edge.

__init__(model)
_add_layer(keras_layer)
_replace_blob_name(old_name, new_name)
get_predecessors(layer_name)
get_successors(layer_name)
get_keras_layer(layer_name)
get_coreml_layers(keras_layer)
make_input_layers()

Extract the ordering of the input layers.

make_output_layers()

Extract the ordering of output layers.

get_input_layers()
get_output_layers()
generate_blob_names()

Generate blob names for each one of the edge. At this time, Keras does not support “fork” operation (a layer with more than 1 blob output). So we just use names of the src layer to identify a blob. We also assume all neural networks are singly-connected graphs - which should be the case.

get_layer_blobs(layer)
reset_model_input_names(new_names)
reset_model_output_names(new_names)
add_recurrent_optionals()
_get_first_embedded_model()
_get_first_shared_layer()
_get_first_layer_of_type(layer_type)
_add_edge(src, snk)
_remove_edge(src, snk)
_remove_layer(layer)

remove the layer and its input/output edges

_remove_layer_and_reconnect(layer)

Remove the layer, and reconnect each of its predecessor to each of its successor

_remove_old_edges(layer)
_remove_layers_of_type(layer_type)
remove_skip_layers(skip_layers)
remove_internal_input_layers()
_insert_layer_after(layer_idx, new_layer, new_keras_layer)

Insert the new_layer, whose parameter is stored in a Keras layer structure new_keras_layer, after the layer whose position is layer_idx.

_insert_layer_between(src, snk, new_layer, new_keras_layer)

Insert the new_layer, whose keras layer parameters are stored in new_keras_layer, between src and snk.

defuse_activation()

Defuse the fused activation layers in the network.

is_activation(layer)
is_1d_layer(layer)
_get_1d_interface_edges()

Get edges that represents transition from not-1D to 1D, and 1D to not-1D. A ‘in_edge e(u,v)’ means u operates on non-1D blobs, but v operates on 1D blobs. An ‘out_edge e(u,v)’ means u operates on 1D blobs, but v operates on non-1D blobs.

insert_1d_permute_layers()

Insert permutation layers before a 1D start point or after 1D end point

insert_permute_for_spatial_bn()
build(is_top_level=True)
print_layer_list()
print_edge_map()
print_reverse_edge_map()
print_mapping()
print_all()