Issue seen in :Coursera | Online Courses & Credentials From Top Educators. Join for Free | Coursera
Error:---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[47], line 3
1 # test your function
2 tf.random.set_seed(1)
----> 3 dataset = create_batch_dataset(train_lines[1:100], vocab, seq_length=16, batch_size=2)
5 print("Prints the elements into a single batch. The batch contains 2 elements: ")
7 for input_example, target_example in dataset.take(1):
Cell In[46], line 33, in create_batch_dataset(lines, vocab, seq_length, batch_size)
31 data_generator = ids_dataset.batch(seq_length + 1, drop_remainder=True)
32 # Map each input sample using the split_input_target function
â> 33 dataset_xy = data_generator.map(split_input_target(single_line_data))
35 # Assemble the final dataset with shuffling, batching, and prefetching
36 dataset = (
37 dataset_xy
38 .shuffle(BUFFER_SIZE)
39 .batch(batch_size, drop_remainder=True)
40 .prefetch(tf.data.experimental.AUTOTUNE)
41 )
File /usr/local/lib/python3.8/dist-packages/tensorflow/python/data/ops/dataset_ops.py:2278, in DatasetV2.map(self, map_func, num_parallel_calls, deterministic, name)
2274 # Loaded lazily due to a circular dependency (dataset_ops â map_op â
2275 # dataset_ops).
2276 # pylint: disable=g-import-not-at-top,protected-access
2277 from tensorflow.python.data.ops import map_op
â 2278 return map_op._map_v2(
2279 self,
2280 map_func,
2281 num_parallel_calls=num_parallel_calls,
2282 deterministic=deterministic,
2283 name=name)
File /usr/local/lib/python3.8/dist-packages/tensorflow/python/data/ops/map_op.py:37, in _map_v2(input_dataset, map_func, num_parallel_calls, deterministic, name)
34 if deterministic is not None and not debug_mode.DEBUG_MODE:
35 warnings.warn("The deterministic
argument has no effect unless the "
36 ânum_parallel_calls
argument is specified.â)
â> 37 return _MapDataset(
38 input_dataset, map_func, preserve_cardinality=True, name=name)
39 else:
40 return _ParallelMapDataset(
41 input_dataset,
42 map_func,
(âŚ)
45 preserve_cardinality=True,
46 name=name)
File /usr/local/lib/python3.8/dist-packages/tensorflow/python/data/ops/map_op.py:107, in _MapDataset.init(self, input_dataset, map_func, use_inter_op_parallelism, preserve_cardinality, use_legacy_function, name)
105 self._use_inter_op_parallelism = use_inter_op_parallelism
106 self._preserve_cardinality = preserve_cardinality
â 107 self._map_func = structured_function.StructuredFunctionWrapper(
108 map_func,
109 self._transformation_name(),
110 dataset=input_dataset,
111 use_legacy_function=use_legacy_function)
112 self._name = name
113 variant_tensor = gen_dataset_ops.map_dataset(
114 input_dataset._variant_tensor, # pylint: disable=protected-access
115 self._map_func.function.captured_inputs,
(âŚ)
118 preserve_cardinality=self._preserve_cardinality,
119 **self._common_args)
File /usr/local/lib/python3.8/dist-packages/tensorflow/python/data/ops/structured_function.py:154, in StructuredFunctionWrapper.init(self, func, transformation_name, dataset, input_classes, input_shapes, input_types, input_structure, add_to_graph, use_legacy_function, defun_kwargs)
147 defun_kwargs = {}
149 readable_transformation_name = transformation_name.replace(
150 â.â, â")[:-2] if len(transformation_name) > 2 else ââ
152 func_name = "â.join(
153 [readable_transformation_name,
â 154 function_utils.get_func_name(func)])
155 # Sanitize function name to remove symbols that interfere with graph
156 # construction.
157 for symbol in [â<â, â>â, â\â, â'â, " "]:
File /usr/local/lib/python3.8/dist-packages/tensorflow/python/util/function_utils.py:97, in get_func_name(func)
95 return str(type(func))
96 else:
â> 97 raise ValueError(
98 âArgument func
must be a callable. â
99 fâReceived func={func} (of type {type(func)})â)
I know I am making some error with the input passedâŚAny pointersâŚ