tf-estimator-tutorials
tf-estimator-tutorials copied to clipboard
Getting ValueError while running Regression Estimator - Training process
Hi,
I made my learning in Collab. I have used Tensorflow 1.15 Version.
I have followed https://github.com/ksalama/tf-estimator-tutorials/blob/master/01%20-%20Regression/01.0%20-%20Regression%20Data%20Generation.ipynb
Nextly , this script https://github.com/ksalama/tf-estimator-tutorials/blob/master/01%20-%20Regression/02.0%20-%20TF%20Regression%20Model%20-%20Estimator%20APIs%20%2B%20Pandas.ipynb
While running the section 5. Train the Estimator
, and the line estimator.train(input_fn = train_input_fn)
I got error as
INFO:tensorflow:Calling model_fn.
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-67-d2bca762b908> in <module>()
----> 1 estimator.train(input_fn = train_input_fn)
10 frames
/tensorflow-1.15.2/python3.6/tensorflow_estimator/python/estimator/estimator.py in train(self, input_fn, hooks, steps, max_steps, saving_listeners)
368
369 saving_listeners = _check_listeners_type(saving_listeners)
--> 370 loss = self._train_model(input_fn, hooks, saving_listeners)
371 logging.info('Loss for final step: %s.', loss)
372 return self
/tensorflow-1.15.2/python3.6/tensorflow_estimator/python/estimator/estimator.py in _train_model(self, input_fn, hooks, saving_listeners)
1159 return self._train_model_distributed(input_fn, hooks, saving_listeners)
1160 else:
-> 1161 return self._train_model_default(input_fn, hooks, saving_listeners)
1162
1163 def _train_model_default(self, input_fn, hooks, saving_listeners):
/tensorflow-1.15.2/python3.6/tensorflow_estimator/python/estimator/estimator.py in _train_model_default(self, input_fn, hooks, saving_listeners)
1189 worker_hooks.extend(input_hooks)
1190 estimator_spec = self._call_model_fn(
-> 1191 features, labels, ModeKeys.TRAIN, self.config)
1192 global_step_tensor = training_util.get_global_step(g)
1193 return self._train_with_estimator_spec(estimator_spec, worker_hooks,
/tensorflow-1.15.2/python3.6/tensorflow_estimator/python/estimator/estimator.py in _call_model_fn(self, features, labels, mode, config)
1147
1148 logging.info('Calling model_fn.')
-> 1149 model_fn_results = self._model_fn(features=features, **kwargs)
1150 logging.info('Done calling model_fn.')
1151
/tensorflow-1.15.2/python3.6/tensorflow_estimator/python/estimator/canned/dnn.py in _model_fn(features, labels, mode, config)
1212 input_layer_partitioner=input_layer_partitioner,
1213 config=config,
-> 1214 batch_norm=batch_norm)
1215
1216 super(DNNRegressor, self).__init__(
/tensorflow-1.15.2/python3.6/tensorflow_estimator/python/estimator/canned/dnn.py in _dnn_model_fn(features, labels, mode, head, hidden_units, feature_columns, optimizer, activation_fn, dropout, input_layer_partitioner, config, use_tpu, batch_norm)
461 input_layer_partitioner=input_layer_partitioner,
462 batch_norm=batch_norm)
--> 463 logits = logit_fn(features=features, mode=mode)
464
465 return _get_dnn_estimator_spec(use_tpu, head, features, labels, mode,
/tensorflow-1.15.2/python3.6/tensorflow_estimator/python/estimator/canned/dnn.py in dnn_logit_fn(features, mode)
106 input_layer_partitioner,
107 batch_norm,
--> 108 name='dnn')
109 return dnn_model(features, mode)
110
/tensorflow-1.15.2/python3.6/tensorflow_estimator/python/estimator/canned/dnn.py in __init__(self, units, hidden_units, feature_columns, activation_fn, dropout, input_layer_partitioner, batch_norm, name, **kwargs)
184 if feature_column_lib.is_feature_column_v2(feature_columns):
185 self._input_layer = dense_features.DenseFeatures(
--> 186 feature_columns=feature_columns, name='input_layer')
187 else:
188 self._input_layer = feature_column.InputLayer(
/tensorflow-1.15.2/python3.6/tensorflow_core/python/feature_column/dense_features.py in __init__(self, feature_columns, trainable, name, **kwargs)
84 name=name,
85 expected_column_type=fc.DenseColumn,
---> 86 **kwargs)
87
88 @property
/tensorflow-1.15.2/python3.6/tensorflow_core/python/feature_column/feature_column_v2.py in __init__(self, feature_columns, expected_column_type, trainable, name, **kwargs)
370 super(_BaseFeaturesLayer, self).__init__(
371 name=name, trainable=trainable, **kwargs)
--> 372 self._feature_columns = _normalize_feature_columns(feature_columns)
373 self._state_manager = _StateManagerImpl(self, self.trainable)
374 for column in self._feature_columns:
/tensorflow-1.15.2/python3.6/tensorflow_core/python/feature_column/feature_column_v2.py in _normalize_feature_columns(feature_columns)
2727 'Given (type {}): {}.'.format(type(column), column))
2728 if not feature_columns:
-> 2729 raise ValueError('feature_columns must not be empty.')
2730 name_to_column = {}
2731 for column in feature_columns:
ValueError: feature_columns must not be empty.
Can you please guide on how to debug this issue.