用法:
mxnet.ndarray.contrib.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.ndarray.contrib.dgl_csr_neighbor_uniform_sample用法及代碼示例
- Python mxnet.ndarray.contrib.dgl_subgraph用法及代碼示例
- Python mxnet.ndarray.contrib.dgl_adjacency用法及代碼示例
- Python mxnet.ndarray.contrib.dgl_csr_neighbor_non_uniform_sample用法及代碼示例
- Python mxnet.ndarray.contrib.group_adagrad_update用法及代碼示例
- Python mxnet.ndarray.contrib.index_copy用法及代碼示例
- Python mxnet.ndarray.contrib.index_array用法及代碼示例
- Python mxnet.ndarray.contrib.isinf用法及代碼示例
- Python mxnet.ndarray.contrib.allclose用法及代碼示例
- Python mxnet.ndarray.contrib.ModulatedDeformableConvolution用法及代碼示例
- Python mxnet.ndarray.contrib.quadratic用法及代碼示例
- Python mxnet.ndarray.contrib.box_non_maximum_suppression用法及代碼示例
- Python mxnet.ndarray.contrib.fft用法及代碼示例
- Python mxnet.ndarray.contrib.foreach用法及代碼示例
- Python mxnet.ndarray.contrib.arange_like用法及代碼示例
- Python mxnet.ndarray.contrib.rand_zipfian用法及代碼示例
- Python mxnet.ndarray.contrib.edge_id用法及代碼示例
- Python mxnet.ndarray.contrib.hawkesll用法及代碼示例
- Python mxnet.ndarray.contrib.cond用法及代碼示例
- Python mxnet.ndarray.contrib.SparseEmbedding用法及代碼示例
注:本文由純淨天空篩選整理自apache.org大神的英文原創作品 mxnet.ndarray.contrib.dgl_graph_compact。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。