Errors/Warnings in 37th code module of handling_sparse_features.ipynb
See original GitHub issueHi,
Was just trying to follow through the Colab demo, but got the following error when running the 37th code module (the second one after “Train and evaluate the ranker”). Any idea what’s up?
INFO:tensorflow:Using config: {‘_save_checkpoints_secs’: None, ‘_num_ps_replicas’: 0, ‘_keep_checkpoint_max’: 5, ‘_task_type’: ‘worker’, ‘_global_id_in_cluster’: 0, ‘_is_chief’: True, ‘_cluster_spec’: ClusterSpec({}), ‘_model_dir’: ‘/tmp/ranking_model_dir’, ‘_protocol’: None, ‘_save_checkpoints_steps’: 1000, ‘_keep_checkpoint_every_n_hours’: 10000, ‘_service’: None, ‘_session_config’: allow_soft_placement: true graph_options { rewrite_options { meta_optimizer_iterations: ONE } } , ‘_tf_random_seed’: None, ‘_save_summary_steps’: 100, ‘_device_fn’: None, ‘_session_creation_timeout_secs’: 7200, ‘_experimental_distribute’: None, ‘_num_worker_replicas’: 1, ‘_task_id’: 0, ‘_log_step_count_steps’: 100, ‘_experimental_max_worker_delay_secs’: None, ‘_evaluation_master’: ‘’, ‘_eval_distribute’: None, ‘_train_distribute’: None, ‘_master’: ‘’} WARNING:tensorflow:Estimator’s model_fn (<function _model_fn at 0x7f47e055ecd0>) includes params argument, but params are not passed to Estimator. INFO:tensorflow:Not using Distribute Coordinator. INFO:tensorflow:Running training and evaluation locally (non-distributed). INFO:tensorflow:Start train and evaluate loop. The evaluate will happen after every checkpoint. Checkpoint frequency is determined based on RunConfig arguments: save_checkpoints_steps 1000 or save_checkpoints_secs None. INFO:tensorflow:vocabulary_size = 30522 in query_tokens is inferred from the number of elements in the vocabulary_file /tmp/vocab.txt. INFO:tensorflow:vocabulary_size = 30522 in document_tokens is inferred from the number of elements in the vocabulary_file /tmp/vocab.txt.
AttributeErrorTraceback (most recent call last) <ipython-input-37-b3402df51ce6> in <module>() 1 get_ipython().system(u’ rm -rf “/tmp/ranking_model_dir” # Clean up the model directory.') 2 ranker, train_spec, eval_spec = train_and_eval_fn() ----> 3 tf.estimator.train_and_evaluate(ranker, train_spec, eval_spec)
11 frames /tensorflow-2.1.0/python2.7/tensorflow_estimator/python/estimator/training.pyc in train_and_evaluate(estimator, train_spec, eval_spec) 471 ‘(with task id 0). Given task id {}’.format(config.task_id)) 472 –> 473 return executor.run() 474 475
/tensorflow-2.1.0/python2.7/tensorflow_estimator/python/estimator/training.pyc in run(self) 611 config.task_type != run_config_lib.TaskType.EVALUATOR): 612 logging.info(‘Running training and evaluation locally (non-distributed).’) –> 613 return self.run_local() 614 615 # Distributed case.
/tensorflow-2.1.0/python2.7/tensorflow_estimator/python/estimator/training.pyc in run_local(self) 712 max_steps=self._train_spec.max_steps, 713 hooks=train_hooks, –> 714 saving_listeners=saving_listeners) 715 716 eval_result = listener_for_eval.eval_result or _EvalResult(
/tensorflow-2.1.0/python2.7/tensorflow_estimator/python/estimator/estimator.pyc in train(self, input_fn, hooks, steps, max_steps, saving_listeners) 372 373 saving_listeners = _check_listeners_type(saving_listeners) –> 374 loss = self._train_model(input_fn, hooks, saving_listeners) 375 logging.info(‘Loss for final step: %s.’, loss) 376 return self
/tensorflow-2.1.0/python2.7/tensorflow_estimator/python/estimator/estimator.pyc in _train_model(self, input_fn, hooks, saving_listeners) 1162 return self._train_model_distributed(input_fn, hooks, saving_listeners) 1163 else: -> 1164 return self._train_model_default(input_fn, hooks, saving_listeners) 1165 1166 def _train_model_default(self, input_fn, hooks, saving_listeners):
/tensorflow-2.1.0/python2.7/tensorflow_estimator/python/estimator/estimator.pyc in _train_model_default(self, input_fn, hooks, saving_listeners) 1189 features, labels, input_hooks = ( 1190 self._get_features_and_labels_from_input_fn( -> 1191 input_fn, ModeKeys.TRAIN)) 1192 worker_hooks.extend(input_hooks) 1193 estimator_spec = self._call_model_fn(
/tensorflow-2.1.0/python2.7/tensorflow_estimator/python/estimator/estimator.pyc in _get_features_and_labels_from_input_fn(self, input_fn, mode)
1026 “”“Extracts the features and labels from return values of input_fn.”“”
1027 return estimator_util.parse_input_fn_result(
-> 1028 self._call_input_fn(input_fn, mode))
1029
1030 def _extract_batch_length(self, preds_evaluated):
/tensorflow-2.1.0/python2.7/tensorflow_estimator/python/estimator/estimator.pyc in _call_input_fn(self, input_fn, mode, input_context) 1117 kwargs[‘input_context’] = input_context 1118 with ops.device(‘/cpu:0’): -> 1119 return input_fn(**kwargs) 1120 1121 def _call_model_fn(self, features, labels, mode, config):
<ipython-input-36-7118f3d7a5f0> in <lambda>() 8 config=run_config) 9 —> 10 train_input_fn = lambda: input_fn(_TRAIN_DATA_PATH) 11 eval_input_fn = lambda: input_fn(_TEST_DATA_PATH, num_epochs=1) 12
<ipython-input-29-c4fcf018fedc> in input_fn(path, num_epochs) 15 reader=tf.data.TFRecordDataset, 16 shuffle=False, —> 17 num_epochs=num_epochs) 18 features = tf.compat.v1.data.make_one_shot_iterator(dataset).get_next() 19 label = tf.squeeze(features.pop(_LABEL_FEATURE), axis=2)
/usr/local/lib/python2.7/dist-packages/tensorflow_ranking/python/data.pyc in build_ranking_dataset(file_pattern, data_format, batch_size, context_feature_spec, example_feature_spec, list_size, **kwargs) 848 example_feature_spec) 849 return build_ranking_dataset_with_parsing_fn( –> 850 file_pattern, parsing_fn=parsing_fn, batch_size=batch_size, **kwargs) 851 852
/usr/local/lib/python2.7/dist-packages/tensorflow_ranking/python/data.pyc in build_ranking_dataset_with_parsing_fn(file_pattern, parsing_fn, batch_size, reader, reader_args, num_epochs, shuffle, shuffle_buffer_size, shuffle_seed, prefetch_buffer_size, reader_num_threads, sloppy_ordering, drop_final_batch, num_parser_threads) 801 # Extract values if tensors are stored as key-value tuples. This happens when 802 # the reader is tf.data.SSTableDataset. –> 803 if dataset.output_types == (tf.string, tf.string): 804 dataset = dataset.map(lambda _, v: v) 805
AttributeError: ‘ParallelInterleaveDataset’ object has no attribute ‘output_types’
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)

Top Related StackOverflow Question
Thanks for pointing out the issue. The demo works now. The issue is due to some deprecated logic in TF 2.1.0 w.r…t TF 2.0.0.
I’ve set a static tensorflow version in the demo code (2.0.0).
I will send out follow up fixes for TF 2.1.0.
Thanks so much!