dgl._ffi.base.DGLError: Expect number of features to match number of nodes (len(u)). Got 943 and 1682 instead


I wrote and modified the code according to my senior’s code, and this problem occurred and i dont know how to resolve it, i wanna get some help. thank you very much

    hg_user = dgl.heterograph({('user', 'um', 'movie'): (mvsu_u, mvsu_m),
                               ('movie', 'mu', 'user'): (mvsu_m, mvsu_u),
                               ('user', 'uu', 'user'): (mvsu_u, mvsu_u),
                               ('movie', 'mm', 'movie'): (mvsu_m, mvsu_m),
                               # ('user', 'umgmu', 'user'): (umgmu_u0, umgmu_u1),  # relation
                               ('movie', 'mg', 'genre'): (mvsg_m, mvsg_g),
                               ('genre', 'gm', 'movie'): (mvsg_g, mvsg_m)
                               })

    user_mp_info = [[['um', 'mu', 'um'], ['mu']],
                    [[-1, -1, -1], [movie_features.shape[1], user_features.shape[1]]]]

Is this all the code you have? This looks like an error thrown at node feature assignment and I couldn’t see it in your code snippet. Could you give us a reproducible example and the complete error stack trace?

thanks a lot for your help, and after deeply checked code,found that i just need one type of node in new_g, but I dont know how to solve. there is the HIN_Embedding_Layer class below.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

What do you mean by “need one type of node in new_g”? Do you mean that the node type doesn’t exist? When creating the graph, you could specify the number of nodes for each type in num_nodes_dict argument in the dgl.heterograph() function.