代码之家  ›  专栏  ›  技术社区  ›  Ihsan Ullah Khan

RuntimeError:维度数必须是sparse_dim(59697)+dense_dim

  •  0
  • Ihsan Ullah Khan  · 技术社区  · 3 年前

    从model/repro/wikimovie/best_model_doc加载模型 epoch 0 0%||0/1202[00:02<?,?it/s] 追溯(最近一次通话): 文件“D:\GraftNet\main.py”,第156行,位于 列车(CFG) 文件“D:\GraftNet\main.py”,第55行,列车中 损失,pred,_=my_model(批次) 文件“C:\Users\TechEnclave Computer\anaconda3\lib\site packages\torch\nn\modules\module.py”,第1501行,在_call_impl中 return forward_call(*args,**kwargs) 文件“D:\GraftNet\GraftNet.py”,第229行,向前 pagerank_e2d=sparse_bmm(entity_pos_mat._indices(),entity_poss_mat_values(),entity_pos_mat.shape,entity_pos_mat,pagerank_d.unsqueeze(dim=2)/e2d_out_dim) 文件“D:\GraftNet\util.py”,第160行,位于sparse_bmm中 X=火炬稀疏浮动张量(X_I.t(),X_V,火炬。大小([B*N,X_shape[1],Y.shape[1])) RuntimeError:维度数必须是sparse_dim(59697)+dense_dim

    def sparse_bmm(X_I,X_V,X_shape,X,Y): """ 此函数执行分批稀疏矩阵乘法(X*Y)。 :param X_I:COO格式的稀疏矩阵的索引(num_nonzero,2) :param X_V:稀疏矩阵的值(num_nonzero,) :param X_shape:稀疏矩阵的形状(2,) :param Y:密集矩阵(batch_size*N,K) :return:稀疏矩阵乘法运算结果(batch_size*N,K) """ B、 N,_=X_shape X=火炬稀疏浮动张量(X_I.t(),X_V,火炬。尺寸([B*N,Y.shape[1]])

    X = X.to_dense()
    X = X.view(B * N, -1)
    result = torch.matmul(X, Y)
    return result
    
    0 回复  |  直到 3 年前