摘要: 【d2l】2.6.概率 本节的代码量比较小,主要在于构建一个对于概率的观念 大数定律 这个部分利用脚本来验证大数定律 先导入所需要的库 %matplotlib inline import torch from torch.distributions import multinomial import 阅读全文
posted @ 2025-12-19 16:47 R4y 阅读(10) 评论(0) 推荐(0)
摘要: 【d2l】2.5.自动微分 这一节看似只讲了torch的反向传播接口,但真正想理解还是得有一个计算图的概念 简单的例子 现在有一个向量\(x\),我需要计算\(y = 2x^\top x\)关于\(x\)求导,实现如下 import torch x = torch.arange(4., requir 阅读全文
posted @ 2025-12-19 16:08 R4y 阅读(6) 评论(0) 推荐(0)
摘要: 【d2l】2.4.微积分 本节主要讲解了微分、偏导、梯度和链式法则 其中梯度需要着重强调 梯度 对于一个多元函数,我们可以对所有变量做偏导数,从而得到该函数的梯度向量 函数\(f:\mathbb{R}^n \rightarrow \mathbb{R}\)输入了一个\(n\)维向量\(x = [x_1 阅读全文
posted @ 2025-12-19 10:22 R4y 阅读(8) 评论(0) 推荐(0)
摘要: 【d2l】2.3.线性代数 标量 这一块采用torch将标量实例化 import torch x = torch.tensor(3.0) y = torch.tensor(2.0) x + y, x * y, x / y, x ** y (tensor(5.), tensor(6.), tensor 阅读全文
posted @ 2025-12-18 22:26 R4y 阅读(7) 评论(0) 推荐(0)
摘要: 【d2l】2.2.数据预处理 本节主要涉及pandas的应用 但是由于我的torch版本较高,因而只能采用高版本torch,有些细节需要加以调整 读取数据集 首先用os库生成一个csv import os os.makedirs(os.path.join('.', 'data'), exist_ok 阅读全文
posted @ 2025-12-18 21:39 R4y 阅读(4) 评论(0) 推荐(0)
摘要: 第一章-第三章 数理逻辑 极小项/极大项表【对应二进制位取值得到整项取值为1/0】 值 极小项 极大项 000 \(\neg p \and \neg q \and \neg r\) \(p \or q \or r\) 001 \(\neg p \and \neg q \and r\) \(p \or 阅读全文
posted @ 2025-12-17 09:49 R4y 阅读(14) 评论(0) 推荐(0)
摘要: 第一章 行列式 定义1.1.(二阶行列式) \[D = \left | \begin{matrix} a_{11}& a_{12} \\ a_{21}& a_{22} \end{matrix} \right | = a_{11}a_{22} - a_{12}a_{21} \]定义1.2.(三阶行列式 阅读全文
posted @ 2025-12-17 08:24 R4y 阅读(27) 评论(0) 推荐(0)
摘要: 第一章 集合与函数 基本概念 笛卡儿乘积: \[A \times B = \{(x, y) | x \in A \and y \in B\} \]引理: 有理数可以表示为\(r = \frac{p}{q}\),其中\(p,q \in \mathbb{Z}\)且\(\gcd(p, q) = 1\) 因 阅读全文
posted @ 2025-12-17 08:23 R4y 阅读(12) 评论(0) 推荐(0)
摘要: 【d2l】2.1.数据操作 import torch 初始化 序列定义 x = torch.arange(12) 全零张量 torch.zeros(2, 3, 4) 全一张量 torch.ones(2, 3, 4) 随机数 torch.randn(3, 4) 自定义 torch.tensor([[1 阅读全文
posted @ 2025-12-13 15:22 R4y 阅读(6) 评论(0) 推荐(0)
摘要: 大一上OJ题回顾 第一章 问题 A: 判断坐标区域 简单的逻辑判断,注意多组读入即可。 #include<iostream> using namespace std; bool judge(int x) { return x >= -2 && x <= 2; } int main() { int x 阅读全文
posted @ 2025-12-10 18:21 R4y 阅读(15) 评论(0) 推荐(0)