深度学习之绘图基础

文章目录

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()

结果图片

相关推荐
云程笔记1 小时前
004.环境搭建基础篇:Python、CUDA、cuDNN、PyTorch/TensorFlow安装与版本兼容性踩坑
pytorch·python·tensorflow
知行合一。。。6 小时前
Python--04--数据容器(总结)
开发语言·python
架构师老Y6 小时前
008、容器化部署:Docker与Python应用打包
python·容器·架构
lifewange7 小时前
pytest-类中测试方法、多文件批量执行
开发语言·python·pytest
pluvium277 小时前
记对 xonsh shell 的使用, 脚本编写, 迁移及调优
linux·python·shell·xonsh
2401_827499997 小时前
python项目实战09-AI智能伴侣(ai_partner_5-6)
开发语言·python
PD我是你的真爱粉7 小时前
MCP 协议详解:从架构、工作流到 Python 技术栈落地
开发语言·python·架构
ZhengEnCi8 小时前
P2G-Python字符串方法完全指南-split、join、strip、replace的Python编程利器
python
是小蟹呀^8 小时前
【总结】LangChain中工具的使用
python·langchain·agent·tool
宝贝儿好8 小时前
【LLM】第二章:文本表示:词袋模型、小案例:基于文本的推荐系统(酒店推荐)
人工智能·python·深度学习·神经网络·自然语言处理·机器人·语音识别