Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix]:fix layer for sequence feature #342

Merged
merged 1 commit into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions easy_rec/python/layers/sequence_feature_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,11 @@ def target_attention(self,
cur_id = cur_id[:tf.shape(hist_id_col)[0], ...] # for negative sampler

if allow_key_transform and (cur_id_dim != seq_emb_dim):
cur_id = tf.layers.dense(
cur_id, seq_emb_dim, name='sequence_key_transform_layer')
cur_key_layer_name = 'sequence_key_transform_layer_' + name
cur_id = tf.layers.dense(cur_id, seq_emb_dim, name=cur_key_layer_name)
cur_fea_layer_name = 'sequence_fea_transform_layer_' + name
hist_id_col = tf.layers.dense(
hist_id_col, seq_emb_dim, name=cur_fea_layer_name)

cur_ids = tf.tile(cur_id, [1, seq_max_len])
cur_ids = tf.reshape(cur_ids,
Expand Down
2 changes: 1 addition & 1 deletion easy_rec/python/test/train_eval_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import threading
import time
import unittest
from distutils.version import LooseVersion

import numpy as np
import six
import tensorflow as tf
from distutils.version import LooseVersion
from tensorflow.python.platform import gfile

from easy_rec.python.main import predict
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,356 @@
train_input_path: "data/test/tb_data/taobao_multi_seq_train_data"
eval_input_path: "data/test/tb_data/taobao_multi_seq_test_data"
model_dir: "experiments/dbmtl_taobao_ckpt"

train_config {
optimizer_config {
adam_optimizer {
learning_rate {
exponential_decay_learning_rate {
initial_learning_rate: 0.001
decay_steps: 1000
decay_factor: 0.5
min_learning_rate: 1e-07
}
}
}
use_moving_average: false
}
num_steps: 1000
sync_replicas: true
save_checkpoints_steps: 100
log_step_count_steps: 100
}
eval_config {
metrics_set {
auc {
}
}
}
data_config {
batch_size: 4096
label_fields: "clk"
label_fields: "buy"
prefetch_size: 1
input_type: CSVInput
input_fields {
input_name: "clk"
input_type: INT32
}
input_fields {
input_name: "buy"
input_type: INT32
}
input_fields {
input_name: "pid"
input_type: STRING
}
input_fields {
input_name: "adgroup_id"
input_type: STRING
}
input_fields {
input_name: "cate_id"
input_type: STRING
}
input_fields {
input_name: "campaign_id"
input_type: STRING
}
input_fields {
input_name: "customer"
input_type: STRING
}
input_fields {
input_name: "brand"
input_type: STRING
}
input_fields {
input_name: "user_id"
input_type: STRING
}
input_fields {
input_name: "cms_segid"
input_type: STRING
}
input_fields {
input_name: "cms_group_id"
input_type: STRING
}
input_fields {
input_name: "final_gender_code"
input_type: STRING
}
input_fields {
input_name: "age_level"
input_type: STRING
}
input_fields {
input_name: "pvalue_level"
input_type: STRING
}
input_fields {
input_name: "shopping_level"
input_type: STRING
}
input_fields {
input_name: "occupation"
input_type: STRING
}
input_fields {
input_name: "new_user_class_level"
input_type: STRING
}
input_fields {
input_name: "tag_category_list"
input_type: STRING
default_val: "0"
}
input_fields {
input_name: "tag_brand_list"
input_type: STRING
default_val: "0"
}
input_fields {
input_name: "price"
input_type: INT32
}
}
feature_configs {
input_names: "pid"
feature_type: IdFeature
embedding_dim: 16
hash_bucket_size: 10
}
feature_configs {
input_names: "adgroup_id"
feature_type: IdFeature
embedding_dim: 16
hash_bucket_size: 100000
}
feature_configs {
input_names: "cate_id"
feature_type: IdFeature
embedding_dim: 16
hash_bucket_size: 10000
}
feature_configs {
input_names: "campaign_id"
feature_type: IdFeature
embedding_dim: 16
hash_bucket_size: 100000
}
feature_configs {
input_names: "customer"
feature_type: IdFeature
embedding_dim: 16
hash_bucket_size: 100000
}
feature_configs {
input_names: "brand"
feature_type: IdFeature
embedding_dim: 16
hash_bucket_size: 100000
}
feature_configs {
input_names: "user_id"
feature_type: IdFeature
embedding_dim: 16
hash_bucket_size: 100000
}
feature_configs {
input_names: "cms_segid"
feature_type: IdFeature
embedding_dim: 16
hash_bucket_size: 100
}
feature_configs {
input_names: "cms_group_id"
feature_type: IdFeature
embedding_dim: 16
hash_bucket_size: 100
}
feature_configs {
input_names: "final_gender_code"
feature_type: IdFeature
embedding_dim: 16
hash_bucket_size: 10
}
feature_configs {
input_names: "age_level"
feature_type: IdFeature
embedding_dim: 16
hash_bucket_size: 10
}
feature_configs {
input_names: "pvalue_level"
feature_type: IdFeature
embedding_dim: 16
hash_bucket_size: 10
}
feature_configs {
input_names: "shopping_level"
feature_type: IdFeature
embedding_dim: 16
hash_bucket_size: 10
}
feature_configs {
input_names: "occupation"
feature_type: IdFeature
embedding_dim: 16
hash_bucket_size: 10
}
feature_configs {
input_names: "new_user_class_level"
feature_type: IdFeature
embedding_dim: 16
hash_bucket_size: 10
}
feature_configs {
input_names: "tag_category_list"
feature_type: SequenceFeature
embedding_dim: 16
boundaries: 15.0
boundaries: 20.0
boundaries: 21.0
boundaries: 23.0
boundaries: 30.0
boundaries: 32.0
boundaries: 40.0
boundaries: 47.0
boundaries: 66.0
boundaries: 70.0
boundaries: 77.0
boundaries: 87.0
boundaries: 99.0
boundaries: 120.0
boundaries: 148.0
boundaries: 188.0
boundaries: 199.0
boundaries: 235.0
boundaries: 301.0
boundaries: 443.0
boundaries: 597.0
boundaries: 1314.0
sub_feature_type: RawFeature
sequence_length: 300
separator: "|"
seq_multi_sep: ";"
}
feature_configs {
input_names: "tag_brand_list"
feature_type: SequenceFeature
embedding_dim: 16
boundaries: 15.0
boundaries: 20.0
boundaries: 21.0
boundaries: 23.0
boundaries: 30.0
boundaries: 32.0
boundaries: 40.0
boundaries: 47.0
boundaries: 66.0
boundaries: 70.0
boundaries: 77.0
boundaries: 87.0
boundaries: 99.0
boundaries: 120.0
boundaries: 148.0
boundaries: 188.0
boundaries: 199.0
boundaries: 235.0
boundaries: 301.0
boundaries: 443.0
boundaries: 597.0
boundaries: 1314.0
sub_feature_type: RawFeature
sequence_length: 300
separator: "|"
seq_multi_sep: ";"
}
feature_configs {
input_names: "price"
feature_type: IdFeature
embedding_dim: 16
num_buckets: 50
}
model_config {
model_class: "DBMTL"
feature_groups {
group_name: "all"
feature_names: "user_id"
feature_names: "cms_segid"
feature_names: "cms_group_id"
feature_names: "age_level"
feature_names: "pvalue_level"
feature_names: "shopping_level"
feature_names: "occupation"
feature_names: "new_user_class_level"
feature_names: "adgroup_id"
feature_names: "cate_id"
feature_names: "campaign_id"
feature_names: "customer"
feature_names: "brand"
feature_names: "price"
feature_names: "pid"
wide_deep: DEEP
sequence_features: {
group_name: "seq_fea"
tf_summary: false
allow_key_transform:true
seq_att_map: {
key: "brand"
hist_seq: "tag_brand_list"
hist_seq: "tag_category_list"
}
}
sequence_features: {
group_name: "seq_fea_2"
tf_summary: false
allow_key_transform:true
seq_att_map: {
key: "brand"
hist_seq: "tag_brand_list"
hist_seq: "tag_category_list"
}
}
}
dbmtl {
bottom_dnn {
hidden_units: [1024, 512, 256]
}
task_towers {
tower_name: "ctr"
label_name: "clk"
loss_type: CLASSIFICATION
metrics_set: {
auc {}
}
dnn {
hidden_units: [256, 128, 64, 32]
}
relation_dnn {
hidden_units: [32]
}
weight: 1.0
}
task_towers {
tower_name: "cvr"
label_name: "buy"
loss_type: CLASSIFICATION
metrics_set: {
auc {}
}
dnn {
hidden_units: [256, 128, 64, 32]
}
relation_tower_names: ["ctr"]
relation_dnn {
hidden_units: [32]
}
weight: 1.0
}
l2_regularization: 1e-6
}
embedding_regularization: 5e-6
}
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ multi_line_output = 7
force_single_line = true
known_standard_library = setuptools
known_first_party = easy_rec
known_third_party = absl,common_io,docutils,future,google,graphlearn,kafka,matplotlib,numpy,oss2,pai,pandas,psutil,six,sklearn,sphinx_markdown_tables,sphinx_rtd_theme,tensorflow,yaml
known_third_party = absl,common_io,distutils,docutils,future,google,graphlearn,kafka,matplotlib,numpy,oss2,pai,pandas,psutil,six,sklearn,sphinx_markdown_tables,sphinx_rtd_theme,tensorflow,yaml
no_lines_before = LOCALFOLDER
default_section = THIRDPARTY
skip = easy_rec/python/protos
Expand Down