Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes for bare-column and column generators as inputs
1) Passing a single feature column (not wrapped in a list) should succeed, or fail clearly (In this change I wrap it in a list so it succeeds) Currently, since concrete `_FeatureColumn` classes are iterable (inherit from named_tuple), the code attempts to interpret the _FeatureColumn object as a list of feature columns. This can give confusing errors: fc.input_layer({'a':[1]},fc.numeric_column('a')) ValueError: Items of feature_columns must be a _FeatureColumn. Given (type <class 'str'>): a. fc.input_layer( {'a':[1]}, fc.indicator_column( fc.categorical_column_with_identity('a', 100))) ValueError: Items of feature_columns must be a _DenseColumn. You can wrap a categorical column with an embedding_column or indicator_column. Given: _IdentityCategoricalColumn(key='a', num_buckets=100, default_value=None) 2) Passing an `iterator` should fail, or convert it to a list (so it can be iterated multiple times). In this change I convert it to a list Currently it throws an unclear error: features = {'a':[1],'b':[2]} columns = (fc.numeric_column(key) for key in features) fc.input_layer(features,columns) ValueError: List argument 'values' to 'ConcatV2' Op with length 0 shorter than minimum length 2. PiperOrigin-RevId: 169314383
- Loading branch information