当前位置:网站首页>Li Mu's learning notes of hands-on learning in depth (6) Chapter 1 preparatory knowledge section 4 Differential
Li Mu's learning notes of hands-on learning in depth (6) Chapter 1 preparatory knowledge section 4 Differential
2022-07-21 22:01:00 【Artificial Idiots】
1.4 differential
1.4.1 Derivative and differential
# The function is when you call matplotlib.pyplot The graph function of plot() When drawing ,
# Or generate a figure When it comes to canvases , It can be directly in your python console There's an image inside .
%matplotlib inline
from IPython import display
from mxnet import np, npx
from d2l import mxnet as d2l
npx.set_np()
# Defined function
def f(x):
return 3 * x ** 2 - 4 * x
# Find the limit
def numerical_lim(f, x, h):
return (f(x + h) - f(x)) / h
h = 0.1
for i in range(5):
#print The string is preceded by f Represents a formatted string , Add f Variables and expressions enclosed in curly braces can be used in the string ,
# If there is no expression in the string , So do you add it in front f The output should be the same .
print(f'h={
h:.5f}, numerical limit = {
numerical_lim(f, 1, h):.5f}')
h *= 0.1
h=0.10000, numerical limit = 2.30000
h=0.01000, numerical limit = 2.03000
h=0.00100, numerical limit = 2.00300
h=0.00010, numerical limit = 2.00030
h=0.00001, numerical limit = 2.00003
def use_svg_display(): #@save
""" send ⽤svg Format in Jupyter Show in the middle ⽰ mapping ."""
display.set_matplotlib_formats('svg')
def set_figsize(figsize = (3.5, 2.5)): #@save
""" Set up matplotlib The chart ⼤⼩."""
use_svg_display()
d2l.plt.rcParams['figure.figsize'] = figsize
#@save
def set_axes(axes, xlabel, ylabel, xlim, ylim, xscale, yscale, legend):
""" Set up matplotlib The shaft ."""
axes.set_xlabel(xlabel)
axes.set_ylabel(ylabel)
axes.set_xscale(xscale)
axes.set_yscale(yscale)
axes.set_xlim(xlim)
axes.set_ylim(ylim)
if legend:
axes.legend(legend)
axes.grid()
#@save
def plot(X, Y=None, xlabel=None, ylabel=None, legend=None, xlim=None,
ylim=None, xscale='linear', yscale='linear',
fmts=('-', 'm--', 'g-.', 'r:'), figsize=(3.5, 2.5), axes=None):
""" Drawing data points ."""
if legend is None:
legend = []
set_figsize(figsize)
axes = axes if axes else d2l.plt.gca()
# If `X` Yes ⼀ Axes , Output True
def has_one_axis(X):
return (hasattr(X, "ndim") and X.ndim == 1 or
isinstance(X, list) and not hasattr(X[0], "__len__"))
if has_one_axis(X):
X = [X]
if Y is None:
X, Y = [[]] * len(X), X
elif has_one_axis(Y):
Y = [Y]
if len(X) != len(Y):
X = X * len(Y)
axes.cla()
for x, y, fmt in zip(X, Y, fmts):
if len(x):
axes.plot(x, y, fmt)
else:
axes.plot(y, fmt)
set_axes(axes, xlabel, ylabel, xlim, ylim, xscale, yscale, legend)
x = np.arange(0, 3, 0.1)
plot(x, [f(x), 2 * x - 3], 'x', 'f(x)', legend=['f(x)', 'Tangent line (x=1)'])
<ipython-input-15-80d5adcc870a>:3: DeprecationWarning: `set_matplotlib_formats` is deprecated since IPython 7.23, directly use `matplotlib_inline.backend_inline.set_matplotlib_formats()`
display.set_matplotlib_formats('svg')
1.4.2 Partial derivative
1.4.3 gradient
1.4.4 The chain rule
边栏推荐
- 字符串类型的数字的加减乘除运算
- Raspberry pie 4B new machine system configuration and computer connection operation
- STM32系列TIMER互补输出详解
- 树莓派 4B 使用拓展板的四声音传感器AO模块连接
- 专题解答:nmn概念股是什么意思,NMN到底是什么
- Seretod2022 data analysis task-based dialogue system challenge for semi supervised and reinforcement learning
- Nimble Bluetooth development III: introduction to nimble ble ble application
- G了,眼看就过年了,突然被领导安排了个新任务
- Raspberry pie 4B switch system and PIP image source
- 【半导体先进工艺制程技术系列】FinFET和UTB-SOI简介
猜你喜欢
线性代数
基于STM32H7x3系列对定时器双向断路输入Bidirectional break inputs的理解
[sentence interactive reprint] 1 Trend analysis of dialogue system
Armv8 cortex-a programming wizard manual learning_ three
Armv8 cortex-a programming wizard manual learning_ two
Kernel upgrade & amd NVIDIA graphics card driver & wireless network card driver and other solutions
全面:Realtek/瑞昱无线产品图谱及市场构成
nimble 蓝牙开发三:nimble BLE 应用介绍
无线充电模组开发的原理和优势
nmn有什么不好的作用吗,深剖nmn的功效与作用
随机推荐
这五款特别的蓝牙芯,哪款最合你应用
什么是直饮机?它的工作原理和优点是什么?
《关于 SylixOS 内核存在的问题 - CAN 内核驱动》
海外LPWAN的王者是我,一文看懂Wi-Sun协议
Asymmetric Discrete Cross-Modal Hashing
nimble 蓝牙开发三:nimble BLE 应用介绍
Swin_ Transformer_ Minivit code interpretation
Realtek USB wireless network card can find WiFi and cannot connect to the network
ROS source switching (ROS sources other than Tsinghua)
Network bugs solved during LwIP learning
带您了解无线充电技术的现状和未来发展趋势
Multi robot navigation and positioning configuration record based on ROS and turtle bot2
UWB environment configuration record
About the problems of sylixos kernel - can kernel driver
Hexadecimal conversion
[reprint] conversation action set definition cued standard dialogue acts
智能电表市场容量分析,年出货破亿颗
基于 MS-RTOS 的 NIMBLE 开发平台
Opencv mask wearing detection
Introduction to the study of care-gnn thesis