随笔分类 - python
摘要:python中类变量是属于类的,不属于具体的对象,所有对象共享一个类变量。类变量可以通过类名.变量名访问,也可以通过实例化后的对象.变量名访问。那么,如果我给对象的变量起的名字和类变量同名会如何?我们写代码测试一下: class Foo: name = "hello" # <- 类变量 def se
阅读全文
摘要:鉴于有评论区用户质疑本文的必要性,首先前排提醒: linux大部分你可能以为需要root的需求都可以不用root解决。 只要你善用conda、.bashrc、LD_LIBRARY_PATH基本可以解决。 conda可以安装各种二进制包,包括各种版本的gcc/g++ 安装最新版gcc和g++ cond
阅读全文
摘要:查看支持的字体: # 查询当前系统所有字体 from matplotlib.font_manager import FontManager mpl_fonts = set(f.name for f in FontManager().ttflist) print('all font list get
阅读全文
摘要:根据个人理解,pytorch显存分3个概念:reserved memory、allocated memory、context memory。参考:https://discuss.pytorch.org/t/difference-between-allocated-and-reserved-memor
阅读全文
摘要:省流:直接看最后 从简单的例子开始,定义装饰器register,定义一个简单的类method,使用装饰器装饰类 def register(*args, name=None): def warpper(method_cls): print('warpper cls') return method_cl
阅读全文
摘要:logging模块处理流程: 分为几个模块: logger: 最高层模块,用来输出log logger.level来筛选log logger.debug()/info()/warning()/error()等输出log handler: 经过logger过滤后log会分发给所有handler处理。每
阅读全文
摘要:列出所有环境 conda env list 创建环境 conda create -n envName python=3.5 激活环境 conda activate tf2 搜索包 conda search python conda search python=3.8.* conda search p
阅读全文
摘要:本文用于记录Python学习过程中的笔记,因为不常使用python,每次想写py都得先查半天百度,这里记录一下,顺便正经学一学,不然每次想写都费半天劲。 先来一点无关内容,vscode的python插件智能提示很慢的话,把Language Server改成Pylance,不要用Jedi。来源:vsc
阅读全文