コード例 #1
0
ファイル: ctr_autoint.py プロジェクト: datamllab/AutoRec
dense_input_node = Input(shape=[numerical_count])
sparse_input_node = Input(shape=[categorical_count])
dense_feat_emb = DenseFeatureMapper(num_of_fields=numerical_count,
                                    embedding_dim=2)(dense_input_node)
sparse_feat_emb = SparseFeatureMapper(num_of_fields=categorical_count,
                                      hash_size=hash_size,
                                      embedding_dim=2)(sparse_input_node)

# Step 2.2: Setup interactors to handle models
attention_output = SelfAttentionInteraction()(
    [dense_feat_emb, sparse_feat_emb])
bottom_mlp_output = MLPInteraction()([dense_feat_emb])
top_mlp_output = MLPInteraction()([attention_output, bottom_mlp_output])

# Step 2.3: Setup optimizer to handle the target task
output = CTRPredictionOptimizer()(top_mlp_output)
model = CTRRecommender(inputs=[dense_input_node, sparse_input_node],
                       outputs=output)

# Step 3: Build the searcher, which provides search algorithm
searcher = Search(
    model=model,
    tuner='random',
    tuner_params={
        'max_trials': 2,
        'overwrite': True
    },
)

# Step 4: Use the searcher to search the recommender
searcher.search(x=[train_X_numerical, train_X_categorical],
コード例 #2
0
ファイル: ctr_autorec.py プロジェクト: datamllab/AutoRec
dense_feat_emb = DenseFeatureMapper(num_of_fields=numerical_count,
                                    embedding_dim=2)(dense_input_node)
sparse_feat_emb = SparseFeatureMapper(num_of_fields=categorical_count,
                                      hash_size=hash_size,
                                      embedding_dim=2)(sparse_input_node)

# Step 2.2: Setup interactors to handle models
sparse_feat_bottom_output = HyperInteraction(meta_interactor_num=2)(
    [sparse_feat_emb])
dense_feat_bottom_output = HyperInteraction(meta_interactor_num=2)(
    [dense_feat_emb])
hyper_output = HyperInteraction(meta_interactor_num=2)(
    [sparse_feat_bottom_output, dense_feat_bottom_output])

# Step 2.3: Setup optimizer to handle the target task
output = CTRPredictionOptimizer()(hyper_output)
model = CTRRecommender(inputs=[dense_input_node, sparse_input_node],
                       outputs=output)

# Step 3: Build the searcher, which provides search algorithm
searcher = Search(
    model=model,
    tuner='random',
    tuner_params={
        'max_trials': 2,
        'overwrite': True
    },
)

# Step 4: Use the searcher to search the recommender
searcher.search(x=[train_X_numerical, train_X_categorical],
コード例 #3
0
ファイル: ctr_neumf.py プロジェクト: datamllab/AutoRec
user_emb_gmf = LatentFactorMapper(column_id=0,
                                  num_of_entities=10000,
                                  embedding_dim=64)(input)
item_emb_gmf = LatentFactorMapper(column_id=1,
                                  num_of_entities=10000,
                                  embedding_dim=64)(input)

user_emb_mlp = LatentFactorMapper(column_id=0,
                                  num_of_entities=10000,
                                  embedding_dim=64)(input)
item_emb_mlp = LatentFactorMapper(column_id=1,
                                  num_of_entities=10000,
                                  embedding_dim=64)(input)
innerproduct_output = InnerProductInteraction()([user_emb_gmf, item_emb_gmf])
mlp_output = MLPInteraction()([user_emb_mlp, item_emb_mlp])
output = CTRPredictionOptimizer()([innerproduct_output, mlp_output])
model = CTRRecommender(inputs=input, outputs=output)

# AutoML search and predict.
searcher = Search(
    model=model,
    tuner='random',
    tuner_params={
        'max_trials': 10,
        'overwrite': True
    },
)
searcher.search(x=[criteo.get_x_categorical(train_X)],
                y=train_y,
                x_val=[criteo.get_x_categorical(val_X)],
                y_val=val_y,
コード例 #4
0
ファイル: ctr_benchmark.py プロジェクト: datamllab/AutoRec
        emb_dict = {'dense': dense_feat_emb, 'sparse': sparse_feat_emb}

    # Step 2.2: Setup interactors to handle models
    if args.model == 'dlrm':
        output = build_dlrm(emb_dict)
    if args.model == 'deepfm':
        output = build_deepfm(emb_dict)
    if args.model == 'crossnet':
        output = build_neumf(emb_dict)
    if args.model == 'autoint':
        output = build_autorec(emb_dict)
    if args.model == 'autorec':
        output = build_autorec(emb_dict)

    # Step 2.3: Setup optimizer to handle the target task
    output = CTRPredictionOptimizer()(output)
    model = CTRRecommender(inputs=input, outputs=output)

    # Step 3: Build the searcher, which provides search algorithm
    searcher = Search(model=model,
                      tuner=args.search,
                      tuner_params={'max_trials': args.trials, 'overwrite': True}
                      )

    # Step 4: Use the searcher to search the recommender
    start_time = time.time()
    searcher.search(x=train_X,
                    y=train_y,
                    x_val=val_X,
                    y_val=val_y,
                    objective='val_BinaryCrossentropy',