'''

class torch.nn.Linear(in_features,out_features,bias = True )[来源]

参数:

in_features - 每个输入样本的大小
out_features - 每个输出样本的大小
bias - 如果设置为False,则图层不会学习附加偏差。默认值:True
'''
import torch

x = torch.randn(3, 2)  # 输入的维度是(3,2)
m = torch.nn.Linear(2, 4) # 2,4是指维度
output = m(x)
print("x",x)
print('m.weight.shape:\n ', m.weight.shape,m.weight)
print('m.bias.shape:\n', m.bias.shape,m.bias)
print('output.shape:\n', output.shape,output)
'''
x tensor([[-0.4972, 1.2745],
[ 1.2993, -0.6580],
[-0.2165, 0.8603]]) m.weight.shape:torch.Size([4, 2]) Parameter containing:
tensor([[-0.5528, -0.1309],
[ 0.6907, 0.5723],
[-0.2242, 0.1904],
[ 0.1678, -0.6903]], requires_grad=True) m.bias.shape:torch.Size([4]) Parameter containing:
tensor([-0.1663, -0.0111, 0.4852, 0.5688], requires_grad=True) output.shape:torch.Size([3, 4])
tensor([[-0.0584, 0.3749, 0.8394, -0.3944],
[-0.7984, 0.5097, 0.0685, 1.2410],
[-0.1593, 0.3317, 0.6975, -0.0614]], grad_fn=<AddmmBackward>) -0.4972*-0.5528+1.2745* -0.1309+-0.1663=-0.0584
'''

  

linear_func的更多相关文章

  1. Java文件操作系列[3]——使用jacob操作word文档

    Java对word文档的操作需要通过第三方组件实现,例如jacob.iText.POI和java2word等.jacob组件的功能最强大,可以操作word,Excel等格式的文件.该组件调用的的是操作 ...

随机推荐

  1. Spring的Aop理解

    主要作用:解决代码复用,避免重复性编写代码. 比较典型的场景:日志打印,权限验证,事务处理 参考网址为:http://moon-walker.iteye.com/blog/2381532 spring ...

  2. leetcode-easy-array-189 Rotate Array

    mycode  75.59% class Solution(object): def rotate(self, nums, k): """ :type nums: Lis ...

  3. maven 安装jar包命令

    以 spring-context-support-3.1.0.RELEASE.jar 为例,在 @3图中已经给出这个 jar 包的 groupId,artifactId,version信息,手动安装的 ...

  4. python - 标准库:subprocess模块

    subprocess的目的就是启动一个新的进程并且与之通信. subprocess模块中只定义了一个类: Popen. subprocess.Popen(args, bufsize=0, execut ...

  5. nginx实现域名跳转

    server { listen 80; server_name www.dd.com www.tt.com; index index.html index.htm index.php; root /u ...

  6. java调用com组件com4j

    com4j A Java library that allows Java applications to seemlessly interoperate with Microsoft Compone ...

  7. Python Requests post方法中data与json参数问题

    1.data参数 你想要发送一些编码为表单形式的数据——非常像一个 HTML 表单.要实现这个,只需简单地传递一个字典给 data 参数.你的数据字典在发出请求时会自动编码为表单形式,header默认 ...

  8. 【MM系列】SAP MM物料账在制品承担差异功能及配置

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP MM物料账在制品承担差异功能 ...

  9. Java中关于Date等日期类的简单使用

    Date Date类不常用,很多方法被废弃了,常用它的两个构造方法来new一个Date对象. Date d1 = new Date(); //不传任何参数,代表当前时间点 System.out.pri ...

  10. 三、Zabbix-zabbix server部署-zabbix server

    LNMP基础环境准备完成,进行zabbix server部署参考官方文档: [https://www.zabbix.com/documentation/3.4/zh/manual/installati ...