示例#1
0
def test_DIEN(gru_type):
    model_name = "DIEN_"+gru_type

    x, y, feature_dim_dict, behavior_feature_list = get_xy_fd(hash_flag=True)

    model = DIEN(feature_dim_dict, behavior_feature_list, hist_len_max=4, embedding_size=8,
                 dnn_hidden_units=[4, 4, 4], dnn_dropout=0.5, gru_type=gru_type)

    check_model(model,model_name,x,y,check_model_io=(gru_type=="GRU"))#TODO:fix bugs when load model in other type
示例#2
0
def test_DIEN_neg():
    model_name = "DIEN_neg"

    x, y, feature_dim_dict, behavior_feature_list = get_xy_fd(use_neg=True)

    model = DIEN(feature_dim_dict, behavior_feature_list, hist_len_max=4, embedding_size=8,
                 dnn_hidden_units=[4, 4, 4], dnn_dropout=0.5, gru_type="AUGRU", use_negsampling=True)

    check_model(model,model_name,x,y)
示例#3
0
文件: DIEN_test.py 项目: Puzz1eX/HFCN
def test_DIEN_neg():
    model_name = "DIEN_neg"
    if version.parse(tf.__version__) >= version.parse("1.14.0"):
        return

    x, y, feature_dim_dict, behavior_feature_list = get_xy_fd(use_neg=True)

    model = DIEN(feature_dim_dict, behavior_feature_list,
                 dnn_hidden_units=[4, 4, 4], dnn_dropout=0.5, gru_type="AUGRU", use_negsampling=True)
    check_model(model,model_name,x,y)
示例#4
0
def test_DIEN(gru_type):
    if tf.__version__ >= '2.0.0':
        tf.compat.v1.disable_eager_execution() #todo
    model_name = "DIEN_"+gru_type

    x, y, feature_columns, behavior_feature_list = get_xy_fd(hash_flag=True)

    model = DIEN(feature_columns, behavior_feature_list, hist_len_max=4, embedding_size=8,
                 dnn_hidden_units=[4, 4, 4], dnn_dropout=0.5, gru_type=gru_type)

    check_model(model,model_name,x,y,check_model_io=(gru_type=="GRU"))#TODO:fix bugs when load model in other type
示例#5
0
def test_DIEN(gru_type):
    if version.parse(tf.__version__) >= version.parse('2.0.0'):
        tf.compat.v1.disable_eager_execution()  # todo
        return
    model_name = "DIEN_" + gru_type

    x, y, feature_columns, behavior_feature_list = get_xy_fd(hash_flag=True)

    model = DIEN(feature_columns,
                 behavior_feature_list,
                 dnn_hidden_units=[4, 4, 4],
                 dnn_dropout=0.5,
                 gru_type=gru_type)

    check_model(model, model_name, x, y, check_model_io=(
        gru_type == "GRU"))  # TODO:fix bugs when load model in other type
示例#6
0
文件: run_dien.py 项目: Puzz1eX/HFCN
                                        embedding_dim=4,
                                        embedding_name='cate_id'),
                             maxlen=4,
                             length_name="seq_length")
        ]

    x = {
        name: feature_dict[name]
        for name in get_feature_names(feature_columns)
    }
    y = [1, 0, 1]
    return x, y, feature_columns, behavior_feature_list


if __name__ == "__main__":
    if tf.__version__ >= '2.0.0':
        tf.compat.v1.disable_eager_execution()

    x, y, feature_columns, behavior_feature_list = get_xy_fd(use_neg=True)
    model = DIEN(feature_columns,
                 behavior_feature_list,
                 dnn_hidden_units=[4, 4, 4],
                 dnn_dropout=0.6,
                 gru_type="AUGRU",
                 use_negsampling=True)

    model.compile('adam',
                  'binary_crossentropy',
                  metrics=['binary_crossentropy'])
    history = model.fit(x, y, verbose=1, epochs=10, validation_split=0.5)
示例#7
0
    if use_neg:
        feature_dict['neg_hist_item'] = np.array([[1, 2, 3, 0], [1, 2, 3, 0],
                                                  [1, 2, 0, 0]])
        feature_dict['neg_hist_item_gender'] = np.array([[1, 1, 2, 0],
                                                         [2, 1, 1, 0],
                                                         [2, 1, 0, 0]])
        x += [
            feature_dict['neg_hist_' + feat] for feat in behavior_feature_list
        ]

    x += [behavior_length]
    y = [1, 0, 1]
    return x, y, feature_dim_dict, behavior_feature_list


if __name__ == "__main__":
    x, y, feature_dim_dict, behavior_feature_list = get_xy_fd(use_neg=True)
    model = DIEN(feature_dim_dict,
                 behavior_feature_list,
                 hist_len_max=4,
                 embedding_size=8,
                 hidden_size=[4, 4, 4],
                 keep_prob=0.6,
                 gru_type="AUGRU",
                 use_negsampling=True)

    model.compile('adam',
                  'binary_crossentropy',
                  metrics=['binary_crossentropy'])
    history = model.fit(x, y, verbose=1, epochs=10, validation_split=0.5)
示例#8
0
if sys.argv[1] == 'DeepFM_UDG':
    model = DeepFM_UDG(linear_feature_columns, dnn_feature_columns, untrainable_features_columns, 
                       (200, 80), uid_feature_name=udg_features, udg_embedding_size=int(sys.argv[5]))
elif sys.argv[1] == 'DeepFM':
    model = DeepFM(linear_feature_columns, dnn_feature_columns, [], (200, 80))
elif sys.argv[1] == 'PNN_UDG':
    model = PNN_UDG(dnn_feature_columns, untrainable_features_columns, (200, 80), uid_feature_name=udg_features, 
                    udg_embedding_size=int(sys.argv[5]))
elif sys.argv[1] == 'PNN':
    model = PNN(dnn_feature_columns, untrainable_features_columns, (200, 80))
elif sys.argv[1] == 'WDL':
    model = WDL(linear_feature_columns, dnn_feature_columns, [], (200, 80))
elif sys.argv[1] == 'WDL_UDG':
    model = WDL_UDG(linear_feature_columns, dnn_feature_columns, untrainable_features_columns, (200, 80), uid_feature_name=udg_features, udg_embedding_size=int(sys.argv[5]))
elif sys.argv[1] == 'DIEN':
    model = DIEN(fixlen_feature_columns, behavior_feature_list,
             dnn_hidden_units=[200, 80], dnn_dropout=0, gru_type="AUGRU", use_negsampling=True)
elif sys.argv[1] == 'DIEN_UDG':
    model = DIEN_UDG(fixlen_feature_columns, untrainable_features_columns, behavior_feature_list, dnn_hidden_units=[200, 80], dnn_dropout=0, gru_type="AUGRU", use_negsampling=True, uid_feature_name=udg_features, udg_embedding_size=int(sys.argv[5]))
elif sys.argv[1] == 'DIN':
    model = DIN(fixlen_feature_columns, behavior_feature_list, dnn_hidden_units=[200, 80], dnn_dropout=0)
elif sys.argv[1] == 'DIN_UDG':
    model = DIN_UDG(fixlen_feature_columns, untrainable_features_columns, behavior_feature_list, dnn_hidden_units=[200, 80], dnn_dropout=0, uid_feature_name=udg_features, udg_embedding_size=int(sys.argv[5]))
    
if sys.argv[4] == 'focal':
    model.compile("adam", loss=focal_loss, metrics=['binary_crossentropy'], )
else:
    model.compile("adam", "binary_crossentropy", metrics=['binary_crossentropy'], )
init_lr = float(tf.keras.backend.get_value(model.optimizer.learning_rate))
lr = [init_lr, init_lr/2, init_lr/4]
history_all = {}
max_auc, min_log, min_rmse, max_rig = 0, 0, 0, 0