Neo's Blog

“生活就是个缓慢受锤的过程”, 只是有的人像铁, 有的人像牛,有的人像铁牛...


  • Home

  • About

  • Archives

  • Categories

  • Tags

使用Python的translate函数处理(替换)字符和中文标点

Posted on 2019-03-05 | Edited on 2019-03-22 | In 随笔 / Writing
Symbols count in article: 740 | Reading time ≈ 1 mins.

使用Translate函数

Python3中的translate函数与Python2中已经不同了,使用Python3的方法如下.

maketrans(table,[deletion],[toNone])函数是在处理字符串str的时候,将其中的table中指定的字符一一对应映射成deletion中指定的字符,将toNone中指定的字符映射成None(即None).

例如:

1
2
3
4
5
import string
# string.punctuation中包含了常用的英文标点符号
translator = str.maketrans(dict.fromkeys(string.punctuation))
s = 'string with "punctuation" inside of it! Does this work? I hope so.'
print(s.translate(translator))

Read more »

使用PIL crop图像的错误:AttributeError: '_idat' object has no attribute 'fileno'

Posted on 2019-02-26 | Edited on 2019-03-12 | In 随笔 / Writing
Symbols count in article: 614 | Reading time ≈ 1 mins.

在使用PIL的Image类的crop方法切割图像时如果报如下错误:

1
2
3
4
5
6
7
AttributeError: '_idat' object has no attribute 'fileno'

During handling of the above exception, another exception occurred:

File "/home/username/anaconda3/lib/python3.7/site-packages/PIL/ImageFile.py", line 489, in _save
e.setimage(im.im, b)
SystemError: tile cannot extend outside image
Read more »

从Python2切换到Python3之后的UnicodeDecodeError

Posted on 2019-02-16 | In 随笔 / Writing
Symbols count in article: 140 | Reading time ≈ 1 mins.

代码从Python2切换为Python3后,使用json等工具包读取非ASCII码的数据时,会出现UnicodeDecodeError错误。
是因为Python3默认的decoding方法是ASCII。解决办法是:

在open文件的时候,显示地指定encoding方法为UTF-8

docker中安装java运行环境JRE

Posted on 2019-02-07 | Edited on 2019-03-12 | In 随笔 / Writing
Symbols count in article: 354 | Reading time ≈ 1 mins.

在docker中或者在Ubuntu命令行中安装java运行环境类似,一般有两种方法:

  1. 通过在java官网下载jdk安装包安装;
  2. 通过apt安装jre;

如果只需要java运行环境的话,方法2已经足够:
(在运行docker后,直接再命令行中运行命令即可)

1
2
sudo apt-get update
sudo apt-get install default-jre

Read more »

git本地新建分支及同步本地分支到远程

Posted on 2018-12-21 | Edited on 2019-03-12 | In 工具 / Tools
Symbols count in article: 329 | Reading time ≈ 1 mins.

本地新建分支

git新建本地分支命令:

1
git checkout -b new_branch

执行后会新建名为new_branch的分支并直接切换到该分支,相当于执行了以下语句:

1
2
git branch new_branch
git checkout new_branch

Read more »

push/pull每次要求输入密码的问题

Posted on 2018-12-21 | Edited on 2018-12-24 | In 工具 / Tools
Symbols count in article: 355 | Reading time ≈ 1 mins.

新创建的git项目,每次pull/push的时候都会要求输入用户名和密码,有两个解决方案:

方案一

进入项目根目录,打开terminal:

1
git config --global credential.helper store

可以在命令行中看到,这个helper的说明是:-- external helper to be called when a username or password credential is needed。 最后的“store”是本地存储的文件名,即在需要用户名和密码的时候会自动保存,下次就不需要了。

因此完成之后,重新任意执行一个push/pull命令,会要求再次输入用户名和密码,此次输入会自动存储,以后再执行相关命令就无须输入了

Read more »

docker运行pytorch报错:RuntimeError: DataLoader worker (pid 493) is killed by signal: Bus error. Details are lost due to multiprocessing. Rerunning with num_workers=0 may give better error trace.

Posted on 2018-12-21 | Edited on 2019-03-12 | In 框架 / Framework , 随笔 / Writing
Symbols count in article: 375 | Reading time ≈ 1 mins.

使用docker运行Pytorch的时候如果报如下错误:

1
RuntimeError: DataLoader worker (pid 493) is killed by signal: Bus error. Details are lost due to multiprocessing. Rerunning with num_workers=0 may give better error trace.

Read more »

Ubuntu安装医学图像处理库openslide-python和pyvips

Posted on 2018-12-19 | Edited on 2018-12-24 | In 随笔 / Writing
Symbols count in article: 435 | Reading time ≈ 1 mins.

使用python处理svs格式的医学图像需要特定库的支持,常见的选择有openslide和pyvips.

Read more »

似然(likelihood)和概率(probability)的区别与联系

Posted on 2018-12-18 | Edited on 2019-12-09 | In 随笔 / Writing
Symbols count in article: 2.6k | Reading time ≈ 2 mins.

虽然经常在paper和教程中看到“似然(likelihood)”的概念,但是一直都没有仔细研究似然与概率的区别,今天查了一些资料,有些收获,在此总结一下。

似然与概率的区别

简单来讲,似然与概率分别是针对不同内容的估计和近似。概率(密度)表达给定$\theta$下样本随机向量$\textbf{X} = {x}$的可能性,而似然表达了给定样本$\textbf{X} = {x}$下参数$\theta=\theta_1$(相对于另外的参数取值$\theta_2$)为真实值的可能性.

Read more »

arXiv和CoRR的区别与关系

Posted on 2018-12-03 | In 随笔 / Writing
Symbols count in article: 1k | Reading time ≈ 1 mins.

之前搜paper就总能看到CoRR的身影,甚至有很多引用也出自该网站。当时只是草草看了一眼,CoRR代表的是:Computer Research Repository,即计算机研究领域的论文库。

但是一直有个问题萦绕心头,没有解决:这个网站和arXiv的区别与关系是啥?

今天看paper时又看到了CoRR,遂稍加仔细看了一下网站内容,在CoRR网站最下方有一行字明确指出了其定位和arXiv的关系:

CoRR is part of the arXiv e-print service. Submissions to arXiv must conform to Cornell University academic standards. arXiv is owned and operated by Cornell University, a private not-for-profit educational institution. arXiv is funded by Cornell University Library and by supporting user institutions. The National Science Foundation funds research and development by Cornell Information Science.

一言以蔽之,CoRR是arXiv电子服务的一部分,同时只关注与计算机领域的内容;同时CoRR和arXiv一样,都是Cornell大学运营的。

Read more »
<i class="fa fa-angle-left" aria-label="Previous page"></i>1…3456<i class="fa fa-angle-right" aria-label="Next page"></i>
江前云后

江前云后

Interested in
Deep Learning & Computer Vision
56 posts
13 categories
23 tags
GitHub zhihu Weibo
© 2021 江前云后 | 48k | 43 mins.
Powered by Hexo v4.2.0
|
Theme – NexT.Pisces v7.0.1
|