使用Neo4j GDS执行FastRP节点嵌入时属性缺失报错问题
FastRP嵌入报错的解决方案
报错原因
featureProperties参数要求指定的属性必须存在于所有投影的节点标签中,但你的Image、Object、Lane三类节点分别只拥有scene_id、obj_type、direction属性,没有任何一个属性是三类节点共有的,因此触发属性不存在的异常。
解决方法
方法1:按节点标签指定专属特征属性(推荐)
使用FastRP的labelSpecificFeatures参数,为不同标签的节点单独配置它们自身拥有的特征属性,这样每个节点只用自己的属性生成嵌入:
CALL gds.fastRP.mutate( 'imgraph1', { embeddingDimension: 64, labelSpecificFeatures: { Image: ['scene_id'], Object: ['obj_type'], Lane: ['direction'] }, iterationWeights: [0.1, 0.1, 0.1, 0.1, 0.1, 0.5], mutateProperty: 'embedding' } )
方法2:为所有节点补充缺失属性的默认值
如果需要统一使用全局的featureProperties,可以在图投影时给每个节点标签补充缺失的属性并设置默认值,确保所有节点都拥有scene_id、obj_type、direction三个属性:
修改后的图投影查询:
CALL gds.graph.project( 'imgraph1', { Image: { properties: { scene_id: {}, obj_type: {defaultValue: 0.0}, direction: {defaultValue: 0.0} } }, Object: { properties: { scene_id: {defaultValue: 0.0}, obj_type: {}, direction: {defaultValue: 0.0} } }, Lane: { properties: { scene_id: {defaultValue: 0.0}, obj_type: {defaultValue: 0.0}, direction: {} } } }, ['CONTAINS', 'IN_LANE'] )
投影完成后,即可正常使用你原来的FastRP查询语句。
内容的提问来源于stack exchange,提问作者Shahid
相关产品推荐
相关产品推荐

