Skip to content

Commit

Permalink
[feat]: format backbone code, add recurrent and sequential layer
Browse files Browse the repository at this point in the history
  • Loading branch information
yangxudong committed Jun 19, 2023
1 parent 136cf37 commit e795f00
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion easy_rec/python/layers/common_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ def __init__(self, config, input_layer, feature_dict):
self._input_layer = input_layer
self._feature_dict = feature_dict

def __call__(self, group, is_training, *args, **kwargs):
def __call__(self, group, is_training, **kwargs):
with tf.name_scope('input_' + group):
return self.call(group, is_training)

def call(self, group, is_training):
if self._config.output_seq_and_normal_feature:
seq_features, target_feature, target_features = self._input_layer(
self._feature_dict, group, is_combine=False)
Expand Down
9 changes: 5 additions & 4 deletions easy_rec/python/layers/keras/mask_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ class MaskNet(tf.keras.layers.Layer):
Refer: https://arxiv.org/pdf/2102.07619.pdf
"""

def __init__(self, params, name='mask_net', l2_reg=None, **kwargs):
def __init__(self, params, name='mask_net', **kwargs):
super(MaskNet, self).__init__(name, **kwargs)
self.config = params.get_pb_config()
if self.config.HasField('mlp'):
p = Parameter.make_from_pb(self.config.mlp)
self.mlp = MLP(p, name='%s/mlp' % name, l2_reg=l2_reg)
p.l2_regularizer = params.l2_regularizer
self.mlp = MLP(p, name='%s/mlp' % name)
else:
self.mlp = None

Expand All @@ -75,7 +76,7 @@ def call(self, inputs, training=None, **kwargs):
for i, block_conf in enumerate(self.config.mask_blocks):
params = Parameter.make_from_pb(block_conf)
mask_layer = MaskBlock(
params, name='%s/block_%d' % (self.name, i), reuse=self.reuse)
params, name='%s/block_%d' % (self.name, i))
mask_outputs.append(mask_layer((inputs, inputs)))
all_mask_outputs = tf.concat(mask_outputs, axis=1)

Expand All @@ -89,7 +90,7 @@ def call(self, inputs, training=None, **kwargs):
for i, block_conf in enumerate(self.config.mask_blocks):
params = Parameter.make_from_pb(block_conf)
mask_layer = MaskBlock(
params, name='%s/block_%d' % (self.name, i), reuse=self.reuse)
params, name='%s/block_%d' % (self.name, i))
net = mask_layer((net, inputs))

if self.mlp is not None:
Expand Down
2 changes: 1 addition & 1 deletion easy_rec/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- encoding:utf-8 -*-
# Copyright (c) Alibaba, Inc. and its affiliates.
__version__ = '0.6.3'
__version__ = '1.0.0'
3 changes: 1 addition & 2 deletions examples/configs/masknet_on_movielens.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ train_config {
}
use_moving_average: false
}
save_checkpoints_steps: 100
save_checkpoints_steps: 2000
sync_replicas: True
num_steps: 2500
}

eval_config {
Expand Down
2 changes: 1 addition & 1 deletion examples/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ python -m easy_rec.python.train_eval --pipeline_config_path examples/configs/dee
| DCN (Backbone) | 1 | 0.8770 |
| AutoInt | 1 | 0.8513 |
| MaskNet | 1 | 0.8872 |
| FibiNet | 1 | 0.8879 |
| FibiNet | 1 | 0.8893 |
备注:`MovieLens-1M` 数据集较小,评估指标方差较大,以上结果仅供参考。
Expand Down

0 comments on commit e795f00

Please sign in to comment.