Beispiel #1
0
if __name__ == '__main__':
    import Recommender_System.utility.gpu_memory_growth
    from tensorflow.keras.optimizers import Adam
    from Recommender_System.data import kg_loader, data_process
    from Recommender_System.algorithm.MKR.model import MKR_model
    from Recommender_System.algorithm.MKR.train import train

    n_user, n_item, n_entity, n_relation, train_data, test_data, kg, topk_data = data_process.pack_kg(
        kg_loader.ml1m_kg_MKR)
    model_rs, model_kge = MKR_model(n_user,
                                    n_item,
                                    n_entity,
                                    n_relation,
                                    dim=8,
                                    L=1,
                                    H=1,
                                    l2=1e-6)
    train(model_rs,
          model_kge,
          train_data,
          test_data,
          kg,
          topk_data,
          kge_interval=3,
          optimizer_rs=Adam(0.02),
          optimizer_kge=Adam(0.01),
          epochs=20,
          batch=4096)
    '''
    n_user, n_item, n_entity, n_relation, train_data, test_data, kg, topk_data = data_process.pack_kg(kg_loader.lastfm_kg_MKR)
    model_rs, model_kge = MKR_model(n_user, n_item, n_entity, n_relation, dim=4, L=2, H=1, l2=1e-6)
Beispiel #2
0
if __name__ == '__main__':
    import Recommender_System.utility.gpu_memory_growth
    from Recommender_System.algorithm.KGCN.tool import construct_undirected_kg, get_adj_list
    from Recommender_System.algorithm.KGCN.model import KGCN_model
    from Recommender_System.algorithm.KGCN.train import train
    from Recommender_System.data import kg_loader, data_process
    import tensorflow as tf

    n_user, n_item, n_entity, n_relation, train_data, test_data, kg, topk_data = data_process.pack_kg(
        kg_loader.ml1m_kg1m, negative_sample_threshold=4)

    neighbor_size = 16
    adj_entity, adj_relation = get_adj_list(construct_undirected_kg(kg),
                                            n_entity, neighbor_size)

    model = KGCN_model(n_user,
                       n_entity,
                       n_relation,
                       adj_entity,
                       adj_relation,
                       neighbor_size,
                       iter_size=1,
                       dim=16,
                       l2=1e-7,
                       aggregator='sum')

    train(model,
          train_data,
          test_data,
          topk_data,
          optimizer=tf.keras.optimizers.Adam(0.01),
Beispiel #3
0
    from Recommender_System.algorithm.RippleNet.train import train
    from Recommender_System.data import kg_loader, data_process
    import tensorflow as tf
    '''
    n_user, n_item, n_entity, n_relation, train_data, test_data, kg, topk_data = data_process.pack_kg(kg_loader.ml20_kg_KGCN, split_ensure_positive=True)

    hop_size, ripple_size = 2, 32

    ripple_set = get_ripple_set(hop_size, ripple_size, get_user_positive_item_list(train_data), construct_directed_kg(kg))

    model = RippleNet_model(n_entity, n_relation, dim=32, hop_size=hop_size, ripple_size=ripple_size, kge_weight=0.01, l2=1e-7)

    train(model, train_data, test_data, topk_data, ripple_set, optimizer=tf.keras.optimizers.Adam(0.01), epochs=10, batch=65536)
    '''

    n_user, n_item, n_entity, n_relation, train_data, test_data, kg, topk_data = data_process.pack_kg(
        kg_loader.ml1m_kg_RippleNet, split_ensure_positive=True)

    hop_size, ripple_size = 2, 32

    ripple_set = get_ripple_set(hop_size, ripple_size,
                                get_user_positive_item_list(train_data),
                                construct_directed_kg(kg))

    model = RippleNet_model(n_entity,
                            n_relation,
                            dim=16,
                            hop_size=hop_size,
                            ripple_size=ripple_size,
                            kge_weight=0,
                            l2=1e-7)