2018-04-07 修改OpenEN,修改TF警告⚠️
2018-04-07 本文已影响45人
啊哈JC熙
1. 修改 OpenEN
主要问题:
(1)import 本地编写的py文件在路径上有问题
还有要注意工程之间的链接和应用
一般都是相对路径,哦!
from libnrl.gcn.utils import *
(2)python版本修改
由于OpenEN是python2的,今天将open修改为pyrhon3.6版本
其中修改主要是print语句
for i in range(20):
print('Iteration ', i)
Iteration 0
Iteration 1
Iteration 2
Iteration 3
Iteration 4
Iteration 5
Iteration 6
Iteration 7
Iteration 8
Iteration 9
Iteration 10
Iteration 11
Iteration 12
Iteration 13
Iteration 14
Iteration 15
Iteration 16
Iteration 17
Iteration 18
Iteration 19
把print('Iteration ', i)改为print 'Iteration ', i 就把python从2.7 改为了python3.6
对于这个问题我只能2333333
一开始打开这个开源项目,吓了我一跳,怎么不能运行,一看报print,2333333
(3)安装gensim
from gensim.models import Word2Vecå
一开始还pip了半 天的Word2Vec,2333333
lijuncheng@lijunchengdeMacBook-Pro ~ $ pip install Word2Vec
Requirement already satisfied: Word2Vec in ./anaconda3/lib/python3.6/site-packages
Requirement already satisfied: numpy in ./anaconda3/lib/python3.6/site-packages (from Word2Vec)
Requirement already satisfied: cython in ./anaconda3/lib/python3.6/site-packages (from Word2Vec)
lijuncheng@lijunchengdeMacBook-Pro ~ $ python
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 6 2017, 12:04:38)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Word2Vec
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'Word2Vec'
>>> import Word2Vec
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'Word2Vec'
>>> quit()
lijuncheng@lijunchengdeMacBook-Pro ~ $ pip install gensim
Collecting gensim
Downloading gensim-3.4.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (22.8MB)
100% |████████████████████████████████| 22.8MB 61kB/s
Requirement already satisfied: numpy>=1.11.3 in ./anaconda3/lib/python3.6/site-packages (from gensim)
Collecting smart-open>=1.2.1 (from gensim)
Downloading smart_open-1.5.7.tar.gz
Requirement already satisfied: scipy>=0.18.1 in ./anaconda3/lib/python3.6/site-packages (from gensim)
Requirement already satisfied: six>=1.5.0 in ./anaconda3/lib/python3.6/site-packages (from gensim)
Requirement already satisfied: boto>=2.32 in ./anaconda3/lib/python3.6/site-packages (from smart-open>=1.2.1->gensim)
Collecting bz2file (from smart-open>=1.2.1->gensim)
Downloading bz2file-0.98.tar.gz
Requirement already satisfied: requests in ./anaconda3/lib/python3.6/site-packages (from smart-open>=1.2.1->gensim)
Collecting boto3 (from smart-open>=1.2.1->gensim)
Downloading boto3-1.7.2-py2.py3-none-any.whl (128kB)
100% |████████████████████████████████| 133kB 496kB/s
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in ./anaconda3/lib/python3.6/site-packages (from requests->smart-open>=1.2.1->gensim)
Requirement already satisfied: idna<2.7,>=2.5 in ./anaconda3/lib/python3.6/site-packages (from requests->smart-open>=1.2.1->gensim)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in ./anaconda3/lib/python3.6/site-packages (from requests->smart-open>=1.2.1->gensim)
Requirement already satisfied: certifi>=2017.4.17 in ./anaconda3/lib/python3.6/site-packages (from requests->smart-open>=1.2.1->gensim)
Collecting s3transfer<0.2.0,>=0.1.10 (from boto3->smart-open>=1.2.1->gensim)
Downloading s3transfer-0.1.13-py2.py3-none-any.whl (59kB)
100% |████████████████████████████████| 61kB 444kB/s
Collecting jmespath<1.0.0,>=0.7.1 (from boto3->smart-open>=1.2.1->gensim)
Downloading jmespath-0.9.3-py2.py3-none-any.whl
Collecting botocore<1.11.0,>=1.10.2 (from boto3->smart-open>=1.2.1->gensim)
Downloading botocore-1.10.2-py2.py3-none-any.whl (4.2MB)
100% |████████████████████████████████| 4.2MB 271kB/s
Requirement already satisfied: python-dateutil<2.7.0,>=2.1 in ./anaconda3/lib/python3.6/site-packages (from botocore<1.11.0,>=1.10.2->boto3->smart-open>=1.2.1->gensim)
Requirement already satisfied: docutils>=0.10 in ./anaconda3/lib/python3.6/site-packages (from botocore<1.11.0,>=1.10.2->boto3->smart-open>=1.2.1->gensim)
Building wheels for collected packages: smart-open, bz2file
Running setup.py bdist_wheel for smart-open ... done
Stored in directory: /Users/lijuncheng/Library/Caches/pip/wheels/cf/54/36/b003d8c2d26aadffc21f0677009ed53cf9575a97fc71fbba76
Running setup.py bdist_wheel for bz2file ... done
Stored in directory: /Users/lijuncheng/Library/Caches/pip/wheels/31/9c/20/996d65ca104cbca940b1b053299b68459391c01c774d073126
Successfully built smart-open bz2file
Installing collected packages: bz2file, jmespath, botocore, s3transfer, boto3, smart-open, gensim
Successfully installed boto3-1.7.2 botocore-1.10.2 bz2file-0.98 gensim-3.4.0 jmespath-0.9.3 s3transfer-0.1.13 smart-open-1.5.7
(4)测试运行
python src/main.py --method node2vec --label-file data/blogCatalog/bc_labels.txt --input data/blogCatalog/bc_adjlist.txt --graph-format adjlist --output vec_all.txt --q 0.25 --p 0.25


python src/main.py --method gcn --label-file data/cora/cora_labels.txt --input data/cora/cora_edgelist.txt --graph-format edgelist --feature-file data/cora/cora.features --epochs 200 --output vec_all.txt --clf-ratio 0.1


2.修改TF警告
警告⚠️:
2018-04-07 17:54:07.725382: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2018-04-07 17:54:07.725402: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2018-04-07 17:54:07.725407: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2018-04-07 17:54:07.725412: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2018-04-07 17:54:07.725417: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
警告原因好像是由于:什么指令集不对怎么样
TensorFlow CPU环境 SSE/AVX/FMA 指令集编译
在StackOverflow上找到相关解释:https://stackoverflow.com/questions/41293077/how-to-compile-tensorflow-with-sse4-2-and-avx-instructions
解决:添加两行代码
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
效果

接下来还有继续跟进对NE的学习,加油。距离月底还有22天,希望尽快形成有小论文的想法。加油⛽️,加油⛽️,加油⛽️....
宝宝明天要上班啦,希望宝宝每天都开心,快乐。少生点气,其实生活很美好😂😂😊