|  View source on GitHub | 
A preprocessing layer which crosses features using the "hashing trick".
Inherits From: Layer, Operation
tf.keras.layers.HashedCrossing(
    num_bins,
    output_mode='int',
    sparse=False,
    name=None,
    dtype=None,
    **kwargs
)
This layer performs crosses of categorical features using the "hashing trick". Conceptually, the transformation can be thought of as: `hash(concatenate(features)) % num_bins.
This layer currently only performs crosses of scalar inputs and batches of
scalar inputs. Valid input shapes are (batch_size, 1), (batch_size,) and
().
Examples:
Crossing two scalar features.
layer = keras.layers.HashedCrossing(num_bins=5)feat1 = np.array(['A', 'B', 'A', 'B', 'A'])feat2 = np.array([101, 101, 101, 102, 102])layer((feat1, feat2))array([1, 4, 1, 1, 3])
Crossing and one-hotting two scalar features.
layer = keras.layers.HashedCrossing(num_bins=5, output_mode='one_hot')feat1 = np.array(['A', 'B', 'A', 'B', 'A'])feat2 = np.array([101, 101, 101, 102, 102])layer((feat1, feat2))array([[0., 1., 0., 0., 0.],[0., 0., 0., 0., 1.],[0., 1., 0., 0., 0.],[0., 1., 0., 0., 0.],[0., 0., 0., 1., 0.]], dtype=float32)
Methods
from_config
@classmethodfrom_config( config )
Creates a layer from its config.
This method is the reverse of get_config,
capable of instantiating the same layer from the config
dictionary. It does not handle layer connectivity
(handled by Network), nor weights (handled by set_weights).
| Args | |
|---|---|
| config | A Python dictionary, typically the output of get_config. | 
| Returns | |
|---|---|
| A layer instance. | 
symbolic_call
symbolic_call(
    *args, **kwargs
)