普通视图

发现新文章,点击刷新页面。
昨天以前MiaoHN's Blog

xjtu 编译原理实验 01

2022年5月29日 19:27
初始 Cool 语言 Cool, an acronym for Classroom Object Oriented Language, is a computer programming language designed by Alexander Aiken for use in an undergraduate compiler course project. While small enough for a one term project, Cool still has many of the features of modern programming languages, including objects, automatic memory management, strong static typing and simple reflection. 实验准备 Linux 环境 编译实

Lecture05 Rasterization 1 (Triangles)

2023年6月18日 14:48
Slide Perspective Projection Link to heading What’s near plane’s l,r,b,t then? If explicitly specified, good Sometimes people prefer: vertical field-of-view (fovY) and aspect ratio (assume symmetry i.e. l=-r, b = -t) How to convert from fovY and aspect to l, r, b, t? Trivial $$ \tan{\frac{fovY}{2}}=\frac{t}{\lvert n\rvert} $$ $$ aspect=\frac{r}{t} $$ Canonical Cube to Screen Link to heading What is a screen?

Lecture04 Transformation Cont.

2023年6月18日 10:56
Slide 3D transformations Link to heading Use homogeneous coordinates again: 3D point = $(x,y,z,1)^T$ 3D vector = $(x,y,z,0)^T$ In general, $(x,y,z,w)(w\neq0)$ is the 3D point: $(x/w,y/w,z/w)$ Use $4\times4$ matrices for affine transformations $$ \begin{pmatrix} x'\\y'\\z'\\1 \end{pmatrix}= \begin{pmatrix} a&b&c&t_x\\d&e&f&t_u\\g&h&i&t_z\\0&0&0&1 \end{pmatrix} \cdot \begin{pmatrix} x\\y\\z\\1 \end{pmatrix} $$ Scale $$ S(s_x,s_y,s_z)=\begin{pmatrix}s_x&0&0&0\\0&s_y&0&0\\0&0&s_z&0\\0&0&0&1\end{pmatrix} $$ Translation $$ T(t_x,t_y,t_z)=\begin{pmatrix}1&0&0&t_x\\0&1&0&t_y\\0&0&1&t_z\\0&0&0&1\end{pmatrix} $$ Rotation around x-, y-, or z-axis $$ R_x(\alpha)=\begin{pmatrix}1&0&0&0\\0&\cos{\alpha}&-\sin{\alpha}&0\\0&\sin{\alpha}&\cos{\alpha}&0\\0&0&0&1\end{pmatrix} $$ $$ R_y(\alpha)=\begin{pmatrix}\cos{\alpha}&0&\sin{\alpha}&0\\0&1&0&0\\-\sin{\alpha}&0&\cos{\alpha}&0\\0&0&0&1\end{pmatrix} $$ $$ R_z(\alpha)=\begin{pmatrix}\cos{\alpha}&-\sin{\alpha}&0&0\\sin{\alpha}&\cos{\alpha}&0&0\\0&0&1&0\\0&0&0&1\end{pmatrix} $$

Lecture03 Transform

2023年6月17日 22:03
Slide Why study transformation Link to heading Modeling Link to heading translation rotation scaling Viewing Link to heading (3D to 2D) projection 2D transformations Link to heading Scale $$ \begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}s_x&0\\0&s_y\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix} $$ Reflection Matrix $$ \begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}-1&0\\0&1\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix} $$ Shear Matrix $$ \begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}1&a\\0&1\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix} $$ Rotate $$ R_\theta=\begin{bmatrix}\cos{\theta}&-\sin{\theta}\\sin{\theta}&\cos{\theta}\end{bmatrix} $$ Linear Transforms = Matrices $$ \begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}a&b\\c&d\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix} $$ $$ x'=\bold{M}x $$ Homogeneous coordinates Link to heading Why Homogeneous Coordinates Link to heading Translation cannot be represented in matrix form $$ \begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}a&b\\c&d\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix}+\begin{bmatrix}t_x\\t_y\end{bmatrix} $$ (So, translation is NOT linear transform!

Lecture02 Review of Linear Algebra

2023年6月17日 20:49
Slide A Swift and Brutal Introduction to Linear Algebra! Graphics' Dependencies Link to heading Basic mathematics Linear algebra, calculus, statistics Basic physics Optics, Mechanics Misc Signal processing Numerical analysis And a bit of asthetics This Course Link to heading More dependent on Linear Algebra Vectors (dot products, cross products, …) Matrices (matrix-matrix, matrix-vector mult.

Lecture01 Overview of Computer Graphics

2023年6月17日 14:34
Slide What can Computer Graphics do? Link to heading Video Games Movies Animations Design Visualization Virtual Reality Digital Illustration Simulation Graphical User Interfaces Typography Why Study Computer Graphics? Link to heading Fundamental Intellectural Challenges Creates and interacts with realistic virtual world Requires understanding of all aspects of physical world New computing methods, displays, technologies Technical Challenges Math of (perspective) projects, curves, surfaces Physics of lighting and shading Representing / Operating shapes in 3D Animation / Simulation Forget about the previous reasons: Computer Graphics is AWESOME!

【统计学习方法】第4章 朴素贝叶斯法

2023年5月13日 22:22
朴素贝叶斯(naive Bayers)法是基于贝叶斯定理与特征条件独立假设的分类方法。对于给定的训练集数据,首先基于特征条件独立假设学习输入/输出的联合分布概率;然后基于此模型,对于给定的输入 $x$,利用贝叶斯定理求出后验概率最大的输出 $y$。 4.1 朴素贝叶斯法 Link to heading 朴素贝叶斯法通过训练数据集学习联合概率分布 $P(X,Y)$。具体地,学习以下先验概率分布及条件概率分布。先验概率分布 $$ P(Y=c_k),k=1,2,\cdots,K $$ 条件概率分布 $$ P(X=x|Y=c_k)=P(X^{(1)}=x^{(1)},\cdots,X^{(n)}=x^{(n)}|Y=c_k),k=1,2,\cdots,K $$ 于是学到联合概率分布 $P(X,Y)$。朴素贝叶斯法对条件概率分布作了条件独立性的假设。具体地,条件独立性假设是 $$ P(X=x|Y=c_k)=\prod_{j=1}^nP(X^{(j)}=x^{(j)}|Y=c_k) $$ 朴素贝叶斯法实际上学习到生成数据的机制,所以属于生成模型。条件独立假设等于说用于分类的特征在类确定的条件下都是条件独立的。这一假设使朴素贝叶斯法变得简单,但有时会牺牲一定的分类准确率。 朴素贝叶斯法分类时,对于给定的输入 $x$,通过学习到的模型计算后验概率分布 $P(Y=c_k|X=x)$,将后验概率最大的类作为 $x$ 的类输出。后验概率计算根据贝叶斯定理进行: $$ P(Y=c_k|X=x)=\frac{P(X=x|Y=c_k)P(Y=c_k)}{\sum_kP(X=x|Y=c_k)P(Y=c_k)} $$ 将上面两个式子进行联立,得到 $$ P(Y=c_k|X=x)=\frac{P(Y=c_k)\prod_jP(X^{(j)}=x^{(j)}|Y=c_k)}{\sum_kP(Y=c_k)\prod_jP(X^{(j)}=x^{(j)}|Y=c_k)},k=1,2,\cdots,K $$ 于是,朴素贝叶斯分类器可表示为 $$ y=f(x)=\argmax_{c_k}\frac{P(Y=c_k)\prod_jP(X^{(j)}=x^{(j)}|Y=c_k)}{\sum_kP(Y=c_k)\prod_jP(X^{(j)}=x^{(j)}|Y=c_k)} $$ 注意到,在上式中分母对所有 $c_k$ 都是相同的,所以 $$ y=\argmax_{c_k}P(Y=c_k)\prod_jP(X^{(j)}=x^{(j)}|Y=c_k) $$ 朴素贝叶斯法将实例分到后验概率最大的类中,等价于期望风险最小化。 4.2 朴素贝叶斯法的参数估计 Link to heading 4.2.1 极大似然估计 Link to heading 在朴素贝叶斯法中,学习意味着估计 $P(Y=c_k)$ 和 $P(X^{(j)}=x^{(j)}|Y=c_k)$。可以应用极大似然估计法估计相应的概率。先验概率 $P(Y=c_k)$ 的极大似然概率估计是

【统计学习方法】第2章 感知机

2023年5月11日 11:15
感知机(perceptron)是二分类的线性分类模型,其输入为实例的特征向量,输出为实例的类别,取 $+1$ 和 $-1$ 二值。感知机对应于输入空间(特征空间)中将实例划分为正负两类的分离超平面,属于判别模型。感知机学习算法具有简单而易于实现的优点,分为原始形式和对偶形式。 2.1 感知机模型 Link to heading 假设输入空间(特征空间)是 $\mathcal{X}\subseteq\mathbb{R}^n$,输出空间是 $\mathcal{Y}=\{+1, -1\}$。由输入空间到输出空间的如下函数: $$ f(x)=sign(w\cdot x+b) $$ 称为感知机。其中,$w$ 和 $b$ 为感知机模型参数,$w\in\mathbb{R}^n$ 叫做权值(weight)或权值向量(weight vector),$b\in\mathbb{R}$ 叫做偏置(bias),$sign$ 是符号函数。 2.2 感知机学习策略 Link to heading 给定训练集 $$ T=\{(x_1,y_1),(x_2,y_2),\cdots,(x_N,y_N)\} $$ 其中,$x_i\in\mathcal{X}=\mathbb{R}^n$,$y_i\in\mathcal{Y}=\{+1,-1\}$,$i=1,2,\cdots,N$。感知机学习的损失函数定义为 $$ L(w,b)=-\sum_{x_i\in M}y_i(w\cdot x_i+b) $$ 其中 $M$ 为误分类点的集合。这个损失函数就是感知机学习的经验风险函数。 2.3 感知机学习算法 Link to heading 2.3.1 感知机学习算法的原始形式 Link to heading 感知机学习算法是误分类驱动的,具体采用随机梯度下降法(stochastic gradient descent)。首先,任意选取一个超平面 $w_0,b_0$,然后用梯度下降法不断地极小化目标函数。极小化过程中不是一次使 $M$ 中所有误分类点的梯度下降,而是一次随机选取一个误分类点使其梯度下降。假设误分类点集合 $M$ 是固定的,那么损失函数 $L(w,b)$ 的梯度由

【统计学习方法】第1章 统计学习方法概论

2023年5月11日 08:33
1.1 统计学习 Link to heading 统计学习的特点 Link to heading 以计算机及网络为平台,是建立在计算机及网络之上的 以数据为研究对象,是数据驱动学科 目的是对数据进行预测与分析 是概率论、统计学、信息论、计算理论、最优化理论及计算机科学等多个领域的交叉学科,并在发展中逐步形成独自的理论体系与方法论 如果一个系统能够通过执行某个过程改进它的性能,这就是学习 — Herbert A. Simon 统计学习的组成 Link to heading 监督学习(supervised learning) 非监督学习(unsupervised learning) 半监督学习(semi-supervised learning) 强化学习(reinforcement learning) 统计学习的三要素 Link to heading 模型(model) 策略(strategy) 算法(algorithm) 实现统计学习方法的步骤 Link to heading 得到一个有限的训练数据集合 确定包含所有可能的模型的假设空间,即学习模型的集合 确定模型选择的准则,即学习的策略 实现求解最优模型的算法,即学习的算法 通过学习方法选择最优模型 利用学习的最优模型对新数据进行预测或分析 1.

测试博客

2023年4月24日 14:59
这是新主题的第一篇博客,在换主题的同时,想将之前的写的一些文章进行整理后陆续移到这里 这个主题(Hermit)非常合我胃口,之前找了好多博客要么花里胡哨要么需要自己改动好多,有几天都想自己写一个主题,但是发现自己写的更丑😂。今天突然在 Github 上看到这个主题,又干净又简单,就给换了,并在此立个 Flag:再也不要在主题上瞎折腾 既然是第一篇博客,那么理应测试一下这个主题的渲染效果: 二级标题 Link to heading 三级标题 Link to heading 四级标题 Link to heading 这是一个引用 这是一个脚注1 // 这是代码 #include <iostream>int main(int argc, char** argv) { return 0; } 这是一些变量:count,total 下面是数学公式: $$ E=mc^2 $$ 这是行内公式:$E=mc^2$ 下面是列表 item item item item item item 这是加粗,这是斜体字 下面是张图: 以后的博客日志就放到这篇文章了:ChangeLogs https://miaohn.github.io ↩︎

[论文阅读|代码学习]PointNet

2023年1月3日 08:55
math: true comment: true Link to heading 论文地址 Tensorflow 实现 Pytorch 实现 math: true comment: true Link to heading 简介 Link to heading Point cloud is an important type of geometric data structure. Due to its irregular format, most researchers transform such data to regular 3D voxel grids or collections of images. This, however, renders data unnecessarily voluminous and causes issues.

Hello World

2022年11月12日 09:55
还记得我在 Visual Studio 上写的第一个程序: #include <stdio.h> int main(int argc, char** argv) { printf("Hello World!\n"); return 0; } 当第一次看到命令行按照以上代码打印出 “Hello World!” 时,我有一种非常奇妙的感觉,因为我发现我好像正在与一台计算机进行交流切磋。而我占据上风,已经吃透了 printf 这个函数,已经吃透了这个程序。可是当我发现项目大小竟然超过 5MB,而程序的二进制大小居然有足足 60KB 时,我被迷惑住了:这么简单的程序怎么这么大?事情似乎没那么简单,这背后有一些我没看见的东西,Visual Studio 是不是在背后偷偷做了什么?能不能写出一个最小的 Hello World 程序? 程序的生成 Link to heading Visual Studio 的集成度比较高,一度让我以为程序是直接通过代码一键生成的。后来渐渐知道,要想从一段代码得到可执行文件,还需要经过编译、链接之类的步骤 为了能够更清楚地学习整个过程,我在 Linux 环境下对 Hello World 程序进行编译。实际上在编译过程中还有很多其他要考虑的东西,在这里通过一个简单的程序,对程序的编译过程有一个感性的认识就算达成目标了 Preprocessing Link to heading 在预处理阶段中会将代码中的头文件以及宏全部展开,便于后面进行编译。使用如下命令进行预处理: $cpp hello_world.c -o hello_world.i 之后会生成一个文本文件,从中摘取一段内容: # 1 "hello_world.c" # 1 "<built-in>" # 1 "<command-line>" .

RSA 加密算法

2022年11月11日 19:13
RSA 加密算法是一种非对称加密算法,在公开密钥加密和电子商业中被广泛使用。RSA 是由罗纳德·李维斯特(Ron Rivest)、阿迪·萨莫尔(Adi Shamir)和伦纳德·阿德曼(Leonard Adleman)在 1977 年一起提出的。当时他们三人都在麻省理工学院工作。RSA 就是他们三人姓氏开头字母拼在一起组成的。 —— 维基百科 互联网是自由的,我们可以在网上获得几乎任何想得到的信息。1960 年,美国国防部高等研究计划署(DARPA)出于冷战的考虑,建立了网络的老祖宗——ARPANET。网络发展初期,人们并没有考虑太多有关网络安全的事,因为那时网络只有军方还有寥寥几所大学在用,大家在网上分享文献书籍,相互交流,如果还要设置密码只会徒增麻烦。网络给人们带来了极大的便利,其巨大的研究价值和商业价值也被人们发现,随之而来的就是互联网的蓬勃发展及大范围普及。随着用户的增多,信息安全越来越重要,人们需要寻找一种可靠的加密算法,这个时候,RSA 算法开始登上历史舞台。 算法的诞生 Link to heading RSA 算法诞生的具体细节可以看这篇博客,写的挺好 算法过程 Link to heading 假如 Alice 要通过网络向 Bob 发送一条私人信息,她可以通过如下几步得到一个公钥和密钥: 随机选取两个不同的大素数 $p$ 和 $q$,比如位数超过 100 位。将这两个数乘起来,得到 $N=pq$ 根据欧拉函数,求得 $r=\varphi(N)=\varphi(p)\times\varphi(q)=(p-1)(q-1)$ 选择一个小于 $r$ 且与 $r$ 互质的整数 $e$。此时必然可以找到一个 $d$ 使得 $ed\equiv 1(mod\ r)$ 销毁 $p$ 和 $q$。现在 $(N,e)$ 就是的公钥,$(N,d)$ 就是密钥 现在 Alice 把公钥 $(N,e)$ 传给 Bob,私钥 $(N,d)$ 自己藏着。当 Bob 想给 Alice 发送消息 m 时,先约定好信息的处理格式,比如将每一个字转换为这个字的 Unicode 码,然后进行分段加密。将消息 m 的每一段视为数字 n,然后通过:

Zigzag 压缩小整数

2022年10月1日 10:28
zigzag 是一个简单好用的小整数压缩算法。 原理 Link to heading 现在一般的计算机都是 32 位或者 64 位机了,每个数据的表示长度和范围都比较多。一个常见的数据类型 int 一般占 4 个字节,但是在实际使用时,数字并不会很大,经常不会超过几万(当然要看实际情况),比如下面几个例子 number: 23 bit: 0000 0000 0000 0000 0000 0000 0001 0111 number: -33 bit: 1111 1111 1111 1111 1111 1111 1101 1111 通过观察可以发现,小正数的左侧有大量的 0,小负数的左侧有大量的 1。zigzag 做的就是将左边的冗余数据全部换为 0,便于后续压缩。 正数 Link to heading 拿 23 举例 将数字左移一位:0000 0000 0000 0000 0000 0000 0010 1110 符号位加到最后一位(正数符号位为 0 不用操作) 得到了最后的压缩结果:0000 0000 0000 0000 0000 0000 0010 1110

编译原理实验 2

2022年5月29日 19:32
Cool 语言堆栈机 Link to heading 1. 操作说明 Link to heading 命令 含义 int 将整数数添加到栈中 + 栈中压入 + s 栈中压入 s e 计算栈顶表达式的值(详见下文) d 打印栈中内容 x 退出 e 命令的作用: 如果 + 在栈顶,那么 + 出栈,栈顶两整数弹出并相加,将结果压入栈 如果 s 在栈顶,那么 s 出栈,下面两个选项在栈内交换 2. 栈的实现 Link to heading 2.
❌
❌