Read example from tfds and constructed named tensor inputs.
(example)
| 378 | metadata) |
| 379 | |
| 380 | def encode_map_fn(example): |
| 381 | """Read example from tfds and constructed named tensor inputs.""" |
| 382 | tensors = tf.py_function( |
| 383 | encode, |
| 384 | inp=[ |
| 385 | example['claim_text'], example['evidence_text'], |
| 386 | example['claim_label'], example['evidence_label'], |
| 387 | example['metadata'], example['wikipedia_url'], |
| 388 | example['sentence_id'] |
| 389 | ], |
| 390 | Tout=(tf.int64, tf.int64, tf.int64, tf.int64, tf.string)) |
| 391 | # Keras expects (x, y), where x can be a dictionary. |
| 392 | x = { |
| 393 | 'claim_text': tensors[0], |
| 394 | 'evidence_text': tensors[1], |
| 395 | 'claim_label': tensors[2], |
| 396 | 'evidence_label': tensors[3], |
| 397 | 'metadata': tensors[4] |
| 398 | } |
| 399 | y = {'claim_classification': tensors[2], 'evidence_matching': tensors[3]} |
| 400 | return x, y |
| 401 | |
| 402 | return encode_map_fn |
| 403 |
nothing calls this directly
no outgoing calls
no test coverage detected