深度学习之绘图基础

文章目录

1.实验目的

熟练绘制各种图像,为深度学习打基础

2. 需求

给定一个函数,需要你画出原图像以及这个函数在某点切线图像

3.代码

python 复制代码
# @File: python绘制函数图像以及倒数图像.py
# @Author: chen_song
# @Time: 2024/6/21 下午8:52

from matplotlib import pyplot as plt
import numpy as np

x = np.arange(0,2*np.pi,0.01)
y = [np.sin(x) for x in x]
plt.plot(x,y)
def getK(y, x):
    h = 1e-4
    return (getFunction(x + h) - getFunction(x)) / h

def getFunction(x):
    return np.sin(x)

k = getK(y, np.pi/4)
b = getFunction(1) - k
print(k,b)
y1 = [k * x + b for x in x]
plt.plot(x,y1)
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.title('正弦函数及其在pi/4处切线图像')
plt.show()

结果图片

相关推荐
默_笙16 小时前
🍙 给每个请求过安检:FastAPI 是怎么把校验写进类型注解的
python
qq_4260039616 小时前
启动playwright录制codegen生成自动化测试脚本
python·自动化
虎头金猫17 小时前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
长沙三为智能科技17 小时前
家政小程序开发从0到上线:五阶段交付流程与验收清单
python
伞伞悦读17 小时前
【第38期】Python 模块与包详解:import、from、模块搜索路径、包结构和 __init__
开发语言·python
只睡四小时18 小时前
Canvas 弹道联机实战:700 行 + 固定时间步长
python·websocket·html5·游戏开发·canvas
奇思妙想聪明勤奋的小羊18 小时前
DeepAgents第5章:子Agent 与上下文隔离—让 Agent学会委派
人工智能·python·学习·语言模型
lpfasd12319 小时前
2026年第38周GitHub趋势周报
python·科技·github
IZero0719 小时前
Jev 与 Laya
python·语言模型