GCN code parsing 
2018-07-18 20:39:11

utils.py 

--- load data 

def load_data(path="../data/cora/", dataset="cora"):
"""Load citation network dataset (cora only for now)"""
print('Loading {} dataset...'.format(dataset)) idx_features_labels = np.genfromtxt("{}{}.content".format(path, dataset),
dtype=np.dtype(str))
features = sp.csr_matrix(idx_features_labels[:, 1:-1], dtype=np.float32)
labels = encode_onehot(idx_features_labels[:, -1]) # build graph
idx = np.array(idx_features_labels[:, 0], dtype=np.int32)
idx_map = {j: i for i, j in enumerate(idx)}
edges_unordered = np.genfromtxt("{}{}.cites".format(path, dataset),
dtype=np.int32)
edges = np.array(list(map(idx_map.get, edges_unordered.flatten())),
dtype=np.int32).reshape(edges_unordered.shape)
adj = sp.coo_matrix((np.ones(edges.shape[0]), (edges[:, 0], edges[:, 1])),
shape=(labels.shape[0], labels.shape[0]),
dtype=np.float32) # build symmetric adjacency matrix
adj = adj + adj.T.multiply(adj.T > adj) - adj.multiply(adj.T > adj) features = normalize(features)
adj = normalize(adj + sp.eye(adj.shape[0])) idx_train = range(140)
idx_val = range(200, 500)
idx_test = range(500, 1500) features = torch.FloatTensor(np.array(features.todense()))
labels = torch.LongTensor(np.where(labels)[1])
adj = sparse_mx_to_torch_sparse_tensor(adj) idx_train = torch.LongTensor(idx_train)
idx_val = torch.LongTensor(idx_val)
idx_test = torch.LongTensor(idx_test) return adj, features, labels, idx_train, idx_val, idx_test

## adj: torch.size([2708, 2708])
## features: torch.Size([2708, 1433])
## labels: torch.Size([2708])
## idx_train: torch.Size([140])
## idx_val: torch.Size([300])
## idx_test: torch.Size([1000])

train.py

GCN code parsing的更多相关文章

  1. codeforce 225B Code Parsing

      Little Vitaly loves different algorithms. Today he has invented a new algorithm just for you. Vita ...

  2. Rewrite MSIL Code on the Fly with the .NET Framework Profiling API

    http://clrprofiler.codeplex.com/ http://blogs.msdn.com/b/davbr/archive/2012/11/19/clrprofiler-4-5-re ...

  3. Codeforces Round #156 (Div. 2)

    A. Greg's Workout 模3求和,算最大值. B. Code Parsing 最后左半部分为x,右半部分为y,那么从中间不断去掉xy,直到其中一种全部消去. C. Almost Arith ...

  4. eclipseGUI的可视化开发工具插件

    一   各种GUI开发插件的特色 Eclipse并不自带GUI的可视化开发工具,那么如果要在Eclipse进行可视化的GUI开发,就需要依靠第三方的插件. 1. Visual Editor Eclip ...

  5. Dojo Style Guide

    Contents: General Quick Reference Naming Conventions Specific Naming Conventions Files Variables Lay ...

  6. 浏览器详谈及其内部工作机制 —— web开发必读

    浏览器介绍 如今,浏览器格局基本上是五分天下,分别是:IE.Firefox.Safari.Chrome.Opera,而浏览器引擎就更加集中了,主要是四大巨头:IE的浏览器排版引擎Trident,目前随 ...

  7. Awesome Go精选的Go框架,库和软件的精选清单.A curated list of awesome Go frameworks, libraries and software

    Awesome Go      financial support to Awesome Go A curated list of awesome Go frameworks, libraries a ...

  8. {Reship}{Code}{CV}

    UIUC的Jia-Bin Huang同学收集了很多计算机视觉方面的代码,链接如下: https://netfiles.uiuc.edu/jbhuang1/www/resources/vision/in ...

  9. Don't Block on Async Code【转】

    http://blog.stephencleary.com/2012/07/dont-block-on-async-code.html This is a problem that is brough ...

随机推荐

  1. 【转】C#中base关键字的几种用法

    base其实最大的使用地方在面相对性开发的多态性上,base可以完成创建派生类实例时调用其基类构造函数或者调用基类上已被其他方法重写的方法.例如: 2.1关于base调用基类构造函数 public c ...

  2. Python -- Pandas介绍及简单实用【转】

    转http://www.datadependence.com/2016/05/scientific-python-pandas/ 一. Pandas简介 1.Python Data Analysis ...

  3. python: ImportError: cannot import name 'Style' from 'openpyxl.styles' 解决方法

    import os, openpyxl from openpyxl.styles import Font, Style os.chdir("C:\\") wb = openpyxl ...

  4. svnrdump:E175000:SSL is not supported错误的解决

    参考博客:https://www.cnblogs.com/jkko123/p/6358461.html 参考博客:https://blog.csdn.net/w171066/article/detai ...

  5. android TextView Unicde编码转换 android中一些特殊字符Unicode码值

    android TextView Unicde编码转换 android中一些特殊字符Unicode码值 android中一些特殊字符(如:←↑→↓等箭头符号,约等于号≍)的Unicode码值 Text ...

  6. 加密对象到locastorage / 从 locastorage解密对象

    var obj={name:"致远",age:21,address:"江西上饶XXXX",hobby:"看书,编程"};//用中文 记得加e ...

  7. js数组内数字按大小排序实现函数

    正常冒泡排序: function evlabc(a) { //排序大小 var i = j = t = 0; for (i = 0; i < a.length; i++) { for (j = ...

  8. 怎样从外网访问内网Jupyter Notebook?

    本地安装了一个Jupyter Notebook,只能在局域网内访问,怎样从外网也能访问到本地的Jupyter Notebook呢?本文将介绍具体的实现步骤. 准备工作 安装并启动Jupyter Not ...

  9. qt裁剪

    1. qt裁剪是什么,qt有哪些模块 1.1 2. windows消息机制,qt的signal slot,android/ios消息机制?

  10. EL和jstl(概念和使用方法)

    概念: 1 .  JSP 标签 是用来替换java代码的技术,容器遇到标签后会将其转换成java代码,jsp标签类似于开始标记.属性.结束标记.标签体. EL表达式是一套简单的运算规则,用于给jsp标 ...