本文整理汇总了Python中tensorflow.python.ops.parsing_ops.decode_raw函数的典型用法代码示例。如果您正苦于以下问题:Python decode_raw函数的具体用法?Python decode_raw怎么用?Python decode_raw使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了decode_raw函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testEndianness
def testEndianness(self):
with self.cached_session():
in_bytes = array_ops.placeholder(dtypes.string, shape=[None])
decode_le = parsing_ops.decode_raw(
in_bytes, out_type=dtypes.int32, little_endian=True)
decode_be = parsing_ops.decode_raw(
in_bytes, out_type=dtypes.int32, little_endian=False)
result = decode_le.eval(feed_dict={in_bytes: ["\x01\x02\x03\x04"]})
self.assertAllEqual([[0x04030201]], result)
result = decode_be.eval(feed_dict={in_bytes: ["\x01\x02\x03\x04"]})
self.assertAllEqual([[0x01020304]], result)
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:11,代码来源:decode_raw_op_test.py
示例2: testEmptyStringInput
def testEmptyStringInput(self):
with self.test_session():
in_bytes = array_ops.placeholder(dtypes.string, shape=[None])
decode = parsing_ops.decode_raw(in_bytes, out_type=dtypes.float16)
result = decode.eval(feed_dict={in_bytes: [""]})
self.assertEqual(len(result), 1)
开发者ID:1000sprites,项目名称:tensorflow,代码行数:7,代码来源:decode_raw_op_test.py
示例3: testEmptyStringInput
def testEmptyStringInput(self):
with self.cached_session():
in_bytes = array_ops.placeholder(dtypes.string, shape=[None])
decode = parsing_ops.decode_raw(in_bytes, out_type=dtypes.float16)
for num_inputs in range(3):
result = decode.eval(feed_dict={in_bytes: [""] * num_inputs})
self.assertEqual((num_inputs, 0), result.shape)
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:8,代码来源:decode_raw_op_test.py
示例4: testToBool
def testToBool(self):
with self.cached_session():
in_bytes = array_ops.placeholder(dtypes.string, shape=[None])
decode = parsing_ops.decode_raw(in_bytes, out_type=dtypes.bool)
self.assertEqual([None, None], decode.get_shape().as_list())
expected_result = np.matrix([[True, False, False, True]], dtype="<b1")
result = decode.eval(feed_dict={in_bytes: [expected_result.tostring()]})
self.assertAllEqual(expected_result, result)
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:10,代码来源:decode_raw_op_test.py
示例5: testToFloat16
def testToFloat16(self):
with self.test_session():
in_bytes = array_ops.placeholder(dtypes.string, shape=[None])
decode = parsing_ops.decode_raw(in_bytes, out_type=dtypes.float16)
self.assertEqual([None, None], decode.get_shape().as_list())
expected_result = np.matrix([[1, -2, -3, 4]], dtype=np.float16)
result = decode.eval(feed_dict={in_bytes: [expected_result.tostring()]})
self.assertAllEqual(expected_result, result)
开发者ID:1000sprites,项目名称:tensorflow,代码行数:10,代码来源:decode_raw_op_test.py
示例6: testRemoteIteratorUsingRemoteCallOpDirectSessionGPUCPU
def testRemoteIteratorUsingRemoteCallOpDirectSessionGPUCPU(self):
if not test_util.is_gpu_available():
self.skipTest("No GPU available")
with ops.device("/job:localhost/replica:0/task:0/cpu:0"):
dataset_3 = dataset_ops.Dataset.from_tensor_slices([1, 2, 3])
iterator_3 = dataset_ops.make_one_shot_iterator(dataset_3)
iterator_3_handle = iterator_3.string_handle()
def _encode_raw(byte_array):
return bytes(bytearray(byte_array))
@function.Defun(dtypes.uint8)
def _remote_fn(h):
handle = script_ops.py_func(_encode_raw, [h], dtypes.string)
remote_iterator = iterator_ops.Iterator.from_string_handle(
handle, dataset_ops.get_legacy_output_types(dataset_3),
dataset_ops.get_legacy_output_shapes(dataset_3))
return remote_iterator.get_next()
with ops.device("/job:localhost/replica:0/task:0/device:GPU:0"):
target_placeholder = array_ops.placeholder(dtypes.string, shape=[])
iterator_3_handle_uint8 = parsing_ops.decode_raw(
bytes=iterator_3_handle, out_type=dtypes.uint8)
remote_op = functional_ops.remote_call(
args=[iterator_3_handle_uint8],
Tout=[dtypes.int32],
f=_remote_fn,
target=target_placeholder)
with self.cached_session() as sess:
elem = sess.run(
remote_op,
feed_dict={
target_placeholder: "/job:localhost/replica:0/task:0/cpu:0"
})
self.assertEqual(elem, [1])
elem = sess.run(
remote_op,
feed_dict={
target_placeholder: "/job:localhost/replica:0/task:0/cpu:0"
})
self.assertEqual(elem, [2])
elem = sess.run(
remote_op,
feed_dict={
target_placeholder: "/job:localhost/replica:0/task:0/cpu:0"
})
self.assertEqual(elem, [3])
with self.assertRaises(errors.OutOfRangeError):
sess.run(
remote_op,
feed_dict={
target_placeholder: "/job:localhost/replica:0/task:0/cpu:0"
})
开发者ID:kylin9872,项目名称:tensorflow,代码行数:55,代码来源:iterator_test.py
示例7: testToComplex128
def testToComplex128(self):
with self.cached_session():
in_bytes = array_ops.placeholder(dtypes.string, shape=[None])
decode = parsing_ops.decode_raw(in_bytes, out_type=dtypes.complex128)
self.assertEqual([None, None], decode.get_shape().as_list())
expected_result = np.matrix([[1 + 1j, 2 - 2j, -3 + 3j, -4 - 4j]],
dtype="<c16")
result = decode.eval(feed_dict={in_bytes: [expected_result.tostring()]})
self.assertAllEqual(expected_result, result)
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:11,代码来源:decode_raw_op_test.py
示例8: testDecompressWithRaw
def testDecompressWithRaw(self):
for compression_type in ["ZLIB", "GZIP", ""]:
with self.cached_session():
in_bytes = array_ops.placeholder(dtypes.string, shape=[None])
decompressed = parsing_ops.decode_compressed(
in_bytes, compression_type=compression_type)
decode = parsing_ops.decode_raw(decompressed, out_type=dtypes.int16)
result = decode.eval(
feed_dict={in_bytes: [self._compress(b"AaBC", compression_type)]})
self.assertAllEqual(
[[ord("A") + ord("a") * 256, ord("B") + ord("C") * 256]], result)
开发者ID:Wajih-O,项目名称:tensorflow,代码行数:12,代码来源:decode_compressed_op_test.py
示例9: testToInt16
def testToInt16(self):
with self.cached_session():
in_bytes = array_ops.placeholder(dtypes.string, shape=[None])
decode = parsing_ops.decode_raw(in_bytes, out_type=dtypes.int16)
self.assertEqual([None, None], decode.get_shape().as_list())
result = decode.eval(feed_dict={in_bytes: ["AaBC"]})
self.assertAllEqual(
[[ord("A") + ord("a") * 256, ord("B") + ord("C") * 256]], result)
with self.assertRaisesOpError(
"Input to DecodeRaw has length 3 that is not a multiple of 2, the "
"size of int16"):
decode.eval(feed_dict={in_bytes: ["123", "456"]})
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:14,代码来源:decode_raw_op_test.py
示例10: testToUInt16
def testToUInt16(self):
with self.cached_session():
in_bytes = array_ops.placeholder(dtypes.string, shape=[None])
decode = parsing_ops.decode_raw(in_bytes, out_type=dtypes.uint16)
self.assertEqual([None, None], decode.get_shape().as_list())
# Use FF/EE/DD/CC so that decoded value is higher than 32768 for uint16
result = decode.eval(feed_dict={in_bytes: [b"\xFF\xEE\xDD\xCC"]})
self.assertAllEqual(
[[0xFF + 0xEE * 256, 0xDD + 0xCC * 256]], result)
with self.assertRaisesOpError(
"Input to DecodeRaw has length 3 that is not a multiple of 2, the "
"size of uint16"):
decode.eval(feed_dict={in_bytes: ["123", "456"]})
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:15,代码来源:decode_raw_op_test.py
示例11: testToUint8
def testToUint8(self):
with self.cached_session():
in_bytes = array_ops.placeholder(dtypes.string, shape=[2])
decode = parsing_ops.decode_raw(in_bytes, out_type=dtypes.uint8)
self.assertEqual([2, None], decode.get_shape().as_list())
result = decode.eval(feed_dict={in_bytes: ["A", "a"]})
self.assertAllEqual([[ord("A")], [ord("a")]], result)
result = decode.eval(feed_dict={in_bytes: ["wer", "XYZ"]})
self.assertAllEqual([[ord("w"), ord("e"), ord("r")],
[ord("X"), ord("Y"), ord("Z")]], result)
with self.assertRaisesOpError(
"DecodeRaw requires input strings to all be the same size, but "
"element 1 has size 5 != 6"):
decode.eval(feed_dict={in_bytes: ["short", "longer"]})
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:17,代码来源:decode_raw_op_test.py
示例12: decode_raw
def decode_raw():
return parsing_ops.decode_raw(image_buffer, dtypes.uint8)
开发者ID:821760408-sp,项目名称:tensorflow,代码行数:2,代码来源:tfexample_decoder.py
示例13: decode_raw
def decode_raw():
"""Decodes a raw image."""
return parsing_ops.decode_raw(image_buffer, out_type=self._dtype)
开发者ID:AndrewTwinz,项目名称:tensorflow,代码行数:3,代码来源:tfexample_decoder.py
示例14: decode_raw
def decode_raw():
return parsing_ops.decode_raw(image_buffer, out_type=self._dtype)
开发者ID:LUTAN,项目名称:tensorflow,代码行数:2,代码来源:tfexample_decoder.py
注:本文中的tensorflow.python.ops.parsing_ops.decode_raw函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论