python tutorial

目录

Beginning Python

1.matplotlib:example of figures

https://matplotlib.org/gallery/index.html

2.font Chinese

import matplotlib.font_manager as fm
import matplotlib.pyplot as plt

plt.title("折线图进阶",fontproperties="simhei")

or

plt.rcParams['font.sans-serif']=['SimHei']

3.print method

print(int(str(i)+str(j)+str(k)),end=' ')

4.if-else

min = x if x<y else y

5.compare two numbers

0.4-0.3 == 0.1 #deviation
math.isclose(0.4-0.3,0.1) 

6.Parameters of legend

plt.legend(loc='best')
plt.legend(loc="upper right",fontsize=8,borderaxespad=0.3)

7.Machine Learning

https://scikit-learn.org/stable/index.html

8.SVM

LibSVM: https://www.csie.ntu.edu.tw/~cjlin/libsvm/

SVM-Light: http://svmlight.joachims.org/

Liblinear:https://www.csie.ntu.edu.tw/~cjlin/liblinear/

valid:

http://ntur.lib.ntu.edu.tw/bitstream/246246/20060927122847351581/1/libsvm.pdf

Tool of Deep Learning

  1. PaddlePaddle: https://github.com/PaddlePaddle/Paddle

    https://paddlepaddle.org

  2. Caffe(image): https://github.com/BVLC/caffe

  3. Tensorflow(C++): https://github.com/tensorflow/tensorflow

  4. keras(Python): https://github.com/fchollet/keras

Tool of Reinforcement Learning

  1. PARL: https://github.com/paddlepaddle/parl

    DQN, DDPG, PPO, A2C

https://pan.baidu.com/s/1t_mBGiwre7eGTio-0MRqmQ

4efy

PyCharm

  1. link: https://pan.baidu.com/s/1t_mBGiwre7eGTio-0MRqmQ
  2. code: 4efy

PiP command

upgrade pip : python -m pip install --upgrade pip

image augmentation

https://github.com/aleju/imgaug

Deep Reinforcement Learning

python tutorial

Attention Matrix Visualization

  1. https://medium.com/datalogue/attention-in-keras-1892773a4f22
  2. https://github.com/zhaocq-nlp/Attention-Visualization
  3. https://github.com/Aurelius84/SPWE

relation between words --decoder

path

(r’D:\python\image.jpg') \ recognization

jieba library

install:

  • easy_install jieba or pip install jieba or pip3 install jieba
  • https://pypi.python.org/pypi/jieba/ python setup.py install
  • put the content of jieba to site-packages
  • import jiebe

numpy list array

python tutorial

​ install: python -m pip intall --user numpy

python tutorial

Python environment conda

1.Create a new environment:

conda create --name <env_name> <package_name>

​ example:

conda create --name python3 python3.7

2.List all envs

conda info --envs

3.activate/del environment

conda activate python3

conda deactivate

conda remove --name python3 --all

  1. Tsinghua tuna
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

conda config --set show_channel_urls yes

conda install numpy

conda remove numpy

conda remove --name <env_name> <package_name>

  • version

conda search --full-name pandas

  • conda list

combinations and permutations

from itertools import *

characters = '1234'
for item in combinations(characters,3):
	print(item,end=' ')
print('\n'+'='*20)
for item in permutations(characters,3):
	print(item,end=' ')

file copy and delete

shutil

Random

import random
random.choice('a','b','c')
random.sample(range(100),10) # sampling without replacement
random.random() # random float 0-1
random.randrange(6) # random integer chosen from range(6)
上一篇:Oracle Words Spelling Error


下一篇:Tutorial 1_UML与面向对象程序设计基本原则