Skip to content

Instantly share code, notes, and snippets.

View YimianDai's full-sized avatar
💭
I may be slow to respond.

Yimian Dai YimianDai

💭
I may be slow to respond.
View GitHub Profile
@YimianDai
YimianDai / markdown.md
Last active July 31, 2019 17:23
Notes on Markdown
@YimianDai
YimianDai / Python.md
Last active September 19, 2019 22:00
Notes on Python
  1. Python Syntax
  2. Python Environment
  3. Python Snippets

Python Syntax

函数注释 Function Annotations

原来的 Python 变量是没有类型的,这个 Function Annotations 其实是为了规范函数中参数的类型,给调用者提供明显的注释,已在运行前对参数类型做出检查,免得运行时,报 ErrorValue 错误。除了 Function Annotations 外,还有一个检查变量类型的方法是 isinstance 方法。

@YimianDai
YimianDai / Numpy.md
Last active September 4, 2019 23:15
Notes on Numpy

在 Numpy 数组中,size 和 shape 都是属性,而非函数,所以调用的时候不要加括号,size 返回的是 里面的元素数,shape 返回的是真正的尺寸

RESHAPE and LINEAR INDEXING: Matlab always allows multi-dimensional arrays to be accessed using scalar or linear indices, NumPy does not. Linear indices are common in Matlab programs, e.g. find() on a matrix returns them, whereas NumPy’s find behaves differently.

When converting Matlab code it might be necessary to first reshape a matrix to a linear sequence, perform some indexing operations and then reshape back. As reshape (usually) produces views onto the same storage, it should be possible to do this fairly efficiently. Note that the scan order used by reshape in NumPy defaults to the ‘C’ order, whereas Matlab uses the Fortran order. If you are simply converting to a linear sequence and back this doesn’t matter. But if you are converting reshapes from Matlab code which relies on the scan order, then this Matlab code: z = reshape(x,3,4); should become z = x.reshape(3,4,order=’F’).copy() in NumPy.

@YimianDai
YimianDai / Matlab.md
Created July 30, 2019 23:37
Notes on Matlab

Matlab Notes

命名规则

参考 Python 代码规范和命名规范

ind2sub

矩阵既可以用单个坐标,可以用(行,列)两个坐标,ind2sub 是转换的函数

@YimianDai
YimianDai / LaTeX.md
Created July 30, 2019 23:32
Notes on LaTeX
@YimianDai
YimianDai / Hexo-Next.md
Created July 30, 2019 23:20
Hexo Next 主题

Hexo Next

安装 Next 主题

$ cd your-hexo-site
$ git clone https://github.com/theme-next/hexo-theme-next themes/next

启用主题

@YimianDai
YimianDai / Gluon-CV-Dataset-Class.md
Created July 30, 2019 23:14
Gluon-CV Dataset Class

Gluon-CV Dataset

不管怎么样,Dataset 是一个 给定 index,然后返回一对 样本 和 label 的结构。

COCODetection 这个数据集中,label 是在 __init__ 函数中通过 self._load_jsons() 函数一次性读取好的,而 image 是在迭代中一次性读取好的。

继承关系:

@YimianDai
YimianDai / git.md
Last active July 30, 2019 23:08
Notes on Git / GitHub

https://gist.github.com/YimianDai/7dcf6340fc435323a328634df0666f5e

查看 Github repo 的大小

$ curl -u "{:username}" https://api.github.com/repos/{:organization}/{:repository}

把花括号内的包括花括号替换成相应的内容即可,比如我的 curl -u "yimiandai" https://api.github.com/repos/yimiandai/images 没有 {:organization} 就跳过,在输出的最后倒数 30 行附近,有一个 size,后面的数字就是这个 repo 的大小,单位是 KB。