Some code tricks

记录一些新学的语法……

Python

[logging](python中logging模块上篇 - Dwzb的文章 - 知乎 https://zhuanlan.zhihu.com/p/38781838)
easydict
defaultdict
yaml
timeit
::
var: type = value
[类型注解](如何看待类型注解在 Python 中的前途? - 张同学的回答 - 知乎 https://www.zhihu.com/question/56167969/answer/417804812)
typing
[Python中的args和*kwargs ](Python中的args和*kwargs - 百晓生的文章 - 知乎 https://zhuanlan.zhihu.com/p/50804195)
@classmethod, @staticmethod
[装饰器](如何理解Python装饰器? - 刘志军的回答 - 知乎 https://www.zhihu.com/question/26930016/answer/99243411)
str.center()
多继承
isinstance()
python -u
yield()
__call__
with打开多个文件
glob模块
getattr()获取类的属性值setattr()
Argparser, add_argument()的dest参数
python 图像数据互转(numpy,bytes,base64,file)
python元组操作
eval()执行字符串表达式
Python __name__==’main’作用详解
python 单例模式singleton
命名元组 collections.namedtuple
json.dumps()

Numpy

NumPy save some arrays at once
numpy.savez()
change datatype of numpy array
np.ascontiguousarray
np.maximum
np.set_printoptions()——控制输出方式
填充array & tensor
检查np数组 numpy.testing.assert_array_less
np.where
np.hstack, vstack
np.newaxis

Pytorch

1、tokenizer.vocab.keys()获取全部词表
2、Tensor.expand()
3、.data()和.detach(), detach()分离计算图
4、nn.Module.apply()
5、Tensor.register_hook(), example
6、Generate new Tensor
7、torch.multiprocessing etc.
8、DistributedDataParallel
9、torch.split
10、contiguous, is_contiguous. Tensor的底层存储顺序
11、nn.Module.register_buffer()
12、torch.split()

C & C++

any_of()
3-D array
‘this’ point
priority_queue
builtin popcount

Shell

重定向
sudo apt install -y
ps -aux | grep panmz

Git

.gitkeep

0%