Deserialize a node. Arguments: layer: layer instance. node_data: Nested structure of `ListWrapper`. Raises: ValueError: In case of improperly formatted `node_data`.
(layer, node_data)
| 995 | unprocessed_nodes[layer].append(node_data) |
| 996 | |
| 997 | def process_node(layer, node_data): |
| 998 | """Deserialize a node. |
| 999 | |
| 1000 | Arguments: |
| 1001 | layer: layer instance. |
| 1002 | node_data: Nested structure of `ListWrapper`. |
| 1003 | |
| 1004 | Raises: |
| 1005 | ValueError: In case of improperly formatted `node_data`. |
| 1006 | """ |
| 1007 | input_tensors = [] |
| 1008 | for input_data in nest.flatten(node_data): |
| 1009 | input_data = input_data.as_list() |
| 1010 | inbound_layer_name = input_data[0] |
| 1011 | inbound_node_index = input_data[1] |
| 1012 | inbound_tensor_index = input_data[2] |
| 1013 | if len(input_data) == 3: |
| 1014 | kwargs = {} |
| 1015 | elif len(input_data) == 4: |
| 1016 | kwargs = input_data[3] |
| 1017 | kwargs = _deserialize_keras_tensors(kwargs, created_layers) |
| 1018 | else: |
| 1019 | raise ValueError('Improperly formatted model config.') |
| 1020 | |
| 1021 | inbound_layer = created_layers[inbound_layer_name] |
| 1022 | if len(inbound_layer._inbound_nodes) <= inbound_node_index: |
| 1023 | add_unprocessed_node(layer, node_data) |
| 1024 | return |
| 1025 | inbound_node = inbound_layer._inbound_nodes[inbound_node_index] |
| 1026 | input_tensors.append( |
| 1027 | nest.flatten(inbound_node.output_tensors)[inbound_tensor_index]) |
| 1028 | input_tensors = nest.pack_sequence_as(node_data, input_tensors) |
| 1029 | # Call layer on its inputs, thus creating the node |
| 1030 | # and building the layer if needed. |
| 1031 | if input_tensors is not None: |
| 1032 | # Preserve compatibility with older configs |
| 1033 | flat_input_tensors = nest.flatten(input_tensors) |
| 1034 | # If this is a single element but not a dict, unwrap. If this is a dict, |
| 1035 | # assume the first layer expects a dict (as is the case with a |
| 1036 | # DenseFeatures layer); pass through. |
| 1037 | if not isinstance(input_tensors, dict) and len(flat_input_tensors) == 1: |
| 1038 | input_tensors = flat_input_tensors[0] |
| 1039 | layer(input_tensors, **kwargs) |
| 1040 | |
| 1041 | def process_layer(layer_data): |
| 1042 | """Deserializes a layer, then call it on appropriate inputs. |
nothing calls this directly
no test coverage detected