[Pytorch函数] .masked_fill_()_Jeanshoe的博客-CSDN博客_torch ...
https://blog.csdn.net/qq_41568188/article/details/10728139511.07.2020 · masked_fill_(mask, value)掩码操作用value填充tensor中与mask中值为1位置相对应的元素。mask的形状必须与要填充的tensor形状一致。a = torch.randn(5,6)x = [5,4,3,2,1]mask = torch.zeros(5,6,dtype=torch.float)for e_id, src_len in enumerate(x): mask[e_id, src_len:] = …
torch.Tensor.masked_fill — PyTorch 1.10.1 documentation
pytorch.org › torchLearn about PyTorch’s features and capabilities. Community. Join the PyTorch developer community to contribute, learn, and get your questions answered. Developer Resources. Find resources and get questions answered. Forums. A place to discuss PyTorch code, issues, install, research. Models (Beta) Discover, publish, and reuse pre-trained models