twint 安装及使用

分享这个post是自己方便查,还有中文网界对这个东西介绍太少。 更多的就看github项目twint吧。 Installation: git+pip3: git clone https://github.com/twintproject/twint.git pip3 install -r requirements.txt pip3 install twint or pip3+pipenv: pip3 install --user --upgrade -e git+https://github.com/twintproject/twint.git@origin/master#egg=twint pipenv install -e git+https://github.com/twintproject/twint.git#egg=twint You may meet module cannot found error when you try to run twint after installation. On ubuntu, add ~/.local/bin into your PATH by: export PATH=$PATH:~/.local/bin You may edit ~/.bashrc file to permanately add the ‘~/.local/bin’ into your PATH. Usage: Running the twint cmd with arguments can give you results. A few simple examples to help you understand the basics:

READ MORE

【GPU】Install pyTorch GPU on Ubuntu16.04

Note: Contents below may out-of-date. But the procedures are referable. Avaliable version combinations for pyTorch/Tensorflow-gpu: python=3.6.5 CUDA=9.2.148 cuDNN=7.1.4 tf-gpu=1.9 python=3.6.5 CUDA=9.1.85 cuDNN=7.1.3 tf-gpu=1.8 CUDA=9.0.176 cudnn=7.3.1.20 tensorflow-gpu=1.12.0 CUDA=9.0; cuDNN=7.4.1 tensorflow-gpu=1.12.0; cuda=9.0; cudnn=7.5.0 tensorflow=1.8.0可以用的 python=3.6.7 cuda=9.0; cuDNN=7.4.2 tensorflow-gpu = 1.9.0 pytorch = 1.0.0 cuda=9.0; cudnn=7.0.5 ================= ================= Install: CUDA=9.0 CUDNN=7.0.5 http://www.twistedwg.com/2018/06/15/cuda9_cudnn7.html https://blog.csdn.net/lukaslong/article/details/81488219 ================= 注意python3, pip3, Follow pyTorch web: https://pytorch.org/get-started/locally/ UPDATE: sudo apt update sudo apt upgrade curl sudo apt-get install curl or: sudo apt install curl check: curl --version Anaconda curl -O https://repo.

READ MORE

【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