GCN code parsing
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的更多相关文章
- codeforce 225B Code Parsing
Little Vitaly loves different algorithms. Today he has invented a new algorithm just for you. Vita ...
- 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 ...
- Codeforces Round #156 (Div. 2)
A. Greg's Workout 模3求和,算最大值. B. Code Parsing 最后左半部分为x,右半部分为y,那么从中间不断去掉xy,直到其中一种全部消去. C. Almost Arith ...
- eclipseGUI的可视化开发工具插件
一 各种GUI开发插件的特色 Eclipse并不自带GUI的可视化开发工具,那么如果要在Eclipse进行可视化的GUI开发,就需要依靠第三方的插件. 1. Visual Editor Eclip ...
- Dojo Style Guide
Contents: General Quick Reference Naming Conventions Specific Naming Conventions Files Variables Lay ...
- 浏览器详谈及其内部工作机制 —— web开发必读
浏览器介绍 如今,浏览器格局基本上是五分天下,分别是:IE.Firefox.Safari.Chrome.Opera,而浏览器引擎就更加集中了,主要是四大巨头:IE的浏览器排版引擎Trident,目前随 ...
- 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 ...
- {Reship}{Code}{CV}
UIUC的Jia-Bin Huang同学收集了很多计算机视觉方面的代码,链接如下: https://netfiles.uiuc.edu/jbhuang1/www/resources/vision/in ...
- 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 ...
随机推荐
- loadrunner 更新中......
一.安装及参考说明 1.51 testing 链接:http://www.51testing.com/zhuanti/LoadRunner.html 2.官网链接:http://learnloadru ...
- centos中yum命令删除还原的补救方法介绍
前言 yum,是Yellow dog Updater Modified的简称,起初是由yellow dog这一发行版的开发者Terra Soft研发,用python写成,那时还叫做yup(yellow ...
- 不能安装vmtools解决:一个命令安装
https://blog.csdn.net/fly66611/article/details/77994339 换好源 sudo su apt-get update apt-get dist-upgr ...
- Python 字典(Dictionary) values()方法
描述 Python 字典(Dictionary) values() 函数以列表返回字典中的所有值. 语法 values()方法语法: dict.values() 参数 NA. 返回值 返回字典中的所有 ...
- python 查询文本文件的层次
I/O系统有一系列的层次构建而成 下面是操作一个文本文件的例子来查看这种层次 >>> f = open('sample.txt','w') >>> f <_i ...
- BIOS 搭配 MBR/GPT 的开机流程
鸟哥私房菜书上内容: BIOS 搭配 MBR/GPT 的开机流程 在计算机概论里面我们有谈到那个可爱的BIOS与CMOS两个东西, CMOS是记录各项硬件参数且嵌入在主板上面的储存器,BIOS则是一个 ...
- docker能用来干嘛
http://blog.csdn.net/wangtaoking1/article/details/44340445 什么是Docker Docker 是一个开源项目,诞生于 2013 年初,最初 ...
- いっしょ / Be Together (暴力枚举)
题目链接:http://abc043.contest.atcoder.jp/tasks/arc059_a Time limit : 2sec / Memory limit : 256MB Score ...
- watch解放你的双手
有时候我们需要重复执行某个命令,观察某个文件和某个结果的变化情况.可以写脚本去实现这些需求,但是有更简单的方法,本文档要介绍的就是watch命令. 1. 以固定时间反复执行某个命令 root@jaki ...
- flask框架----flask入门
一.Flask介绍(轻量级的框架,非常快速的就能把程序搭建起来) Flask是一个基于Python开发并且依赖jinja2模板和Werkzeug WSGI服务的一个微型框架,对于Werkzeug本质是 ...