KGAT推荐系统

编程入门 行业动态 更新时间:2024-10-12 10:25:09

KGAT推荐<a href=https://www.elefans.com/category/jswz/34/1770742.html style=系统"/>

KGAT推荐系统

1:数据处理,数据分割。2:模型构建。包括各个网络的搭建损失函数的设计等。3:构建trainer,包括模型训练fit,和模型评估evaluate。4:数据预测
1:数据处理,数据分割
根据需要的数据集合inter,link,kg数据。进行remap。数据进行分割操作包括以8:1:1的方式分割成train,valid,test。并且根据模型的不同计算neg_item。kg_neg_item。最后返回三个dataloader。
2:KGAT模型构建
网络层的设计,Loss设计,以及Aggarater设计,A的初始化,Cal_Loss,Cal_kg_loss,Updata_A,predict。
3:构建trainer,包括,构建优化器,fit函数,和evaluate函数。

1:数据处理
拼接路径
kg_path = os.path.join(dataset_path, f’{token}.kg’)

‘/Users/apple/Desktop/Code/Recommendation_System/rec/config/…/dataset_example/ml-100k/ml-100k.kg’

这个为拼接起来的路径加文件。

with open(kg_path, ‘r’) as f:
head = f.readline()[:-1]

‘head_id:token\trelation_id:token\ttail_id:token’

for field_type in head.split(field_separator):
field, ftype = field_type.split(‘:’)
columns.append(field)
usecols.append(field_type)
dtype[field_type] = np.float64 if ftype == FeatureType.FLOAT else str

columns->[‘head_id’, ‘relation_id’, ‘tail_id’]
usecols->[‘head_id:token’, ‘relation_id:token’, ‘tail_id:token’]
dtype->{‘head_id:token’: <class ‘str’>, ‘relation_id:token’: <class ‘str’>, ‘tail_id:token’: <class ‘str’>}

之后用df = pd.read_csv(filepath, delimiter=self.config[‘field_separator’], usecols=usecols, dtype=dtype)读取数据
读取的kg数据

更多推荐

KGAT推荐系统

本文发布于:2024-02-10 22:28:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1677653.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:系统   KGAT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!