摘要:
如果bool()里是个ndarry这种报错如上, 可以用is not none 判断 阅读全文
摘要:
如果添加了@Component或@Configuration,又添加了@WebFilter(),那么会初始化两次Filter,并且会过滤所有路径+自己指定的路径 ,便会出现对没有指定的URL也会进行过滤 阅读全文
摘要:
注释还可以这么写: # # Our data model looks like this (queues are indicated with curly brackets): # # main process || # | || # {index_queue} || # | || # worker 阅读全文
摘要:
int(torch.empty((), dtype=torch.int64).random_().item()) 文档里是这么描述.random_()的: """ random_(from=0, to=None, *, generator=None) -> Tensor Fills :attr:`s 阅读全文
摘要:
z = torch.full((3,4),-5) print(z) a = ~z print(a) print('') import numpy b = numpy.full((3,4),-5) print(z) a = ~z print(a) tensor([[-5, -5, -5, -5], [ 阅读全文
摘要:
一个简单的主入口是这样滴: import sys sys.path.append('..') import torch from pytorch_pretrained_bert import BertTokenizer, BertModel, BertForMaskedLM # Load pre-t 阅读全文
摘要:
@dataclass class StarWarsMovie: title: str episode_id: int opening_crawl: str director: str producer: str release_date: datetime characters: List[str] 阅读全文
摘要:
tuple不加逗号 () + () 在运算里表示的是优先级!!! 如果要叠加变成: (layer_output,)+([1],) 这个是tuple的expand操作,结果是一个tuple,(tensor,list) 同理,list的expand也可以表示为: [1,]+[2,] 结果是[1,2],但 阅读全文
摘要:
from itertools import chain a = [1, 2, 3, 4] b = ['x', 'y', 'z'] for x in chain(a, b): print(x) ''' # 使用 chain() 的一个常见场景是当你想对不同的集合中所有元素执行某些操作的时候。 # Va 阅读全文
摘要:
class A(object): # 属性默认为类属性(可以给直接被类本身调用) num = "类属性" # 实例化方法(必须实例化类之后才能被调用) def func1(self): # self : 表示实例化类后的地址id print("func1") print(self) # 类方法(不需 阅读全文