最近在搞二进制分析的东西,对于字符编码特别糊涂,所以学习了一下,本来觉得阮一峰的笔记挺好的,但是感觉又有点问题,所以我这里在自己总结一下,以下大部分内容还是来源于阮一峰的笔记。当然我自己总结的可能也不太对(知识有限呀),之后可以再修改。

ASCII 码

计算机中,每一个二进制位(bit)有01两种状态,因此八个二进制位就可以组合出256种状态,这被称为一个字节(byte)。也就是说,一个字节一共可以用来表示256种不同的状态,每一个状态对应一个符号,就是256个符号,从0000000011111111

上个世纪60年代,美国制定了一套字符编码,对英语字符与二进制位之间的关系,做了统一规定。这被称为 ASCII 码,一直沿用至今。

ASCII 码一共规定了128个字符的编码,比如空格SPACE是32(二进制00100000),大写的字母A是65(二进制01000001)。这128个符号(包括32个不能打印出来的控制符号),只占用了一个字节的后面7位,最前面的一位统一规定为0

阅读全文 »

之前一直知道Pytorch、numpy之类有好几种变换维度的方法,但是之前了解的不深,今天总结一下。

Reshape

Pytorch在reshape的时候,是按照行存储的方式进行的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import torch

In [16]: x = torch.randn(2, 3, 4)

In [17]: x
Out[17]:
tensor([[[ 0.2921, -0.1806, -1.0838, -0.6770],
[-0.7797, 0.2614, -0.5380, 1.8941],
[-0.7261, 0.8209, 0.0286, 0.0997]],

[[ 0.5549, 0.9036, 0.8790, -0.5776],
[ 0.3745, 0.6963, -0.3445, -0.0022],
[-0.5991, 1.4639, -0.5396, -0.1702]]])

In [19]: torch.reshape(x, (-1, 2))
Out[19]:
tensor([[ 0.2921, -0.1806],
[-1.0838, -0.6770],
[-0.7797, 0.2614],
[-0.5380, 1.8941],
[-0.7261, 0.8209],
[ 0.0286, 0.0997],
[ 0.5549, 0.9036],
[ 0.8790, -0.5776],
[ 0.3745, 0.6963],
[-0.3445, -0.0022],
[-0.5991, 1.4639],
[-0.5396, -0.1702]])

permute

阅读全文 »

brew安装历史版本

由于Mac中使用homebrew安装的库都是最新的,有时需要老版本的软件,就很难办。

在工作中想用opencv3.3,但是使用brew安装的都是3.4,后来查到个方法,就是指定需要安装的opencv.rb文件

使用brew info opencv 可以看到:(最新的是3.4,我安装的是3.3)

1
2
3
4
5
6
opencv: stable 3.4.0 (bottled)
Open source computer vision library
https://opencv.org/
/usr/local/Cellar/opencv/3.3.0_3 (516 files, 123MB) *
Poured from bottle on 2018-02-24 at 15:28:54
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/opencv.rb
阅读全文 »

注意这篇文章来源于Pytorch中的仿射变换(affine_grid),感觉写的很好,所以转运过来了。

在看 pytorch 的 Spatial Transformer Network 教程 时,在 stn 层中的 affine_gridgrid_sample 函数上卡住了,不知道这两个函数该如何使用,经过一些实验终于搞清楚了其作用。

参考:详细解读 Spatial Transformer Networks (STN),该文章与李宏毅的课程一样,推荐听李老师的 STN 这一课,讲的比较清楚;

假设我们有这么一张图片:

阅读全文 »

服务器端配置

首先配置~/.jupyter/jupyter_lab_config.py,内容为:

1
2
3
4
5
6
7
8
9
10
c.LabApp.allow_origin = '*'
c.ServerApp.ip = '0.0.0.0'
c.LabApp.allow_remote_access = True
c.LabApp.allow_root = True
c.LabApp.base_url = '/jupyter'
c.LabApp.open_browser = False
c.LabApp.token = "***********************"
c.LabApp.port = 80
c.LabApp.terminals_enabled = True
c.LabApp.tornado_settings = {'shell_command': ['/usr/bin/zsh']}

其中将c.LabApp.token为密码,当你登陆Jupyter Lab的时候需要使用。

c.LabApp.tornado_settings设置不是必须的,只是方便使用zsh时,可以通过配置让终端可以好看点。下面的Environment同理。

阅读全文 »

GAN

原理

生成对抗网络(GAN)由2个重要的部分构成:

  1. 生成器(Generator):通过机器生成数据(大部分情况下是图像),目的是“骗过”判别器
  2. 判别器(Discriminator):判断这张图像是真实的还是机器生成的,目的是找出生成器做的“假数据”

生成对抗网络GANs由生成器和判别器构成

阅读全文 »

注意:这种方法会卸载现有的Office365,具体原因未知,所以暂时不可用。

现在的电脑有的预装office365,但是此时安装visio会报错。可以采用如下方式解决。

首先从mdsn中下载最新的VisioPro2016的安装镜像,下载地址

下载之后第一步要把镜像文件加载至光驱,比如加载到了E:\。正常情况下,点击 setup 会直接进入 Visio 程序的安装,但是现在不能够进行正常的安装,在任务管理器也不会看见进程开启

第二步 到 Office 2016 Deployment Tool 下载文件,打开下载到的部署工具安装文件,选择任意路径解压;解压后路径内有一个 Setup.exe 文件和若干个配置文件;新建配置文件,例如命名为 configuration.xml,内容如下:

阅读全文 »

之前因为考虑不得当,没有采用分支的方法管理同一个工程。在github上建立了多个仓库,强迫症发作了,想合并这些仓库到同一个git中,并保留所有的git记录。具体来说,假设我们有如下几个仓库:

  1. OldA:要合并的仓库A
  2. OldB:要合并的仓库B
  3. C:将OldA和OldB两个仓库合并到该git中

具体操作过程如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
mkdir C
cd C
# Assume the current directory is where we want the new repository to be created, Create the new repository
git init

# Before we do a merge, we have to have an initial commit, so we’ll make a dummy commit
dir > deleteme.txt
git add .
git commit -m "Initial dummy commit"

# Add a remote for and fetch the old repo
git remote add -f old_a <OldA repo URL>

# Merge the files from old_a/master into new/master
git merge old_a/master
# if occurs "fatal: refusing to merge unrelated histories"
git merge old_a/master --allow-unrelated-histories

# Clean up our dummy file because we don’t need it any more
git rm .\deleteme.txt
git commit -m "Clean up initial file"

# Move the old_a repo files and folders into a subdirectory so they don’t collide with the other repo coming later
mkdir old_a
dir -exclude old_a | %{git mv $_.Name old_a}

# Commit the move
git commit -m "Move old_a files into subdir"

接着合并其余仓库,如OldB

阅读全文 »

安装

Vim大概有如下几个版本:vim、vim-athena、vim-gnome、vim-gtk、vim-gtk3、vim-noxvim-tiny。它们中有编译进最小功能的 Vim 包(vim-tiny),有较全功能的文本界面 Vim 包(vim-nox),有适用于老的 X-Window 界面的版本(vim-athena),有适用于 KDE 环境的 GTK2 版本(vim-gtk),等等。

对于Ubuntu而言,一般情况下sudo apt install vim-gtk3即可。在 Ubuntu 上,vim 和 gvim 都是指向同一个应用程序的符号链接,且 gvim 的执行效果和 vim -g 相同。所以要启动图像化界面的vim,直接在终端执行gvim即可。

另外,若使用远程软件连接到Linux机器上,需要注意远程终端软件的远程字符集(如 PuTTY 中的“Windows > Translation > Remote character set”)应当设置成 UTF-8。

然后,还可以安装中文版本的帮助文件:

阅读全文 »