![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
pytorch
发动机一号
学习要持之以恒,锻炼身体要持之以恒
展开
-
2021/9/10在模型中定义连续线性变换函数的简便方法
代码import torchimport torch.nn as nnclass my_module(nn.Module): def __init__(self,*args): super(my_module, self).__init__() for block in args: self._modules[block] = block # self.linear = nn.Linear(2,3) #原创 2021-09-10 23:34:45 · 174 阅读 · 0 评论 -
LongTensor的使用场景(未解决)
在读cs244n_pytorch_tutorial时,谈到创建张量时,文档说:longtensor在nlp中特别重要。原来如下LongTensors are particularly important in NLP as many methods that deal with indices require the indices to be passed as a LongTensor, which is a 64 bit integer.索引需要当作LongTensor传入------什么意思原创 2021-06-13 15:03:58 · 2310 阅读 · 1 评论 -
torch中三种sigmoid使用方法
关于下面三种sigmoid的使用方法torch.sigmoid()torch.nn.functional.sigmoid()torch.Sigmoid相同点都是将值映射到0-1之间,没用区别不同点所属类型不同方法:torch.sigmoid() 和torch.nn.funtional.sigmoid()类:torch.Sigmoid使用方法不同两个方法函数直接传输向量就行,而类需要先定义一个类,然后再通过调用类本身的__call__函数去使用。a = torch.tens原创 2021-06-07 18:30:46 · 28752 阅读 · 1 评论 -
2021-05-30 skip-gram
skip-gramone-hot编码one-hot简介为了让词语能在电脑中,利用独热编码进行表示。one-hot缺点任意两个词的独热向量,正交为0;因为前者缺点,因此无法表示任意两个独热向量的天然联系。Word2Vec嵌入矩阵为了解决one-hot的缺点,引入嵌入矩阵,使得词向量均为dense vector,由诸多特征构成,特征够多,向量之间的联系与区别才会更丰富。没想好标题设ttt为center word的序号,同时令mmm为the window size of原创 2021-05-30 23:34:45 · 91 阅读 · 0 评论