当前位置:网站首页>Torch. NN. Linear() function
Torch. NN. Linear() function
2022-07-28 20:21:00 【LifeBackwards】
torch.nn.Linear(in_features, out_features, bias=True) Function is a linear transformation function :
![]()
among ,in_features Enter the sample size for ,out_features Is the size of the output sample ,bias The default is true. If you set bias = false Then this layer will not learn an additive bias .
Linear() Function is usually used to set the Fully connected layer .
Use cases :
import torch
x = torch.randn(128, 20) # The input samples
fc = torch.nn.Linear(20, 30) # 20 Enter the sample size for ,30 Is the output sample size
output = fc(x)
print('fc.weight.shape:\n ', fc.weight.shape)
print('fc.bias.shape:\n', fc.bias.shape)
print('output.shape:\n', output.shape)
ans = torch.mm(x,torch.t(fc.weight))+fc.bias # The results are in agreement with fc(x) identical
print('ans.shape:\n', ans.shape)
print(torch.equal(ans, output))Running results :
m.weight.shape:
torch.Size([30, 20])
m.bias.shape:
torch.Size([30])
output.shape:
torch.Size([128, 30])
ans.shape:
torch.Size([128, 30])
true
边栏推荐
- Stories of Party members | Li qingai uses cartoons to drive farmers to increase income and become rich
- Common commands of raspberry pie
- DSACTF7月re
- C language - control statement
- Usage of const and assert
- Array out of bounds
- Using Lex (Flex) to generate lexical analyzer of PL language
- [experiment sharing] CCIE BGP reflector experiment
- 基于 MinIO 对象存储保障 Rancher 数据
- local/chain/run_ tdnn.sh:
猜你喜欢

C语言数据 3(2)

七种轮询介绍(后附实践链接)

Basic knowledge of communication network 01

Array out of bounds

Raspberry pie CM4 -- using metartc3.0 to integrate ffmpeg to realize webrtc push-pull streaming

树行表达方式
![[C language] step jumping problem [recursion]](/img/0c/32870484e89b494e41068f7c38b08e.png)
[C language] step jumping problem [recursion]
![[C language] guessing numbers game [function]](/img/db/8ebdb02f137878224367503b730803.png)
[C language] guessing numbers game [function]

Reverse string

NEIL: Extracting Visual Knowledge from Web Data
随机推荐
6. Functions of C language, why functions are needed, how functions are defined, and the classification of functions
[C language] shutdown game [loop and switch statement]
七种轮询介绍(后附实践链接)
[C language] simulation implementation of pow function (recursion)
[C language] guessing numbers game [function]
Introduction to seven kinds of polling (practice link attached)
zfoo增加类似于mydog的路由
C language - control statement
2、 Relationship between software operation and memory
[C language] Fibonacci sequence [recursion and iteration]
C language data 3 (2)
Common instructions of vim software
Raspberry pie 4B ffmpeg RTMP streaming
HSETNX KEY_NAME FIELD VALUE 用法
JVM(二十四) -- 性能监控与调优(五) -- 分析GC日志
Method number problem for solving sum of numbers (knapsack problem)
C language function
C language - pointer
【实验分享】CCIE—BGP反射器实验
NEIL: Extracting Visual Knowledge from Web Data