四月 19, 2019
晚间遐思
偶然的某个晚上,回忆起祖父的葬礼。原来我爷爷还在军队里面立过各种四等功?然后突然感到精神上一阵震动,仿佛与什么产生了共鸣一样。
原来某些东西真的是刻在基因深处代代相传的吗?不大不小的四等功,一如我的蓝桥杯和数学竞赛。边缘化了的奖项,无非是渴望获得认同罢了。他人看来是上进心的成分,也许并不单纯吧。怨恨、不甘是催动前进的真正的幕后黑手,可是一旦稍有成就便会松懈下来吗?!
如果遗传是种诅咒,那么变异才是破咒的方法。
四月 11, 2019
Pytorch模型训练翻车记录
背景 在Google Colab上进行压缩采样的图像重建模型的训练。已经有了训练好的压缩率是0.20的模型(下文用r0.20之类的记号表示压缩率
二月 3, 2019
Installing nvidia driver on Fedora 29
Forewords
Installing the nvidia driver on Fedora has been a painful experience for me. If I don’t get it wrong, I have been trying since F26!
I will not touch on bumblebee. I will instead use nvidia-xrun to utilize the driver.
This article serves as a reminder for myself on what did I do to make things work for my Intel/nvidia hybrid laptop. It might hopefully help other people as well.
九月 16, 2018
lambda in Python: is it returning multiple values?
To begin with let’s just have look at the old school of lambda in Python.
As we know, lambda x: return x**2 is exactly equivalent to
def squared(x): return x**2 Now look at this
>>> f1 = lambda x,y,z: x+1, y+1, z+1 >>> print(f1(1,1,1)) What will you get on the screen? A tuple of (2, 2, 2)? No. You get an error instead.
Traceback (most recent call last): File "<pyshell#7>", line 1, in <module> print(f1(1,1,1)) TypeError: 'tuple' object is not callable</module> Now that the “returning part” of lambda is covering the contents before comma only, let’s explicitly add the brackets:
九月 11, 2018
Quick note on Python syntax magics
As noted in Python 3 documention, behaviors of +, -, *, etc. can be redefined.
Specially, I would like to take notes on some special yet common methods.
__repr__ method This method is called when you apply print on the instance. Could be useful when debugging class related problems.
__enter__, __exit__ methods Those two methods are key components of a context manager. Refer to https://jeffknupp.com/blog/2016/03/07/python-with-context-managers/ to get a sense on how to manage the fragile resouces with context manager.