标签为“Research”的页面如下
回复审稿人意见的笔记
题目:我原来的题目是“修改说明”,老师改成了“稿件修稿说明”
排版:
(1) 专家原来提出的问题用粗体字标出,每一组问题-答复之间不空行。(我本来是蓝色字体标出,且每一天意见的回复之后都会空行。)
Pytorch模型训练翻车记录
背景
在Google Colab上进行压缩采样的图像重建模型的训练。已经有了训练好的压缩率是0.20的模型(下文用r0.20之类的记号表示压缩率及其对应的模型)。现在想训练r0.25。觉得从头开始训练很费时间于是就想出了这么个办法
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:
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.