当前位置:网站首页>Common library code snippet pytorch_ based【tips】
Common library code snippet pytorch_ based【tips】
2022-07-28 22:43:00 【It's too simple】
torch library
torch.empty(): Returns an uninitialized tensor .
torch.nn.softmax(): Use softmax function .pytorch:nn.Softmax()_ Unadorned melody blog -CSDN Blog _pytorch softmax function Deep learning softmax Function understanding _ Maverick's blog -CSDN Blog _ Deep learning softmax
torch.nn.AvgPool2d(): The average pooling .nn.AvgPool2d() function _ Code farmer's blog of Lanxiang technical school -CSDN Blog _avgpool2d
torch.nn.Linear(): Whole company class .PyTorch Of nn.Linear() Detailed explanation _ When the wind and snow return at night o The blog of -CSDN Blog _nn.linear Other methods
torch.nn.ConvTransposed(): deconvolution .
torch.nn.utils.clip_grad_norm_(): Gradient cut (Clipping Gradient):torch.nn.utils.clip_grad_norm_aabb7654321 The blog of -CSDN Blog
torch.nn.Parameter(): Let some variables constantly modify their values in the process of learning to achieve optimization .PyTorch Medium torch.nn.Parameter() Detailed explanation _Adenialzz The blog of -CSDN Blog _nn parameter
.requires_grad=True: Track calculation records .detach()、data、with no_grad()、requires_grad The relationship between _ Unbearable blog -CSDN Blog
torch.tensor(): Depending on the type of data entered , Output corresponding tensor tensor , The data can be list/tuple/array/scalar.torch.Tensor and torch.tensor The difference between _Vic_Hao The blog of -CSDN Blog _torch.t
torch.detach():pytorch Medium .detach() .detach_()_ Xiaoyihong's blog -CSDN Blog _.detach()
torch.index_select():pytorch Function torch.index_select_ Thigh strong blog -CSDN Blog _torch.index_select
torch.mean(): Return mean ,keepdim=True Then keep the original tensor dimension unchanged , Otherwise, it will disappear after calculating the mean value .pytorch in tensor.mean(axis, keepdim) Parameter understanding small experiment _ Pumpkin pie three vegetables blog -CSDN Blog _tensor.mean
torch.range() and torch.arrange():arrange It doesn't contain end,range contain end, Created tensor The types are different .pytorch.range() and pytorch.arange() The difference between _Who is abc The blog of -CSDN Blog _torch.arrange
torch.matmul(): Tensor multiplication torch.matmul() Tensor multiplication _y4ung The blog of -CSDN Blog _torch.matmul
torch.pow(): Power the input tensor every fraction .torch.randn()、torch.mean()、torch.pow()、torch.matmul()_ Only a cautious blog -CSDN Blog _torch.randn()
torch.topk(): Return tensor K The biggest / Small value .torch.topk() Function details _ewahiogj The blog of -CSDN Blog _torch.topk()
torch.nn.functional.pad(): Expand the image matrix or characteristic matrix .F.pad() Function details _ Xiaoyezhu's blog -CSDN Blog _f.pad
torch.mul(): Dot matrix .torch.mul()—— Matrix point multiplication _ Visual sprouting 、 The blog of -CSDN Blog _torch Dot matrix
.item(): take tensor The tensor is converted to python Scalar .Pytorch in .numpy() .item() .cpu() difference _ Ma Pengsen's blog -CSDN Blog
numpy library
numpy.logx(): With x Log base .
np.concatenate(): Yes array Spliced functions .
np.random.permutation(): Generate a scrambled list for a given list .
np.zeros_like(): Output has the same structure as input 0 matrix .numpy And zeros_like()_Nicola-Zhang The blog of -CSDN Blog _numpy zeros_like
.min(),.max(),.mean():numpy Array for maximum and minimum .numpy.max In the parameter axis The problem of the value of _Zpadger The blog of -CSDN Blog _max(axis=0)
np.percentile(): Any percentage digit of the array .
np.clip():np.clip() usage Numpy in clip Use of functions _yctjin The blog of -CSDN Blog _np.clip
np.expand_dims(): Expand the shape of the array .np.expand_dims Xiaobai explained in detail _ watermelon 6 The blog of -CSDN Blog _np.expand_dims()
np.astype(): transformation numpy Array .np.astype()_ The plum blossom 14 The blog of -CSDN Blog _.astype
np.uint8:Opencv numpy in uint8 Type store image _ Programmer hair loss blog -CSDN Blog _np.uint8
np.cov():【[Numpy Learning record 】np.cov Detailed explanation _jeffery0207 The blog of -CSDN Blog _np.cov() Mathematical principle of covariance matrix ,numpy Calculate the covariance matrix (np.cov) Function explanation and source code analysis _Codefmeister The blog of -CSDN Blog _np Calculate covariance
np.astype(): transformation numpy Data type of array .np.astype()_ The plum blossom 14 The blog of -CSDN Blog _.astype
np.unit8:uint8 It is specially used to store various images ( Include RGB, Gray scale image, etc ), Range 0–255.Opencv numpy in uint8 Type store image _ Programmer hair loss blog -CSDN Blog _np.uint8
torchvision library
transforms.ColorJitter(): Data to enhance , Image brightness can be changed / Contrast / saturation / tonal .PyTorch - transforms.ColorJitter Change the properties of the image : brightness (brightness)、 Contrast (contrast)、 saturation (saturation) And hue (hue)_TheOldManAndTheSea The blog of -CSDN Blog _transforms.colorjitter
functools library
functools.partial(): Partial function , It is applicable to a large number of calls to the same function with different default parameter values , Make a call platform . Detailed explanation Python Partial functions in (Partial Function)-functools.partial_ Super super genius blog -CSDN Blog
random library
random.uniform(): Generate random real numbers , Including the minimum value .[Python] random.uniform( ) Function tutorial and instance parsing _Harry Wow blog -CSDN Blog _python random.uniform
cv2 library
cv2.pyrDown(): Down sample the original image . First, Gaussian transform , Then discard even lines , Even columns realize down sampling . The first 11 Chapter Image pyramid -- Down sampling cv2.pyrDown() , On the sampling cv2.pyrUp()_Enzo Blog that wants to smash the computer -CSDN Blog _cv2 Down sampling
cv2.pyrUp():pyrDown() Anti operation of .
cv2.subtract(): The two images are subtracted .OpenCV-Python Subtraction of images cv2.subtract Function details and comparison with matrix subtraction _LaoYuanPython The blog of -CSDN Blog _opencv subtract
cv.getStructuringElement(): use 0,1 Building structural elements . Structured elements cv2.getStructuringElement()_Xahoo! The blog of -CSDN Blog _ Structured elements
cv2.morphologyEx(): Carry out various morphological transformations .opencv-python And cv2.morphologyEx()_ Yizhi bubble's blog -CSDN Blog _morphologyex python
model operation
model.train(): The model has BN layer ,Dropout add . Yes BN The layer ensures that the average value of each batch of input data is updated , variance .
model.eval(): Guarantee BN The layer directly uses the mean variance obtained from the previous training , Ensure that the mean variance remains unchanged during the test .pytorch Learning notes - In network training ,model.train() model.eval() Use _ Up in the sky ! The blog of -CSDN Blog name
matplotlib library
plt.clf(): Clear all axes , The window opens .【Matplotlib】 clear axes and figure(plt.cla、plt.clf、plt.close)_ZSYL The blog of -CSDN Blog _matplotlib Empty axes
plt.subplot(): Divide the display interface into grids .matplotlib Medium plt.subplot() Introduction _ The blog of the little famous cute ghost -CSDN Blog _plt.subplot
Built in functions
set(): Is an unordered sequence of non repeating elements . Frequently used {} or set() Function representation .
.index():Python Medium index() Method _ Beimu . The blog of -CSDN Blog _python in index
sample():(a,n):a Is a sequence ,n For random from a Mid extraction n Number .python sample function _ Dr. Xiang's blog -CSDN Blog _python sample function
-------------------- Ongoing update --------------------
边栏推荐
- JS convert numbers to letters
- Which is the file transfer command in the basic services of the Internet
- Summary of common error types in JS
- Install PCL and VTK under the background of ROS installation, and solve VTK and PCL_ ROS conflict problem
- NPM switch Taobao source (NPM source)
- 微信小程序使用canvas绘图,圆形头像,网络背景图,文字,虚线,直线
- STM32 - advanced control timer (time base unit, functional block diagram, input, capture, output, open circuit)
- 【转载】token令牌在登录场景使用
- JVM——自定义类加载器
- [connect your mobile phone wirelessly] - debug your mobile device wirelessly via LAN
猜你喜欢
![Memseg [anomaly detection: embedded based]](/img/10/aea2b6ecf55e04fe24f78e5fb897be.png)
Memseg [anomaly detection: embedded based]

Imx6q GPIO multiplexing

Research cup element recognition multi label classification task based on ernie-3.0 cail2019 method

CMD common commands

When can I sign up for the 2022 class I constructor examination?
![MKD [anomaly detection: knowledge disruption]](/img/15/10f5c8d6851e94dac764517c488dbc.png)
MKD [anomaly detection: knowledge disruption]

842. Arrange numbers

imx6q gpio复用

STM32 -- program startup process

Quadruped robot | gem (elevation map) + fast_ Deployment records of Leo (odometry) environment
随机推荐
When can I sign up for the 2022 class I constructor examination?
Detection and tracking evaluation index
2022年一级建造师考试什么时候才能报名?
NPM switch Taobao source (NPM source)
Soft exam network engineer
Imx6q GPIO multiplexing
Log4j vulnerability elk platform processing method (logstah5.5.1)
PC side web page effects (client series, scroll series, immediate function execution, sidebar effects)
微信小程序剪切图片的功能
MySQL installation and configuration (super detailed, simple and practical)
PaddleNLP基于ERNIR3.0文本分类以中医疗搜索检索词意图分类(KUAKE-QIC)为例【多分类(单标签)】
Att & CK Threat Intelligence
771. 字符串中最长的连续出现的字符
Ngrok intranet penetration
Sword finger offer II 063. replacement word (medium prefix tree string)
使用PCL批量显示PCD点云数据流
PC side special effects - animation function
JVM——自定义类加载器
842. Arrange numbers
Pictures are named in batches in order (change size /jpg to PNG) [tips]