您的位置:首页 > 编程语言 > Python开发

[DL]python使用相关工具说明

2017-05-07 17:05 267 查看
说明:当前基本以windows版本下的使用介绍,from udacity

1.Dos conmand

熟悉基本指令:Windows-command-line-basics

目录切换: cd \ ; F: ; cd .. ; dir (相当于ls) path

2.python包管理工具 anaconda

2.1安装Anaconda

conda list
conda upgrade --all
conda install package-name (such as numpy)
conda install pkg1 pkg2 pkg=1.0
conda自动安装相应的依赖 (suchas, scipy依赖numpy)
conda remove pkg-name
conda list
conda search pkg


2.2管理环境

conda create -n env_name pkg1 pkg2(创建安装有pkg1 pkg2的env_name环境)
conda create -n py3 python=3.5
conda env lsit
进入环境:activate py3
进入环境后,你会在终端提示符中看到环境名称,它类似于 (my_env) ~ $。环境中只安装了几个默认的包,以及你在创建它时安装的包。
conda list
继续安装: conda install pkg_name2
退出原环境: deactivate py3


2.3 保存与加载环境

conda env export > environment_1.yaml
利用环境文件创建新环境:
conda env create -f environment_1.yaml
conda env list
conda env remove -n env_name


个人proect 最好采用创建环境的方式, conda共享或用pip freeze的方式。

conda详细手册

py2与py3中print区别

#py2
print "Hello", "world!"
#py3
print("Hello", "world!")
#Python 2.6+ 导入函数print_function
from __future__ import print_function
print("Hello", "world!")


3 Jupyter notebook

Jupyter notebook 是一种 Web 应用,能让用户将说明文本、数学方程、代码和可视化内容全部组合到一个易于共享的文档中。

How IPython and Jupyter Notebook work



3.1 安装jupyter notebook

conda install jupyter notebook
pip install jupyter notebook (或)


C:\Users\yhzhao.conda

3.2 启动notebook服务器

jupyter notebook
服务器地址 http://localhost:8888 jupyter notebook password  创建服务器密码




终端中两次 Ctrl + C,可以关闭整个服务器。记得关闭 noteboo前保存相应内容

3.3 Magic 关键字 嵌入jupyter的命令行中

使用 %matplotlib 将 matplotlib 设置为以交互方式在 notebook 中工作。Magic 命令的前面带有一个或两个百分号(% 或 %%),分别对应行 Magic 命令和单元格 Magic 命令。

%%timeit
%matplotlib
%config InlineBackend.figure_format = 'retina' 来呈现分辨率较高的图像。
%pdb 开启交互式调试器


more

3.4 Python·Jupyter Notebook各种使用方法记录·持续更新

PythonJupyter Notebook各种使用方法记录持续更新
一 Jupyter NoteBook的安装
1 新版本Anaconda自带Jupyter
2 老版本Anacodna需自己安装Jupyter
二 更改Jupyter notebook的工作空间
1 Jupyter的工作空间在哪里指定
2 如何找到该配置文件
三Jupyter的各种快捷键
四Jupyter Notebook如何导入代码
1 将本地的py文件load到jupyter的一个cell中
2 从网络load代码到jupyter
五Jupyter运行python文件
六Jupyter一些其他琐碎用法
1 jupyter的cell可以作为unix command使用
2 Magic functions
3 获取current working directory
4 使用Matplotlib绘图
七Jupyter中的Markdown
1 在jupyter中设置link需要设置两部分
2 为Jupyter Notebook添加目录功能


(为Jupyter Notebook添加目录) []https://zhuanlan.zhihu.com/p/24029578?refer=learnMLb/jupyter_contrib_nbextensions]

4 markdown的使用说明

4.1 标题’#’

# Header 1
## Header 2
### Header 3


4.2 链接 []和()

[kint_zhao](http://blog.csdn.net/zyh821351004)


kint_zhao

4.3 强调效果(* 或 _)

对于斜体,在文本两侧加上一个星号或下划线

粗体文本使用两个符号

_gelato_ 或 *gelato*
会呈现为 gelato 或 gelato 。

**aardvark** 或 __aardvark__
会呈现为aardvarkaardvark

4.4 代码

可以通过两种不同的方式显示代码,一种是与文本内联,另一种是将代码块与文本分离。要将代码变为内联格式,请在文本两侧加上反撇号。
```


要创建代码块,请另起一行并用三个反撇号将文本包起来:“`

或者将代码块的每一行都缩进四个空格。

import requests

response = requests.get(‘https://www.udacity.com‘)

4.5 数学表达式

latex入门指导文档

在 Markdown 单元格中,可以使用 LaTeX 符号创建数学表达式。notebook 使用 MathJax 将 LaTeX 符号呈现为数学符号。要启动数学模式,请在 LaTeX 符号两侧加上美元符号
$  $
,以创建内联的数学表达式。对于数学符号块,请使用两个美元符号
$$  $$


y=mx+b

P(A∣B)=P(B∣A)P(A)P(B)

e2x e2x 10C5

2π−−√

α,β,γ : α, β, γ.

Φ,Λ,Γ : Φ, Λ, Γ.

Note that uppercase beta is just B, so there is no \Beta.

×,±,∪,⊕ : ×, ±, ∪, ⊕

sin,cosh,arctan : sinsin, coshcosh, arctanarctan.

≤,≥,≈,≠ : ≤, ≥, ≈, ≠

⋯,…,⋱ : ⋯, …, ⋱

∞,∇,∂ : ∞, ∇, ∂

Put a hat: :x^ absˆ

means :x¯ abs¯¯¯¯¯

derivatives :x˙ x¨

Arrows: :x⃗ ,xy−→

z=(dxdy)1/3

make brackets stretchy, use \left and \right,

z=(dxdy)1/3

Vertical lines with | or \vert |x| |x

P(A∣B)

Angle brackets: ⟨ϕ∣ψ⟩ gives ⟨ϕ∣ψ⟩

Group brackets for matrices (also, hey, here’s how to make a matrix):

⎧⎩⎪⎪⎪acbd⎫⎭⎪⎪⎪

∫f(x)dx gives

Fornon−italicizedRomantext,useRomanorRoman:RomanRomanorRomanRomanTochangethefontsize:tinyTinysmallnormallgLgLGhgHg

For larger spaces, use and.

对齐

a1=b1+c1a2=b2+c2+d2

a1a2=b1+c1=b2+c2+d2

$$y=mx+b$$
$$P(A\mid B) = \frac{P(B\mid A)P(A)}{P(B)}$$

$e^2x$  $e^{2x}$  $_{10}C_5$

$\sqrt{2\pi}$
$\alpha, \beta, \gamma$  : α, β, γ.

$\Phi, \Lambda, \Gamma$   : Φ, Λ, Γ.
Note that uppercase beta is just B, so there is no $\Beta$.

$ \times,\pm, \cup, \oplus$  : ×, ±, ∪, ⊕

$ \sin, \cosh, \arctan$ : sinsin, coshcosh, arctanarctan.

$ \leq, \geq, \approx, \neq$ : ≤, ≥, ≈, ≠

$ \cdots, \ldots, \ddots$ : ⋯, …, ⋱

$ \infty, \nabla, \partial$ : ∞, ∇, ∂

Put a hat:    :$ \hat x $  $ \widehat{abs}$
means         :$ \bar x$   $ \overline{abs}$
derivatives   :$ \dot x$   $ \ddot x$
Arrows:       :$ \vec{x}$ ,$ \overrightarrow{xy} $

$z = (\frac{dx}{dy})^{1/3}$

make brackets stretchy, use \left and \right,
$$z = \left(\frac{dx}{dy}\right)^{1/3}$$

Vertical lines with | or \vert   $|x|$ $\vert x$
$P(A\mid B)$

Angle brackets: $\langle \phi \mid \psi \rangle$ gives ⟨ϕ∣ψ⟩

Group brackets for matrices (also, hey, here's how to make a matrix):
$\left\lgroup \matrix{a & b\cr c & d} \right\rgroup$

$\int f(x)\,dx$ gives

$$
For non-italicized Roman text, use \textrm{Roman} or \rm Roman: RomanRoman or RomanRoman
To change the font size: \rm\tiny tiny \Tiny Tiny \small small \normalsize normal \large lg \Large Lg \LARGE LG \huge hg \Huge Hg
$$

For larger spaces, use $\quad and \qquad$.

对齐
$$
a_1 = b_1 + c_1 \\
a_2 = b_2 + c_2 + d_2
$$

$$
\begin{align}
a_1 & = b_1 + c_1 \\
a_2 & = b_2 + c_2 + d_2
\end{align}
$$
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息