example_proto_coder_test.py 文件源码

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

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

    # Assert the data is decoded into the expected format.
    decoded = coder.decode(data)
    np.testing.assert_equal(expected_decoded, decoded)

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

    # Assert the data can be decoded from the encoded string.
    decoded_again = coder.decode(encoded)
    np.testing.assert_equal(expected_decoded, decoded_again)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号