MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _insert_ancillary_layers

Function _insert_ancillary_layers

tensorflow/python/keras/models.py:60–70  ·  view source on GitHub ↗

Inserts ancillary layers into the model with the proper order.

(model, ancillary_layers, metrics_names, new_nodes)

Source from the content-addressed store, hash-verified

58
59
60def _insert_ancillary_layers(model, ancillary_layers, metrics_names, new_nodes):
61 """Inserts ancillary layers into the model with the proper order."""
62 # Sort `AddMetric` layers so they agree with metrics_names.
63 metric_layers = [
64 layer for layer in ancillary_layers if isinstance(layer, AddMetric)
65 ]
66 metric_layers.sort(key=lambda layer: metrics_names.index(layer.metric_name))
67 ancillary_layers = [
68 layer for layer in ancillary_layers if not isinstance(layer, AddMetric)
69 ] + metric_layers
70 model._insert_layers(ancillary_layers, relevant_nodes=list(new_nodes))
71
72
73def _make_new_nodes(nodes_by_depth, layer_fn, layer_map, tensor_map):

Callers 2

_clone_functional_modelFunction · 0.85
_clone_sequential_modelFunction · 0.85

Calls 3

_insert_layersMethod · 0.80
sortMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected