![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Pytorch
文章平均质量分 60
今天也是要加油的DD
这个作者很懒,什么都没留下…
展开
-
pytorch Glove 下载到使用
ref:Basics of Using Pre-trained GloVe Vectors in Python.1. 下载从 glove官网 获取下载地址# 下载glove文件import urllib import requestsurllib.request.urlretrieve('https://nlp.stanford.edu/data/wordvecs/glove.840B.300d.zip', "glove.840B.300d.zip")2. 解压 glove文件压缩解压zi原创 2021-02-12 18:00:56 · 2693 阅读 · 4 评论 -
visdom可视化pytorch训练过程
referance: https://www.lagou.com/lgeduarticle/36232.htmlvisdom的安装比较简单,可以直接使用pip命令。# visdom 安装指令pip install visdom #执行安装命令后,可以执行以下命令启动visdom。# 启动 visdom web服务器python -m visdom.server若安装成功,则会返回一个网页地址;若报错,则安装失败,可以自行去github上下载源码安装。将网址复制后在浏览器中打开,就可以转载 2020-11-30 13:28:40 · 322 阅读 · 0 评论 -
focal loss in pytorch
def multi_label_loss(y_pred, y_true): ''' Zhang, M. L., & Zhou, Z. H. (2006). Multilabel neural networks with applications to functional genomics and text categorization. IEEE transactions on Knowledge and Data Engineering, 18(10), 1338-1351. '''原创 2020-11-26 22:15:56 · 191 阅读 · 0 评论 -
pytorch 中对某一层参数设置限制
想要设置某一层的weight值在0-1之间:参考回答:https://discuss.pytorch.org/t/set-constraints-on-parameters-or-layers/23620/11It is impossible to declare a constrained parameter in pytorch. So, in init an unconstained parameter is declared, e.g.:self.my_param = nn.Parameter原创 2020-11-26 20:01:22 · 3643 阅读 · 2 评论 -
pytorch: 根据mask标记,从pad的层级数据中取出非pad的 true 和 pred 数据
def collect_NotMask_sents(y_true,y_out,mask): ''' y_pred,y_true: shape = (batch, max_len, n_class) mask.shape = (batch, max_len,) mask 中pad 部分为 0,真实存在句子则为 1 return: all_true,all_out, 非mask 的句子,shape = [n,n_class] '''原创 2020-11-26 16:20:41 · 508 阅读 · 0 评论