功能描述

Applies a bilinear transformation to the incoming data: math:`y = x_1^T A x_2 + b`
Shape:
Input1: (N, *, Hin1) where Hin1 =  in1_features and * means any number of additional dimensions. All but the last dimension of the inputs should be the same.
Input2: (N, *, Hin2) where Hin2 =  in2_features.
Output: (N, *, Hout) where Hout = out_features and all but the last dimension are the same shape as the input.

该函数主要的作用是对于输入的数据进行双线性的变换,它有两个输入,并且对于输入、输出的最后一个维度应该和nn.Bilinear(in1_features,in2_features,out_features)是相同的。在该函数中bias服从均匀分布

examples:

# 导入所需要的包
import torch
import torch.nn as nn# 对于输入数据进行双线性变换  math:`y = x_1^T A x_2 + b`
# ['in1_features', 'in2_features', 'out_features']
m=nn.Bilinear(50,20,10)
input1 = torch.randn(256,50)
input2 = torch.randn(256,20)
output = m(input1,input2)
print("output is {}".format(output))
print(output.size())

result:

output is tensor([[ 2.1250, -1.6710,  0.4189,  ..., -3.0687, -1.3695, -2.9742],[-0.4245, -3.0566, -2.1428,  ...,  4.7407,  4.0031, -4.6528],[ 0.7700,  2.9252, -1.7279,  ...,  1.9816, -0.4914, -1.9483],...,[ 2.7378, -0.9335,  2.3370,  ...,  1.3155, -6.5961, -2.6716],[-4.0953,  4.5987, -4.3022,  ..., -0.6784, -1.0126, -0.6979],[ 0.4568,  1.4662,  0.3095,  ..., -0.3748,  4.5659,  2.3969]],grad_fn=<AddBackward0>)
torch.Size([256, 10])

写的比较好的文章:pytorch中的nn.Bilinear的计算原理详解nn.Bilinear

官方文档:Bilinear — PyTorch 1.10.0 documentationhttps://pytorch.org/docs/stable/generated/torch.nn.Bilinear.html?highlight=bilinear#torch.nn.Bilinear

torch.nn.modules.linear—Bilinear相关推荐

  1. Can‘t get attribute ‘SiLU‘ on <module ‘torch.nn.modules.activation

    在yolov5 4.0版本测试的时候,加载模型报错: Can't get attribute 'SiLU' on <module 'torch.nn.modules.activation 报错代 ...

  2. yolov5 v3.0训练报错: torch.nn.modules.module.ModuleAttributeError: ‘BatchNorm2d‘ object has no attribute

    欢迎大家关注笔者,你的关注是我持续更博的最大动力 原创文章,转载告知,盗版必究 yolov5 v3.0版本训练报错:torch.nn.modules.module.ModuleAttributeErr ...

  3. TypeError: torch.nn.modules.batchnorm.BatchNorm2d is not a Module subclass

    TypeError: torch.nn.modules.batchnorm.BatchNorm2d is not a Module subclass torch.nn.modules.batchnor ...

  4. torch.nn.modules.activation.ReLU is not a Module subclass

    torch.nn.modules.activation.ReLU is not a Module subclass 定位到问题代码: 修改为: fc_layers.append(nn.ReLU())

  5. torch.nn.Linear详解

    在学习transformer时,遇到过非常频繁的nn.Linear()函数,这里对nn.Linear进行一个详解. 参考:https://pytorch.org/docs/stable/_module ...

  6. 为什么torch.nn.Linear的表达形式为y=xA^T+b而不是常见的y=Ax+b?

    今天看代码,对比了常见的公式表达与代码的表达,发觉torch.nn.Linear的数学表达与我想象的有点不同,于是思索了一番. 众多周知,torch.nn.Linear作为全连接层,将下一层的每个结点 ...

  7. torch.nn.Module()

    torch.nn.Module() 如果自己想研究,官方文档 它是所有的神经网络的根父类! 你的神经网络必然要继承! 模块也可以包含其他模块,允许将它们嵌套在树结构中.所以呢,你可以将子模块指定为常规 ...

  8. AttributeError: module 'torch.nn.init' has no attribute 'zeros_'

    问题 File "E:\wj-lab\expStad\model.py", line 50, in __init__feat_block.apply(weights_init_ka ...

  9. Pytorch:模型的保存与加载 torch.save()、torch.load()、torch.nn.Module.load_state_dict()

    Pytorch 保存和加载模型后缀:.pt 和.pth 1 torch.save() [source] 保存一个序列化(serialized)的目标到磁盘.函数使用了Python的pickle程序用于 ...

最新文章

  1. minus oracle 顺序_oracle minus的用法来一波
  2. 【每日一算法】独特的电子邮件地址
  3. linux落字效果代码,Shell中实现飞行文字效果
  4. hadoop学习--基于Hive的Hadoop日志分析
  5. 猪年看猪,猪男猪女一共十个。
  6. $.get、$.post 和 $().load()
  7. id jquery选择器 开头_HTML的id选择器类选择器
  8. pitr 原理_PostgeSQL 数据库备份与恢复实验 (PITR)
  9. Unity 使物体朝向某个方位
  10. linux ssh知识
  11. 使用jxls导出报错:Connot load XLS transformer please make sure a Transformer implementation is in classpath
  12. h5页面不随微信字体大小改变
  13. 一文解读Masked Autoencoder(MAE)
  14. css fixed定位失效问题
  15. python爬虫:lxml爬取链家网二手房信息
  16. ASP.NET MVC --- 身份认证与授权
  17. 关于unity3D shader的UV理解
  18. ICD建模功能约束(详见DL/T860.73附录B)
  19. percona toolkit 简介
  20. python智慧树判断题_智慧树_Python数据分析与数据可视化_判断题答案

热门文章

  1. 我想以《曾经的你》这首歌开始我的博客生涯
  2. 路由器串联的2种方法
  3. [转]广义正交匹配追踪(gOMP)
  4. 2011年托业考试时间
  5. android 微信登录返回 -6
  6. 智云通CRM:产品和人脉是销售的“终极武器”?
  7. Java开发的汽车俱乐部系统源码小程序app
  8. python html文本 转义字符,python处理html转义字符的方法详解
  9. #pragma不为人知的秘密
  10. 手把手教您制作并发布个人网站或主页(一)(图解教程针对小白)