文章目录

问题

在跑Keras版GCN源码解析的时候,发现以下问题:TypeError: sparse matrix length is ambiguous; use getnnz() or shape[0]
TypeError: sparse matrix length is ambiguous; use getnnz() or shape[0]

原因

在model.fit时,输入了特征矩阵,和邻接矩阵,但邻接矩阵A是<class ‘scipy.sparse.csr.csr_matrix’>。可能是fit函数接受不了’scipy.sparse.csr.csr_matrix’, 要加某些参数,但还不确定

解决

决定将邻接矩阵变为A = preprocess_adj(A, SYM_NORM).todense(),密集矩阵形式,即<class ‘numpy.matrix’>。
同时,对输入 G = [Input(shape=(None, None), batch_shape=(None, None),sparse=True)] 去掉sparse=True参数。
TypeError: sparse matrix length is ambiguous; use getnnz() or shape[0]

相关文章:

  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-07
  • 2022-12-23
  • 2021-09-22
  • 2021-09-07
  • 2022-12-23
  • 2022-01-12
  • 2021-09-08
相关资源
相似解决方案