小行星

热爱平淡,向往未知


  • 首页

  • 分类

  • 归档

  • 关于

  • 阅读排行

  • 搜索

git使用

发表于 2018-02-Sat | 阅读次数:

远程操作

git clone

git remote

git fetch

git pull

git push

git clone

1
git clone <版本库的网址> <本地目录名>

git remote -v

显示remote 信息

1
git remote add <主机名> <网址>
1
git remote rm <主机名>
1
git remote rename <原主机名> <新主机名>

git fetch

1
2
git fetch <远程主机名> <分支名>
git fetch origin master
1
git merge origin/master

git pull

1
git pull <远程主机名> <远程分支名>:<本地分支名>
1
git pull origin next  默认省去本地的

本地master 自动追踪origin/master, 这样可以修改

1
git branch --set-upstream master origin/next
1
git pull origin 本地分支自动追踪远程对应分支
1
git pull 如果本地只有一个分支

自动删除远程删除的

1
2
3
4
git pull -p
# 等同于下面的命令
git fetch --prune origin
git fetch -p

git push

1
git push <远程主机名> <本地分支名>:<远程分支名>

指定默认推送主机/分支

1
git push -u origin master

增加tag

1
git push origin --tags

http://www.ruanyifeng.com/blog/2014/06/git_remote.html

pyenv 虚拟环境

发表于 2018-01-Tue | 阅读次数:
1
2
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
export PYENV_VIRTUALENV_DISABLE_PROMPT=1

查看本机安装 Python 版本

1
pyenv versions

查看可安装 Python 版本

1
pyenv install -l

python 安装与卸载

1
2
$ pyenv install 2.7.3   # 安装python
$ pyenv uninstall 2.7.3 # 卸载python

python切换

1
2
$ pyenv global 2.7.3  # 设置全局的 Python 版本,通过将版本号写入 ~/.pyenv/version 文件的方式。
$ pyenv local 2.7.3 # 设置 Python 本地版本,通过将版本号写入当前目录下的 .python-version 文件的方式。通过这种方式设置的 Python 版本优先级较 global 高。

创建虚拟环境

1
$ pyenv virtualenv 2.7.10 env-2.7.10

列出当前虚拟环境

1
2
3
pyenv virtualenvs
pyenv activate env-name # 激活虚拟环境
pyenv deactivate #退出虚拟环境,回到系统环境

删除虚拟环境

1
2
pyenv uninstall my-virtual-env
rm -rf ~/.pyenv/versions/env-name # 或者删除其真实目录

更换 pip 源

1
2
3
4
5
6
vim ~/.pip/pip.conf
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com


http://einverne.github.io/post/2017/04/pyenv.html

pytorch tensor常用函数

发表于 2018-01-Mon | 阅读次数:
1
2
3
4
5
6
7
a = Variable(torch.Tensor([1, 2, 3]))
print(a.size(0))
``

```python
if output.data.is_cuda:
output.data = output.data.cpu()
1
2
3
4
keypoints = []
for sample_data in test_data_batches:
keypoints.append(output.numpy())
keypoints = np.concatenate(keypoints, axis=0)

/和//的区别

发表于 2018-01-Mon | 阅读次数:
1
2
3
4
5
In [4]: 6.9 // 2
Out[4]: 3.0

In [5]: 6.9 / 2
Out[5]: 3.45

gitignore使用

发表于 2018-01-Mon | 阅读次数:

/data/ 和 data/的区别

/data是从根目录来的
data/是任意包含data的路径

numpy十大函数

发表于 2018-01-Sun | 阅读次数:

reshape

1
a.reshape(2,4)

resize

1
a.resize(2,4)

transpose

1
b = a.transpose(1,0,2)

concatenate

1
2
3
4
5
6
7
8
9
10
11
>>> from numpy import *
>>> x = array([[1,2],[3,4]])
>>> y = array([[5,6],[7,8]])
>>> concatenate((x,y)) # default is axis=0
array([[1, 2],
[3, 4],
[5, 6],
[7, 8]])
>>> concatenate((x,y),axis=1)
array([[1, 2, 5, 6],
[3, 4, 7, 8]])

hstack

1
2
3
4
5
6
>>> from numpy import *
>>> a =array([[1],[2]]) # 2x1 array
>>> b = array([[3,4],[5,6]]) # 2x2 array
>>> hstack((a,b,a)) # only the 2nd dimension of the arrays is allowed to be different
array([[1, 3, 4, 1],
[2, 5, 6, 2]])

vstack

1
2
3
4
5
6
7
8
>>> from numpy import *
>>> a =array([1,2])
>>> b = array([[3,4],[5,6]])
>>> vstack((a,b,a)) # only the first dimension of the arrays is allowed to be different
array([[1, 2],
[3, 4],
[5, 6],
[1, 2]])

dtype

1
x_train = np.array([], dtype=np.float32)

unsqueeze

1
test_x = Variable(torch.unsqueeze(test_data.test_data, dim=1), volatile=True).type(torch.FloatTensor)[:2000]/255.   # shape from (2000, 28, 28) to (2000, 1, 28, 28), value in range(0,1)

zeros

1
2
3
4
5
6
np.zeros([20, 18])
```

### squeeze, expand_dims
```python
y = np.expand_dims(x, axis=0)

a[np.newaxis, :]

np.tile(a, [2,2])

np.append()

1
2
3

>>> np.append([1, 2, 3], [[4, 5, 6], [7, 8, 9]])
array([1, 2, 3, 4, 5, 6, 7, 8, 9])

静态库与动态库

发表于 2018-01-Sat | 阅读次数:

静态库

编译时候放入可执行文件

生成

1
2
1. gcc -c main.cpp -o main.o
2. a.o b.o c.o => all.a

命名

1
libxxx.a

操作

1
2
ar rcs libmyhello.a hello.o
gcc -o hello main.c -static -L. -lmyhello

动态库

运行时候载入内存

命名

1
libxxxx.so.major.minor

操作

1
2
gcc -shared -fPIC -o libmyhello.so hello.o
gcc -o hello main.c -L. -lmyhello

执行时候如何定位动态库位置

1
2
LD_LIBRARY_PATH 里面记录了位置
export LD_LIBRARY_PATH=’pwd’

这个目录自动包含

1
2
/lib
/usr/lib

在新安装一个库之后如何让系统能够找到他

如果安装在/lib或者/usr/lib下,那么ld默认能够找到,无需其他操作。

如果安装在其他目录,需要将其添加到/etc/ld.so.cache文件中,步骤如下

  1. 编辑/etc/ld.so.conf文件,加入库文件所在目录的路径
  2. 运行ldconfig,该命令会重建/etc/ld.so.cache文件

动态库查找目录

1
2
3
4
5
它先后搜索
1.elf文件的 DT_RPATH段
2.环境变量LD_LIBRARY_PATH
3./etc/ld.so.cache文件列表
4./lib/,/usr/lib目录找到库文件后将其载入内存,但是我们生成的共享库在当前文件夹下,并没有加到上述的4个路径的任何一个中,因此,执行后会出现错误)

查看依赖

1
ldd /bin/lnlibc.so.6

http://www.cppblog.com/deane/articles/165216.html

torch 常用函数

发表于 2018-01-Sat | 阅读次数:

Tensor的内容以及信息

z = torch.Tensor(3,4)
x = z:nDimension() – 2
y = z:size() – y的值为size2的一维数组。3和4
t = z:nElement() – 12

ssh公钥配置

发表于 2018-01-Tue | 阅读次数:
1
ssh-keygen -t rsa
1
2
3
4
A主机上操作
$ cat /root/.ssh/id_rsa.pub | ssh root@远程服务器ip 'cat - >> ~/.ssh/authorized_keys'
B主机上操作
$ chmod 600 ~/.ssh/authorized_keys
1
2
3
$ vim /etc/ssh/sshd_config
PubkeyAuthentication yes //将该项改为yes
sudo service sshd restart

batch norm预测坑

发表于 2018-01-Mon | 阅读次数:

预测的时候数据如果只有一个,输出应该都是差不多的,
因为batch norm会对它正则化。

1…515253…59
fangyh

fangyh

最爱的是那苍穹之外的浩渺宇宙

588 日志
4 分类
66 标签
© 2020 fangyh
由 Hexo 强力驱动
|
主题 — NexT.Mist v5.1.3
|本站总访问量次