Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/tensorflow/python/ops/gen_parsing_ops.py: 7%

1070 statements  

« prev     ^ index     » next       coverage.py v7.4.0, created at 2024-01-03 07:57 +0000

1"""Python wrappers around TensorFlow ops. 

2 

3This file is MACHINE GENERATED! Do not edit. 

4""" 

5 

6import collections 

7 

8from tensorflow.python import pywrap_tfe as pywrap_tfe 

9from tensorflow.python.eager import context as _context 

10from tensorflow.python.eager import core as _core 

11from tensorflow.python.eager import execute as _execute 

12from tensorflow.python.framework import dtypes as _dtypes 

13from tensorflow.security.fuzzing.py import annotation_types as _atypes 

14 

15from tensorflow.python.framework import op_def_registry as _op_def_registry 

16from tensorflow.python.framework import ops as _ops 

17from tensorflow.python.framework import op_def_library as _op_def_library 

18from tensorflow.python.util.deprecation import deprecated_endpoints 

19from tensorflow.python.util import dispatch as _dispatch 

20from tensorflow.python.util.tf_export import tf_export 

21 

22from typing import TypeVar 

23 

24def decode_csv(records, record_defaults, field_delim=",", use_quote_delim=True, na_value="", select_cols=[], name=None): 

25 r"""Convert CSV records to tensors. Each column maps to one tensor. 

26 

27 RFC 4180 format is expected for the CSV records. 

28 (https://tools.ietf.org/html/rfc4180) 

29 Note that we allow leading and trailing spaces with int or float field. 

30 

31 Args: 

32 records: A `Tensor` of type `string`. 

33 Each string is a record/row in the csv and all records should have 

34 the same format. 

35 record_defaults: A list of `Tensor` objects with types from: `float32`, `float64`, `int32`, `int64`, `string`. 

36 One tensor per column of the input record, with either a 

37 scalar default value for that column or an empty vector if the column is 

38 required. 

39 field_delim: An optional `string`. Defaults to `","`. 

40 char delimiter to separate fields in a record. 

41 use_quote_delim: An optional `bool`. Defaults to `True`. 

42 If false, treats double quotation marks as regular 

43 characters inside of the string fields (ignoring RFC 4180, Section 2, 

44 Bullet 5). 

45 na_value: An optional `string`. Defaults to `""`. 

46 Additional string to recognize as NA/NaN. 

47 select_cols: An optional list of `ints`. Defaults to `[]`. 

48 name: A name for the operation (optional). 

49 

50 Returns: 

51 A list of `Tensor` objects. Has the same type as `record_defaults`. 

52 """ 

53 _ctx = _context._context or _context.context() 

54 tld = _ctx._thread_local_data 

55 if tld.is_eager: 

56 try: 

57 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

58 _ctx, "DecodeCSV", name, records, record_defaults, "field_delim", 

59 field_delim, "use_quote_delim", use_quote_delim, "na_value", na_value, 

60 "select_cols", select_cols) 

61 return _result 

62 except _core._NotOkStatusException as e: 

63 _ops.raise_from_not_ok_status(e, name) 

64 except _core._FallbackException: 

65 pass 

66 try: 

67 return decode_csv_eager_fallback( 

68 records, record_defaults, field_delim=field_delim, 

69 use_quote_delim=use_quote_delim, na_value=na_value, 

70 select_cols=select_cols, name=name, ctx=_ctx) 

71 except _core._SymbolicException: 

72 pass # Add nodes to the TensorFlow graph. 

73 # Add nodes to the TensorFlow graph. 

74 if field_delim is None: 

75 field_delim = "," 

76 field_delim = _execute.make_str(field_delim, "field_delim") 

77 if use_quote_delim is None: 

78 use_quote_delim = True 

79 use_quote_delim = _execute.make_bool(use_quote_delim, "use_quote_delim") 

80 if na_value is None: 

81 na_value = "" 

82 na_value = _execute.make_str(na_value, "na_value") 

83 if select_cols is None: 

84 select_cols = [] 

85 if not isinstance(select_cols, (list, tuple)): 

86 raise TypeError( 

87 "Expected list for 'select_cols' argument to " 

88 "'decode_csv' Op, not %r." % select_cols) 

89 select_cols = [_execute.make_int(_i, "select_cols") for _i in select_cols] 

90 _, _, _op, _outputs = _op_def_library._apply_op_helper( 

91 "DecodeCSV", records=records, record_defaults=record_defaults, 

92 field_delim=field_delim, use_quote_delim=use_quote_delim, 

93 na_value=na_value, select_cols=select_cols, name=name) 

94 _result = _outputs[:] 

95 if _execute.must_record_gradient(): 

96 _attrs = ("OUT_TYPE", _op.get_attr("OUT_TYPE"), "field_delim", 

97 _op.get_attr("field_delim"), "use_quote_delim", 

98 _op._get_attr_bool("use_quote_delim"), "na_value", 

99 _op.get_attr("na_value"), "select_cols", 

100 _op.get_attr("select_cols")) 

101 _inputs_flat = _op.inputs 

102 _execute.record_gradient( 

103 "DecodeCSV", _inputs_flat, _attrs, _result) 

104 return _result 

105 

106DecodeCSV = tf_export("raw_ops.DecodeCSV")(_ops.to_raw_op(decode_csv)) 

107 

108 

109def decode_csv_eager_fallback(records, record_defaults, field_delim, use_quote_delim, na_value, select_cols, name, ctx): 

110 if field_delim is None: 

111 field_delim = "," 

112 field_delim = _execute.make_str(field_delim, "field_delim") 

113 if use_quote_delim is None: 

114 use_quote_delim = True 

115 use_quote_delim = _execute.make_bool(use_quote_delim, "use_quote_delim") 

116 if na_value is None: 

117 na_value = "" 

118 na_value = _execute.make_str(na_value, "na_value") 

119 if select_cols is None: 

120 select_cols = [] 

121 if not isinstance(select_cols, (list, tuple)): 

122 raise TypeError( 

123 "Expected list for 'select_cols' argument to " 

124 "'decode_csv' Op, not %r." % select_cols) 

125 select_cols = [_execute.make_int(_i, "select_cols") for _i in select_cols] 

126 _attr_OUT_TYPE, record_defaults = _execute.convert_to_mixed_eager_tensors(record_defaults, ctx) 

127 records = _ops.convert_to_tensor(records, _dtypes.string) 

128 _inputs_flat = [records] + list(record_defaults) 

129 _attrs = ("OUT_TYPE", _attr_OUT_TYPE, "field_delim", field_delim, 

130 "use_quote_delim", use_quote_delim, "na_value", na_value, "select_cols", 

131 select_cols) 

132 _result = _execute.execute(b"DecodeCSV", len(record_defaults), 

133 inputs=_inputs_flat, attrs=_attrs, ctx=ctx, 

134 name=name) 

135 if _execute.must_record_gradient(): 

136 _execute.record_gradient( 

137 "DecodeCSV", _inputs_flat, _attrs, _result) 

138 return _result 

139 

140 

141@_dispatch.add_fallback_dispatch_list 

142@_dispatch.add_type_based_api_dispatcher 

143@tf_export('io.decode_compressed', v1=['io.decode_compressed', 'decode_compressed']) 

144@deprecated_endpoints('decode_compressed') 

145def decode_compressed(bytes, compression_type="", name=None): 

146 r"""Decompress strings. 

147 

148 This op decompresses each element of the `bytes` input `Tensor`, which 

149 is assumed to be compressed using the given `compression_type`. 

150 

151 The `output` is a string `Tensor` of the same shape as `bytes`, 

152 each element containing the decompressed data from the corresponding 

153 element in `bytes`. 

154 

155 Args: 

156 bytes: A `Tensor` of type `string`. 

157 A Tensor of string which is compressed. 

158 compression_type: An optional `string`. Defaults to `""`. 

159 A scalar containing either (i) the empty string (no 

160 compression), (ii) "ZLIB", or (iii) "GZIP". 

161 name: A name for the operation (optional). 

162 

163 Returns: 

164 A `Tensor` of type `string`. 

165 """ 

166 _ctx = _context._context or _context.context() 

167 tld = _ctx._thread_local_data 

168 if tld.is_eager: 

169 try: 

170 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

171 _ctx, "DecodeCompressed", name, bytes, "compression_type", 

172 compression_type) 

173 return _result 

174 except _core._NotOkStatusException as e: 

175 _ops.raise_from_not_ok_status(e, name) 

176 except _core._FallbackException: 

177 pass 

178 try: 

179 _result = _dispatcher_for_decode_compressed( 

180 (bytes, compression_type, name,), None) 

181 if _result is not NotImplemented: 

182 return _result 

183 return decode_compressed_eager_fallback( 

184 bytes, compression_type=compression_type, name=name, ctx=_ctx) 

185 except _core._SymbolicException: 

186 pass # Add nodes to the TensorFlow graph. 

187 except (TypeError, ValueError): 

188 _result = _dispatch.dispatch( 

189 decode_compressed, (), dict(bytes=bytes, 

190 compression_type=compression_type, 

191 name=name) 

192 ) 

193 if _result is not _dispatch.OpDispatcher.NOT_SUPPORTED: 

194 return _result 

195 raise 

196 else: 

197 _result = _dispatcher_for_decode_compressed( 

198 (bytes, compression_type, name,), None) 

199 if _result is not NotImplemented: 

200 return _result 

201 # Add nodes to the TensorFlow graph. 

202 if compression_type is None: 

203 compression_type = "" 

204 compression_type = _execute.make_str(compression_type, "compression_type") 

205 try: 

206 _, _, _op, _outputs = _op_def_library._apply_op_helper( 

207 "DecodeCompressed", bytes=bytes, compression_type=compression_type, 

208 name=name) 

209 except (TypeError, ValueError): 

210 _result = _dispatch.dispatch( 

211 decode_compressed, (), dict(bytes=bytes, 

212 compression_type=compression_type, 

213 name=name) 

214 ) 

215 if _result is not _dispatch.OpDispatcher.NOT_SUPPORTED: 

216 return _result 

217 raise 

218 _result = _outputs[:] 

219 if _execute.must_record_gradient(): 

220 _attrs = ("compression_type", _op.get_attr("compression_type")) 

221 _inputs_flat = _op.inputs 

222 _execute.record_gradient( 

223 "DecodeCompressed", _inputs_flat, _attrs, _result) 

224 _result, = _result 

225 return _result 

226 

227DecodeCompressed = tf_export("raw_ops.DecodeCompressed")(_ops.to_raw_op(decode_compressed)) 

228_dispatcher_for_decode_compressed = decode_compressed._tf_type_based_dispatcher.Dispatch 

229 

230 

231def decode_compressed_eager_fallback(bytes, compression_type, name, ctx): 

232 if compression_type is None: 

233 compression_type = "" 

234 compression_type = _execute.make_str(compression_type, "compression_type") 

235 bytes = _ops.convert_to_tensor(bytes, _dtypes.string) 

236 _inputs_flat = [bytes] 

237 _attrs = ("compression_type", compression_type) 

238 _result = _execute.execute(b"DecodeCompressed", 1, inputs=_inputs_flat, 

239 attrs=_attrs, ctx=ctx, name=name) 

240 if _execute.must_record_gradient(): 

241 _execute.record_gradient( 

242 "DecodeCompressed", _inputs_flat, _attrs, _result) 

243 _result, = _result 

244 return _result 

245 

246 

247def decode_json_example(json_examples, name=None): 

248 r"""Convert JSON-encoded Example records to binary protocol buffer strings. 

249 

250  

251 Note: This is **not** a general purpose JSON parsing op. 

252 

253 This op converts JSON-serialized 

254 `tf.train.Example` (created with `json_format.MessageToJson`, following the 

255 [standard JSON mapping](https://developers.google.com/protocol-buffers/docs/proto3#json)) 

256 to a binary-serialized `tf.train.Example` (equivalent to 

257 `Example.SerializeToString()`) suitable for conversion to tensors with 

258 `tf.io.parse_example`. 

259 

260 Args: 

261 json_examples: A `Tensor` of type `string`. 

262 Each string is a JSON object serialized according to the JSON 

263 mapping of the Example proto. 

264 name: A name for the operation (optional). 

265 

266 Returns: 

267 A `Tensor` of type `string`. 

268 """ 

269 _ctx = _context._context or _context.context() 

270 tld = _ctx._thread_local_data 

271 if tld.is_eager: 

272 try: 

273 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

274 _ctx, "DecodeJSONExample", name, json_examples) 

275 return _result 

276 except _core._NotOkStatusException as e: 

277 _ops.raise_from_not_ok_status(e, name) 

278 except _core._FallbackException: 

279 pass 

280 try: 

281 return decode_json_example_eager_fallback( 

282 json_examples, name=name, ctx=_ctx) 

283 except _core._SymbolicException: 

284 pass # Add nodes to the TensorFlow graph. 

285 # Add nodes to the TensorFlow graph. 

286 _, _, _op, _outputs = _op_def_library._apply_op_helper( 

287 "DecodeJSONExample", json_examples=json_examples, name=name) 

288 _result = _outputs[:] 

289 if _execute.must_record_gradient(): 

290 _attrs = () 

291 _inputs_flat = _op.inputs 

292 _execute.record_gradient( 

293 "DecodeJSONExample", _inputs_flat, _attrs, _result) 

294 _result, = _result 

295 return _result 

296 

297DecodeJSONExample = tf_export("raw_ops.DecodeJSONExample")(_ops.to_raw_op(decode_json_example)) 

298 

299 

300def decode_json_example_eager_fallback(json_examples, name, ctx): 

301 json_examples = _ops.convert_to_tensor(json_examples, _dtypes.string) 

302 _inputs_flat = [json_examples] 

303 _attrs = None 

304 _result = _execute.execute(b"DecodeJSONExample", 1, inputs=_inputs_flat, 

305 attrs=_attrs, ctx=ctx, name=name) 

306 if _execute.must_record_gradient(): 

307 _execute.record_gradient( 

308 "DecodeJSONExample", _inputs_flat, _attrs, _result) 

309 _result, = _result 

310 return _result 

311 

312 

313def decode_padded_raw(input_bytes, fixed_length, out_type, little_endian=True, name=None): 

314 r"""Reinterpret the bytes of a string as a vector of numbers. 

315 

316 Args: 

317 input_bytes: A `Tensor` of type `string`. Tensor of string to be decoded. 

318 fixed_length: A `Tensor` of type `int32`. 

319 Length in bytes for each element of the decoded output. Must be a multiple 

320 of the size of the output type. 

321 out_type: A `tf.DType` from: `tf.half, tf.float32, tf.float64, tf.int32, tf.uint16, tf.uint8, tf.int16, tf.int8, tf.int64, tf.bfloat16`. 

322 little_endian: An optional `bool`. Defaults to `True`. 

323 Whether the input `input_bytes` is in little-endian order. Ignored for 

324 `out_type` values that are stored in a single byte, like `uint8` 

325 name: A name for the operation (optional). 

326 

327 Returns: 

328 A `Tensor` of type `out_type`. 

329 """ 

330 _ctx = _context._context or _context.context() 

331 tld = _ctx._thread_local_data 

332 if tld.is_eager: 

333 try: 

334 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

335 _ctx, "DecodePaddedRaw", name, input_bytes, fixed_length, "out_type", 

336 out_type, "little_endian", little_endian) 

337 return _result 

338 except _core._NotOkStatusException as e: 

339 _ops.raise_from_not_ok_status(e, name) 

340 except _core._FallbackException: 

341 pass 

342 try: 

343 return decode_padded_raw_eager_fallback( 

344 input_bytes, fixed_length, out_type=out_type, 

345 little_endian=little_endian, name=name, ctx=_ctx) 

346 except _core._SymbolicException: 

347 pass # Add nodes to the TensorFlow graph. 

348 # Add nodes to the TensorFlow graph. 

349 out_type = _execute.make_type(out_type, "out_type") 

350 if little_endian is None: 

351 little_endian = True 

352 little_endian = _execute.make_bool(little_endian, "little_endian") 

353 _, _, _op, _outputs = _op_def_library._apply_op_helper( 

354 "DecodePaddedRaw", input_bytes=input_bytes, fixed_length=fixed_length, 

355 out_type=out_type, little_endian=little_endian, 

356 name=name) 

357 _result = _outputs[:] 

358 if _execute.must_record_gradient(): 

359 _attrs = ("out_type", _op._get_attr_type("out_type"), "little_endian", 

360 _op._get_attr_bool("little_endian")) 

361 _inputs_flat = _op.inputs 

362 _execute.record_gradient( 

363 "DecodePaddedRaw", _inputs_flat, _attrs, _result) 

364 _result, = _result 

365 return _result 

366 

367DecodePaddedRaw = tf_export("raw_ops.DecodePaddedRaw")(_ops.to_raw_op(decode_padded_raw)) 

368 

369 

370def decode_padded_raw_eager_fallback(input_bytes, fixed_length, out_type, little_endian, name, ctx): 

371 out_type = _execute.make_type(out_type, "out_type") 

372 if little_endian is None: 

373 little_endian = True 

374 little_endian = _execute.make_bool(little_endian, "little_endian") 

375 input_bytes = _ops.convert_to_tensor(input_bytes, _dtypes.string) 

376 fixed_length = _ops.convert_to_tensor(fixed_length, _dtypes.int32) 

377 _inputs_flat = [input_bytes, fixed_length] 

378 _attrs = ("out_type", out_type, "little_endian", little_endian) 

379 _result = _execute.execute(b"DecodePaddedRaw", 1, inputs=_inputs_flat, 

380 attrs=_attrs, ctx=ctx, name=name) 

381 if _execute.must_record_gradient(): 

382 _execute.record_gradient( 

383 "DecodePaddedRaw", _inputs_flat, _attrs, _result) 

384 _result, = _result 

385 return _result 

386 

387 

388def decode_raw(bytes, out_type, little_endian=True, name=None): 

389 r"""Reinterpret the bytes of a string as a vector of numbers. 

390 

391 Args: 

392 bytes: A `Tensor` of type `string`. 

393 All the elements must have the same length. 

394 out_type: A `tf.DType` from: `tf.half, tf.float32, tf.float64, tf.int32, tf.uint16, tf.uint8, tf.int16, tf.int8, tf.int64, tf.complex64, tf.complex128, tf.bool, tf.bfloat16`. 

395 little_endian: An optional `bool`. Defaults to `True`. 

396 Whether the input `bytes` are in little-endian order. 

397 Ignored for `out_type` values that are stored in a single byte like 

398 `uint8`. 

399 name: A name for the operation (optional). 

400 

401 Returns: 

402 A `Tensor` of type `out_type`. 

403 """ 

404 _ctx = _context._context or _context.context() 

405 tld = _ctx._thread_local_data 

406 if tld.is_eager: 

407 try: 

408 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

409 _ctx, "DecodeRaw", name, bytes, "out_type", out_type, "little_endian", 

410 little_endian) 

411 return _result 

412 except _core._NotOkStatusException as e: 

413 _ops.raise_from_not_ok_status(e, name) 

414 except _core._FallbackException: 

415 pass 

416 try: 

417 return decode_raw_eager_fallback( 

418 bytes, out_type=out_type, little_endian=little_endian, name=name, 

419 ctx=_ctx) 

420 except _core._SymbolicException: 

421 pass # Add nodes to the TensorFlow graph. 

422 # Add nodes to the TensorFlow graph. 

423 out_type = _execute.make_type(out_type, "out_type") 

424 if little_endian is None: 

425 little_endian = True 

426 little_endian = _execute.make_bool(little_endian, "little_endian") 

427 _, _, _op, _outputs = _op_def_library._apply_op_helper( 

428 "DecodeRaw", bytes=bytes, out_type=out_type, 

429 little_endian=little_endian, name=name) 

430 _result = _outputs[:] 

431 if _execute.must_record_gradient(): 

432 _attrs = ("out_type", _op._get_attr_type("out_type"), "little_endian", 

433 _op._get_attr_bool("little_endian")) 

434 _inputs_flat = _op.inputs 

435 _execute.record_gradient( 

436 "DecodeRaw", _inputs_flat, _attrs, _result) 

437 _result, = _result 

438 return _result 

439 

440DecodeRaw = tf_export("raw_ops.DecodeRaw")(_ops.to_raw_op(decode_raw)) 

441 

442 

443def decode_raw_eager_fallback(bytes, out_type, little_endian, name, ctx): 

444 out_type = _execute.make_type(out_type, "out_type") 

445 if little_endian is None: 

446 little_endian = True 

447 little_endian = _execute.make_bool(little_endian, "little_endian") 

448 bytes = _ops.convert_to_tensor(bytes, _dtypes.string) 

449 _inputs_flat = [bytes] 

450 _attrs = ("out_type", out_type, "little_endian", little_endian) 

451 _result = _execute.execute(b"DecodeRaw", 1, inputs=_inputs_flat, 

452 attrs=_attrs, ctx=ctx, name=name) 

453 if _execute.must_record_gradient(): 

454 _execute.record_gradient( 

455 "DecodeRaw", _inputs_flat, _attrs, _result) 

456 _result, = _result 

457 return _result 

458 

459_ParseExampleOutput = collections.namedtuple( 

460 "ParseExample", 

461 ["sparse_indices", "sparse_values", "sparse_shapes", "dense_values"]) 

462 

463 

464def parse_example(serialized, names, sparse_keys, dense_keys, dense_defaults, sparse_types, dense_shapes, name=None): 

465 r"""Transforms a vector of brain.Example protos (as strings) into typed tensors. 

466 

467 Args: 

468 serialized: A `Tensor` of type `string`. 

469 A vector containing a batch of binary serialized Example protos. 

470 names: A `Tensor` of type `string`. 

471 A vector containing the names of the serialized protos. 

472 May contain, for example, table key (descriptive) names for the 

473 corresponding serialized protos. These are purely useful for debugging 

474 purposes, and the presence of values here has no effect on the output. 

475 May also be an empty vector if no names are available. 

476 If non-empty, this vector must be the same length as "serialized". 

477 sparse_keys: A list of `Tensor` objects with type `string`. 

478 A list of Nsparse string Tensors (scalars). 

479 The keys expected in the Examples' features associated with sparse values. 

480 dense_keys: A list of `Tensor` objects with type `string`. 

481 A list of Ndense string Tensors (scalars). 

482 The keys expected in the Examples' features associated with dense values. 

483 dense_defaults: A list of `Tensor` objects with types from: `float32`, `int64`, `string`. 

484 A list of Ndense Tensors (some may be empty). 

485 dense_defaults[j] provides default values 

486 when the example's feature_map lacks dense_key[j]. If an empty Tensor is 

487 provided for dense_defaults[j], then the Feature dense_keys[j] is required. 

488 The input type is inferred from dense_defaults[j], even when it's empty. 

489 If dense_defaults[j] is not empty, and dense_shapes[j] is fully defined, 

490 then the shape of dense_defaults[j] must match that of dense_shapes[j]. 

491 If dense_shapes[j] has an undefined major dimension (variable strides dense 

492 feature), dense_defaults[j] must contain a single element: 

493 the padding element. 

494 sparse_types: A list of `tf.DTypes` from: `tf.float32, tf.int64, tf.string`. 

495 A list of Nsparse types; the data types of data in each Feature 

496 given in sparse_keys. 

497 Currently the ParseExample supports DT_FLOAT (FloatList), 

498 DT_INT64 (Int64List), and DT_STRING (BytesList). 

499 dense_shapes: A list of shapes (each a `tf.TensorShape` or list of `ints`). 

500 A list of Ndense shapes; the shapes of data in each Feature 

501 given in dense_keys. 

502 The number of elements in the Feature corresponding to dense_key[j] 

503 must always equal dense_shapes[j].NumEntries(). 

504 If dense_shapes[j] == (D0, D1, ..., DN) then the shape of output 

505 Tensor dense_values[j] will be (|serialized|, D0, D1, ..., DN): 

506 The dense outputs are just the inputs row-stacked by batch. 

507 This works for dense_shapes[j] = (-1, D1, ..., DN). In this case 

508 the shape of the output Tensor dense_values[j] will be 

509 (|serialized|, M, D1, .., DN), where M is the maximum number of blocks 

510 of elements of length D1 * .... * DN, across all minibatch entries 

511 in the input. Any minibatch entry with less than M blocks of elements of 

512 length D1 * ... * DN will be padded with the corresponding default_value 

513 scalar element along the second dimension. 

514 name: A name for the operation (optional). 

515 

516 Returns: 

517 A tuple of `Tensor` objects (sparse_indices, sparse_values, sparse_shapes, dense_values). 

518 

519 sparse_indices: A list with the same length as `sparse_keys` of `Tensor` objects with type `int64`. 

520 sparse_values: A list of `Tensor` objects of type `sparse_types`. 

521 sparse_shapes: A list with the same length as `sparse_keys` of `Tensor` objects with type `int64`. 

522 dense_values: A list of `Tensor` objects. Has the same type as `dense_defaults`. 

523 """ 

524 _ctx = _context._context or _context.context() 

525 tld = _ctx._thread_local_data 

526 if tld.is_eager: 

527 try: 

528 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

529 _ctx, "ParseExample", name, serialized, names, sparse_keys, 

530 dense_keys, dense_defaults, "sparse_types", sparse_types, 

531 "dense_shapes", dense_shapes) 

532 _result = _ParseExampleOutput._make(_result) 

533 return _result 

534 except _core._NotOkStatusException as e: 

535 _ops.raise_from_not_ok_status(e, name) 

536 except _core._FallbackException: 

537 pass 

538 try: 

539 return parse_example_eager_fallback( 

540 serialized, names, sparse_keys, dense_keys, dense_defaults, 

541 sparse_types=sparse_types, dense_shapes=dense_shapes, name=name, 

542 ctx=_ctx) 

543 except _core._SymbolicException: 

544 pass # Add nodes to the TensorFlow graph. 

545 # Add nodes to the TensorFlow graph. 

546 if not isinstance(sparse_keys, (list, tuple)): 

547 raise TypeError( 

548 "Expected list for 'sparse_keys' argument to " 

549 "'parse_example' Op, not %r." % sparse_keys) 

550 _attr_Nsparse = len(sparse_keys) 

551 if not isinstance(dense_keys, (list, tuple)): 

552 raise TypeError( 

553 "Expected list for 'dense_keys' argument to " 

554 "'parse_example' Op, not %r." % dense_keys) 

555 _attr_Ndense = len(dense_keys) 

556 if not isinstance(sparse_types, (list, tuple)): 

557 raise TypeError( 

558 "Expected list for 'sparse_types' argument to " 

559 "'parse_example' Op, not %r." % sparse_types) 

560 sparse_types = [_execute.make_type(_t, "sparse_types") for _t in sparse_types] 

561 if not isinstance(dense_shapes, (list, tuple)): 

562 raise TypeError( 

563 "Expected list for 'dense_shapes' argument to " 

564 "'parse_example' Op, not %r." % dense_shapes) 

565 dense_shapes = [_execute.make_shape(_s, "dense_shapes") for _s in dense_shapes] 

566 _, _, _op, _outputs = _op_def_library._apply_op_helper( 

567 "ParseExample", serialized=serialized, names=names, 

568 sparse_keys=sparse_keys, dense_keys=dense_keys, 

569 dense_defaults=dense_defaults, 

570 sparse_types=sparse_types, dense_shapes=dense_shapes, 

571 name=name) 

572 _result = _outputs[:] 

573 if _execute.must_record_gradient(): 

574 _attrs = ("Nsparse", _op._get_attr_int("Nsparse"), "Ndense", 

575 _op._get_attr_int("Ndense"), "sparse_types", 

576 _op.get_attr("sparse_types"), "Tdense", _op.get_attr("Tdense"), 

577 "dense_shapes", _op.get_attr("dense_shapes")) 

578 _inputs_flat = _op.inputs 

579 _execute.record_gradient( 

580 "ParseExample", _inputs_flat, _attrs, _result) 

581 _result = [_result[:_attr_Nsparse]] + _result[_attr_Nsparse:] 

582 _result = _result[:1] + [_result[1:1 + len(sparse_types)]] + _result[1 + len(sparse_types):] 

583 _result = _result[:2] + [_result[2:2 + _attr_Nsparse]] + _result[2 + _attr_Nsparse:] 

584 _result = _result[:3] + [_result[3:]] 

585 _result = _ParseExampleOutput._make(_result) 

586 return _result 

587 

588ParseExample = tf_export("raw_ops.ParseExample")(_ops.to_raw_op(parse_example)) 

589 

590 

591def parse_example_eager_fallback(serialized, names, sparse_keys, dense_keys, dense_defaults, sparse_types, dense_shapes, name, ctx): 

592 if not isinstance(sparse_keys, (list, tuple)): 

593 raise TypeError( 

594 "Expected list for 'sparse_keys' argument to " 

595 "'parse_example' Op, not %r." % sparse_keys) 

596 _attr_Nsparse = len(sparse_keys) 

597 if not isinstance(dense_keys, (list, tuple)): 

598 raise TypeError( 

599 "Expected list for 'dense_keys' argument to " 

600 "'parse_example' Op, not %r." % dense_keys) 

601 _attr_Ndense = len(dense_keys) 

602 if not isinstance(sparse_types, (list, tuple)): 

603 raise TypeError( 

604 "Expected list for 'sparse_types' argument to " 

605 "'parse_example' Op, not %r." % sparse_types) 

606 sparse_types = [_execute.make_type(_t, "sparse_types") for _t in sparse_types] 

607 if not isinstance(dense_shapes, (list, tuple)): 

608 raise TypeError( 

609 "Expected list for 'dense_shapes' argument to " 

610 "'parse_example' Op, not %r." % dense_shapes) 

611 dense_shapes = [_execute.make_shape(_s, "dense_shapes") for _s in dense_shapes] 

612 _attr_Tdense, dense_defaults = _execute.convert_to_mixed_eager_tensors(dense_defaults, ctx) 

613 serialized = _ops.convert_to_tensor(serialized, _dtypes.string) 

614 names = _ops.convert_to_tensor(names, _dtypes.string) 

615 sparse_keys = _ops.convert_n_to_tensor(sparse_keys, _dtypes.string) 

616 dense_keys = _ops.convert_n_to_tensor(dense_keys, _dtypes.string) 

617 _inputs_flat = [serialized, names] + list(sparse_keys) + list(dense_keys) + list(dense_defaults) 

618 _attrs = ("Nsparse", _attr_Nsparse, "Ndense", _attr_Ndense, "sparse_types", 

619 sparse_types, "Tdense", _attr_Tdense, "dense_shapes", dense_shapes) 

620 _result = _execute.execute(b"ParseExample", _attr_Nsparse + 

621 len(sparse_types) + _attr_Nsparse + 

622 len(dense_defaults), inputs=_inputs_flat, 

623 attrs=_attrs, ctx=ctx, name=name) 

624 if _execute.must_record_gradient(): 

625 _execute.record_gradient( 

626 "ParseExample", _inputs_flat, _attrs, _result) 

627 _result = [_result[:_attr_Nsparse]] + _result[_attr_Nsparse:] 

628 _result = _result[:1] + [_result[1:1 + len(sparse_types)]] + _result[1 + len(sparse_types):] 

629 _result = _result[:2] + [_result[2:2 + _attr_Nsparse]] + _result[2 + _attr_Nsparse:] 

630 _result = _result[:3] + [_result[3:]] 

631 _result = _ParseExampleOutput._make(_result) 

632 return _result 

633 

634_ParseExampleV2Output = collections.namedtuple( 

635 "ParseExampleV2", 

636 ["sparse_indices", "sparse_values", "sparse_shapes", "dense_values", "ragged_values", "ragged_row_splits"]) 

637 

638 

639def parse_example_v2(serialized, names, sparse_keys, dense_keys, ragged_keys, dense_defaults, num_sparse, sparse_types, ragged_value_types, ragged_split_types, dense_shapes, name=None): 

640 r"""Transforms a vector of tf.Example protos (as strings) into typed tensors. 

641 

642 Args: 

643 serialized: A `Tensor` of type `string`. 

644 A scalar or vector containing binary serialized Example protos. 

645 names: A `Tensor` of type `string`. 

646 A tensor containing the names of the serialized protos. 

647 Corresponds 1:1 with the `serialized` tensor. 

648 May contain, for example, table key (descriptive) names for the 

649 corresponding serialized protos. These are purely useful for debugging 

650 purposes, and the presence of values here has no effect on the output. 

651 May also be an empty vector if no names are available. 

652 If non-empty, this tensor must have the same shape as "serialized". 

653 sparse_keys: A `Tensor` of type `string`. Vector of strings. 

654 The keys expected in the Examples' features associated with sparse values. 

655 dense_keys: A `Tensor` of type `string`. Vector of strings. 

656 The keys expected in the Examples' features associated with dense values. 

657 ragged_keys: A `Tensor` of type `string`. Vector of strings. 

658 The keys expected in the Examples' features associated with ragged values. 

659 dense_defaults: A list of `Tensor` objects with types from: `float32`, `int64`, `string`. 

660 A list of Tensors (some may be empty). Corresponds 1:1 with `dense_keys`. 

661 dense_defaults[j] provides default values 

662 when the example's feature_map lacks dense_key[j]. If an empty Tensor is 

663 provided for dense_defaults[j], then the Feature dense_keys[j] is required. 

664 The input type is inferred from dense_defaults[j], even when it's empty. 

665 If dense_defaults[j] is not empty, and dense_shapes[j] is fully defined, 

666 then the shape of dense_defaults[j] must match that of dense_shapes[j]. 

667 If dense_shapes[j] has an undefined major dimension (variable strides dense 

668 feature), dense_defaults[j] must contain a single element: 

669 the padding element. 

670 num_sparse: An `int` that is `>= 0`. The number of sparse keys. 

671 sparse_types: A list of `tf.DTypes` from: `tf.float32, tf.int64, tf.string`. 

672 A list of `num_sparse` types; the data types of data in each Feature 

673 given in sparse_keys. 

674 Currently the ParseExample supports DT_FLOAT (FloatList), 

675 DT_INT64 (Int64List), and DT_STRING (BytesList). 

676 ragged_value_types: A list of `tf.DTypes` from: `tf.float32, tf.int64, tf.string`. 

677 A list of `num_ragged` types; the data types of data in each Feature 

678 given in ragged_keys (where `num_ragged = sparse_keys.size()`). 

679 Currently the ParseExample supports DT_FLOAT (FloatList), 

680 DT_INT64 (Int64List), and DT_STRING (BytesList). 

681 ragged_split_types: A list of `tf.DTypes` from: `tf.int32, tf.int64`. 

682 A list of `num_ragged` types; the data types of row_splits in each Feature 

683 given in ragged_keys (where `num_ragged = sparse_keys.size()`). 

684 May be DT_INT32 or DT_INT64. 

685 dense_shapes: A list of shapes (each a `tf.TensorShape` or list of `ints`). 

686 A list of `num_dense` shapes; the shapes of data in each Feature 

687 given in dense_keys (where `num_dense = dense_keys.size()`). 

688 The number of elements in the Feature corresponding to dense_key[j] 

689 must always equal dense_shapes[j].NumEntries(). 

690 If dense_shapes[j] == (D0, D1, ..., DN) then the shape of output 

691 Tensor dense_values[j] will be (|serialized|, D0, D1, ..., DN): 

692 The dense outputs are just the inputs row-stacked by batch. 

693 This works for dense_shapes[j] = (-1, D1, ..., DN). In this case 

694 the shape of the output Tensor dense_values[j] will be 

695 (|serialized|, M, D1, .., DN), where M is the maximum number of blocks 

696 of elements of length D1 * .... * DN, across all minibatch entries 

697 in the input. Any minibatch entry with less than M blocks of elements of 

698 length D1 * ... * DN will be padded with the corresponding default_value 

699 scalar element along the second dimension. 

700 name: A name for the operation (optional). 

701 

702 Returns: 

703 A tuple of `Tensor` objects (sparse_indices, sparse_values, sparse_shapes, dense_values, ragged_values, ragged_row_splits). 

704 

705 sparse_indices: A list of `num_sparse` `Tensor` objects with type `int64`. 

706 sparse_values: A list of `Tensor` objects of type `sparse_types`. 

707 sparse_shapes: A list of `num_sparse` `Tensor` objects with type `int64`. 

708 dense_values: A list of `Tensor` objects. Has the same type as `dense_defaults`. 

709 ragged_values: A list of `Tensor` objects of type `ragged_value_types`. 

710 ragged_row_splits: A list of `Tensor` objects of type `ragged_split_types`. 

711 """ 

712 _ctx = _context._context or _context.context() 

713 tld = _ctx._thread_local_data 

714 if tld.is_eager: 

715 try: 

716 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

717 _ctx, "ParseExampleV2", name, serialized, names, sparse_keys, 

718 dense_keys, ragged_keys, dense_defaults, "num_sparse", num_sparse, 

719 "sparse_types", sparse_types, "ragged_value_types", 

720 ragged_value_types, "ragged_split_types", ragged_split_types, 

721 "dense_shapes", dense_shapes) 

722 _result = _ParseExampleV2Output._make(_result) 

723 return _result 

724 except _core._NotOkStatusException as e: 

725 _ops.raise_from_not_ok_status(e, name) 

726 except _core._FallbackException: 

727 pass 

728 try: 

729 return parse_example_v2_eager_fallback( 

730 serialized, names, sparse_keys, dense_keys, ragged_keys, 

731 dense_defaults, num_sparse=num_sparse, sparse_types=sparse_types, 

732 ragged_value_types=ragged_value_types, 

733 ragged_split_types=ragged_split_types, dense_shapes=dense_shapes, 

734 name=name, ctx=_ctx) 

735 except _core._SymbolicException: 

736 pass # Add nodes to the TensorFlow graph. 

737 # Add nodes to the TensorFlow graph. 

738 num_sparse = _execute.make_int(num_sparse, "num_sparse") 

739 if not isinstance(sparse_types, (list, tuple)): 

740 raise TypeError( 

741 "Expected list for 'sparse_types' argument to " 

742 "'parse_example_v2' Op, not %r." % sparse_types) 

743 sparse_types = [_execute.make_type(_t, "sparse_types") for _t in sparse_types] 

744 if not isinstance(ragged_value_types, (list, tuple)): 

745 raise TypeError( 

746 "Expected list for 'ragged_value_types' argument to " 

747 "'parse_example_v2' Op, not %r." % ragged_value_types) 

748 ragged_value_types = [_execute.make_type(_t, "ragged_value_types") for _t in ragged_value_types] 

749 if not isinstance(ragged_split_types, (list, tuple)): 

750 raise TypeError( 

751 "Expected list for 'ragged_split_types' argument to " 

752 "'parse_example_v2' Op, not %r." % ragged_split_types) 

753 ragged_split_types = [_execute.make_type(_t, "ragged_split_types") for _t in ragged_split_types] 

754 if not isinstance(dense_shapes, (list, tuple)): 

755 raise TypeError( 

756 "Expected list for 'dense_shapes' argument to " 

757 "'parse_example_v2' Op, not %r." % dense_shapes) 

758 dense_shapes = [_execute.make_shape(_s, "dense_shapes") for _s in dense_shapes] 

759 _, _, _op, _outputs = _op_def_library._apply_op_helper( 

760 "ParseExampleV2", serialized=serialized, names=names, 

761 sparse_keys=sparse_keys, dense_keys=dense_keys, 

762 ragged_keys=ragged_keys, 

763 dense_defaults=dense_defaults, 

764 num_sparse=num_sparse, sparse_types=sparse_types, 

765 ragged_value_types=ragged_value_types, 

766 ragged_split_types=ragged_split_types, 

767 dense_shapes=dense_shapes, name=name) 

768 _result = _outputs[:] 

769 if _execute.must_record_gradient(): 

770 _attrs = ("Tdense", _op.get_attr("Tdense"), "num_sparse", 

771 _op._get_attr_int("num_sparse"), "sparse_types", 

772 _op.get_attr("sparse_types"), "ragged_value_types", 

773 _op.get_attr("ragged_value_types"), "ragged_split_types", 

774 _op.get_attr("ragged_split_types"), "dense_shapes", 

775 _op.get_attr("dense_shapes")) 

776 _inputs_flat = _op.inputs 

777 _execute.record_gradient( 

778 "ParseExampleV2", _inputs_flat, _attrs, _result) 

779 _result = [_result[:num_sparse]] + _result[num_sparse:] 

780 _result = _result[:1] + [_result[1:1 + len(sparse_types)]] + _result[1 + len(sparse_types):] 

781 _result = _result[:2] + [_result[2:2 + num_sparse]] + _result[2 + num_sparse:] 

782 _result = _result[:3] + [_result[3:3 + len(dense_defaults)]] + _result[3 + len(dense_defaults):] 

783 _result = _result[:4] + [_result[4:4 + len(ragged_value_types)]] + _result[4 + len(ragged_value_types):] 

784 _result = _result[:5] + [_result[5:]] 

785 _result = _ParseExampleV2Output._make(_result) 

786 return _result 

787 

788ParseExampleV2 = tf_export("raw_ops.ParseExampleV2")(_ops.to_raw_op(parse_example_v2)) 

789 

790 

791def parse_example_v2_eager_fallback(serialized, names, sparse_keys, dense_keys, ragged_keys, dense_defaults, num_sparse, sparse_types, ragged_value_types, ragged_split_types, dense_shapes, name, ctx): 

792 num_sparse = _execute.make_int(num_sparse, "num_sparse") 

793 if not isinstance(sparse_types, (list, tuple)): 

794 raise TypeError( 

795 "Expected list for 'sparse_types' argument to " 

796 "'parse_example_v2' Op, not %r." % sparse_types) 

797 sparse_types = [_execute.make_type(_t, "sparse_types") for _t in sparse_types] 

798 if not isinstance(ragged_value_types, (list, tuple)): 

799 raise TypeError( 

800 "Expected list for 'ragged_value_types' argument to " 

801 "'parse_example_v2' Op, not %r." % ragged_value_types) 

802 ragged_value_types = [_execute.make_type(_t, "ragged_value_types") for _t in ragged_value_types] 

803 if not isinstance(ragged_split_types, (list, tuple)): 

804 raise TypeError( 

805 "Expected list for 'ragged_split_types' argument to " 

806 "'parse_example_v2' Op, not %r." % ragged_split_types) 

807 ragged_split_types = [_execute.make_type(_t, "ragged_split_types") for _t in ragged_split_types] 

808 if not isinstance(dense_shapes, (list, tuple)): 

809 raise TypeError( 

810 "Expected list for 'dense_shapes' argument to " 

811 "'parse_example_v2' Op, not %r." % dense_shapes) 

812 dense_shapes = [_execute.make_shape(_s, "dense_shapes") for _s in dense_shapes] 

813 _attr_Tdense, dense_defaults = _execute.convert_to_mixed_eager_tensors(dense_defaults, ctx) 

814 serialized = _ops.convert_to_tensor(serialized, _dtypes.string) 

815 names = _ops.convert_to_tensor(names, _dtypes.string) 

816 sparse_keys = _ops.convert_to_tensor(sparse_keys, _dtypes.string) 

817 dense_keys = _ops.convert_to_tensor(dense_keys, _dtypes.string) 

818 ragged_keys = _ops.convert_to_tensor(ragged_keys, _dtypes.string) 

819 _inputs_flat = [serialized, names, sparse_keys, dense_keys, ragged_keys] + list(dense_defaults) 

820 _attrs = ("Tdense", _attr_Tdense, "num_sparse", num_sparse, "sparse_types", 

821 sparse_types, "ragged_value_types", ragged_value_types, 

822 "ragged_split_types", ragged_split_types, "dense_shapes", dense_shapes) 

823 _result = _execute.execute(b"ParseExampleV2", num_sparse + len(sparse_types) 

824 + num_sparse + len(dense_defaults) + 

825 len(ragged_value_types) + 

826 len(ragged_split_types), inputs=_inputs_flat, 

827 attrs=_attrs, ctx=ctx, name=name) 

828 if _execute.must_record_gradient(): 

829 _execute.record_gradient( 

830 "ParseExampleV2", _inputs_flat, _attrs, _result) 

831 _result = [_result[:num_sparse]] + _result[num_sparse:] 

832 _result = _result[:1] + [_result[1:1 + len(sparse_types)]] + _result[1 + len(sparse_types):] 

833 _result = _result[:2] + [_result[2:2 + num_sparse]] + _result[2 + num_sparse:] 

834 _result = _result[:3] + [_result[3:3 + len(dense_defaults)]] + _result[3 + len(dense_defaults):] 

835 _result = _result[:4] + [_result[4:4 + len(ragged_value_types)]] + _result[4 + len(ragged_value_types):] 

836 _result = _result[:5] + [_result[5:]] 

837 _result = _ParseExampleV2Output._make(_result) 

838 return _result 

839 

840_ParseSequenceExampleOutput = collections.namedtuple( 

841 "ParseSequenceExample", 

842 ["context_sparse_indices", "context_sparse_values", "context_sparse_shapes", "context_dense_values", "feature_list_sparse_indices", "feature_list_sparse_values", "feature_list_sparse_shapes", "feature_list_dense_values", "feature_list_dense_lengths"]) 

843 

844 

845def parse_sequence_example(serialized, debug_name, context_dense_defaults, feature_list_dense_missing_assumed_empty, context_sparse_keys, context_dense_keys, feature_list_sparse_keys, feature_list_dense_keys, Ncontext_sparse=0, Ncontext_dense=0, Nfeature_list_sparse=0, Nfeature_list_dense=0, context_sparse_types=[], feature_list_dense_types=[], context_dense_shapes=[], feature_list_sparse_types=[], feature_list_dense_shapes=[], name=None): 

846 r"""Transforms a vector of brain.SequenceExample protos (as strings) into typed tensors. 

847 

848 Args: 

849 serialized: A `Tensor` of type `string`. 

850 A vector containing binary serialized SequenceExample protos. 

851 debug_name: A `Tensor` of type `string`. 

852 A vector containing the names of the serialized protos. 

853 May contain, for example, table key (descriptive) name for the 

854 corresponding serialized proto. This is purely useful for debugging 

855 purposes, and the presence of values here has no effect on the output. 

856 May also be an empty vector if no name is available. 

857 context_dense_defaults: A list of `Tensor` objects with types from: `float32`, `int64`, `string`. 

858 A list of Ncontext_dense Tensors (some may be empty). 

859 context_dense_defaults[j] provides default values 

860 when the SequenceExample's context map lacks context_dense_key[j]. 

861 If an empty Tensor is provided for context_dense_defaults[j], 

862 then the Feature context_dense_keys[j] is required. 

863 The input type is inferred from context_dense_defaults[j], even when it's 

864 empty. If context_dense_defaults[j] is not empty, its shape must match 

865 context_dense_shapes[j]. 

866 feature_list_dense_missing_assumed_empty: A list of `strings`. 

867 A vector listing the 

868 FeatureList keys which may be missing from the SequenceExamples. If the 

869 associated FeatureList is missing, it is treated as empty. By default, 

870 any FeatureList not listed in this vector must exist in the SequenceExamples. 

871 context_sparse_keys: A list of `strings`. 

872 A list of Ncontext_sparse string Tensors (scalars). 

873 The keys expected in the Examples' features associated with context_sparse 

874 values. 

875 context_dense_keys: A list of `strings`. 

876 A list of Ncontext_dense string Tensors (scalars). 

877 The keys expected in the SequenceExamples' context features associated with 

878 dense values. 

879 feature_list_sparse_keys: A list of `strings`. 

880 A list of Nfeature_list_sparse string Tensors 

881 (scalars). The keys expected in the FeatureLists associated with sparse 

882 values. 

883 feature_list_dense_keys: A list of `strings`. 

884 A list of Nfeature_list_dense string Tensors (scalars). 

885 The keys expected in the SequenceExamples' feature_lists associated 

886 with lists of dense values. 

887 Ncontext_sparse: An optional `int` that is `>= 0`. Defaults to `0`. 

888 Ncontext_dense: An optional `int` that is `>= 0`. Defaults to `0`. 

889 Nfeature_list_sparse: An optional `int` that is `>= 0`. Defaults to `0`. 

890 Nfeature_list_dense: An optional `int` that is `>= 0`. Defaults to `0`. 

891 context_sparse_types: An optional list of `tf.DTypes` from: `tf.float32, tf.int64, tf.string`. Defaults to `[]`. 

892 A list of Ncontext_sparse types; the data types of data in 

893 each context Feature given in context_sparse_keys. 

894 Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList), 

895 DT_INT64 (Int64List), and DT_STRING (BytesList). 

896 feature_list_dense_types: An optional list of `tf.DTypes` from: `tf.float32, tf.int64, tf.string`. Defaults to `[]`. 

897 context_dense_shapes: An optional list of shapes (each a `tf.TensorShape` or list of `ints`). Defaults to `[]`. 

898 A list of Ncontext_dense shapes; the shapes of data in 

899 each context Feature given in context_dense_keys. 

900 The number of elements in the Feature corresponding to context_dense_key[j] 

901 must always equal context_dense_shapes[j].NumEntries(). 

902 The shape of context_dense_values[j] will match context_dense_shapes[j]. 

903 feature_list_sparse_types: An optional list of `tf.DTypes` from: `tf.float32, tf.int64, tf.string`. Defaults to `[]`. 

904 A list of Nfeature_list_sparse types; the data types 

905 of data in each FeatureList given in feature_list_sparse_keys. 

906 Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList), 

907 DT_INT64 (Int64List), and DT_STRING (BytesList). 

908 feature_list_dense_shapes: An optional list of shapes (each a `tf.TensorShape` or list of `ints`). Defaults to `[]`. 

909 A list of Nfeature_list_dense shapes; the shapes of 

910 data in each FeatureList given in feature_list_dense_keys. 

911 The shape of each Feature in the FeatureList corresponding to 

912 feature_list_dense_key[j] must always equal 

913 feature_list_dense_shapes[j].NumEntries(). 

914 name: A name for the operation (optional). 

915 

916 Returns: 

917 A tuple of `Tensor` objects (context_sparse_indices, context_sparse_values, context_sparse_shapes, context_dense_values, feature_list_sparse_indices, feature_list_sparse_values, feature_list_sparse_shapes, feature_list_dense_values, feature_list_dense_lengths). 

918 

919 context_sparse_indices: A list of `Ncontext_sparse` `Tensor` objects with type `int64`. 

920 context_sparse_values: A list of `Tensor` objects of type `context_sparse_types`. 

921 context_sparse_shapes: A list of `Ncontext_sparse` `Tensor` objects with type `int64`. 

922 context_dense_values: A list of `Tensor` objects. Has the same type as `context_dense_defaults`. 

923 feature_list_sparse_indices: A list of `Nfeature_list_sparse` `Tensor` objects with type `int64`. 

924 feature_list_sparse_values: A list of `Tensor` objects of type `feature_list_sparse_types`. 

925 feature_list_sparse_shapes: A list of `Nfeature_list_sparse` `Tensor` objects with type `int64`. 

926 feature_list_dense_values: A list of `Tensor` objects of type `feature_list_dense_types`. 

927 feature_list_dense_lengths: A list of `Nfeature_list_dense` `Tensor` objects with type `int64`. 

928 """ 

929 _ctx = _context._context or _context.context() 

930 tld = _ctx._thread_local_data 

931 if tld.is_eager: 

932 try: 

933 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

934 _ctx, "ParseSequenceExample", name, serialized, debug_name, 

935 context_dense_defaults, "feature_list_dense_missing_assumed_empty", 

936 feature_list_dense_missing_assumed_empty, "context_sparse_keys", 

937 context_sparse_keys, "context_dense_keys", context_dense_keys, 

938 "feature_list_sparse_keys", feature_list_sparse_keys, 

939 "feature_list_dense_keys", feature_list_dense_keys, "Ncontext_sparse", 

940 Ncontext_sparse, "Ncontext_dense", Ncontext_dense, 

941 "Nfeature_list_sparse", Nfeature_list_sparse, "Nfeature_list_dense", 

942 Nfeature_list_dense, "context_sparse_types", context_sparse_types, 

943 "feature_list_dense_types", feature_list_dense_types, 

944 "context_dense_shapes", context_dense_shapes, 

945 "feature_list_sparse_types", feature_list_sparse_types, 

946 "feature_list_dense_shapes", feature_list_dense_shapes) 

947 _result = _ParseSequenceExampleOutput._make(_result) 

948 return _result 

949 except _core._NotOkStatusException as e: 

950 _ops.raise_from_not_ok_status(e, name) 

951 except _core._FallbackException: 

952 pass 

953 try: 

954 return parse_sequence_example_eager_fallback( 

955 serialized, debug_name, context_dense_defaults, 

956 feature_list_dense_missing_assumed_empty=feature_list_dense_missing_assumed_empty, 

957 context_sparse_keys=context_sparse_keys, 

958 context_dense_keys=context_dense_keys, 

959 feature_list_sparse_keys=feature_list_sparse_keys, 

960 feature_list_dense_keys=feature_list_dense_keys, 

961 Ncontext_sparse=Ncontext_sparse, Ncontext_dense=Ncontext_dense, 

962 Nfeature_list_sparse=Nfeature_list_sparse, 

963 Nfeature_list_dense=Nfeature_list_dense, 

964 context_sparse_types=context_sparse_types, 

965 feature_list_dense_types=feature_list_dense_types, 

966 context_dense_shapes=context_dense_shapes, 

967 feature_list_sparse_types=feature_list_sparse_types, 

968 feature_list_dense_shapes=feature_list_dense_shapes, name=name, 

969 ctx=_ctx) 

970 except _core._SymbolicException: 

971 pass # Add nodes to the TensorFlow graph. 

972 # Add nodes to the TensorFlow graph. 

973 if not isinstance(feature_list_dense_missing_assumed_empty, (list, tuple)): 

974 raise TypeError( 

975 "Expected list for 'feature_list_dense_missing_assumed_empty' argument to " 

976 "'parse_sequence_example' Op, not %r." % feature_list_dense_missing_assumed_empty) 

977 feature_list_dense_missing_assumed_empty = [_execute.make_str(_s, "feature_list_dense_missing_assumed_empty") for _s in feature_list_dense_missing_assumed_empty] 

978 if not isinstance(context_sparse_keys, (list, tuple)): 

979 raise TypeError( 

980 "Expected list for 'context_sparse_keys' argument to " 

981 "'parse_sequence_example' Op, not %r." % context_sparse_keys) 

982 context_sparse_keys = [_execute.make_str(_s, "context_sparse_keys") for _s in context_sparse_keys] 

983 if not isinstance(context_dense_keys, (list, tuple)): 

984 raise TypeError( 

985 "Expected list for 'context_dense_keys' argument to " 

986 "'parse_sequence_example' Op, not %r." % context_dense_keys) 

987 context_dense_keys = [_execute.make_str(_s, "context_dense_keys") for _s in context_dense_keys] 

988 if not isinstance(feature_list_sparse_keys, (list, tuple)): 

989 raise TypeError( 

990 "Expected list for 'feature_list_sparse_keys' argument to " 

991 "'parse_sequence_example' Op, not %r." % feature_list_sparse_keys) 

992 feature_list_sparse_keys = [_execute.make_str(_s, "feature_list_sparse_keys") for _s in feature_list_sparse_keys] 

993 if not isinstance(feature_list_dense_keys, (list, tuple)): 

994 raise TypeError( 

995 "Expected list for 'feature_list_dense_keys' argument to " 

996 "'parse_sequence_example' Op, not %r." % feature_list_dense_keys) 

997 feature_list_dense_keys = [_execute.make_str(_s, "feature_list_dense_keys") for _s in feature_list_dense_keys] 

998 if Ncontext_sparse is None: 

999 Ncontext_sparse = 0 

1000 Ncontext_sparse = _execute.make_int(Ncontext_sparse, "Ncontext_sparse") 

1001 if Ncontext_dense is None: 

1002 Ncontext_dense = 0 

1003 Ncontext_dense = _execute.make_int(Ncontext_dense, "Ncontext_dense") 

1004 if Nfeature_list_sparse is None: 

1005 Nfeature_list_sparse = 0 

1006 Nfeature_list_sparse = _execute.make_int(Nfeature_list_sparse, "Nfeature_list_sparse") 

1007 if Nfeature_list_dense is None: 

1008 Nfeature_list_dense = 0 

1009 Nfeature_list_dense = _execute.make_int(Nfeature_list_dense, "Nfeature_list_dense") 

1010 if context_sparse_types is None: 

1011 context_sparse_types = [] 

1012 if not isinstance(context_sparse_types, (list, tuple)): 

1013 raise TypeError( 

1014 "Expected list for 'context_sparse_types' argument to " 

1015 "'parse_sequence_example' Op, not %r." % context_sparse_types) 

1016 context_sparse_types = [_execute.make_type(_t, "context_sparse_types") for _t in context_sparse_types] 

1017 if feature_list_dense_types is None: 

1018 feature_list_dense_types = [] 

1019 if not isinstance(feature_list_dense_types, (list, tuple)): 

1020 raise TypeError( 

1021 "Expected list for 'feature_list_dense_types' argument to " 

1022 "'parse_sequence_example' Op, not %r." % feature_list_dense_types) 

1023 feature_list_dense_types = [_execute.make_type(_t, "feature_list_dense_types") for _t in feature_list_dense_types] 

1024 if context_dense_shapes is None: 

1025 context_dense_shapes = [] 

1026 if not isinstance(context_dense_shapes, (list, tuple)): 

1027 raise TypeError( 

1028 "Expected list for 'context_dense_shapes' argument to " 

1029 "'parse_sequence_example' Op, not %r." % context_dense_shapes) 

1030 context_dense_shapes = [_execute.make_shape(_s, "context_dense_shapes") for _s in context_dense_shapes] 

1031 if feature_list_sparse_types is None: 

1032 feature_list_sparse_types = [] 

1033 if not isinstance(feature_list_sparse_types, (list, tuple)): 

1034 raise TypeError( 

1035 "Expected list for 'feature_list_sparse_types' argument to " 

1036 "'parse_sequence_example' Op, not %r." % feature_list_sparse_types) 

1037 feature_list_sparse_types = [_execute.make_type(_t, "feature_list_sparse_types") for _t in feature_list_sparse_types] 

1038 if feature_list_dense_shapes is None: 

1039 feature_list_dense_shapes = [] 

1040 if not isinstance(feature_list_dense_shapes, (list, tuple)): 

1041 raise TypeError( 

1042 "Expected list for 'feature_list_dense_shapes' argument to " 

1043 "'parse_sequence_example' Op, not %r." % feature_list_dense_shapes) 

1044 feature_list_dense_shapes = [_execute.make_shape(_s, "feature_list_dense_shapes") for _s in feature_list_dense_shapes] 

1045 _, _, _op, _outputs = _op_def_library._apply_op_helper( 

1046 "ParseSequenceExample", serialized=serialized, debug_name=debug_name, 

1047 context_dense_defaults=context_dense_defaults, 

1048 feature_list_dense_missing_assumed_empty=feature_list_dense_missing_assumed_empty, 

1049 context_sparse_keys=context_sparse_keys, 

1050 context_dense_keys=context_dense_keys, 

1051 feature_list_sparse_keys=feature_list_sparse_keys, 

1052 feature_list_dense_keys=feature_list_dense_keys, 

1053 Ncontext_sparse=Ncontext_sparse, 

1054 Ncontext_dense=Ncontext_dense, 

1055 Nfeature_list_sparse=Nfeature_list_sparse, 

1056 Nfeature_list_dense=Nfeature_list_dense, 

1057 context_sparse_types=context_sparse_types, 

1058 feature_list_dense_types=feature_list_dense_types, 

1059 context_dense_shapes=context_dense_shapes, 

1060 feature_list_sparse_types=feature_list_sparse_types, 

1061 feature_list_dense_shapes=feature_list_dense_shapes, 

1062 name=name) 

1063 _result = _outputs[:] 

1064 if _execute.must_record_gradient(): 

1065 _attrs = ("feature_list_dense_missing_assumed_empty", 

1066 _op.get_attr("feature_list_dense_missing_assumed_empty"), 

1067 "context_sparse_keys", _op.get_attr("context_sparse_keys"), 

1068 "context_dense_keys", _op.get_attr("context_dense_keys"), 

1069 "feature_list_sparse_keys", 

1070 _op.get_attr("feature_list_sparse_keys"), 

1071 "feature_list_dense_keys", 

1072 _op.get_attr("feature_list_dense_keys"), "Ncontext_sparse", 

1073 _op._get_attr_int("Ncontext_sparse"), "Ncontext_dense", 

1074 _op._get_attr_int("Ncontext_dense"), "Nfeature_list_sparse", 

1075 _op._get_attr_int("Nfeature_list_sparse"), 

1076 "Nfeature_list_dense", _op._get_attr_int("Nfeature_list_dense"), 

1077 "context_sparse_types", _op.get_attr("context_sparse_types"), 

1078 "Tcontext_dense", _op.get_attr("Tcontext_dense"), 

1079 "feature_list_dense_types", 

1080 _op.get_attr("feature_list_dense_types"), 

1081 "context_dense_shapes", _op.get_attr("context_dense_shapes"), 

1082 "feature_list_sparse_types", 

1083 _op.get_attr("feature_list_sparse_types"), 

1084 "feature_list_dense_shapes", 

1085 _op.get_attr("feature_list_dense_shapes")) 

1086 _inputs_flat = _op.inputs 

1087 _execute.record_gradient( 

1088 "ParseSequenceExample", _inputs_flat, _attrs, _result) 

1089 _result = [_result[:Ncontext_sparse]] + _result[Ncontext_sparse:] 

1090 _result = _result[:1] + [_result[1:1 + len(context_sparse_types)]] + _result[1 + len(context_sparse_types):] 

1091 _result = _result[:2] + [_result[2:2 + Ncontext_sparse]] + _result[2 + Ncontext_sparse:] 

1092 _result = _result[:3] + [_result[3:3 + len(context_dense_defaults)]] + _result[3 + len(context_dense_defaults):] 

1093 _result = _result[:4] + [_result[4:4 + Nfeature_list_sparse]] + _result[4 + Nfeature_list_sparse:] 

1094 _result = _result[:5] + [_result[5:5 + len(feature_list_sparse_types)]] + _result[5 + len(feature_list_sparse_types):] 

1095 _result = _result[:6] + [_result[6:6 + Nfeature_list_sparse]] + _result[6 + Nfeature_list_sparse:] 

1096 _result = _result[:7] + [_result[7:7 + len(feature_list_dense_types)]] + _result[7 + len(feature_list_dense_types):] 

1097 _result = _result[:8] + [_result[8:]] 

1098 _result = _ParseSequenceExampleOutput._make(_result) 

1099 return _result 

1100 

1101ParseSequenceExample = tf_export("raw_ops.ParseSequenceExample")(_ops.to_raw_op(parse_sequence_example)) 

1102 

1103 

1104def parse_sequence_example_eager_fallback(serialized, debug_name, context_dense_defaults, feature_list_dense_missing_assumed_empty, context_sparse_keys, context_dense_keys, feature_list_sparse_keys, feature_list_dense_keys, Ncontext_sparse, Ncontext_dense, Nfeature_list_sparse, Nfeature_list_dense, context_sparse_types, feature_list_dense_types, context_dense_shapes, feature_list_sparse_types, feature_list_dense_shapes, name, ctx): 

1105 if not isinstance(feature_list_dense_missing_assumed_empty, (list, tuple)): 

1106 raise TypeError( 

1107 "Expected list for 'feature_list_dense_missing_assumed_empty' argument to " 

1108 "'parse_sequence_example' Op, not %r." % feature_list_dense_missing_assumed_empty) 

1109 feature_list_dense_missing_assumed_empty = [_execute.make_str(_s, "feature_list_dense_missing_assumed_empty") for _s in feature_list_dense_missing_assumed_empty] 

1110 if not isinstance(context_sparse_keys, (list, tuple)): 

1111 raise TypeError( 

1112 "Expected list for 'context_sparse_keys' argument to " 

1113 "'parse_sequence_example' Op, not %r." % context_sparse_keys) 

1114 context_sparse_keys = [_execute.make_str(_s, "context_sparse_keys") for _s in context_sparse_keys] 

1115 if not isinstance(context_dense_keys, (list, tuple)): 

1116 raise TypeError( 

1117 "Expected list for 'context_dense_keys' argument to " 

1118 "'parse_sequence_example' Op, not %r." % context_dense_keys) 

1119 context_dense_keys = [_execute.make_str(_s, "context_dense_keys") for _s in context_dense_keys] 

1120 if not isinstance(feature_list_sparse_keys, (list, tuple)): 

1121 raise TypeError( 

1122 "Expected list for 'feature_list_sparse_keys' argument to " 

1123 "'parse_sequence_example' Op, not %r." % feature_list_sparse_keys) 

1124 feature_list_sparse_keys = [_execute.make_str(_s, "feature_list_sparse_keys") for _s in feature_list_sparse_keys] 

1125 if not isinstance(feature_list_dense_keys, (list, tuple)): 

1126 raise TypeError( 

1127 "Expected list for 'feature_list_dense_keys' argument to " 

1128 "'parse_sequence_example' Op, not %r." % feature_list_dense_keys) 

1129 feature_list_dense_keys = [_execute.make_str(_s, "feature_list_dense_keys") for _s in feature_list_dense_keys] 

1130 if Ncontext_sparse is None: 

1131 Ncontext_sparse = 0 

1132 Ncontext_sparse = _execute.make_int(Ncontext_sparse, "Ncontext_sparse") 

1133 if Ncontext_dense is None: 

1134 Ncontext_dense = 0 

1135 Ncontext_dense = _execute.make_int(Ncontext_dense, "Ncontext_dense") 

1136 if Nfeature_list_sparse is None: 

1137 Nfeature_list_sparse = 0 

1138 Nfeature_list_sparse = _execute.make_int(Nfeature_list_sparse, "Nfeature_list_sparse") 

1139 if Nfeature_list_dense is None: 

1140 Nfeature_list_dense = 0 

1141 Nfeature_list_dense = _execute.make_int(Nfeature_list_dense, "Nfeature_list_dense") 

1142 if context_sparse_types is None: 

1143 context_sparse_types = [] 

1144 if not isinstance(context_sparse_types, (list, tuple)): 

1145 raise TypeError( 

1146 "Expected list for 'context_sparse_types' argument to " 

1147 "'parse_sequence_example' Op, not %r." % context_sparse_types) 

1148 context_sparse_types = [_execute.make_type(_t, "context_sparse_types") for _t in context_sparse_types] 

1149 if feature_list_dense_types is None: 

1150 feature_list_dense_types = [] 

1151 if not isinstance(feature_list_dense_types, (list, tuple)): 

1152 raise TypeError( 

1153 "Expected list for 'feature_list_dense_types' argument to " 

1154 "'parse_sequence_example' Op, not %r." % feature_list_dense_types) 

1155 feature_list_dense_types = [_execute.make_type(_t, "feature_list_dense_types") for _t in feature_list_dense_types] 

1156 if context_dense_shapes is None: 

1157 context_dense_shapes = [] 

1158 if not isinstance(context_dense_shapes, (list, tuple)): 

1159 raise TypeError( 

1160 "Expected list for 'context_dense_shapes' argument to " 

1161 "'parse_sequence_example' Op, not %r." % context_dense_shapes) 

1162 context_dense_shapes = [_execute.make_shape(_s, "context_dense_shapes") for _s in context_dense_shapes] 

1163 if feature_list_sparse_types is None: 

1164 feature_list_sparse_types = [] 

1165 if not isinstance(feature_list_sparse_types, (list, tuple)): 

1166 raise TypeError( 

1167 "Expected list for 'feature_list_sparse_types' argument to " 

1168 "'parse_sequence_example' Op, not %r." % feature_list_sparse_types) 

1169 feature_list_sparse_types = [_execute.make_type(_t, "feature_list_sparse_types") for _t in feature_list_sparse_types] 

1170 if feature_list_dense_shapes is None: 

1171 feature_list_dense_shapes = [] 

1172 if not isinstance(feature_list_dense_shapes, (list, tuple)): 

1173 raise TypeError( 

1174 "Expected list for 'feature_list_dense_shapes' argument to " 

1175 "'parse_sequence_example' Op, not %r." % feature_list_dense_shapes) 

1176 feature_list_dense_shapes = [_execute.make_shape(_s, "feature_list_dense_shapes") for _s in feature_list_dense_shapes] 

1177 _attr_Tcontext_dense, context_dense_defaults = _execute.convert_to_mixed_eager_tensors(context_dense_defaults, ctx) 

1178 serialized = _ops.convert_to_tensor(serialized, _dtypes.string) 

1179 debug_name = _ops.convert_to_tensor(debug_name, _dtypes.string) 

1180 _inputs_flat = [serialized, debug_name] + list(context_dense_defaults) 

1181 _attrs = ("feature_list_dense_missing_assumed_empty", 

1182 feature_list_dense_missing_assumed_empty, "context_sparse_keys", 

1183 context_sparse_keys, "context_dense_keys", context_dense_keys, 

1184 "feature_list_sparse_keys", feature_list_sparse_keys, 

1185 "feature_list_dense_keys", feature_list_dense_keys, "Ncontext_sparse", 

1186 Ncontext_sparse, "Ncontext_dense", Ncontext_dense, "Nfeature_list_sparse", 

1187 Nfeature_list_sparse, "Nfeature_list_dense", Nfeature_list_dense, 

1188 "context_sparse_types", context_sparse_types, "Tcontext_dense", 

1189 _attr_Tcontext_dense, "feature_list_dense_types", feature_list_dense_types, 

1190 "context_dense_shapes", context_dense_shapes, "feature_list_sparse_types", 

1191 feature_list_sparse_types, "feature_list_dense_shapes", 

1192 feature_list_dense_shapes) 

1193 _result = _execute.execute(b"ParseSequenceExample", Ncontext_sparse + 

1194 len(context_sparse_types) + Ncontext_sparse + 

1195 len(context_dense_defaults) + 

1196 Nfeature_list_sparse + 

1197 len(feature_list_sparse_types) + 

1198 Nfeature_list_sparse + 

1199 len(feature_list_dense_types) + 

1200 Nfeature_list_dense, inputs=_inputs_flat, 

1201 attrs=_attrs, ctx=ctx, name=name) 

1202 if _execute.must_record_gradient(): 

1203 _execute.record_gradient( 

1204 "ParseSequenceExample", _inputs_flat, _attrs, _result) 

1205 _result = [_result[:Ncontext_sparse]] + _result[Ncontext_sparse:] 

1206 _result = _result[:1] + [_result[1:1 + len(context_sparse_types)]] + _result[1 + len(context_sparse_types):] 

1207 _result = _result[:2] + [_result[2:2 + Ncontext_sparse]] + _result[2 + Ncontext_sparse:] 

1208 _result = _result[:3] + [_result[3:3 + len(context_dense_defaults)]] + _result[3 + len(context_dense_defaults):] 

1209 _result = _result[:4] + [_result[4:4 + Nfeature_list_sparse]] + _result[4 + Nfeature_list_sparse:] 

1210 _result = _result[:5] + [_result[5:5 + len(feature_list_sparse_types)]] + _result[5 + len(feature_list_sparse_types):] 

1211 _result = _result[:6] + [_result[6:6 + Nfeature_list_sparse]] + _result[6 + Nfeature_list_sparse:] 

1212 _result = _result[:7] + [_result[7:7 + len(feature_list_dense_types)]] + _result[7 + len(feature_list_dense_types):] 

1213 _result = _result[:8] + [_result[8:]] 

1214 _result = _ParseSequenceExampleOutput._make(_result) 

1215 return _result 

1216 

1217_ParseSequenceExampleV2Output = collections.namedtuple( 

1218 "ParseSequenceExampleV2", 

1219 ["context_sparse_indices", "context_sparse_values", "context_sparse_shapes", "context_dense_values", "context_ragged_values", "context_ragged_row_splits", "feature_list_sparse_indices", "feature_list_sparse_values", "feature_list_sparse_shapes", "feature_list_dense_values", "feature_list_dense_lengths", "feature_list_ragged_values", "feature_list_ragged_outer_splits", "feature_list_ragged_inner_splits"]) 

1220 

1221 

1222def parse_sequence_example_v2(serialized, debug_name, context_sparse_keys, context_dense_keys, context_ragged_keys, feature_list_sparse_keys, feature_list_dense_keys, feature_list_ragged_keys, feature_list_dense_missing_assumed_empty, context_dense_defaults, Ncontext_sparse=0, context_sparse_types=[], context_ragged_value_types=[], context_ragged_split_types=[], context_dense_shapes=[], Nfeature_list_sparse=0, Nfeature_list_dense=0, feature_list_dense_types=[], feature_list_sparse_types=[], feature_list_ragged_value_types=[], feature_list_ragged_split_types=[], feature_list_dense_shapes=[], name=None): 

1223 r"""Transforms a vector of tf.io.SequenceExample protos (as strings) into 

1224typed tensors. 

1225 

1226 Args: 

1227 serialized: A `Tensor` of type `string`. 

1228 A scalar or vector containing binary serialized SequenceExample protos. 

1229 debug_name: A `Tensor` of type `string`. 

1230 A scalar or vector containing the names of the serialized protos. 

1231 May contain, for example, table key (descriptive) name for the 

1232 corresponding serialized proto. This is purely useful for debugging 

1233 purposes, and the presence of values here has no effect on the output. 

1234 May also be an empty vector if no name is available. 

1235 context_sparse_keys: A `Tensor` of type `string`. 

1236 The keys expected in the Examples' features associated with context_sparse 

1237 values. 

1238 context_dense_keys: A `Tensor` of type `string`. 

1239 The keys expected in the SequenceExamples' context features associated with 

1240 dense values. 

1241 context_ragged_keys: A `Tensor` of type `string`. 

1242 The keys expected in the Examples' features associated with context_ragged 

1243 values. 

1244 feature_list_sparse_keys: A `Tensor` of type `string`. 

1245 The keys expected in the FeatureLists associated with sparse values. 

1246 feature_list_dense_keys: A `Tensor` of type `string`. 

1247 The keys expected in the SequenceExamples' feature_lists associated 

1248 with lists of dense values. 

1249 feature_list_ragged_keys: A `Tensor` of type `string`. 

1250 The keys expected in the FeatureLists associated with ragged values. 

1251 feature_list_dense_missing_assumed_empty: A `Tensor` of type `bool`. 

1252 A vector corresponding 1:1 with feature_list_dense_keys, indicating which 

1253 features may be missing from the SequenceExamples. If the associated 

1254 FeatureList is missing, it is treated as empty. 

1255 context_dense_defaults: A list of `Tensor` objects with types from: `float32`, `int64`, `string`. 

1256 A list of Ncontext_dense Tensors (some may be empty). 

1257 context_dense_defaults[j] provides default values 

1258 when the SequenceExample's context map lacks context_dense_key[j]. 

1259 If an empty Tensor is provided for context_dense_defaults[j], 

1260 then the Feature context_dense_keys[j] is required. 

1261 The input type is inferred from context_dense_defaults[j], even when it's 

1262 empty. If context_dense_defaults[j] is not empty, its shape must match 

1263 context_dense_shapes[j]. 

1264 Ncontext_sparse: An optional `int` that is `>= 0`. Defaults to `0`. 

1265 context_sparse_types: An optional list of `tf.DTypes` from: `tf.float32, tf.int64, tf.string`. Defaults to `[]`. 

1266 A list of Ncontext_sparse types; the data types of data in 

1267 each context Feature given in context_sparse_keys. 

1268 Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList), 

1269 DT_INT64 (Int64List), and DT_STRING (BytesList). 

1270 context_ragged_value_types: An optional list of `tf.DTypes` from: `tf.float32, tf.int64, tf.string`. Defaults to `[]`. 

1271 RaggedTensor.value dtypes for the ragged context features. 

1272 context_ragged_split_types: An optional list of `tf.DTypes` from: `tf.int32, tf.int64`. Defaults to `[]`. 

1273 RaggedTensor.row_split dtypes for the ragged context features. 

1274 context_dense_shapes: An optional list of shapes (each a `tf.TensorShape` or list of `ints`). Defaults to `[]`. 

1275 A list of Ncontext_dense shapes; the shapes of data in 

1276 each context Feature given in context_dense_keys. 

1277 The number of elements in the Feature corresponding to context_dense_key[j] 

1278 must always equal context_dense_shapes[j].NumEntries(). 

1279 The shape of context_dense_values[j] will match context_dense_shapes[j]. 

1280 Nfeature_list_sparse: An optional `int` that is `>= 0`. Defaults to `0`. 

1281 Nfeature_list_dense: An optional `int` that is `>= 0`. Defaults to `0`. 

1282 feature_list_dense_types: An optional list of `tf.DTypes` from: `tf.float32, tf.int64, tf.string`. Defaults to `[]`. 

1283 feature_list_sparse_types: An optional list of `tf.DTypes` from: `tf.float32, tf.int64, tf.string`. Defaults to `[]`. 

1284 A list of Nfeature_list_sparse types; the data types 

1285 of data in each FeatureList given in feature_list_sparse_keys. 

1286 Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList), 

1287 DT_INT64 (Int64List), and DT_STRING (BytesList). 

1288 feature_list_ragged_value_types: An optional list of `tf.DTypes` from: `tf.float32, tf.int64, tf.string`. Defaults to `[]`. 

1289 RaggedTensor.value dtypes for the ragged FeatureList features. 

1290 feature_list_ragged_split_types: An optional list of `tf.DTypes` from: `tf.int32, tf.int64`. Defaults to `[]`. 

1291 RaggedTensor.row_split dtypes for the ragged FeatureList features. 

1292 feature_list_dense_shapes: An optional list of shapes (each a `tf.TensorShape` or list of `ints`). Defaults to `[]`. 

1293 A list of Nfeature_list_dense shapes; the shapes of 

1294 data in each FeatureList given in feature_list_dense_keys. 

1295 The shape of each Feature in the FeatureList corresponding to 

1296 feature_list_dense_key[j] must always equal 

1297 feature_list_dense_shapes[j].NumEntries(). 

1298 name: A name for the operation (optional). 

1299 

1300 Returns: 

1301 A tuple of `Tensor` objects (context_sparse_indices, context_sparse_values, context_sparse_shapes, context_dense_values, context_ragged_values, context_ragged_row_splits, feature_list_sparse_indices, feature_list_sparse_values, feature_list_sparse_shapes, feature_list_dense_values, feature_list_dense_lengths, feature_list_ragged_values, feature_list_ragged_outer_splits, feature_list_ragged_inner_splits). 

1302 

1303 context_sparse_indices: A list of `Ncontext_sparse` `Tensor` objects with type `int64`. 

1304 context_sparse_values: A list of `Tensor` objects of type `context_sparse_types`. 

1305 context_sparse_shapes: A list of `Ncontext_sparse` `Tensor` objects with type `int64`. 

1306 context_dense_values: A list of `Tensor` objects. Has the same type as `context_dense_defaults`. 

1307 context_ragged_values: A list of `Tensor` objects of type `context_ragged_value_types`. 

1308 context_ragged_row_splits: A list of `Tensor` objects of type `context_ragged_split_types`. 

1309 feature_list_sparse_indices: A list of `Nfeature_list_sparse` `Tensor` objects with type `int64`. 

1310 feature_list_sparse_values: A list of `Tensor` objects of type `feature_list_sparse_types`. 

1311 feature_list_sparse_shapes: A list of `Nfeature_list_sparse` `Tensor` objects with type `int64`. 

1312 feature_list_dense_values: A list of `Tensor` objects of type `feature_list_dense_types`. 

1313 feature_list_dense_lengths: A list of `Nfeature_list_dense` `Tensor` objects with type `int64`. 

1314 feature_list_ragged_values: A list of `Tensor` objects of type `feature_list_ragged_value_types`. 

1315 feature_list_ragged_outer_splits: A list of `Tensor` objects of type `feature_list_ragged_split_types`. 

1316 feature_list_ragged_inner_splits: A list of `Tensor` objects of type `feature_list_ragged_split_types`. 

1317 """ 

1318 _ctx = _context._context or _context.context() 

1319 tld = _ctx._thread_local_data 

1320 if tld.is_eager: 

1321 try: 

1322 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

1323 _ctx, "ParseSequenceExampleV2", name, serialized, debug_name, 

1324 context_sparse_keys, context_dense_keys, context_ragged_keys, 

1325 feature_list_sparse_keys, feature_list_dense_keys, 

1326 feature_list_ragged_keys, feature_list_dense_missing_assumed_empty, 

1327 context_dense_defaults, "Ncontext_sparse", Ncontext_sparse, 

1328 "context_sparse_types", context_sparse_types, 

1329 "context_ragged_value_types", context_ragged_value_types, 

1330 "context_ragged_split_types", context_ragged_split_types, 

1331 "context_dense_shapes", context_dense_shapes, "Nfeature_list_sparse", 

1332 Nfeature_list_sparse, "Nfeature_list_dense", Nfeature_list_dense, 

1333 "feature_list_dense_types", feature_list_dense_types, 

1334 "feature_list_sparse_types", feature_list_sparse_types, 

1335 "feature_list_ragged_value_types", feature_list_ragged_value_types, 

1336 "feature_list_ragged_split_types", feature_list_ragged_split_types, 

1337 "feature_list_dense_shapes", feature_list_dense_shapes) 

1338 _result = _ParseSequenceExampleV2Output._make(_result) 

1339 return _result 

1340 except _core._NotOkStatusException as e: 

1341 _ops.raise_from_not_ok_status(e, name) 

1342 except _core._FallbackException: 

1343 pass 

1344 try: 

1345 return parse_sequence_example_v2_eager_fallback( 

1346 serialized, debug_name, context_sparse_keys, context_dense_keys, 

1347 context_ragged_keys, feature_list_sparse_keys, 

1348 feature_list_dense_keys, feature_list_ragged_keys, 

1349 feature_list_dense_missing_assumed_empty, context_dense_defaults, 

1350 Ncontext_sparse=Ncontext_sparse, 

1351 context_sparse_types=context_sparse_types, 

1352 context_ragged_value_types=context_ragged_value_types, 

1353 context_ragged_split_types=context_ragged_split_types, 

1354 context_dense_shapes=context_dense_shapes, 

1355 Nfeature_list_sparse=Nfeature_list_sparse, 

1356 Nfeature_list_dense=Nfeature_list_dense, 

1357 feature_list_dense_types=feature_list_dense_types, 

1358 feature_list_sparse_types=feature_list_sparse_types, 

1359 feature_list_ragged_value_types=feature_list_ragged_value_types, 

1360 feature_list_ragged_split_types=feature_list_ragged_split_types, 

1361 feature_list_dense_shapes=feature_list_dense_shapes, name=name, 

1362 ctx=_ctx) 

1363 except _core._SymbolicException: 

1364 pass # Add nodes to the TensorFlow graph. 

1365 # Add nodes to the TensorFlow graph. 

1366 if Ncontext_sparse is None: 

1367 Ncontext_sparse = 0 

1368 Ncontext_sparse = _execute.make_int(Ncontext_sparse, "Ncontext_sparse") 

1369 if context_sparse_types is None: 

1370 context_sparse_types = [] 

1371 if not isinstance(context_sparse_types, (list, tuple)): 

1372 raise TypeError( 

1373 "Expected list for 'context_sparse_types' argument to " 

1374 "'parse_sequence_example_v2' Op, not %r." % context_sparse_types) 

1375 context_sparse_types = [_execute.make_type(_t, "context_sparse_types") for _t in context_sparse_types] 

1376 if context_ragged_value_types is None: 

1377 context_ragged_value_types = [] 

1378 if not isinstance(context_ragged_value_types, (list, tuple)): 

1379 raise TypeError( 

1380 "Expected list for 'context_ragged_value_types' argument to " 

1381 "'parse_sequence_example_v2' Op, not %r." % context_ragged_value_types) 

1382 context_ragged_value_types = [_execute.make_type(_t, "context_ragged_value_types") for _t in context_ragged_value_types] 

1383 if context_ragged_split_types is None: 

1384 context_ragged_split_types = [] 

1385 if not isinstance(context_ragged_split_types, (list, tuple)): 

1386 raise TypeError( 

1387 "Expected list for 'context_ragged_split_types' argument to " 

1388 "'parse_sequence_example_v2' Op, not %r." % context_ragged_split_types) 

1389 context_ragged_split_types = [_execute.make_type(_t, "context_ragged_split_types") for _t in context_ragged_split_types] 

1390 if context_dense_shapes is None: 

1391 context_dense_shapes = [] 

1392 if not isinstance(context_dense_shapes, (list, tuple)): 

1393 raise TypeError( 

1394 "Expected list for 'context_dense_shapes' argument to " 

1395 "'parse_sequence_example_v2' Op, not %r." % context_dense_shapes) 

1396 context_dense_shapes = [_execute.make_shape(_s, "context_dense_shapes") for _s in context_dense_shapes] 

1397 if Nfeature_list_sparse is None: 

1398 Nfeature_list_sparse = 0 

1399 Nfeature_list_sparse = _execute.make_int(Nfeature_list_sparse, "Nfeature_list_sparse") 

1400 if Nfeature_list_dense is None: 

1401 Nfeature_list_dense = 0 

1402 Nfeature_list_dense = _execute.make_int(Nfeature_list_dense, "Nfeature_list_dense") 

1403 if feature_list_dense_types is None: 

1404 feature_list_dense_types = [] 

1405 if not isinstance(feature_list_dense_types, (list, tuple)): 

1406 raise TypeError( 

1407 "Expected list for 'feature_list_dense_types' argument to " 

1408 "'parse_sequence_example_v2' Op, not %r." % feature_list_dense_types) 

1409 feature_list_dense_types = [_execute.make_type(_t, "feature_list_dense_types") for _t in feature_list_dense_types] 

1410 if feature_list_sparse_types is None: 

1411 feature_list_sparse_types = [] 

1412 if not isinstance(feature_list_sparse_types, (list, tuple)): 

1413 raise TypeError( 

1414 "Expected list for 'feature_list_sparse_types' argument to " 

1415 "'parse_sequence_example_v2' Op, not %r." % feature_list_sparse_types) 

1416 feature_list_sparse_types = [_execute.make_type(_t, "feature_list_sparse_types") for _t in feature_list_sparse_types] 

1417 if feature_list_ragged_value_types is None: 

1418 feature_list_ragged_value_types = [] 

1419 if not isinstance(feature_list_ragged_value_types, (list, tuple)): 

1420 raise TypeError( 

1421 "Expected list for 'feature_list_ragged_value_types' argument to " 

1422 "'parse_sequence_example_v2' Op, not %r." % feature_list_ragged_value_types) 

1423 feature_list_ragged_value_types = [_execute.make_type(_t, "feature_list_ragged_value_types") for _t in feature_list_ragged_value_types] 

1424 if feature_list_ragged_split_types is None: 

1425 feature_list_ragged_split_types = [] 

1426 if not isinstance(feature_list_ragged_split_types, (list, tuple)): 

1427 raise TypeError( 

1428 "Expected list for 'feature_list_ragged_split_types' argument to " 

1429 "'parse_sequence_example_v2' Op, not %r." % feature_list_ragged_split_types) 

1430 feature_list_ragged_split_types = [_execute.make_type(_t, "feature_list_ragged_split_types") for _t in feature_list_ragged_split_types] 

1431 if feature_list_dense_shapes is None: 

1432 feature_list_dense_shapes = [] 

1433 if not isinstance(feature_list_dense_shapes, (list, tuple)): 

1434 raise TypeError( 

1435 "Expected list for 'feature_list_dense_shapes' argument to " 

1436 "'parse_sequence_example_v2' Op, not %r." % feature_list_dense_shapes) 

1437 feature_list_dense_shapes = [_execute.make_shape(_s, "feature_list_dense_shapes") for _s in feature_list_dense_shapes] 

1438 _, _, _op, _outputs = _op_def_library._apply_op_helper( 

1439 "ParseSequenceExampleV2", serialized=serialized, 

1440 debug_name=debug_name, 

1441 context_sparse_keys=context_sparse_keys, 

1442 context_dense_keys=context_dense_keys, 

1443 context_ragged_keys=context_ragged_keys, 

1444 feature_list_sparse_keys=feature_list_sparse_keys, 

1445 feature_list_dense_keys=feature_list_dense_keys, 

1446 feature_list_ragged_keys=feature_list_ragged_keys, 

1447 feature_list_dense_missing_assumed_empty=feature_list_dense_missing_assumed_empty, 

1448 context_dense_defaults=context_dense_defaults, 

1449 Ncontext_sparse=Ncontext_sparse, 

1450 context_sparse_types=context_sparse_types, 

1451 context_ragged_value_types=context_ragged_value_types, 

1452 context_ragged_split_types=context_ragged_split_types, 

1453 context_dense_shapes=context_dense_shapes, 

1454 Nfeature_list_sparse=Nfeature_list_sparse, 

1455 Nfeature_list_dense=Nfeature_list_dense, 

1456 feature_list_dense_types=feature_list_dense_types, 

1457 feature_list_sparse_types=feature_list_sparse_types, 

1458 feature_list_ragged_value_types=feature_list_ragged_value_types, 

1459 feature_list_ragged_split_types=feature_list_ragged_split_types, 

1460 feature_list_dense_shapes=feature_list_dense_shapes, 

1461 name=name) 

1462 _result = _outputs[:] 

1463 if _execute.must_record_gradient(): 

1464 _attrs = ("Ncontext_sparse", _op._get_attr_int("Ncontext_sparse"), 

1465 "Tcontext_dense", _op.get_attr("Tcontext_dense"), 

1466 "context_sparse_types", _op.get_attr("context_sparse_types"), 

1467 "context_ragged_value_types", 

1468 _op.get_attr("context_ragged_value_types"), 

1469 "context_ragged_split_types", 

1470 _op.get_attr("context_ragged_split_types"), 

1471 "context_dense_shapes", _op.get_attr("context_dense_shapes"), 

1472 "Nfeature_list_sparse", 

1473 _op._get_attr_int("Nfeature_list_sparse"), 

1474 "Nfeature_list_dense", _op._get_attr_int("Nfeature_list_dense"), 

1475 "feature_list_dense_types", 

1476 _op.get_attr("feature_list_dense_types"), 

1477 "feature_list_sparse_types", 

1478 _op.get_attr("feature_list_sparse_types"), 

1479 "feature_list_ragged_value_types", 

1480 _op.get_attr("feature_list_ragged_value_types"), 

1481 "feature_list_ragged_split_types", 

1482 _op.get_attr("feature_list_ragged_split_types"), 

1483 "feature_list_dense_shapes", 

1484 _op.get_attr("feature_list_dense_shapes")) 

1485 _inputs_flat = _op.inputs 

1486 _execute.record_gradient( 

1487 "ParseSequenceExampleV2", _inputs_flat, _attrs, _result) 

1488 _result = [_result[:Ncontext_sparse]] + _result[Ncontext_sparse:] 

1489 _result = _result[:1] + [_result[1:1 + len(context_sparse_types)]] + _result[1 + len(context_sparse_types):] 

1490 _result = _result[:2] + [_result[2:2 + Ncontext_sparse]] + _result[2 + Ncontext_sparse:] 

1491 _result = _result[:3] + [_result[3:3 + len(context_dense_defaults)]] + _result[3 + len(context_dense_defaults):] 

1492 _result = _result[:4] + [_result[4:4 + len(context_ragged_value_types)]] + _result[4 + len(context_ragged_value_types):] 

1493 _result = _result[:5] + [_result[5:5 + len(context_ragged_split_types)]] + _result[5 + len(context_ragged_split_types):] 

1494 _result = _result[:6] + [_result[6:6 + Nfeature_list_sparse]] + _result[6 + Nfeature_list_sparse:] 

1495 _result = _result[:7] + [_result[7:7 + len(feature_list_sparse_types)]] + _result[7 + len(feature_list_sparse_types):] 

1496 _result = _result[:8] + [_result[8:8 + Nfeature_list_sparse]] + _result[8 + Nfeature_list_sparse:] 

1497 _result = _result[:9] + [_result[9:9 + len(feature_list_dense_types)]] + _result[9 + len(feature_list_dense_types):] 

1498 _result = _result[:10] + [_result[10:10 + Nfeature_list_dense]] + _result[10 + Nfeature_list_dense:] 

1499 _result = _result[:11] + [_result[11:11 + len(feature_list_ragged_value_types)]] + _result[11 + len(feature_list_ragged_value_types):] 

1500 _result = _result[:12] + [_result[12:12 + len(feature_list_ragged_split_types)]] + _result[12 + len(feature_list_ragged_split_types):] 

1501 _result = _result[:13] + [_result[13:]] 

1502 _result = _ParseSequenceExampleV2Output._make(_result) 

1503 return _result 

1504 

1505ParseSequenceExampleV2 = tf_export("raw_ops.ParseSequenceExampleV2")(_ops.to_raw_op(parse_sequence_example_v2)) 

1506 

1507 

1508def parse_sequence_example_v2_eager_fallback(serialized, debug_name, context_sparse_keys, context_dense_keys, context_ragged_keys, feature_list_sparse_keys, feature_list_dense_keys, feature_list_ragged_keys, feature_list_dense_missing_assumed_empty, context_dense_defaults, Ncontext_sparse, context_sparse_types, context_ragged_value_types, context_ragged_split_types, context_dense_shapes, Nfeature_list_sparse, Nfeature_list_dense, feature_list_dense_types, feature_list_sparse_types, feature_list_ragged_value_types, feature_list_ragged_split_types, feature_list_dense_shapes, name, ctx): 

1509 if Ncontext_sparse is None: 

1510 Ncontext_sparse = 0 

1511 Ncontext_sparse = _execute.make_int(Ncontext_sparse, "Ncontext_sparse") 

1512 if context_sparse_types is None: 

1513 context_sparse_types = [] 

1514 if not isinstance(context_sparse_types, (list, tuple)): 

1515 raise TypeError( 

1516 "Expected list for 'context_sparse_types' argument to " 

1517 "'parse_sequence_example_v2' Op, not %r." % context_sparse_types) 

1518 context_sparse_types = [_execute.make_type(_t, "context_sparse_types") for _t in context_sparse_types] 

1519 if context_ragged_value_types is None: 

1520 context_ragged_value_types = [] 

1521 if not isinstance(context_ragged_value_types, (list, tuple)): 

1522 raise TypeError( 

1523 "Expected list for 'context_ragged_value_types' argument to " 

1524 "'parse_sequence_example_v2' Op, not %r." % context_ragged_value_types) 

1525 context_ragged_value_types = [_execute.make_type(_t, "context_ragged_value_types") for _t in context_ragged_value_types] 

1526 if context_ragged_split_types is None: 

1527 context_ragged_split_types = [] 

1528 if not isinstance(context_ragged_split_types, (list, tuple)): 

1529 raise TypeError( 

1530 "Expected list for 'context_ragged_split_types' argument to " 

1531 "'parse_sequence_example_v2' Op, not %r." % context_ragged_split_types) 

1532 context_ragged_split_types = [_execute.make_type(_t, "context_ragged_split_types") for _t in context_ragged_split_types] 

1533 if context_dense_shapes is None: 

1534 context_dense_shapes = [] 

1535 if not isinstance(context_dense_shapes, (list, tuple)): 

1536 raise TypeError( 

1537 "Expected list for 'context_dense_shapes' argument to " 

1538 "'parse_sequence_example_v2' Op, not %r." % context_dense_shapes) 

1539 context_dense_shapes = [_execute.make_shape(_s, "context_dense_shapes") for _s in context_dense_shapes] 

1540 if Nfeature_list_sparse is None: 

1541 Nfeature_list_sparse = 0 

1542 Nfeature_list_sparse = _execute.make_int(Nfeature_list_sparse, "Nfeature_list_sparse") 

1543 if Nfeature_list_dense is None: 

1544 Nfeature_list_dense = 0 

1545 Nfeature_list_dense = _execute.make_int(Nfeature_list_dense, "Nfeature_list_dense") 

1546 if feature_list_dense_types is None: 

1547 feature_list_dense_types = [] 

1548 if not isinstance(feature_list_dense_types, (list, tuple)): 

1549 raise TypeError( 

1550 "Expected list for 'feature_list_dense_types' argument to " 

1551 "'parse_sequence_example_v2' Op, not %r." % feature_list_dense_types) 

1552 feature_list_dense_types = [_execute.make_type(_t, "feature_list_dense_types") for _t in feature_list_dense_types] 

1553 if feature_list_sparse_types is None: 

1554 feature_list_sparse_types = [] 

1555 if not isinstance(feature_list_sparse_types, (list, tuple)): 

1556 raise TypeError( 

1557 "Expected list for 'feature_list_sparse_types' argument to " 

1558 "'parse_sequence_example_v2' Op, not %r." % feature_list_sparse_types) 

1559 feature_list_sparse_types = [_execute.make_type(_t, "feature_list_sparse_types") for _t in feature_list_sparse_types] 

1560 if feature_list_ragged_value_types is None: 

1561 feature_list_ragged_value_types = [] 

1562 if not isinstance(feature_list_ragged_value_types, (list, tuple)): 

1563 raise TypeError( 

1564 "Expected list for 'feature_list_ragged_value_types' argument to " 

1565 "'parse_sequence_example_v2' Op, not %r." % feature_list_ragged_value_types) 

1566 feature_list_ragged_value_types = [_execute.make_type(_t, "feature_list_ragged_value_types") for _t in feature_list_ragged_value_types] 

1567 if feature_list_ragged_split_types is None: 

1568 feature_list_ragged_split_types = [] 

1569 if not isinstance(feature_list_ragged_split_types, (list, tuple)): 

1570 raise TypeError( 

1571 "Expected list for 'feature_list_ragged_split_types' argument to " 

1572 "'parse_sequence_example_v2' Op, not %r." % feature_list_ragged_split_types) 

1573 feature_list_ragged_split_types = [_execute.make_type(_t, "feature_list_ragged_split_types") for _t in feature_list_ragged_split_types] 

1574 if feature_list_dense_shapes is None: 

1575 feature_list_dense_shapes = [] 

1576 if not isinstance(feature_list_dense_shapes, (list, tuple)): 

1577 raise TypeError( 

1578 "Expected list for 'feature_list_dense_shapes' argument to " 

1579 "'parse_sequence_example_v2' Op, not %r." % feature_list_dense_shapes) 

1580 feature_list_dense_shapes = [_execute.make_shape(_s, "feature_list_dense_shapes") for _s in feature_list_dense_shapes] 

1581 _attr_Tcontext_dense, context_dense_defaults = _execute.convert_to_mixed_eager_tensors(context_dense_defaults, ctx) 

1582 serialized = _ops.convert_to_tensor(serialized, _dtypes.string) 

1583 debug_name = _ops.convert_to_tensor(debug_name, _dtypes.string) 

1584 context_sparse_keys = _ops.convert_to_tensor(context_sparse_keys, _dtypes.string) 

1585 context_dense_keys = _ops.convert_to_tensor(context_dense_keys, _dtypes.string) 

1586 context_ragged_keys = _ops.convert_to_tensor(context_ragged_keys, _dtypes.string) 

1587 feature_list_sparse_keys = _ops.convert_to_tensor(feature_list_sparse_keys, _dtypes.string) 

1588 feature_list_dense_keys = _ops.convert_to_tensor(feature_list_dense_keys, _dtypes.string) 

1589 feature_list_ragged_keys = _ops.convert_to_tensor(feature_list_ragged_keys, _dtypes.string) 

1590 feature_list_dense_missing_assumed_empty = _ops.convert_to_tensor(feature_list_dense_missing_assumed_empty, _dtypes.bool) 

1591 _inputs_flat = [serialized, debug_name, context_sparse_keys, context_dense_keys, context_ragged_keys, feature_list_sparse_keys, feature_list_dense_keys, feature_list_ragged_keys, feature_list_dense_missing_assumed_empty] + list(context_dense_defaults) 

1592 _attrs = ("Ncontext_sparse", Ncontext_sparse, "Tcontext_dense", 

1593 _attr_Tcontext_dense, "context_sparse_types", context_sparse_types, 

1594 "context_ragged_value_types", context_ragged_value_types, 

1595 "context_ragged_split_types", context_ragged_split_types, 

1596 "context_dense_shapes", context_dense_shapes, "Nfeature_list_sparse", 

1597 Nfeature_list_sparse, "Nfeature_list_dense", Nfeature_list_dense, 

1598 "feature_list_dense_types", feature_list_dense_types, 

1599 "feature_list_sparse_types", feature_list_sparse_types, 

1600 "feature_list_ragged_value_types", feature_list_ragged_value_types, 

1601 "feature_list_ragged_split_types", feature_list_ragged_split_types, 

1602 "feature_list_dense_shapes", feature_list_dense_shapes) 

1603 _result = _execute.execute(b"ParseSequenceExampleV2", Ncontext_sparse + 

1604 len(context_sparse_types) + Ncontext_sparse + 

1605 len(context_dense_defaults) + 

1606 len(context_ragged_value_types) + 

1607 len(context_ragged_split_types) + 

1608 Nfeature_list_sparse + 

1609 len(feature_list_sparse_types) + 

1610 Nfeature_list_sparse + 

1611 len(feature_list_dense_types) + 

1612 Nfeature_list_dense + 

1613 len(feature_list_ragged_value_types) + 

1614 len(feature_list_ragged_split_types) + 

1615 len(feature_list_ragged_split_types), 

1616 inputs=_inputs_flat, attrs=_attrs, ctx=ctx, 

1617 name=name) 

1618 if _execute.must_record_gradient(): 

1619 _execute.record_gradient( 

1620 "ParseSequenceExampleV2", _inputs_flat, _attrs, _result) 

1621 _result = [_result[:Ncontext_sparse]] + _result[Ncontext_sparse:] 

1622 _result = _result[:1] + [_result[1:1 + len(context_sparse_types)]] + _result[1 + len(context_sparse_types):] 

1623 _result = _result[:2] + [_result[2:2 + Ncontext_sparse]] + _result[2 + Ncontext_sparse:] 

1624 _result = _result[:3] + [_result[3:3 + len(context_dense_defaults)]] + _result[3 + len(context_dense_defaults):] 

1625 _result = _result[:4] + [_result[4:4 + len(context_ragged_value_types)]] + _result[4 + len(context_ragged_value_types):] 

1626 _result = _result[:5] + [_result[5:5 + len(context_ragged_split_types)]] + _result[5 + len(context_ragged_split_types):] 

1627 _result = _result[:6] + [_result[6:6 + Nfeature_list_sparse]] + _result[6 + Nfeature_list_sparse:] 

1628 _result = _result[:7] + [_result[7:7 + len(feature_list_sparse_types)]] + _result[7 + len(feature_list_sparse_types):] 

1629 _result = _result[:8] + [_result[8:8 + Nfeature_list_sparse]] + _result[8 + Nfeature_list_sparse:] 

1630 _result = _result[:9] + [_result[9:9 + len(feature_list_dense_types)]] + _result[9 + len(feature_list_dense_types):] 

1631 _result = _result[:10] + [_result[10:10 + Nfeature_list_dense]] + _result[10 + Nfeature_list_dense:] 

1632 _result = _result[:11] + [_result[11:11 + len(feature_list_ragged_value_types)]] + _result[11 + len(feature_list_ragged_value_types):] 

1633 _result = _result[:12] + [_result[12:12 + len(feature_list_ragged_split_types)]] + _result[12 + len(feature_list_ragged_split_types):] 

1634 _result = _result[:13] + [_result[13:]] 

1635 _result = _ParseSequenceExampleV2Output._make(_result) 

1636 return _result 

1637 

1638_ParseSingleExampleOutput = collections.namedtuple( 

1639 "ParseSingleExample", 

1640 ["sparse_indices", "sparse_values", "sparse_shapes", "dense_values"]) 

1641 

1642 

1643def parse_single_example(serialized, dense_defaults, num_sparse, sparse_keys, dense_keys, sparse_types, dense_shapes, name=None): 

1644 r"""Transforms a tf.Example proto (as a string) into typed tensors. 

1645 

1646 Args: 

1647 serialized: A `Tensor` of type `string`. 

1648 A vector containing a batch of binary serialized Example protos. 

1649 dense_defaults: A list of `Tensor` objects with types from: `float32`, `int64`, `string`. 

1650 A list of Tensors (some may be empty), whose length matches 

1651 the length of `dense_keys`. dense_defaults[j] provides default values 

1652 when the example's feature_map lacks dense_key[j]. If an empty Tensor is 

1653 provided for dense_defaults[j], then the Feature dense_keys[j] is required. 

1654 The input type is inferred from dense_defaults[j], even when it's empty. 

1655 If dense_defaults[j] is not empty, and dense_shapes[j] is fully defined, 

1656 then the shape of dense_defaults[j] must match that of dense_shapes[j]. 

1657 If dense_shapes[j] has an undefined major dimension (variable strides dense 

1658 feature), dense_defaults[j] must contain a single element: 

1659 the padding element. 

1660 num_sparse: An `int` that is `>= 0`. 

1661 The number of sparse features to be parsed from the example. This 

1662 must match the lengths of `sparse_keys` and `sparse_types`. 

1663 sparse_keys: A list of `strings`. A list of `num_sparse` strings. 

1664 The keys expected in the Examples' features associated with sparse values. 

1665 dense_keys: A list of `strings`. 

1666 The keys expected in the Examples' features associated with dense 

1667 values. 

1668 sparse_types: A list of `tf.DTypes` from: `tf.float32, tf.int64, tf.string`. 

1669 A list of `num_sparse` types; the data types of data in each 

1670 Feature given in sparse_keys. 

1671 Currently the ParseSingleExample op supports DT_FLOAT (FloatList), 

1672 DT_INT64 (Int64List), and DT_STRING (BytesList). 

1673 dense_shapes: A list of shapes (each a `tf.TensorShape` or list of `ints`). 

1674 The shapes of data in each Feature given in dense_keys. 

1675 The length of this list must match the length of `dense_keys`. The 

1676 number of elements in the Feature corresponding to dense_key[j] must 

1677 always equal dense_shapes[j].NumEntries(). If dense_shapes[j] == 

1678 (D0, D1, ..., DN) then the shape of output Tensor dense_values[j] 

1679 will be (D0, D1, ..., DN): In the case dense_shapes[j] = (-1, D1, 

1680 ..., DN), the shape of the output Tensor dense_values[j] will be (M, 

1681 D1, .., DN), where M is the number of blocks of elements of length 

1682 D1 * .... * DN, in the input. 

1683 name: A name for the operation (optional). 

1684 

1685 Returns: 

1686 A tuple of `Tensor` objects (sparse_indices, sparse_values, sparse_shapes, dense_values). 

1687 

1688 sparse_indices: A list of `num_sparse` `Tensor` objects with type `int64`. 

1689 sparse_values: A list of `Tensor` objects of type `sparse_types`. 

1690 sparse_shapes: A list of `num_sparse` `Tensor` objects with type `int64`. 

1691 dense_values: A list of `Tensor` objects. Has the same type as `dense_defaults`. 

1692 """ 

1693 _ctx = _context._context or _context.context() 

1694 tld = _ctx._thread_local_data 

1695 if tld.is_eager: 

1696 try: 

1697 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

1698 _ctx, "ParseSingleExample", name, serialized, dense_defaults, 

1699 "num_sparse", num_sparse, "sparse_keys", sparse_keys, "dense_keys", 

1700 dense_keys, "sparse_types", sparse_types, "dense_shapes", 

1701 dense_shapes) 

1702 _result = _ParseSingleExampleOutput._make(_result) 

1703 return _result 

1704 except _core._NotOkStatusException as e: 

1705 _ops.raise_from_not_ok_status(e, name) 

1706 except _core._FallbackException: 

1707 pass 

1708 try: 

1709 return parse_single_example_eager_fallback( 

1710 serialized, dense_defaults, num_sparse=num_sparse, 

1711 sparse_keys=sparse_keys, dense_keys=dense_keys, 

1712 sparse_types=sparse_types, dense_shapes=dense_shapes, name=name, 

1713 ctx=_ctx) 

1714 except _core._SymbolicException: 

1715 pass # Add nodes to the TensorFlow graph. 

1716 # Add nodes to the TensorFlow graph. 

1717 num_sparse = _execute.make_int(num_sparse, "num_sparse") 

1718 if not isinstance(sparse_keys, (list, tuple)): 

1719 raise TypeError( 

1720 "Expected list for 'sparse_keys' argument to " 

1721 "'parse_single_example' Op, not %r." % sparse_keys) 

1722 sparse_keys = [_execute.make_str(_s, "sparse_keys") for _s in sparse_keys] 

1723 if not isinstance(dense_keys, (list, tuple)): 

1724 raise TypeError( 

1725 "Expected list for 'dense_keys' argument to " 

1726 "'parse_single_example' Op, not %r." % dense_keys) 

1727 dense_keys = [_execute.make_str(_s, "dense_keys") for _s in dense_keys] 

1728 if not isinstance(sparse_types, (list, tuple)): 

1729 raise TypeError( 

1730 "Expected list for 'sparse_types' argument to " 

1731 "'parse_single_example' Op, not %r." % sparse_types) 

1732 sparse_types = [_execute.make_type(_t, "sparse_types") for _t in sparse_types] 

1733 if not isinstance(dense_shapes, (list, tuple)): 

1734 raise TypeError( 

1735 "Expected list for 'dense_shapes' argument to " 

1736 "'parse_single_example' Op, not %r." % dense_shapes) 

1737 dense_shapes = [_execute.make_shape(_s, "dense_shapes") for _s in dense_shapes] 

1738 _, _, _op, _outputs = _op_def_library._apply_op_helper( 

1739 "ParseSingleExample", serialized=serialized, 

1740 dense_defaults=dense_defaults, 

1741 num_sparse=num_sparse, sparse_keys=sparse_keys, 

1742 dense_keys=dense_keys, 

1743 sparse_types=sparse_types, 

1744 dense_shapes=dense_shapes, name=name) 

1745 _result = _outputs[:] 

1746 if _execute.must_record_gradient(): 

1747 _attrs = ("num_sparse", _op._get_attr_int("num_sparse"), "sparse_keys", 

1748 _op.get_attr("sparse_keys"), "dense_keys", 

1749 _op.get_attr("dense_keys"), "sparse_types", 

1750 _op.get_attr("sparse_types"), "Tdense", _op.get_attr("Tdense"), 

1751 "dense_shapes", _op.get_attr("dense_shapes")) 

1752 _inputs_flat = _op.inputs 

1753 _execute.record_gradient( 

1754 "ParseSingleExample", _inputs_flat, _attrs, _result) 

1755 _result = [_result[:num_sparse]] + _result[num_sparse:] 

1756 _result = _result[:1] + [_result[1:1 + len(sparse_types)]] + _result[1 + len(sparse_types):] 

1757 _result = _result[:2] + [_result[2:2 + num_sparse]] + _result[2 + num_sparse:] 

1758 _result = _result[:3] + [_result[3:]] 

1759 _result = _ParseSingleExampleOutput._make(_result) 

1760 return _result 

1761 

1762ParseSingleExample = tf_export("raw_ops.ParseSingleExample")(_ops.to_raw_op(parse_single_example)) 

1763 

1764 

1765def parse_single_example_eager_fallback(serialized, dense_defaults, num_sparse, sparse_keys, dense_keys, sparse_types, dense_shapes, name, ctx): 

1766 num_sparse = _execute.make_int(num_sparse, "num_sparse") 

1767 if not isinstance(sparse_keys, (list, tuple)): 

1768 raise TypeError( 

1769 "Expected list for 'sparse_keys' argument to " 

1770 "'parse_single_example' Op, not %r." % sparse_keys) 

1771 sparse_keys = [_execute.make_str(_s, "sparse_keys") for _s in sparse_keys] 

1772 if not isinstance(dense_keys, (list, tuple)): 

1773 raise TypeError( 

1774 "Expected list for 'dense_keys' argument to " 

1775 "'parse_single_example' Op, not %r." % dense_keys) 

1776 dense_keys = [_execute.make_str(_s, "dense_keys") for _s in dense_keys] 

1777 if not isinstance(sparse_types, (list, tuple)): 

1778 raise TypeError( 

1779 "Expected list for 'sparse_types' argument to " 

1780 "'parse_single_example' Op, not %r." % sparse_types) 

1781 sparse_types = [_execute.make_type(_t, "sparse_types") for _t in sparse_types] 

1782 if not isinstance(dense_shapes, (list, tuple)): 

1783 raise TypeError( 

1784 "Expected list for 'dense_shapes' argument to " 

1785 "'parse_single_example' Op, not %r." % dense_shapes) 

1786 dense_shapes = [_execute.make_shape(_s, "dense_shapes") for _s in dense_shapes] 

1787 _attr_Tdense, dense_defaults = _execute.convert_to_mixed_eager_tensors(dense_defaults, ctx) 

1788 serialized = _ops.convert_to_tensor(serialized, _dtypes.string) 

1789 _inputs_flat = [serialized] + list(dense_defaults) 

1790 _attrs = ("num_sparse", num_sparse, "sparse_keys", sparse_keys, 

1791 "dense_keys", dense_keys, "sparse_types", sparse_types, "Tdense", 

1792 _attr_Tdense, "dense_shapes", dense_shapes) 

1793 _result = _execute.execute(b"ParseSingleExample", num_sparse + 

1794 len(sparse_types) + num_sparse + 

1795 len(dense_defaults), inputs=_inputs_flat, 

1796 attrs=_attrs, ctx=ctx, name=name) 

1797 if _execute.must_record_gradient(): 

1798 _execute.record_gradient( 

1799 "ParseSingleExample", _inputs_flat, _attrs, _result) 

1800 _result = [_result[:num_sparse]] + _result[num_sparse:] 

1801 _result = _result[:1] + [_result[1:1 + len(sparse_types)]] + _result[1 + len(sparse_types):] 

1802 _result = _result[:2] + [_result[2:2 + num_sparse]] + _result[2 + num_sparse:] 

1803 _result = _result[:3] + [_result[3:]] 

1804 _result = _ParseSingleExampleOutput._make(_result) 

1805 return _result 

1806 

1807_ParseSingleSequenceExampleOutput = collections.namedtuple( 

1808 "ParseSingleSequenceExample", 

1809 ["context_sparse_indices", "context_sparse_values", "context_sparse_shapes", "context_dense_values", "feature_list_sparse_indices", "feature_list_sparse_values", "feature_list_sparse_shapes", "feature_list_dense_values"]) 

1810 

1811 

1812def parse_single_sequence_example(serialized, feature_list_dense_missing_assumed_empty, context_sparse_keys, context_dense_keys, feature_list_sparse_keys, feature_list_dense_keys, context_dense_defaults, debug_name, context_sparse_types=[], feature_list_dense_types=[], context_dense_shapes=[], feature_list_sparse_types=[], feature_list_dense_shapes=[], name=None): 

1813 r"""Transforms a scalar brain.SequenceExample proto (as strings) into typed tensors. 

1814 

1815 Args: 

1816 serialized: A `Tensor` of type `string`. 

1817 A scalar containing a binary serialized SequenceExample proto. 

1818 feature_list_dense_missing_assumed_empty: A `Tensor` of type `string`. 

1819 A vector listing the 

1820 FeatureList keys which may be missing from the SequenceExample. If the 

1821 associated FeatureList is missing, it is treated as empty. By default, 

1822 any FeatureList not listed in this vector must exist in the SequenceExample. 

1823 context_sparse_keys: A list of `Tensor` objects with type `string`. 

1824 A list of Ncontext_sparse string Tensors (scalars). 

1825 The keys expected in the Examples' features associated with context_sparse 

1826 values. 

1827 context_dense_keys: A list of `Tensor` objects with type `string`. 

1828 A list of Ncontext_dense string Tensors (scalars). 

1829 The keys expected in the SequenceExamples' context features associated with 

1830 dense values. 

1831 feature_list_sparse_keys: A list of `Tensor` objects with type `string`. 

1832 A list of Nfeature_list_sparse string Tensors 

1833 (scalars). The keys expected in the FeatureLists associated with sparse 

1834 values. 

1835 feature_list_dense_keys: A list of `Tensor` objects with type `string`. 

1836 A list of Nfeature_list_dense string Tensors (scalars). 

1837 The keys expected in the SequenceExamples' feature_lists associated 

1838 with lists of dense values. 

1839 context_dense_defaults: A list of `Tensor` objects with types from: `float32`, `int64`, `string`. 

1840 A list of Ncontext_dense Tensors (some may be empty). 

1841 context_dense_defaults[j] provides default values 

1842 when the SequenceExample's context map lacks context_dense_key[j]. 

1843 If an empty Tensor is provided for context_dense_defaults[j], 

1844 then the Feature context_dense_keys[j] is required. 

1845 The input type is inferred from context_dense_defaults[j], even when it's 

1846 empty. If context_dense_defaults[j] is not empty, its shape must match 

1847 context_dense_shapes[j]. 

1848 debug_name: A `Tensor` of type `string`. 

1849 A scalar containing the name of the serialized proto. 

1850 May contain, for example, table key (descriptive) name for the 

1851 corresponding serialized proto. This is purely useful for debugging 

1852 purposes, and the presence of values here has no effect on the output. 

1853 May also be an empty scalar if no name is available. 

1854 context_sparse_types: An optional list of `tf.DTypes` from: `tf.float32, tf.int64, tf.string`. Defaults to `[]`. 

1855 A list of Ncontext_sparse types; the data types of data in 

1856 each context Feature given in context_sparse_keys. 

1857 Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList), 

1858 DT_INT64 (Int64List), and DT_STRING (BytesList). 

1859 feature_list_dense_types: An optional list of `tf.DTypes` from: `tf.float32, tf.int64, tf.string`. Defaults to `[]`. 

1860 context_dense_shapes: An optional list of shapes (each a `tf.TensorShape` or list of `ints`). Defaults to `[]`. 

1861 A list of Ncontext_dense shapes; the shapes of data in 

1862 each context Feature given in context_dense_keys. 

1863 The number of elements in the Feature corresponding to context_dense_key[j] 

1864 must always equal context_dense_shapes[j].NumEntries(). 

1865 The shape of context_dense_values[j] will match context_dense_shapes[j]. 

1866 feature_list_sparse_types: An optional list of `tf.DTypes` from: `tf.float32, tf.int64, tf.string`. Defaults to `[]`. 

1867 A list of Nfeature_list_sparse types; the data types 

1868 of data in each FeatureList given in feature_list_sparse_keys. 

1869 Currently the ParseSingleSequenceExample supports DT_FLOAT (FloatList), 

1870 DT_INT64 (Int64List), and DT_STRING (BytesList). 

1871 feature_list_dense_shapes: An optional list of shapes (each a `tf.TensorShape` or list of `ints`). Defaults to `[]`. 

1872 A list of Nfeature_list_dense shapes; the shapes of 

1873 data in each FeatureList given in feature_list_dense_keys. 

1874 The shape of each Feature in the FeatureList corresponding to 

1875 feature_list_dense_key[j] must always equal 

1876 feature_list_dense_shapes[j].NumEntries(). 

1877 name: A name for the operation (optional). 

1878 

1879 Returns: 

1880 A tuple of `Tensor` objects (context_sparse_indices, context_sparse_values, context_sparse_shapes, context_dense_values, feature_list_sparse_indices, feature_list_sparse_values, feature_list_sparse_shapes, feature_list_dense_values). 

1881 

1882 context_sparse_indices: A list with the same length as `context_sparse_keys` of `Tensor` objects with type `int64`. 

1883 context_sparse_values: A list of `Tensor` objects of type `context_sparse_types`. 

1884 context_sparse_shapes: A list with the same length as `context_sparse_keys` of `Tensor` objects with type `int64`. 

1885 context_dense_values: A list of `Tensor` objects. Has the same type as `context_dense_defaults`. 

1886 feature_list_sparse_indices: A list with the same length as `feature_list_sparse_keys` of `Tensor` objects with type `int64`. 

1887 feature_list_sparse_values: A list of `Tensor` objects of type `feature_list_sparse_types`. 

1888 feature_list_sparse_shapes: A list with the same length as `feature_list_sparse_keys` of `Tensor` objects with type `int64`. 

1889 feature_list_dense_values: A list of `Tensor` objects of type `feature_list_dense_types`. 

1890 """ 

1891 _ctx = _context._context or _context.context() 

1892 tld = _ctx._thread_local_data 

1893 if tld.is_eager: 

1894 try: 

1895 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

1896 _ctx, "ParseSingleSequenceExample", name, serialized, 

1897 feature_list_dense_missing_assumed_empty, context_sparse_keys, 

1898 context_dense_keys, feature_list_sparse_keys, feature_list_dense_keys, 

1899 context_dense_defaults, debug_name, "context_sparse_types", 

1900 context_sparse_types, "feature_list_dense_types", 

1901 feature_list_dense_types, "context_dense_shapes", 

1902 context_dense_shapes, "feature_list_sparse_types", 

1903 feature_list_sparse_types, "feature_list_dense_shapes", 

1904 feature_list_dense_shapes) 

1905 _result = _ParseSingleSequenceExampleOutput._make(_result) 

1906 return _result 

1907 except _core._NotOkStatusException as e: 

1908 _ops.raise_from_not_ok_status(e, name) 

1909 except _core._FallbackException: 

1910 pass 

1911 try: 

1912 return parse_single_sequence_example_eager_fallback( 

1913 serialized, feature_list_dense_missing_assumed_empty, 

1914 context_sparse_keys, context_dense_keys, feature_list_sparse_keys, 

1915 feature_list_dense_keys, context_dense_defaults, debug_name, 

1916 context_sparse_types=context_sparse_types, 

1917 feature_list_dense_types=feature_list_dense_types, 

1918 context_dense_shapes=context_dense_shapes, 

1919 feature_list_sparse_types=feature_list_sparse_types, 

1920 feature_list_dense_shapes=feature_list_dense_shapes, name=name, 

1921 ctx=_ctx) 

1922 except _core._SymbolicException: 

1923 pass # Add nodes to the TensorFlow graph. 

1924 # Add nodes to the TensorFlow graph. 

1925 if not isinstance(context_sparse_keys, (list, tuple)): 

1926 raise TypeError( 

1927 "Expected list for 'context_sparse_keys' argument to " 

1928 "'parse_single_sequence_example' Op, not %r." % context_sparse_keys) 

1929 _attr_Ncontext_sparse = len(context_sparse_keys) 

1930 if not isinstance(context_dense_keys, (list, tuple)): 

1931 raise TypeError( 

1932 "Expected list for 'context_dense_keys' argument to " 

1933 "'parse_single_sequence_example' Op, not %r." % context_dense_keys) 

1934 _attr_Ncontext_dense = len(context_dense_keys) 

1935 if not isinstance(feature_list_sparse_keys, (list, tuple)): 

1936 raise TypeError( 

1937 "Expected list for 'feature_list_sparse_keys' argument to " 

1938 "'parse_single_sequence_example' Op, not %r." % feature_list_sparse_keys) 

1939 _attr_Nfeature_list_sparse = len(feature_list_sparse_keys) 

1940 if not isinstance(feature_list_dense_keys, (list, tuple)): 

1941 raise TypeError( 

1942 "Expected list for 'feature_list_dense_keys' argument to " 

1943 "'parse_single_sequence_example' Op, not %r." % feature_list_dense_keys) 

1944 _attr_Nfeature_list_dense = len(feature_list_dense_keys) 

1945 if context_sparse_types is None: 

1946 context_sparse_types = [] 

1947 if not isinstance(context_sparse_types, (list, tuple)): 

1948 raise TypeError( 

1949 "Expected list for 'context_sparse_types' argument to " 

1950 "'parse_single_sequence_example' Op, not %r." % context_sparse_types) 

1951 context_sparse_types = [_execute.make_type(_t, "context_sparse_types") for _t in context_sparse_types] 

1952 if feature_list_dense_types is None: 

1953 feature_list_dense_types = [] 

1954 if not isinstance(feature_list_dense_types, (list, tuple)): 

1955 raise TypeError( 

1956 "Expected list for 'feature_list_dense_types' argument to " 

1957 "'parse_single_sequence_example' Op, not %r." % feature_list_dense_types) 

1958 feature_list_dense_types = [_execute.make_type(_t, "feature_list_dense_types") for _t in feature_list_dense_types] 

1959 if context_dense_shapes is None: 

1960 context_dense_shapes = [] 

1961 if not isinstance(context_dense_shapes, (list, tuple)): 

1962 raise TypeError( 

1963 "Expected list for 'context_dense_shapes' argument to " 

1964 "'parse_single_sequence_example' Op, not %r." % context_dense_shapes) 

1965 context_dense_shapes = [_execute.make_shape(_s, "context_dense_shapes") for _s in context_dense_shapes] 

1966 if feature_list_sparse_types is None: 

1967 feature_list_sparse_types = [] 

1968 if not isinstance(feature_list_sparse_types, (list, tuple)): 

1969 raise TypeError( 

1970 "Expected list for 'feature_list_sparse_types' argument to " 

1971 "'parse_single_sequence_example' Op, not %r." % feature_list_sparse_types) 

1972 feature_list_sparse_types = [_execute.make_type(_t, "feature_list_sparse_types") for _t in feature_list_sparse_types] 

1973 if feature_list_dense_shapes is None: 

1974 feature_list_dense_shapes = [] 

1975 if not isinstance(feature_list_dense_shapes, (list, tuple)): 

1976 raise TypeError( 

1977 "Expected list for 'feature_list_dense_shapes' argument to " 

1978 "'parse_single_sequence_example' Op, not %r." % feature_list_dense_shapes) 

1979 feature_list_dense_shapes = [_execute.make_shape(_s, "feature_list_dense_shapes") for _s in feature_list_dense_shapes] 

1980 _, _, _op, _outputs = _op_def_library._apply_op_helper( 

1981 "ParseSingleSequenceExample", serialized=serialized, 

1982 feature_list_dense_missing_assumed_empty=feature_list_dense_missing_assumed_empty, 

1983 context_sparse_keys=context_sparse_keys, 

1984 context_dense_keys=context_dense_keys, 

1985 feature_list_sparse_keys=feature_list_sparse_keys, 

1986 feature_list_dense_keys=feature_list_dense_keys, 

1987 context_dense_defaults=context_dense_defaults, 

1988 debug_name=debug_name, 

1989 context_sparse_types=context_sparse_types, 

1990 feature_list_dense_types=feature_list_dense_types, 

1991 context_dense_shapes=context_dense_shapes, 

1992 feature_list_sparse_types=feature_list_sparse_types, 

1993 feature_list_dense_shapes=feature_list_dense_shapes, 

1994 name=name) 

1995 _result = _outputs[:] 

1996 if _execute.must_record_gradient(): 

1997 _attrs = ("Ncontext_sparse", _op._get_attr_int("Ncontext_sparse"), 

1998 "Ncontext_dense", _op._get_attr_int("Ncontext_dense"), 

1999 "Nfeature_list_sparse", 

2000 _op._get_attr_int("Nfeature_list_sparse"), 

2001 "Nfeature_list_dense", _op._get_attr_int("Nfeature_list_dense"), 

2002 "context_sparse_types", _op.get_attr("context_sparse_types"), 

2003 "Tcontext_dense", _op.get_attr("Tcontext_dense"), 

2004 "feature_list_dense_types", 

2005 _op.get_attr("feature_list_dense_types"), 

2006 "context_dense_shapes", _op.get_attr("context_dense_shapes"), 

2007 "feature_list_sparse_types", 

2008 _op.get_attr("feature_list_sparse_types"), 

2009 "feature_list_dense_shapes", 

2010 _op.get_attr("feature_list_dense_shapes")) 

2011 _inputs_flat = _op.inputs 

2012 _execute.record_gradient( 

2013 "ParseSingleSequenceExample", _inputs_flat, _attrs, _result) 

2014 _result = [_result[:_attr_Ncontext_sparse]] + _result[_attr_Ncontext_sparse:] 

2015 _result = _result[:1] + [_result[1:1 + len(context_sparse_types)]] + _result[1 + len(context_sparse_types):] 

2016 _result = _result[:2] + [_result[2:2 + _attr_Ncontext_sparse]] + _result[2 + _attr_Ncontext_sparse:] 

2017 _result = _result[:3] + [_result[3:3 + len(context_dense_defaults)]] + _result[3 + len(context_dense_defaults):] 

2018 _result = _result[:4] + [_result[4:4 + _attr_Nfeature_list_sparse]] + _result[4 + _attr_Nfeature_list_sparse:] 

2019 _result = _result[:5] + [_result[5:5 + len(feature_list_sparse_types)]] + _result[5 + len(feature_list_sparse_types):] 

2020 _result = _result[:6] + [_result[6:6 + _attr_Nfeature_list_sparse]] + _result[6 + _attr_Nfeature_list_sparse:] 

2021 _result = _result[:7] + [_result[7:]] 

2022 _result = _ParseSingleSequenceExampleOutput._make(_result) 

2023 return _result 

2024 

2025ParseSingleSequenceExample = tf_export("raw_ops.ParseSingleSequenceExample")(_ops.to_raw_op(parse_single_sequence_example)) 

2026 

2027 

2028def parse_single_sequence_example_eager_fallback(serialized, feature_list_dense_missing_assumed_empty, context_sparse_keys, context_dense_keys, feature_list_sparse_keys, feature_list_dense_keys, context_dense_defaults, debug_name, context_sparse_types, feature_list_dense_types, context_dense_shapes, feature_list_sparse_types, feature_list_dense_shapes, name, ctx): 

2029 if not isinstance(context_sparse_keys, (list, tuple)): 

2030 raise TypeError( 

2031 "Expected list for 'context_sparse_keys' argument to " 

2032 "'parse_single_sequence_example' Op, not %r." % context_sparse_keys) 

2033 _attr_Ncontext_sparse = len(context_sparse_keys) 

2034 if not isinstance(context_dense_keys, (list, tuple)): 

2035 raise TypeError( 

2036 "Expected list for 'context_dense_keys' argument to " 

2037 "'parse_single_sequence_example' Op, not %r." % context_dense_keys) 

2038 _attr_Ncontext_dense = len(context_dense_keys) 

2039 if not isinstance(feature_list_sparse_keys, (list, tuple)): 

2040 raise TypeError( 

2041 "Expected list for 'feature_list_sparse_keys' argument to " 

2042 "'parse_single_sequence_example' Op, not %r." % feature_list_sparse_keys) 

2043 _attr_Nfeature_list_sparse = len(feature_list_sparse_keys) 

2044 if not isinstance(feature_list_dense_keys, (list, tuple)): 

2045 raise TypeError( 

2046 "Expected list for 'feature_list_dense_keys' argument to " 

2047 "'parse_single_sequence_example' Op, not %r." % feature_list_dense_keys) 

2048 _attr_Nfeature_list_dense = len(feature_list_dense_keys) 

2049 if context_sparse_types is None: 

2050 context_sparse_types = [] 

2051 if not isinstance(context_sparse_types, (list, tuple)): 

2052 raise TypeError( 

2053 "Expected list for 'context_sparse_types' argument to " 

2054 "'parse_single_sequence_example' Op, not %r." % context_sparse_types) 

2055 context_sparse_types = [_execute.make_type(_t, "context_sparse_types") for _t in context_sparse_types] 

2056 if feature_list_dense_types is None: 

2057 feature_list_dense_types = [] 

2058 if not isinstance(feature_list_dense_types, (list, tuple)): 

2059 raise TypeError( 

2060 "Expected list for 'feature_list_dense_types' argument to " 

2061 "'parse_single_sequence_example' Op, not %r." % feature_list_dense_types) 

2062 feature_list_dense_types = [_execute.make_type(_t, "feature_list_dense_types") for _t in feature_list_dense_types] 

2063 if context_dense_shapes is None: 

2064 context_dense_shapes = [] 

2065 if not isinstance(context_dense_shapes, (list, tuple)): 

2066 raise TypeError( 

2067 "Expected list for 'context_dense_shapes' argument to " 

2068 "'parse_single_sequence_example' Op, not %r." % context_dense_shapes) 

2069 context_dense_shapes = [_execute.make_shape(_s, "context_dense_shapes") for _s in context_dense_shapes] 

2070 if feature_list_sparse_types is None: 

2071 feature_list_sparse_types = [] 

2072 if not isinstance(feature_list_sparse_types, (list, tuple)): 

2073 raise TypeError( 

2074 "Expected list for 'feature_list_sparse_types' argument to " 

2075 "'parse_single_sequence_example' Op, not %r." % feature_list_sparse_types) 

2076 feature_list_sparse_types = [_execute.make_type(_t, "feature_list_sparse_types") for _t in feature_list_sparse_types] 

2077 if feature_list_dense_shapes is None: 

2078 feature_list_dense_shapes = [] 

2079 if not isinstance(feature_list_dense_shapes, (list, tuple)): 

2080 raise TypeError( 

2081 "Expected list for 'feature_list_dense_shapes' argument to " 

2082 "'parse_single_sequence_example' Op, not %r." % feature_list_dense_shapes) 

2083 feature_list_dense_shapes = [_execute.make_shape(_s, "feature_list_dense_shapes") for _s in feature_list_dense_shapes] 

2084 _attr_Tcontext_dense, context_dense_defaults = _execute.convert_to_mixed_eager_tensors(context_dense_defaults, ctx) 

2085 serialized = _ops.convert_to_tensor(serialized, _dtypes.string) 

2086 feature_list_dense_missing_assumed_empty = _ops.convert_to_tensor(feature_list_dense_missing_assumed_empty, _dtypes.string) 

2087 context_sparse_keys = _ops.convert_n_to_tensor(context_sparse_keys, _dtypes.string) 

2088 context_dense_keys = _ops.convert_n_to_tensor(context_dense_keys, _dtypes.string) 

2089 feature_list_sparse_keys = _ops.convert_n_to_tensor(feature_list_sparse_keys, _dtypes.string) 

2090 feature_list_dense_keys = _ops.convert_n_to_tensor(feature_list_dense_keys, _dtypes.string) 

2091 debug_name = _ops.convert_to_tensor(debug_name, _dtypes.string) 

2092 _inputs_flat = [serialized, feature_list_dense_missing_assumed_empty] + list(context_sparse_keys) + list(context_dense_keys) + list(feature_list_sparse_keys) + list(feature_list_dense_keys) + list(context_dense_defaults) + [debug_name] 

2093 _attrs = ("Ncontext_sparse", _attr_Ncontext_sparse, "Ncontext_dense", 

2094 _attr_Ncontext_dense, "Nfeature_list_sparse", _attr_Nfeature_list_sparse, 

2095 "Nfeature_list_dense", _attr_Nfeature_list_dense, "context_sparse_types", 

2096 context_sparse_types, "Tcontext_dense", _attr_Tcontext_dense, 

2097 "feature_list_dense_types", feature_list_dense_types, 

2098 "context_dense_shapes", context_dense_shapes, "feature_list_sparse_types", 

2099 feature_list_sparse_types, "feature_list_dense_shapes", 

2100 feature_list_dense_shapes) 

2101 _result = _execute.execute(b"ParseSingleSequenceExample", 

2102 _attr_Ncontext_sparse + len(context_sparse_types) 

2103 + _attr_Ncontext_sparse + 

2104 len(context_dense_defaults) + 

2105 _attr_Nfeature_list_sparse + 

2106 len(feature_list_sparse_types) + 

2107 _attr_Nfeature_list_sparse + 

2108 len(feature_list_dense_types), 

2109 inputs=_inputs_flat, attrs=_attrs, ctx=ctx, 

2110 name=name) 

2111 if _execute.must_record_gradient(): 

2112 _execute.record_gradient( 

2113 "ParseSingleSequenceExample", _inputs_flat, _attrs, _result) 

2114 _result = [_result[:_attr_Ncontext_sparse]] + _result[_attr_Ncontext_sparse:] 

2115 _result = _result[:1] + [_result[1:1 + len(context_sparse_types)]] + _result[1 + len(context_sparse_types):] 

2116 _result = _result[:2] + [_result[2:2 + _attr_Ncontext_sparse]] + _result[2 + _attr_Ncontext_sparse:] 

2117 _result = _result[:3] + [_result[3:3 + len(context_dense_defaults)]] + _result[3 + len(context_dense_defaults):] 

2118 _result = _result[:4] + [_result[4:4 + _attr_Nfeature_list_sparse]] + _result[4 + _attr_Nfeature_list_sparse:] 

2119 _result = _result[:5] + [_result[5:5 + len(feature_list_sparse_types)]] + _result[5 + len(feature_list_sparse_types):] 

2120 _result = _result[:6] + [_result[6:6 + _attr_Nfeature_list_sparse]] + _result[6 + _attr_Nfeature_list_sparse:] 

2121 _result = _result[:7] + [_result[7:]] 

2122 _result = _ParseSingleSequenceExampleOutput._make(_result) 

2123 return _result 

2124 

2125 

2126@_dispatch.add_fallback_dispatch_list 

2127@_dispatch.add_type_based_api_dispatcher 

2128@tf_export('io.parse_tensor', v1=['io.parse_tensor', 'parse_tensor']) 

2129@deprecated_endpoints('parse_tensor') 

2130def parse_tensor(serialized, out_type, name=None): 

2131 r"""Transforms a serialized tensorflow.TensorProto proto into a Tensor. 

2132 

2133 Args: 

2134 serialized: A `Tensor` of type `string`. 

2135 A scalar string containing a serialized TensorProto proto. 

2136 out_type: A `tf.DType`. 

2137 The type of the serialized tensor. The provided type must match the 

2138 type of the serialized tensor and no implicit conversion will take place. 

2139 name: A name for the operation (optional). 

2140 

2141 Returns: 

2142 A `Tensor` of type `out_type`. 

2143 """ 

2144 _ctx = _context._context or _context.context() 

2145 tld = _ctx._thread_local_data 

2146 if tld.is_eager: 

2147 try: 

2148 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

2149 _ctx, "ParseTensor", name, serialized, "out_type", out_type) 

2150 return _result 

2151 except _core._NotOkStatusException as e: 

2152 _ops.raise_from_not_ok_status(e, name) 

2153 except _core._FallbackException: 

2154 pass 

2155 try: 

2156 _result = _dispatcher_for_parse_tensor( 

2157 (serialized, out_type, name,), None) 

2158 if _result is not NotImplemented: 

2159 return _result 

2160 return parse_tensor_eager_fallback( 

2161 serialized, out_type=out_type, name=name, ctx=_ctx) 

2162 except _core._SymbolicException: 

2163 pass # Add nodes to the TensorFlow graph. 

2164 except (TypeError, ValueError): 

2165 _result = _dispatch.dispatch( 

2166 parse_tensor, (), dict(serialized=serialized, out_type=out_type, 

2167 name=name) 

2168 ) 

2169 if _result is not _dispatch.OpDispatcher.NOT_SUPPORTED: 

2170 return _result 

2171 raise 

2172 else: 

2173 _result = _dispatcher_for_parse_tensor( 

2174 (serialized, out_type, name,), None) 

2175 if _result is not NotImplemented: 

2176 return _result 

2177 # Add nodes to the TensorFlow graph. 

2178 out_type = _execute.make_type(out_type, "out_type") 

2179 try: 

2180 _, _, _op, _outputs = _op_def_library._apply_op_helper( 

2181 "ParseTensor", serialized=serialized, out_type=out_type, name=name) 

2182 except (TypeError, ValueError): 

2183 _result = _dispatch.dispatch( 

2184 parse_tensor, (), dict(serialized=serialized, out_type=out_type, 

2185 name=name) 

2186 ) 

2187 if _result is not _dispatch.OpDispatcher.NOT_SUPPORTED: 

2188 return _result 

2189 raise 

2190 _result = _outputs[:] 

2191 if _execute.must_record_gradient(): 

2192 _attrs = ("out_type", _op._get_attr_type("out_type")) 

2193 _inputs_flat = _op.inputs 

2194 _execute.record_gradient( 

2195 "ParseTensor", _inputs_flat, _attrs, _result) 

2196 _result, = _result 

2197 return _result 

2198 

2199ParseTensor = tf_export("raw_ops.ParseTensor")(_ops.to_raw_op(parse_tensor)) 

2200_dispatcher_for_parse_tensor = parse_tensor._tf_type_based_dispatcher.Dispatch 

2201 

2202 

2203def parse_tensor_eager_fallback(serialized, out_type, name, ctx): 

2204 out_type = _execute.make_type(out_type, "out_type") 

2205 serialized = _ops.convert_to_tensor(serialized, _dtypes.string) 

2206 _inputs_flat = [serialized] 

2207 _attrs = ("out_type", out_type) 

2208 _result = _execute.execute(b"ParseTensor", 1, inputs=_inputs_flat, 

2209 attrs=_attrs, ctx=ctx, name=name) 

2210 if _execute.must_record_gradient(): 

2211 _execute.record_gradient( 

2212 "ParseTensor", _inputs_flat, _attrs, _result) 

2213 _result, = _result 

2214 return _result 

2215 

2216 

2217def serialize_tensor(tensor, name=None): 

2218 r"""Transforms a Tensor into a serialized TensorProto proto. 

2219 

2220 Args: 

2221 tensor: A `Tensor`. A Tensor of type `T`. 

2222 name: A name for the operation (optional). 

2223 

2224 Returns: 

2225 A `Tensor` of type `string`. 

2226 """ 

2227 _ctx = _context._context or _context.context() 

2228 tld = _ctx._thread_local_data 

2229 if tld.is_eager: 

2230 try: 

2231 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

2232 _ctx, "SerializeTensor", name, tensor) 

2233 return _result 

2234 except _core._NotOkStatusException as e: 

2235 _ops.raise_from_not_ok_status(e, name) 

2236 except _core._FallbackException: 

2237 pass 

2238 try: 

2239 return serialize_tensor_eager_fallback( 

2240 tensor, name=name, ctx=_ctx) 

2241 except _core._SymbolicException: 

2242 pass # Add nodes to the TensorFlow graph. 

2243 # Add nodes to the TensorFlow graph. 

2244 _, _, _op, _outputs = _op_def_library._apply_op_helper( 

2245 "SerializeTensor", tensor=tensor, name=name) 

2246 _result = _outputs[:] 

2247 if _execute.must_record_gradient(): 

2248 _attrs = ("T", _op._get_attr_type("T")) 

2249 _inputs_flat = _op.inputs 

2250 _execute.record_gradient( 

2251 "SerializeTensor", _inputs_flat, _attrs, _result) 

2252 _result, = _result 

2253 return _result 

2254 

2255SerializeTensor = tf_export("raw_ops.SerializeTensor")(_ops.to_raw_op(serialize_tensor)) 

2256 

2257 

2258def serialize_tensor_eager_fallback(tensor, name, ctx): 

2259 _attr_T, (tensor,) = _execute.args_to_matching_eager([tensor], ctx, []) 

2260 _inputs_flat = [tensor] 

2261 _attrs = ("T", _attr_T) 

2262 _result = _execute.execute(b"SerializeTensor", 1, inputs=_inputs_flat, 

2263 attrs=_attrs, ctx=ctx, name=name) 

2264 if _execute.must_record_gradient(): 

2265 _execute.record_gradient( 

2266 "SerializeTensor", _inputs_flat, _attrs, _result) 

2267 _result, = _result 

2268 return _result 

2269 

2270 

2271def string_to_number(string_tensor, out_type=_dtypes.float32, name=None): 

2272 r"""Converts each string in the input Tensor to the specified numeric type. 

2273 

2274 (Note that int32 overflow results in an error while float overflow 

2275 results in a rounded value.) 

2276 

2277 Example: 

2278 

2279 >>> strings = ["5.0", "3.0", "7.0"] 

2280 >>> tf.strings.to_number(strings) 

2281 <tf.Tensor: shape=(3,), dtype=float32, numpy=array([5., 3., 7.], dtype=float32)> 

2282 

2283 Args: 

2284 string_tensor: A `Tensor` of type `string`. 

2285 out_type: An optional `tf.DType` from: `tf.float32, tf.float64, tf.int32, tf.int64`. Defaults to `tf.float32`. 

2286 The numeric type to interpret each string in `string_tensor` as. 

2287 name: A name for the operation (optional). 

2288 

2289 Returns: 

2290 A `Tensor` of type `out_type`. 

2291 """ 

2292 _ctx = _context._context or _context.context() 

2293 tld = _ctx._thread_local_data 

2294 if tld.is_eager: 

2295 try: 

2296 _result = pywrap_tfe.TFE_Py_FastPathExecute( 

2297 _ctx, "StringToNumber", name, string_tensor, "out_type", out_type) 

2298 return _result 

2299 except _core._NotOkStatusException as e: 

2300 _ops.raise_from_not_ok_status(e, name) 

2301 except _core._FallbackException: 

2302 pass 

2303 try: 

2304 return string_to_number_eager_fallback( 

2305 string_tensor, out_type=out_type, name=name, ctx=_ctx) 

2306 except _core._SymbolicException: 

2307 pass # Add nodes to the TensorFlow graph. 

2308 # Add nodes to the TensorFlow graph. 

2309 if out_type is None: 

2310 out_type = _dtypes.float32 

2311 out_type = _execute.make_type(out_type, "out_type") 

2312 _, _, _op, _outputs = _op_def_library._apply_op_helper( 

2313 "StringToNumber", string_tensor=string_tensor, out_type=out_type, 

2314 name=name) 

2315 _result = _outputs[:] 

2316 if _execute.must_record_gradient(): 

2317 _attrs = ("out_type", _op._get_attr_type("out_type")) 

2318 _inputs_flat = _op.inputs 

2319 _execute.record_gradient( 

2320 "StringToNumber", _inputs_flat, _attrs, _result) 

2321 _result, = _result 

2322 return _result 

2323 

2324StringToNumber = tf_export("raw_ops.StringToNumber")(_ops.to_raw_op(string_to_number)) 

2325 

2326 

2327def string_to_number_eager_fallback(string_tensor, out_type, name, ctx): 

2328 if out_type is None: 

2329 out_type = _dtypes.float32 

2330 out_type = _execute.make_type(out_type, "out_type") 

2331 string_tensor = _ops.convert_to_tensor(string_tensor, _dtypes.string) 

2332 _inputs_flat = [string_tensor] 

2333 _attrs = ("out_type", out_type) 

2334 _result = _execute.execute(b"StringToNumber", 1, inputs=_inputs_flat, 

2335 attrs=_attrs, ctx=ctx, name=name) 

2336 if _execute.must_record_gradient(): 

2337 _execute.record_gradient( 

2338 "StringToNumber", _inputs_flat, _attrs, _result) 

2339 _result, = _result 

2340 return _result 

2341