コード例 #1
0
  def test_convert_inner_node_data(self):
    data = tf_utils.convert_inner_node_data((tf_utils.ListWrapper(['l', 2, 3]),
                                             tf_utils.ListWrapper(['l', 5, 6])))
    self.assertEqual(data, (['l', 2, 3], ['l', 5, 6]))

    data = tf_utils.convert_inner_node_data(((['l', 2, 3], ['l', 5, 6])),
                                            wrap=True)
    self.assertTrue(all(isinstance(ele, tf_utils.ListWrapper) for ele in data))
コード例 #2
0
 def serialize_first_arg_tensor(t):
     if is_keras_tensor(t):
         kh = t._keras_history
         node_index = kh.node_index
         node_key = make_node_key(kh.layer.name, node_index)
         new_node_index = node_conversion_map.get(node_key, 0)
         data = [kh.layer.name, new_node_index, kh.tensor_index, kwargs]
     else:
         # If an element in the first call argument did not originate as a
         # keras tensor and is a constant value, we save it using the format
         # ['_CONSTANT_VALUE', -1, serialized_tensor_or_python_constant]
         # (potentially including serialized kwargs in an optional 4th argument).
         data = [
             _CONSTANT_VALUE, -1,
             _serialize_keras_tensor(t), kwargs
         ]
     return tf_utils.ListWrapper(data)