Type feature_column
Namespace tensorflow.contrib.feature_column
Methods
- concatenate_context_input
- concatenate_context_input_dyn
- sequence_categorical_column_with_hash_bucket
- sequence_categorical_column_with_hash_bucket
- sequence_categorical_column_with_hash_bucket
- sequence_categorical_column_with_hash_bucket_dyn
- sequence_categorical_column_with_identity
- sequence_categorical_column_with_identity
- sequence_categorical_column_with_identity
- sequence_categorical_column_with_identity_dyn
- sequence_categorical_column_with_vocabulary_file
- sequence_categorical_column_with_vocabulary_file
- sequence_categorical_column_with_vocabulary_file
- sequence_categorical_column_with_vocabulary_file_dyn
- sequence_categorical_column_with_vocabulary_list
- sequence_categorical_column_with_vocabulary_list
- sequence_categorical_column_with_vocabulary_list
- sequence_categorical_column_with_vocabulary_list_dyn
- sequence_input_layer
- sequence_input_layer_dyn
- sequence_numeric_column
- sequence_numeric_column
- sequence_numeric_column_dyn
Properties
- _SequenceNumericColumn_fn
- concatenate_context_input_fn
- sequence_categorical_column_with_hash_bucket_fn
- sequence_categorical_column_with_identity_fn
- sequence_categorical_column_with_vocabulary_file_fn
- sequence_categorical_column_with_vocabulary_list_fn
- sequence_input_layer_fn
- sequence_numeric_column_fn
Public static methods
Tensor concatenate_context_input(IGraphNodeBase context_input, IGraphNodeBase sequence_input)
object concatenate_context_input_dyn(object context_input, object sequence_input)
_SequenceCategoricalColumn sequence_categorical_column_with_hash_bucket(string key, IEnumerable<object> hash_bucket_size, ImplicitContainer<T> dtype)
A sequence of categorical terms where ids are set by hashing. Pass this to `embedding_column` or `indicator_column` to convert sequence
categorical data into dense representation for input to sequence NN, such as
RNN. Example:
Parameters
-
string
key - A unique string identifying the input feature.
-
IEnumerable<object>
hash_bucket_size - An int > 1. The number of buckets.
-
ImplicitContainer<T>
dtype - The type of features. Only string and integer types are supported.
Returns
-
_SequenceCategoricalColumn
- A `SequenceCategoricalColumn`.
Show Example
tokens = sequence_categorical_column_with_hash_bucket( 'tokens', hash_bucket_size=1000) tokens_embedding = embedding_column(tokens, dimension=10) columns = [tokens_embedding] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
_SequenceCategoricalColumn sequence_categorical_column_with_hash_bucket(string key, string hash_bucket_size, ImplicitContainer<T> dtype)
A sequence of categorical terms where ids are set by hashing. Pass this to `embedding_column` or `indicator_column` to convert sequence
categorical data into dense representation for input to sequence NN, such as
RNN. Example:
Parameters
-
string
key - A unique string identifying the input feature.
-
string
hash_bucket_size - An int > 1. The number of buckets.
-
ImplicitContainer<T>
dtype - The type of features. Only string and integer types are supported.
Returns
-
_SequenceCategoricalColumn
- A `SequenceCategoricalColumn`.
Show Example
tokens = sequence_categorical_column_with_hash_bucket( 'tokens', hash_bucket_size=1000) tokens_embedding = embedding_column(tokens, dimension=10) columns = [tokens_embedding] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
_SequenceCategoricalColumn sequence_categorical_column_with_hash_bucket(string key, int hash_bucket_size, ImplicitContainer<T> dtype)
A sequence of categorical terms where ids are set by hashing. Pass this to `embedding_column` or `indicator_column` to convert sequence
categorical data into dense representation for input to sequence NN, such as
RNN. Example:
Parameters
-
string
key - A unique string identifying the input feature.
-
int
hash_bucket_size - An int > 1. The number of buckets.
-
ImplicitContainer<T>
dtype - The type of features. Only string and integer types are supported.
Returns
-
_SequenceCategoricalColumn
- A `SequenceCategoricalColumn`.
Show Example
tokens = sequence_categorical_column_with_hash_bucket( 'tokens', hash_bucket_size=1000) tokens_embedding = embedding_column(tokens, dimension=10) columns = [tokens_embedding] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
object sequence_categorical_column_with_hash_bucket_dyn(object key, object hash_bucket_size, ImplicitContainer<T> dtype)
A sequence of categorical terms where ids are set by hashing. Pass this to `embedding_column` or `indicator_column` to convert sequence
categorical data into dense representation for input to sequence NN, such as
RNN. Example:
Parameters
-
object
key - A unique string identifying the input feature.
-
object
hash_bucket_size - An int > 1. The number of buckets.
-
ImplicitContainer<T>
dtype - The type of features. Only string and integer types are supported.
Returns
-
object
- A `SequenceCategoricalColumn`.
Show Example
tokens = sequence_categorical_column_with_hash_bucket( 'tokens', hash_bucket_size=1000) tokens_embedding = embedding_column(tokens, dimension=10) columns = [tokens_embedding] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
_SequenceCategoricalColumn sequence_categorical_column_with_identity(string key, string num_buckets, object default_value)
Returns a feature column that represents sequences of integers. Pass this to `embedding_column` or `indicator_column` to convert sequence
categorical data into dense representation for input to sequence NN, such as
RNN. Example:
Parameters
-
string
key - A unique string identifying the input feature.
-
string
num_buckets - Range of inputs. Namely, inputs are expected to be in the range `[0, num_buckets)`.
-
object
default_value - If `None`, this column's graph operations will fail for out-of-range inputs. Otherwise, this value must be in the range `[0, num_buckets)`, and will replace out-of-range inputs.
Returns
-
_SequenceCategoricalColumn
- A `SequenceCategoricalColumn`.
Show Example
watches = sequence_categorical_column_with_identity( 'watches', num_buckets=1000) watches_embedding = embedding_column(watches, dimension=10) columns = [watches_embedding] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
_SequenceCategoricalColumn sequence_categorical_column_with_identity(string key, IEnumerable<object> num_buckets, object default_value)
Returns a feature column that represents sequences of integers. Pass this to `embedding_column` or `indicator_column` to convert sequence
categorical data into dense representation for input to sequence NN, such as
RNN. Example:
Parameters
-
string
key - A unique string identifying the input feature.
-
IEnumerable<object>
num_buckets - Range of inputs. Namely, inputs are expected to be in the range `[0, num_buckets)`.
-
object
default_value - If `None`, this column's graph operations will fail for out-of-range inputs. Otherwise, this value must be in the range `[0, num_buckets)`, and will replace out-of-range inputs.
Returns
-
_SequenceCategoricalColumn
- A `SequenceCategoricalColumn`.
Show Example
watches = sequence_categorical_column_with_identity( 'watches', num_buckets=1000) watches_embedding = embedding_column(watches, dimension=10) columns = [watches_embedding] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
_SequenceCategoricalColumn sequence_categorical_column_with_identity(string key, int num_buckets, object default_value)
Returns a feature column that represents sequences of integers. Pass this to `embedding_column` or `indicator_column` to convert sequence
categorical data into dense representation for input to sequence NN, such as
RNN. Example:
Parameters
-
string
key - A unique string identifying the input feature.
-
int
num_buckets - Range of inputs. Namely, inputs are expected to be in the range `[0, num_buckets)`.
-
object
default_value - If `None`, this column's graph operations will fail for out-of-range inputs. Otherwise, this value must be in the range `[0, num_buckets)`, and will replace out-of-range inputs.
Returns
-
_SequenceCategoricalColumn
- A `SequenceCategoricalColumn`.
Show Example
watches = sequence_categorical_column_with_identity( 'watches', num_buckets=1000) watches_embedding = embedding_column(watches, dimension=10) columns = [watches_embedding] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
object sequence_categorical_column_with_identity_dyn(object key, object num_buckets, object default_value)
Returns a feature column that represents sequences of integers. Pass this to `embedding_column` or `indicator_column` to convert sequence
categorical data into dense representation for input to sequence NN, such as
RNN. Example:
Parameters
-
object
key - A unique string identifying the input feature.
-
object
num_buckets - Range of inputs. Namely, inputs are expected to be in the range `[0, num_buckets)`.
-
object
default_value - If `None`, this column's graph operations will fail for out-of-range inputs. Otherwise, this value must be in the range `[0, num_buckets)`, and will replace out-of-range inputs.
Returns
-
object
- A `SequenceCategoricalColumn`.
Show Example
watches = sequence_categorical_column_with_identity( 'watches', num_buckets=1000) watches_embedding = embedding_column(watches, dimension=10) columns = [watches_embedding] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
_SequenceCategoricalColumn sequence_categorical_column_with_vocabulary_file(string key, IEnumerable<object> vocabulary_file, Nullable<int> vocabulary_size, int num_oov_buckets, object default_value, ImplicitContainer<T> dtype)
A sequence of categorical terms where ids use a vocabulary file. Pass this to `embedding_column` or `indicator_column` to convert sequence
categorical data into dense representation for input to sequence NN, such as
RNN. Example:
Parameters
-
string
key - A unique string identifying the input feature.
-
IEnumerable<object>
vocabulary_file - The vocabulary file name.
-
Nullable<int>
vocabulary_size - Number of the elements in the vocabulary. This must be no greater than length of `vocabulary_file`, if less than length, later values are ignored. If None, it is set to the length of `vocabulary_file`.
-
int
num_oov_buckets - Non-negative integer, the number of out-of-vocabulary buckets. All out-of-vocabulary inputs will be assigned IDs in the range `[vocabulary_size, vocabulary_size+num_oov_buckets)` based on a hash of the input value. A positive `num_oov_buckets` can not be specified with `default_value`.
-
object
default_value - The integer ID value to return for out-of-vocabulary feature values, defaults to `-1`. This can not be specified with a positive `num_oov_buckets`.
-
ImplicitContainer<T>
dtype - The type of features. Only string and integer types are supported.
Returns
-
_SequenceCategoricalColumn
- A `SequenceCategoricalColumn`.
Show Example
states = sequence_categorical_column_with_vocabulary_file( key='states', vocabulary_file='/us/states.txt', vocabulary_size=50, num_oov_buckets=5) states_embedding = embedding_column(states, dimension=10) columns = [states_embedding] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
_SequenceCategoricalColumn sequence_categorical_column_with_vocabulary_file(string key, int vocabulary_file, Nullable<int> vocabulary_size, int num_oov_buckets, object default_value, ImplicitContainer<T> dtype)
A sequence of categorical terms where ids use a vocabulary file. Pass this to `embedding_column` or `indicator_column` to convert sequence
categorical data into dense representation for input to sequence NN, such as
RNN. Example:
Parameters
-
string
key - A unique string identifying the input feature.
-
int
vocabulary_file - The vocabulary file name.
-
Nullable<int>
vocabulary_size - Number of the elements in the vocabulary. This must be no greater than length of `vocabulary_file`, if less than length, later values are ignored. If None, it is set to the length of `vocabulary_file`.
-
int
num_oov_buckets - Non-negative integer, the number of out-of-vocabulary buckets. All out-of-vocabulary inputs will be assigned IDs in the range `[vocabulary_size, vocabulary_size+num_oov_buckets)` based on a hash of the input value. A positive `num_oov_buckets` can not be specified with `default_value`.
-
object
default_value - The integer ID value to return for out-of-vocabulary feature values, defaults to `-1`. This can not be specified with a positive `num_oov_buckets`.
-
ImplicitContainer<T>
dtype - The type of features. Only string and integer types are supported.
Returns
-
_SequenceCategoricalColumn
- A `SequenceCategoricalColumn`.
Show Example
states = sequence_categorical_column_with_vocabulary_file( key='states', vocabulary_file='/us/states.txt', vocabulary_size=50, num_oov_buckets=5) states_embedding = embedding_column(states, dimension=10) columns = [states_embedding] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
_SequenceCategoricalColumn sequence_categorical_column_with_vocabulary_file(string key, string vocabulary_file, Nullable<int> vocabulary_size, int num_oov_buckets, object default_value, ImplicitContainer<T> dtype)
A sequence of categorical terms where ids use a vocabulary file. Pass this to `embedding_column` or `indicator_column` to convert sequence
categorical data into dense representation for input to sequence NN, such as
RNN. Example:
Parameters
-
string
key - A unique string identifying the input feature.
-
string
vocabulary_file - The vocabulary file name.
-
Nullable<int>
vocabulary_size - Number of the elements in the vocabulary. This must be no greater than length of `vocabulary_file`, if less than length, later values are ignored. If None, it is set to the length of `vocabulary_file`.
-
int
num_oov_buckets - Non-negative integer, the number of out-of-vocabulary buckets. All out-of-vocabulary inputs will be assigned IDs in the range `[vocabulary_size, vocabulary_size+num_oov_buckets)` based on a hash of the input value. A positive `num_oov_buckets` can not be specified with `default_value`.
-
object
default_value - The integer ID value to return for out-of-vocabulary feature values, defaults to `-1`. This can not be specified with a positive `num_oov_buckets`.
-
ImplicitContainer<T>
dtype - The type of features. Only string and integer types are supported.
Returns
-
_SequenceCategoricalColumn
- A `SequenceCategoricalColumn`.
Show Example
states = sequence_categorical_column_with_vocabulary_file( key='states', vocabulary_file='/us/states.txt', vocabulary_size=50, num_oov_buckets=5) states_embedding = embedding_column(states, dimension=10) columns = [states_embedding] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
object sequence_categorical_column_with_vocabulary_file_dyn(object key, object vocabulary_file, object vocabulary_size, ImplicitContainer<T> num_oov_buckets, object default_value, ImplicitContainer<T> dtype)
A sequence of categorical terms where ids use a vocabulary file. Pass this to `embedding_column` or `indicator_column` to convert sequence
categorical data into dense representation for input to sequence NN, such as
RNN. Example:
Parameters
-
object
key - A unique string identifying the input feature.
-
object
vocabulary_file - The vocabulary file name.
-
object
vocabulary_size - Number of the elements in the vocabulary. This must be no greater than length of `vocabulary_file`, if less than length, later values are ignored. If None, it is set to the length of `vocabulary_file`.
-
ImplicitContainer<T>
num_oov_buckets - Non-negative integer, the number of out-of-vocabulary buckets. All out-of-vocabulary inputs will be assigned IDs in the range `[vocabulary_size, vocabulary_size+num_oov_buckets)` based on a hash of the input value. A positive `num_oov_buckets` can not be specified with `default_value`.
-
object
default_value - The integer ID value to return for out-of-vocabulary feature values, defaults to `-1`. This can not be specified with a positive `num_oov_buckets`.
-
ImplicitContainer<T>
dtype - The type of features. Only string and integer types are supported.
Returns
-
object
- A `SequenceCategoricalColumn`.
Show Example
states = sequence_categorical_column_with_vocabulary_file( key='states', vocabulary_file='/us/states.txt', vocabulary_size=50, num_oov_buckets=5) states_embedding = embedding_column(states, dimension=10) columns = [states_embedding] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
_SequenceCategoricalColumn sequence_categorical_column_with_vocabulary_list(string key, IEnumerable<object> vocabulary_list, DType dtype, int default_value, int num_oov_buckets)
A sequence of categorical terms where ids use an in-memory list. Pass this to `embedding_column` or `indicator_column` to convert sequence
categorical data into dense representation for input to sequence NN, such as
RNN. Example:
Parameters
-
string
key - A unique string identifying the input feature.
-
IEnumerable<object>
vocabulary_list - An ordered iterable defining the vocabulary. Each feature is mapped to the index of its value (if present) in `vocabulary_list`. Must be castable to `dtype`.
-
DType
dtype - The type of features. Only string and integer types are supported. If `None`, it will be inferred from `vocabulary_list`.
-
int
default_value - The integer ID value to return for out-of-vocabulary feature values, defaults to `-1`. This can not be specified with a positive `num_oov_buckets`.
-
int
num_oov_buckets - Non-negative integer, the number of out-of-vocabulary buckets. All out-of-vocabulary inputs will be assigned IDs in the range `[len(vocabulary_list), len(vocabulary_list)+num_oov_buckets)` based on a hash of the input value. A positive `num_oov_buckets` can not be specified with `default_value`.
Returns
-
_SequenceCategoricalColumn
- A `SequenceCategoricalColumn`.
Show Example
colors = sequence_categorical_column_with_vocabulary_list( key='colors', vocabulary_list=('R', 'G', 'B', 'Y'), num_oov_buckets=2) colors_embedding = embedding_column(colors, dimension=3) columns = [colors_embedding] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
_SequenceCategoricalColumn sequence_categorical_column_with_vocabulary_list(string key, string vocabulary_list, DType dtype, int default_value, int num_oov_buckets)
A sequence of categorical terms where ids use an in-memory list. Pass this to `embedding_column` or `indicator_column` to convert sequence
categorical data into dense representation for input to sequence NN, such as
RNN. Example:
Parameters
-
string
key - A unique string identifying the input feature.
-
string
vocabulary_list - An ordered iterable defining the vocabulary. Each feature is mapped to the index of its value (if present) in `vocabulary_list`. Must be castable to `dtype`.
-
DType
dtype - The type of features. Only string and integer types are supported. If `None`, it will be inferred from `vocabulary_list`.
-
int
default_value - The integer ID value to return for out-of-vocabulary feature values, defaults to `-1`. This can not be specified with a positive `num_oov_buckets`.
-
int
num_oov_buckets - Non-negative integer, the number of out-of-vocabulary buckets. All out-of-vocabulary inputs will be assigned IDs in the range `[len(vocabulary_list), len(vocabulary_list)+num_oov_buckets)` based on a hash of the input value. A positive `num_oov_buckets` can not be specified with `default_value`.
Returns
-
_SequenceCategoricalColumn
- A `SequenceCategoricalColumn`.
Show Example
colors = sequence_categorical_column_with_vocabulary_list( key='colors', vocabulary_list=('R', 'G', 'B', 'Y'), num_oov_buckets=2) colors_embedding = embedding_column(colors, dimension=3) columns = [colors_embedding] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
_SequenceCategoricalColumn sequence_categorical_column_with_vocabulary_list(string key, int vocabulary_list, DType dtype, int default_value, int num_oov_buckets)
A sequence of categorical terms where ids use an in-memory list. Pass this to `embedding_column` or `indicator_column` to convert sequence
categorical data into dense representation for input to sequence NN, such as
RNN. Example:
Parameters
-
string
key - A unique string identifying the input feature.
-
int
vocabulary_list - An ordered iterable defining the vocabulary. Each feature is mapped to the index of its value (if present) in `vocabulary_list`. Must be castable to `dtype`.
-
DType
dtype - The type of features. Only string and integer types are supported. If `None`, it will be inferred from `vocabulary_list`.
-
int
default_value - The integer ID value to return for out-of-vocabulary feature values, defaults to `-1`. This can not be specified with a positive `num_oov_buckets`.
-
int
num_oov_buckets - Non-negative integer, the number of out-of-vocabulary buckets. All out-of-vocabulary inputs will be assigned IDs in the range `[len(vocabulary_list), len(vocabulary_list)+num_oov_buckets)` based on a hash of the input value. A positive `num_oov_buckets` can not be specified with `default_value`.
Returns
-
_SequenceCategoricalColumn
- A `SequenceCategoricalColumn`.
Show Example
colors = sequence_categorical_column_with_vocabulary_list( key='colors', vocabulary_list=('R', 'G', 'B', 'Y'), num_oov_buckets=2) colors_embedding = embedding_column(colors, dimension=3) columns = [colors_embedding] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
object sequence_categorical_column_with_vocabulary_list_dyn(object key, object vocabulary_list, object dtype, ImplicitContainer<T> default_value, ImplicitContainer<T> num_oov_buckets)
A sequence of categorical terms where ids use an in-memory list. Pass this to `embedding_column` or `indicator_column` to convert sequence
categorical data into dense representation for input to sequence NN, such as
RNN. Example:
Parameters
-
object
key - A unique string identifying the input feature.
-
object
vocabulary_list - An ordered iterable defining the vocabulary. Each feature is mapped to the index of its value (if present) in `vocabulary_list`. Must be castable to `dtype`.
-
object
dtype - The type of features. Only string and integer types are supported. If `None`, it will be inferred from `vocabulary_list`.
-
ImplicitContainer<T>
default_value - The integer ID value to return for out-of-vocabulary feature values, defaults to `-1`. This can not be specified with a positive `num_oov_buckets`.
-
ImplicitContainer<T>
num_oov_buckets - Non-negative integer, the number of out-of-vocabulary buckets. All out-of-vocabulary inputs will be assigned IDs in the range `[len(vocabulary_list), len(vocabulary_list)+num_oov_buckets)` based on a hash of the input value. A positive `num_oov_buckets` can not be specified with `default_value`.
Returns
-
object
- A `SequenceCategoricalColumn`.
Show Example
colors = sequence_categorical_column_with_vocabulary_list( key='colors', vocabulary_list=('R', 'G', 'B', 'Y'), num_oov_buckets=2) colors_embedding = embedding_column(colors, dimension=3) columns = [colors_embedding] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
ValueTuple<Tensor, object> sequence_input_layer(IDictionary<string, object> features, IEnumerable<_EmbeddingColumn> feature_columns, object weight_collections, bool trainable)
object sequence_input_layer_dyn(object features, object feature_columns, object weight_collections, ImplicitContainer<T> trainable)
_SequenceNumericColumn sequence_numeric_column(string key, ImplicitContainer<T> shape, double default_value, ImplicitContainer<T> dtype, PythonFunctionContainer normalizer_fn)
Returns a feature column that represents sequences of numeric data. Example:
Parameters
-
string
key - A unique string identifying the input features.
-
ImplicitContainer<T>
shape - The shape of the input data per sequence id. E.g. if `shape=(2,)`, each example must contain `2 * sequence_length` values.
-
double
default_value - A single value compatible with `dtype` that is used for padding the sparse data into a dense `Tensor`.
-
ImplicitContainer<T>
dtype - The type of values.
-
PythonFunctionContainer
normalizer_fn - If not `None`, a function that can be used to normalize the value of the tensor after `default_value` is applied for parsing. Normalizer function takes the input `Tensor` as its argument, and returns the output `Tensor`. (e.g. lambda x: (x - 3.0) / 4.2). Please note that even though the most common use case of this function is normalization, it can be used for any kind of Tensorflow transformations.
Returns
-
_SequenceNumericColumn
- A `SequenceNumericColumn`.
Show Example
temperature = sequence_numeric_column('temperature') columns = [temperature] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
_SequenceNumericColumn sequence_numeric_column(string key, ImplicitContainer<T> shape, double default_value, ImplicitContainer<T> dtype, string normalizer_fn)
Returns a feature column that represents sequences of numeric data. Example:
Parameters
-
string
key - A unique string identifying the input features.
-
ImplicitContainer<T>
shape - The shape of the input data per sequence id. E.g. if `shape=(2,)`, each example must contain `2 * sequence_length` values.
-
double
default_value - A single value compatible with `dtype` that is used for padding the sparse data into a dense `Tensor`.
-
ImplicitContainer<T>
dtype - The type of values.
-
string
normalizer_fn - If not `None`, a function that can be used to normalize the value of the tensor after `default_value` is applied for parsing. Normalizer function takes the input `Tensor` as its argument, and returns the output `Tensor`. (e.g. lambda x: (x - 3.0) / 4.2). Please note that even though the most common use case of this function is normalization, it can be used for any kind of Tensorflow transformations.
Returns
-
_SequenceNumericColumn
- A `SequenceNumericColumn`.
Show Example
temperature = sequence_numeric_column('temperature') columns = [temperature] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)
object sequence_numeric_column_dyn(object key, ImplicitContainer<T> shape, ImplicitContainer<T> default_value, ImplicitContainer<T> dtype, object normalizer_fn)
Returns a feature column that represents sequences of numeric data. Example:
Parameters
-
object
key - A unique string identifying the input features.
-
ImplicitContainer<T>
shape - The shape of the input data per sequence id. E.g. if `shape=(2,)`, each example must contain `2 * sequence_length` values.
-
ImplicitContainer<T>
default_value - A single value compatible with `dtype` that is used for padding the sparse data into a dense `Tensor`.
-
ImplicitContainer<T>
dtype - The type of values.
-
object
normalizer_fn - If not `None`, a function that can be used to normalize the value of the tensor after `default_value` is applied for parsing. Normalizer function takes the input `Tensor` as its argument, and returns the output `Tensor`. (e.g. lambda x: (x - 3.0) / 4.2). Please note that even though the most common use case of this function is normalization, it can be used for any kind of Tensorflow transformations.
Returns
-
object
- A `SequenceNumericColumn`.
Show Example
temperature = sequence_numeric_column('temperature') columns = [temperature] features = tf.io.parse_example(..., features=make_parse_example_spec(columns)) sequence_feature_layer = SequenceFeatures(columns) sequence_input, sequence_length = sequence_feature_layer(features) sequence_length_mask = tf.sequence_mask(sequence_length) rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size) rnn_layer = tf.keras.layers.RNN(rnn_cell) outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)