InvalidArgumentError Traceback (most recent call last)
Cell In[33], line 2
1 # Test your function
----> 2 w1_unittest.test_line_to_tensor(line_to_tensor)
File /tf/w1_unittest.py:21, in test_line_to_tensor(target)
18 assert tf.math.reduce_all(tf.equal(ids, [3, 2, 3, 2, 3, 3, 3, 2])), f"Unit test 1 failed. "
20 line = “123”
—> 21 ids = target(line, vocab)
22 assert tf.is_tensor(ids), f"Wrong type, your function must return a Tensor"
23 assert len(ids) == len(line), f"Wrong length. Expected: {len(line)} but got {len(ids)}"
Cell In[31], line 22, in line_to_tensor(line, vocab)
19 chars = list(line)
21 # Map characters to their respective integer values using the lookup table
—> 22 ids = vocab_table(chars)
24 return ids
File /usr/local/lib/python3.8/dist-packages/keras/src/utils/traceback_utils.py:70, in filter_traceback..error_handler(*args, **kwargs)
67 filtered_tb = _process_traceback_frames(e.traceback)
68 # To get the full stack trace, call:
69 # tf.debugging.disable_traceback_filtering()
—> 70 raise e.with_traceback(filtered_tb) from None
71 finally:
72 del filtered_tb
File /usr/local/lib/python3.8/dist-packages/tensorflow/python/ops/control_flow_assert.py:102, in Assert(condition, data, summarize, name)
100 xs = ops.convert_n_to_tensor(data)
101 data_str = [_summarize_eager(x, summarize) for x in xs]
→ 102 raise errors.InvalidArgumentError(
103 node_def=None,
104 op=None,
105 message="Expected ‘%s’ to be true. Summarized data: s"
106 (condition, “\n”.join(data_str)))
107 return
109 with ops.name_scope(name, “Assert”, [condition, data]) as name:
InvalidArgumentError: Exception encountered when calling layer ‘string_lookup_22’ (type StringLookup).
Expected ‘tf.Tensor(False, shape=(), dtype=bool)’ to be true. Summarized data: b’When num_oov_indices=0 all inputs should be in vocabulary, found OOV values [“2” “3”], consider setting num_oov_indices=1.’
Call arguments received by layer ‘string_lookup_22’ (type StringLookup):
• inputs=[“‘1’”, “‘2’”, “‘3’”]
