You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Hash Layer with pre-defined key-value vocabulary
326
+
327
+
This examples how to use pre-defined key-value vocabulary in `Hash` Layer.`movielens_age_vocabulary.csv` stores the key-value mapping for `age` feature.
328
+
329
+
```python
330
+
from deepctr.models import DeepFM
331
+
from deepctr.feature_column import SparseFeat, VarLenSparseFeat, get_feature_names
332
+
import numpy as np
333
+
import pandas as pd
334
+
from tensorflow.python.keras.preprocessing.sequence import pad_sequences
Copy file name to clipboardExpand all lines: docs/source/Features.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,10 +26,10 @@ DNN based CTR prediction models usually have following 4 modules:
26
26
``SparseFeat`` is a namedtuple with signature ``SparseFeat(name, vocabulary_size, embedding_dim, use_hash, vocabulary_path, dtype, embeddings_initializer, embedding_name, group_name, trainable)``
27
27
28
28
- name : feature name
29
-
- vocabulary_size : number of unique feature values for sprase feature or hashing space when `use_hash=True`
29
+
- vocabulary_size : number of unique feature values for sparse feature or hashing space when `use_hash=True`
30
30
- embedding_dim : embedding dimension
31
31
- use_hash : default `False`.If `True` the input will be hashed to space of size `vocabulary_size`.
32
-
- vocabulary_path : default `None`. The `CSV` text file path of the vocabulary table used by `tf.lookup.TextFileInitializer`, which assigns one entry in the table for each line in the file. One entry contains two columns seperated by comma, the first is the value column, the second is the key column. The `0` value is reserved to use if a key is missing in the table, so hash value need start from `1`.
32
+
- vocabulary_path : default `None`. The `CSV` text file path of the vocabulary table used by `tf.lookup.TextFileInitializer`, which assigns one entry in the table for each line in the file. One entry contains two columns separated by comma, the first is the value column, the second is the key column. The `0` value is reserved to use if a key is missing in the table, so hash value need start from `1`.
33
33
- dtype : default `int32`.dtype of input tensor.
34
34
- embeddings_initializer : initializer for the `embeddings` matrix.
35
35
- embedding_name : default `None`. If None, the embedding_name will be same as `name`.
0 commit comments