Parses `Example` protos. Args: serialized: A scalar (0-D Tensor) string, containing a binary serialized `Example` proto. sparse_keys: A list of string keys in the examples' features. The results for these keys will be returned as `SparseTensor` objects. sparse_types: A lis
(serialized, sparse_keys, sparse_types,
dense_keys, dense_types, dense_defaults,
dense_shapes, name)
| 2095 | |
| 2096 | |
| 2097 | def _parse_single_example_v2_raw(serialized, sparse_keys, sparse_types, |
| 2098 | dense_keys, dense_types, dense_defaults, |
| 2099 | dense_shapes, name): |
| 2100 | """Parses `Example` protos. |
| 2101 | |
| 2102 | Args: |
| 2103 | serialized: A scalar (0-D Tensor) string, containing a binary |
| 2104 | serialized `Example` proto. |
| 2105 | sparse_keys: A list of string keys in the examples' features. |
| 2106 | The results for these keys will be returned as `SparseTensor` objects. |
| 2107 | sparse_types: A list of `DTypes` of the same length as `sparse_keys`. |
| 2108 | Only `tf.float32` (`FloatList`), `tf.int64` (`Int64List`), |
| 2109 | and `tf.string` (`BytesList`) are supported. |
| 2110 | dense_keys: A list of string keys in the examples' features. |
| 2111 | The results for these keys will be returned as `Tensor`s |
| 2112 | dense_types: A list of DTypes of the same length as `dense_keys`. |
| 2113 | Only `tf.float32` (`FloatList`), `tf.int64` (`Int64List`), |
| 2114 | and `tf.string` (`BytesList`) are supported. |
| 2115 | dense_defaults: A dict mapping string keys to `Tensor`s. |
| 2116 | The keys of the dict must match the dense_keys of the feature. |
| 2117 | dense_shapes: A list of tuples with the same length as `dense_keys`. |
| 2118 | The shape of the data for each dense feature referenced by `dense_keys`. |
| 2119 | Required for any input tensors identified by `dense_keys`. Must be |
| 2120 | either fully defined, or may contain an unknown first dimension. |
| 2121 | An unknown first dimension means the feature is treated as having |
| 2122 | a variable number of blocks, and the output shape along this dimension |
| 2123 | is considered unknown at graph build time. Padding is applied for |
| 2124 | minibatch elements smaller than the maximum number of blocks for the |
| 2125 | given feature along this dimension. |
| 2126 | name: A name for this operation (optional). |
| 2127 | |
| 2128 | Returns: |
| 2129 | A `dict` mapping keys to `Tensor`s and `SparseTensor`s. |
| 2130 | |
| 2131 | Raises: |
| 2132 | ValueError: If sparse and dense key sets intersect, or input lengths do not |
| 2133 | match up. |
| 2134 | """ |
| 2135 | with ops.name_scope(name, "ParseSingleExample", [serialized]): |
| 2136 | serialized = ops.convert_to_tensor(serialized, name="serialized") |
| 2137 | dense_defaults = collections.OrderedDict( |
| 2138 | ) if dense_defaults is None else dense_defaults |
| 2139 | sparse_keys = [] if sparse_keys is None else sparse_keys |
| 2140 | sparse_types = [] if sparse_types is None else sparse_types |
| 2141 | dense_keys = [] if dense_keys is None else dense_keys |
| 2142 | dense_types = [] if dense_types is None else dense_types |
| 2143 | dense_shapes = ([[]] * len(dense_keys) |
| 2144 | if dense_shapes is None else dense_shapes) |
| 2145 | |
| 2146 | num_dense = len(dense_keys) |
| 2147 | num_sparse = len(sparse_keys) |
| 2148 | |
| 2149 | if len(dense_shapes) != num_dense: |
| 2150 | raise ValueError("len(dense_shapes) != len(dense_keys): %d vs. %d" % |
| 2151 | (len(dense_shapes), num_dense)) |
| 2152 | if len(dense_types) != num_dense: |
| 2153 | raise ValueError("len(dense_types) != len(num_dense): %d vs. %d" % |
| 2154 | (len(dense_types), num_dense)) |
no test coverage detected