【GPU】Install Tensorflow GPU with CUDA 10.1 for python on Windows

How to install Tensorflow GPU with CUDA 10.1 for python on Windows 在cuda 10.0的windows上安装Tensorflow GPU, python ref: https://www.pytorials.com/how-to-install-tensorflow-gpu-with-cuda-10-0-for-python-on-windows/ But the above link is too complicated and the success is not garanteed. Before start, Notations neet to know: 20190825: Note the cuda10.1 is NOT supported by pyTorch by now. Want pyTorch? recommend: cuda10.0 Install Tensorflow GPU with CUDA 10.1 for python on Windows Tasks (四位爷): Install visual studio Install Cuda (i.e., Cuda ToolKit) Install cuDNN Install tensorflow 那么问题是,这四位爷的版本得对上。 所以就有人做了这个东西:https://github.com/fo40225/tensorflow-windows-wheel 里面详细列出来每个安装包对应的四位爷的版本。follow this link to strictly keep the fix of versions.

READ MORE

【GPU】ubuntu 18.4 install GPU

put the below into inst_gpu.sh file: #!/bin/bash ## This gist contains step by step instructions to install cuda v9.0 and cudnn 7.2 in ubuntu 18.04 ### steps #### # verify the system has a cuda-capable gpu # download and install the nvidia cuda toolkit and cudnn # setup environmental variables # verify the installation # CUDA 9.0 requires NVIDIA driver version 384 or above ### ### to verify your gpu is cuda enable check lspci | grep -i nvidia ### gcc compiler is required for development using the cuda toolkit.

READ MORE

weighted choice in python

对列表按概率采样 Input: a collection C of elements and a probability distribution p over C; Output: an element chosen at random from C according to p. C有n 个元素,1-n, 概率 (p = (p[1], …, p[n])。 我们只有random.random()函数,它会给我们均匀分布的[0,1]上的一个float. 基本思想是分割[0,1]into n segments of length p[1] … p[n] ( ∑ p[i] = 1) . 如果均匀地在[0,1]上打点,那它在第i个segment上停住的概率就是p[i]. 因此可以用random.random()函数来实现。查看停止的地方在[0,1]的哪个位置,然后返回其所在的那个segment index. python如下实现: ref: https://scaron.info/blog/python-weighted-choice.html 对列表按概率采样 import random import collections def weighted_choice(seq, weights): assert len(weights) == len(seq) assert abs(1. - sum(weights)) < 1e-6 x = random.random() for i, elmt in enumerate(seq): if x <= weights[i]: return elmt x -= weights[i] def gen_weight_list(seq, gt_set, incline_ratio): ''' :param seq: :param gt_list: :param incline_ratio: :return: seqe = [1,2,3,4,5] gt_list = [3,5,7] # incline_ratio = 0.

READ MORE

python绘制图的度分布柱状图, draw graph degree histogram with Python

图的度数分布 import collections import matplotlib.pyplot as plt import networkx as nx G = nx.gnp_random_graph(100, 0.02) degree_sequence = sorted([d for n, d in G.degree()], reverse=True) # degree sequence # print "Degree sequence", degree_sequence degreeCount = collections.Counter(degree_sequence) deg, cnt = zip(*degreeCount.items()) # #as an alternation, you can pick out the top N items for the plot: #d = sorted(degreeCount.items(), key=lambda item:item[1], reverse=True)[:30] # pick out the up 30 items from counter #deg = [i[0] for i in d] #cnt = [i[1] for i in d] fig, ax = plt.

READ MORE

一波儿networkx 读写edgelist,给节点加attribute的操作

一波儿networkx 读写edgelist,给节点加attribute的操作 read more: nx official: Reading and writing graphs import numpy as np import networkx as nx import operator G1 = nx.DiGraph(name='network1') # Directed Graph #networkx 导入edgelist with open(net1_path, 'r') as edgeReader: # 从文件中读取edgelist生成Graph of networkx for line in edgeReader.readlines(): edges_net1.append(tuple(map(int, line.strip().split(' ')))) G1.add_edges_from(edges_net1) print('\n== info of net1 original: ') print(nx.info(G1)) triad_list_net1 = [] for i in edges_net1: triad = tuple([i[0], i[1], i[0]+i[1]]) triad_list_net1.append(triad) # list of triads triad_list_net1.sort(key=operator.itemgetter(2)) # sort the list by the 3rd item of triad isgt_dict1 = dict(zip(G1.

READ MORE

The list of list is modified unexpected, python

Be careful! The list of list is modified unexpected, python # code patch A: list = [1,2,3,4,5,6,7] print('list A :', list) for i in list: temp = i if i > 5: temp = i + 10000 print('list A\':', list) # code patch B: list = [[1],[2],[3],[4],[5],[6],[7]] new_list = [] print('\nlist B : ',list) for i in list: temp = i # will this allocate a new RAM space for var 'temp'? if i[0] > 5: temp[0] = i[0] + 1000 new_list.

READ MORE

Graph Convolutional Network

How to do Deep Learning on Graphs with Graph Convolutional Networks https://towardsdatascience.com/how-to-do-deep-learning-on-graphs-with-graph-convolutional-networks-7d2250723780 scientific internet may need.

READ MORE

Check the port occupy on Mac OSX

Check the port occupy on Mac OSX lsof -i :7070 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME sivoxy 64888 wgg 6u IPv4 0x6ddd270 0t0 TCP *:gds_db (LISTEN) We have the PID of that app occupying port. Locating the executable file of that PID ps xuwww -p PID PID (64888) is the process id you are looking. for More help on pscommand you can find with man ps

READ MORE

Change the environment variable for python code running

python程序运行中改变环境变量: Trying to change the way the loader works for a running Python is very tricky; probably OS/version dependent; may not work. One work-around that might help in some circumstances is to launch a sub-process that changes the environment parameter using a shell script and then launch a new Python using the shell. So, before the python code is executed, the env var is loaded. Ref: https://stackoverflow.com/questions/1178094/change-current-process-environments-ld-library-path But how to launch a sub-process that changes the environment parameter: You can ref: https://stackoverflow.

READ MORE

basic deepwalk

Get to know How deepwalk works by this project. Two steps: 1. gen the graph, and gen the corpus on the graph via random walk. 2. use the corpus generated by step1 to fit the Word2vec model and calculate the similarity of two nodes. Project link: https://gitee.com/sonica/basic-deepwalk Read more about develop word2vec model with python: https://machinelearningmastery.com/develop-word-embeddings-python-gensim/ This blog will tell you: How to train your own word2vec word embedding model on text data. How to visualize a trained word embedding model using Principal Component Analysis.

READ MORE