'''

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. 微信小程序 API 路由

    路由:由于页面的跳转: wx.switchTab() 跳转到 tabBar 页面,并关闭掉其他所有非 tabBar 页面: 参数:为对象, 对象的属性: url:需要跳转的 tabBar 的页面路径( ...

  2. C语言的AES加密

    C语言的AES加密 稍微封装了几个函数 方便使用 #if 1 #include <stdio.h> #include <stdlib.h> #include <strin ...

  3. Mybaits基本的CURD操作

    1 首先在Mapper.xml配置 <!-- parameterType:参数类型,可以省略, 获取自增主键的值: mysql支持自增主键,自增主键值的获取,mybatis也是利用stateme ...

  4. 学习Linux的基础网站

    http://c.biancheng.net/view/726.html

  5. Appium关键字

    *** Settings *** Library AppiumLibrary Library AutoItLibrary Library os *** Keywords *** xpath应该匹配次数 ...

  6. 【Hibernate】---Query、Criteria、SQLQuery

    一.核心配置文件 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-con ...

  7. SSTap | ProxyCap

    SSTap  SSTap 全称 SOCKSTap, 是一款利用虚拟网卡技术在网络层实现的代理工具.SSTap 能在网络层拦截所有连接并转发给 HTTP, SOCKS4/5, SHADOWSOCKS(R ...

  8. Jmeter---后置处理器 BeanShell PostProcessor 获取JDBC结果(多行)并以列表传入另一个请求

    之前用python+locust对脚本生成商品编码, 商品上架,购买商品进行编写脚本和压测: 开始是打算用Jmeter,后来遇到问题在 Jmeter如何读取JDBC多行并组成列表,作为下一个请求 一直 ...

  9. 各种开源许可 license 区别

    copy from http://www.ruanyifeng.com/blog/2011/05/how_to_choose_free_software_licenses.html

  10. [Git] 018 冲突在所难免,需要巧妙化解

    0. 回顾 [Git] 005 初识 Git 与 GitHub 之分支 中"4.2 情形二"的 9 提及了"解决冲突" 当时没有展开,这回详谈 我这回反其道而行 ...