用法:
mxnet.contrib.ndarray.dgl_graph_compact(*graph_data, **kwargs)
out:- 此函数的输出。
NDArray 或 NDArray 列表
参数:
返回:
返回类型:
此运算符压缩由 dgl_csr_neighbor_uniform_sample 和 dgl_csr_neighbor_non_uniform_sample 生成的 CSR 矩阵。这两个算子生成的 CSR 矩阵的末尾可能有很多空行和很多空列。此运算符删除这些空行和空列。
示例:
shape = (5, 5) data_np = np.array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20], dtype=np.int64) indices_np = np.array([1,2,3,4,0,2,3,4,0,1,3,4,0,1,2,4,0,1,2,3], dtype=np.int64) indptr_np = np.array([0,4,8,12,16,20], dtype=np.int64) a = mx.nd.sparse.csr_matrix((data_np, indices_np, indptr_np), shape=shape) seed = mx.nd.array([0,1,2,3,4], dtype=np.int64) out = mx.nd.contrib.dgl_csr_neighbor_uniform_sample(a, seed, num_args=2, num_hops=1, num_neighbor=2, max_num_vertices=6) subg_v = out[0] subg = out[1] compact = mx.nd.contrib.dgl_graph_compact(subg, subg_v, graph_sizes=(subg_v[-1].asnumpy()[0]), return_mapping=False) compact.asnumpy() array([[0, 0, 0, 1, 0], [2, 0, 3, 0, 0], [0, 4, 0, 0, 5], [0, 6, 0, 0, 7], [8, 9, 0, 0, 0]])
相关用法
- Python mxnet.contrib.ndarray.dgl_subgraph用法及代码示例
- Python mxnet.contrib.ndarray.dgl_csr_neighbor_non_uniform_sample用法及代码示例
- Python mxnet.contrib.ndarray.dgl_csr_neighbor_uniform_sample用法及代码示例
- Python mxnet.contrib.ndarray.dgl_adjacency用法及代码示例
- Python mxnet.contrib.ndarray.index_copy用法及代码示例
- Python mxnet.contrib.ndarray.hawkesll用法及代码示例
- Python mxnet.contrib.ndarray.SparseEmbedding用法及代码示例
- Python mxnet.contrib.ndarray.ifft用法及代码示例
- Python mxnet.contrib.ndarray.group_adagrad_update用法及代码示例
- Python mxnet.contrib.ndarray.fft用法及代码示例
- Python mxnet.contrib.ndarray.boolean_mask用法及代码示例
- Python mxnet.contrib.ndarray.edge_id用法及代码示例
- Python mxnet.contrib.ndarray.ModulatedDeformableConvolution用法及代码示例
- Python mxnet.contrib.ndarray.arange_like用法及代码示例
- Python mxnet.contrib.ndarray.box_nms用法及代码示例
- Python mxnet.contrib.ndarray.index_array用法及代码示例
- Python mxnet.contrib.ndarray.count_sketch用法及代码示例
- Python mxnet.contrib.ndarray.box_non_maximum_suppression用法及代码示例
- Python mxnet.contrib.ndarray.DeformableConvolution用法及代码示例
- Python mxnet.contrib.ndarray.quadratic用法及代码示例
注:本文由纯净天空筛选整理自apache.org大神的英文原创作品 mxnet.contrib.ndarray.dgl_graph_compact。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。