example_proto_coder_test.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:transform 作者: tensorflow 项目源码 文件源码
def _assert_decode_encode(self, coder, expected_proto_text, expected_decoded):
    example = tf.train.Example()
    text_format.Merge(expected_proto_text, example)

    # Assert the expected decoded data can be encoded into the expected proto.
    encoded = coder.encode(expected_decoded)
    parsed_example = tf.train.Example()
    parsed_example.ParseFromString(encoded)
    self.assertEqual(example, parsed_example)

    # Assert the encoded data can be decoded into the original input.
    decoded = coder.decode(encoded)
    np.testing.assert_equal(expected_decoded, decoded)

    # Assert the decoded data can be encoded back into the expected proto.
    encoded_again = coder.encode(decoded)
    parsed_example_again = tf.train.Example()
    parsed_example_again.ParseFromString(encoded_again)
    np.testing.assert_equal(example, parsed_example_again)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号