1,torch设置随机数种子,种子相同,则输出相同的随机数,但是在输出随机数之前都要重新生成相同的种子。

2,easydict


3,tar j解压,压缩:
tar xvf ./VOCtrainval_06-Nov-2007.tar -C ./ (将VOC所在目录解压到当前路径)
可参考:

4, gb2312的xml读取
config_file为xml文件。
方法一:
# # transform gb2312 xml to utf-8
# f = codecs.open(config_file, 'rb', 'gb2312')
# text = f.read().encode('utf-8').decode('utf-8')
# text = text.replace('<?xml version="1.0" encoding="gb2312"?>', '<?xml version="1.0" encoding="utf-8"?>')
# f.close()
# tempfilename = config_file.split('.xml')[0] + 'temp.xml'
# f = open(tempfilename, 'wb')
# f.write(text.encode('utf-8'))
# f.close()
#
# tree = ET.parse(tempfilename)
# slide = tree.getroot()
方法二:
with open(config_file) as f:
line = f.read()
slide = ET.fromstring(line)
5, pycharm调用其他project中的函数
在当前项目的
中找到

点击+add content root,,,,将需要import的其他工程添加进来,就可以在当前工程下看到
2个工程,就可以正常Import了。
6,虚拟环境相关命令
conda装好虚拟环境之后,可用该命令查看wyold环境下的安装目录:conda list --name wyold
7,python中继承父类时调用的super.__init__:



reference :"http://www.runoob.com/w3cnote/python-extends-init.html"
ing..
本文介绍了Py开发中的多项实用技巧,包括设置torch随机数种子确保实验可复现、使用easydict管理配置、处理gb2312编码的XML文件、跨项目调用函数的方法、创建虚拟环境及使用super进行类初始化等。
797

被折叠的 条评论
为什么被折叠?



