
pytorch学习
哆来咪发呀
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
pytorch学习之注意力机制
Attention 是一种通用的带权池化方法,输入由两部分构成:询问(query)和键值对(key-value pairs)。 不同的attetion layer的区别在于score函数的选择,两种常用的注意层 Dot-product Attention 和 Multilayer Perceptron Attention 点积注意力 class DotProductAttention(nn....原创 2020-02-19 20:30:43 · 1352 阅读 · 0 评论 -
pytorch学习——Softmax与分类模型
Softmax与分类模型 Softmax原理 softmax通过下式将输出值变换成值为正且和为1的概率分布: 因此softmax运算不改变预测类别输出。 pytorch定义softmax函数如下: def softmax(X): X_exp = X.exp() partition = X_exp.sum(dim=1, keepdim=True) return X_exp ...原创 2020-02-14 13:10:17 · 574 阅读 · 0 评论 -
pytorch线性回归
pytorch线性回归 线性回归假设输出与各个输入之间是线性关系:y = wx+b pytorch定义线性回归模型: def linreg(X, w, b): return torch.mm(X, w) + b 线性回归常用损失函数是平方损失: def squared_loss(y_hat, y): return (y_hat - y.view(y_hat.size())) ...原创 2020-02-14 12:58:08 · 268 阅读 · 0 评论