上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 22 下一页
摘要: 错误1: Expected object of backend CPU but got backend CUDA for argument #2 'weight' #之前: model = model.cuda() #之后: model = torch.nn.DataParallel(model). 阅读全文
posted @ 2020-07-08 16:18 Manuel 阅读(144) 评论(0) 推荐(0) 编辑
摘要: http://www.fly63.com/article/detial/8409?type=4 官网下载Git时,速度几乎是超不过20KB,解决方法有很多,这里介绍几个简单粗暴的方法。这里使用windows系统作为演示,其他系统对号入座即可。 方法一:淘宝镜像 淘宝有一个镜像的网站 可以提供下载:h 阅读全文
posted @ 2020-07-04 14:23 Manuel 阅读(138) 评论(0) 推荐(0) 编辑
摘要: https://blog.csdn.net/weixin_43279853/article/details/99757127 阅读全文
posted @ 2020-07-03 17:25 Manuel 阅读(294) 评论(0) 推荐(0) 编辑
摘要: https://www.cnblogs.com/linhaifeng/articles/8029564.html 元类 元类属于python面向对象编程的深层魔法,99%的人都不得要领,一些自以为搞明白元类的人其实也只是自圆其说、点到为止,从对元类的控制上来看就破绽百出、逻辑混乱,今天我就来带大家来 阅读全文
posted @ 2020-05-11 20:10 Manuel 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 一个静态属性property本质就是实现了get,set,delete三种方法 class Foo: @property def AAA(self): print('get的时候运行我啊') @AAA.setter def AAA(self,value): print('set的时候运行我啊') @ 阅读全文
posted @ 2020-05-11 17:54 Manuel 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 1 描述符是什么:描述符本质就是一个新式类,在这个新式类中,至少实现了__get__(),__set__(),__delete__()中的一个,这也被称为描述符协议__get__():调用一个属性时,触发__set__():为一个属性赋值时,触发__delete__():采用del删除属性时,触发 阅读全文
posted @ 2020-05-11 16:57 Manuel 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 我们知道在操作文件对象的时候可以这么写 1 with open('a.txt') as f: 2 '代码块' 上述叫做上下文管理协议,即with语句,为了让一个对象兼容with语句,必须在这个对象的类中声明__enter__和__exit__方法 class Open: def __init__(s 阅读全文
posted @ 2020-05-11 16:10 Manuel 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 描述符: 1 阅读全文
posted @ 2020-05-11 16:07 Manuel 阅读(96) 评论(0) 推荐(0) 编辑
摘要: __iter__()将对象转换为可迭代对象,__next__()返回实现迭代 #_*_coding:utf-8_*_ __author__ = 'Linhaifeng' class Foo: def __init__(self,x): self.x=x def __iter__(self): ret 阅读全文
posted @ 2020-05-10 17:46 Manuel 阅读(162) 评论(0) 推荐(0) 编辑
摘要: __call__()方法 对象后面加括号,触发执行, 注:构造方法的执行是由创建对象触发的,即:对象 = 类名() ;而对于 __call__ 方法的执行是由对象后加括号触发的,即:对象() 或者 类()() class Foo: def __init__(self): pass def __cal 阅读全文
posted @ 2020-05-10 17:02 Manuel 阅读(106) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 22 下一页