当前位置:网站首页>Torch learning notes (4) -- torch's dynamic calculation diagram
Torch learning notes (4) -- torch's dynamic calculation diagram
2022-07-03 18:22:00 【ZRX_ GIS】
import torch
import numpy as np
import matplotlib.pyplot as plt
# Calculation chart (Computer Graph) Is a directed acyclic graph used to describe operations
# CG There are two main elements : node (Node)、 edge (Edge)
# Node According to the data
# Edge Representation operation
# If you want to use non leaf Gradient of nodes . You need to call before back propagation .retain_grad()
# CG effect : Convenient gradient calculation and back propagation
# Case study
# y = (x+w)(w+1), Then when w=1,x=2 when ,y Yes w Of grad How much is the ?
w = torch.tensor([1.], requires_grad=True)
x = torch.tensor([2.], requires_grad=True)
a = torch.add(w, x)
b = torch.add(w, 1)
y = torch.mul(a, b)
y.backward()
# Can pass .grad Determine whether the variable has grad, After the end of back propagation, it is not leaf Nodal grad Will be released
print(w.grad)
# grad_fn Used to record the creation of tensor Used in function, The essence is to record Edge
print(y.grad_fn)
# according to CG Construction method , Can be CG It is divided into dynamic graph and static graph
# Dynamic graph (Dynamic Graph) Operation and loading are carried out at the same time , self-driving tours
# Static diagram (Computation Graph) First loading diagram , Post operation , Travel with a group
边栏推荐
- AcWing 271. 杨老师的照相排列【多维DP】
- Codeforces Round #803 (Div. 2) C. 3SUM Closure
- [combinatorics] exponential generating function (concept of exponential generating function | permutation number exponential generating function = combinatorial number ordinary generating function | e
- OpenSSL的SSL/BIO_get_fd
- PHP MySQL where clause
- win32:堆破壞的dump文件分析
- [combinatorics] generating function (use generating function to solve the number of solutions of indefinite equation example 2 | extended to integer solution)
- English语法_名词 - 分类
- Ssl/bio of OpenSSL_ get_ fd
- Count the number of pixel values in the image
猜你喜欢
Grammaire anglaise Nom - Classification
Should I be laid off at the age of 40? IBM is suspected of age discrimination, calling its old employees "dinosaurs" and planning to dismiss, but the employees can't refute it
2022-2028 global marking ink industry research and trend analysis report
2022-2028 global scar care product industry research and trend analysis report
How to analyze the rising and falling rules of London gold trend chart
Lesson 13 of the Blue Bridge Cup -- tree array and line segment tree [exercise]
Win32: analyse du fichier dump pour la défaillance du tas
What problems can cross-border e-commerce sellers solve with multi platform ERP management system
[enumeration] annoying frogs always step on my rice fields: (who is the most hateful? (POJ hundred practice 2812)
CTO and programmer were both sentenced for losing control of the crawler
随机推荐
189. Rotation array
Lesson 13 of the Blue Bridge Cup -- tree array and line segment tree [exercise]
English语法_名词 - 分类
Computer graduation design PHP campus address book telephone number inquiry system
[combinatorics] generating function (example of using generating function to solve the number of solutions of indefinite equation)
Codeforces Round #803 (Div. 2) C. 3SUM Closure
PHP MySQL where clause
解决Zabbix用snmp监控网络流量不准的问题
Distributed task distribution framework gearman
Redis core technology and practice - learning notes (VII) sentinel mechanism
[untitled]
模块九作业
Redis on local access server
[Yu Yue education] family education SPOC class 2 reference materials of Shanghai Normal University
What London Silver Trading software supports multiple languages
Golang string (string) and byte array ([]byte) are converted to each other
Count the number of pixel values in the image
毕业总结
[combinatorics] exponential generating function (example 2 of solving multiple set permutation with exponential generating function)
2022-2028 global petroleum pipe joint industry research and trend analysis report