├── .gitignore ├── CS214-算法与复杂性 └── algorithm.pdf ├── CS240-计算机伦理学 └── 期末大作业 │ ├── 伦理学期末大作业.docx │ └── 伦理学期末大作业.pdf ├── CS337-计算机图形学 ├── .DS_Store ├── imgs │ ├── 3D_rotation.jpeg │ ├── alpha.png │ ├── ani_sample.png │ ├── barycentric.jpeg │ ├── barycentric_formula.jpeg │ ├── bezier.jpeg │ ├── bezier1.jpg │ ├── cc_subdivide.jpeg │ ├── cross_product.jpeg │ ├── ex1.png │ ├── ex2.png │ ├── ex3.png │ ├── gooch_shading.jpeg │ ├── hardware.jpeg │ ├── mesh_vs_topo.jpeg │ ├── mipmap.png │ ├── ortho_proj.jpeg │ ├── pers_proj.jpeg │ ├── phong_shade.png │ ├── pipeline.jpeg │ ├── process1.jpeg │ ├── process2.jpeg │ ├── ray_trace.jpeg │ ├── rog_rotation.jpeg │ ├── update_new.jpeg │ ├── update_old.jpeg │ ├── view_trans.jpeg │ ├── viewport.jpeg │ └── z-buffer.jpg ├── main.tex └── 计算机图形学-复习.pdf ├── CS339-计算机网络 ├── MapReduce.md ├── README.md ├── exam_example.pdf ├── imgs │ ├── 1.png │ ├── 10.png │ ├── 11.png │ ├── 12.png │ ├── 13.png │ ├── 14.png │ ├── 15.png │ ├── 16.png │ ├── 17.png │ ├── 18.png │ ├── 19.png │ ├── 2.png │ ├── 20.png │ ├── 21.png │ ├── 22.png │ ├── 23.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ └── 9.png ├── mapreduce-slides.pdf ├── quiz总复习.md ├── 作业整理 │ ├── solution for chap1.docx │ ├── solutions for chap2.docx │ ├── solutions for chap3-.doc │ ├── solutions for chap4.doc │ ├── solutions for chap5+6.doc │ └── ~$lutions for chap5+6.doc └── 知识点总复习.md ├── CS359-计算机体系结构 ├── .DS_Store ├── review(上).pdf └── review(下).pdf ├── CS386-数字图像处理 ├── .DS_Store └── 2021秋-数字图像处理复习.pptx ├── CS410-人工智能 ├── ai_review_map_yanjieze.html ├── imgs │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ └── 6.png ├── my_hw3.pdf └── my_hw4.pdf ├── CS499-计算机科学中的数学基础 ├── .DS_Store ├── RandomGraph.pdf ├── hard_problem.pdf ├── review(上).pdf └── review(下).pdf ├── MA238-离散数学 ├── .DS_Store ├── notes.pdf ├── 作业13.pdf └── 作业13参考解答.pdf ├── README.md ├── SUMMARY.md ├── TH029-毛概 ├── 2021毛概.docx └── 复习要点与辨析题与问答题.pdf ├── da-er ├── README.md ├── cs214-suan-fa-yu-fu-za-xing.md ├── cs359-ji-suan-ji-ti-xi-jie-gou.md ├── cs499-ji-suan-ji-ke-xue-zhong-de-shu-xue-ji-chu.md ├── ma238-li-san-shu-xue │ ├── README.md │ └── notes.md └── th029-mao-gai │ ├── README.md │ └── fu-xi-yao-dian-yu-bian-xi-ti-yu-wen-da-ti.md ├── da-san ├── README.md ├── cs240-ji-suan-ji-lun-li-xue │ ├── README.md │ └── review.md ├── cs337-ji-suan-ji-tu-xing-xue.md ├── cs386-shu-zi-tu-xiang-chu-li.md └── cs410-ren-gong-zhi-neng │ ├── README.md │ ├── ai-review.md │ └── imgs │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ └── 6.png └── 元学习笔记.pdf /.gitignore: -------------------------------------------------------------------------------- 1 | # 暂时ignore 2 | CS236-云计算技术/ 3 | 4 | 5 | .DS_Store -------------------------------------------------------------------------------- /CS214-算法与复杂性/algorithm.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS214-算法与复杂性/algorithm.pdf -------------------------------------------------------------------------------- /CS240-计算机伦理学/期末大作业/伦理学期末大作业.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS240-计算机伦理学/期末大作业/伦理学期末大作业.docx -------------------------------------------------------------------------------- /CS240-计算机伦理学/期末大作业/伦理学期末大作业.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS240-计算机伦理学/期末大作业/伦理学期末大作业.pdf -------------------------------------------------------------------------------- /CS337-计算机图形学/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/.DS_Store -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/3D_rotation.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/3D_rotation.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/alpha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/alpha.png -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/ani_sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/ani_sample.png -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/barycentric.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/barycentric.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/barycentric_formula.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/barycentric_formula.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/bezier.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/bezier.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/bezier1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/bezier1.jpg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/cc_subdivide.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/cc_subdivide.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/cross_product.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/cross_product.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/ex1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/ex1.png -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/ex2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/ex2.png -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/ex3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/ex3.png -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/gooch_shading.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/gooch_shading.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/hardware.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/hardware.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/mesh_vs_topo.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/mesh_vs_topo.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/mipmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/mipmap.png -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/ortho_proj.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/ortho_proj.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/pers_proj.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/pers_proj.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/phong_shade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/phong_shade.png -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/pipeline.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/pipeline.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/process1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/process1.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/process2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/process2.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/ray_trace.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/ray_trace.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/rog_rotation.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/rog_rotation.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/update_new.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/update_new.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/update_old.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/update_old.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/view_trans.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/view_trans.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/viewport.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/viewport.jpeg -------------------------------------------------------------------------------- /CS337-计算机图形学/imgs/z-buffer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/imgs/z-buffer.jpg -------------------------------------------------------------------------------- /CS337-计算机图形学/main.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage[utf8]{inputenc} 3 | \usepackage{graphicx} 4 | \usepackage{float} 5 | \usepackage{mathptmx} 6 | \usepackage{amsmath} 7 | 8 | \title{Computer Graphics: A Review} 9 | 10 | \author{Yanjie Ze } 11 | \date{\today} 12 | 13 | \begin{document} 14 | 15 | \maketitle 16 | This is the course note for CS337: Computer Graphics, taught by Prof. Bin Sheng, written by Yanjie Ze. 17 | 18 | \section{Introduction} 19 | \begin{itemize} 20 | \item What is Computer Graphics? 21 | 22 | Generating images with the aid of computers. 23 | 24 | \item Grading Policy. 25 | 26 | \begin{itemize} 27 | \item Quiz 30\% 28 | \item Exam 30\% 29 | \item Project 40\% 30 | \end{itemize} 31 | \end{itemize} 32 | 33 | 34 | \section{Graphics Pipeline} 35 | \begin{itemize} 36 | \item Hardware: 37 | \begin{figure}[H] 38 | \centering 39 | \includegraphics[width=0.8\textwidth]{imgs/hardware.jpeg} 40 | \end{figure} 41 | 42 | \item Pipeline: 43 | 44 | \begin{itemize} 45 | \item Input of Pipeline: 46 | \begin{itemize} 47 | \item Primitives: 48 | 49 | The inputs to the Graphics Rendering Pipeline are geometric primitives (such as triangle, point, line or quad), which is formed by one or more vertices. 50 | 51 | Each vertex is associated with its attributes such as the position, color, normal and texture. 52 | \item Vertices: 53 | 54 | \begin{itemize} 55 | \item 56 | 57 | Position in 3D space V=(x, y, z): typically expressed in floating point numbers. 58 | 59 | \item 60 | Color: expressed in RGB (Red-Green-Blue) or RGBA (Red-Green-Blue-Alpha) components. 61 | 62 | \item 63 | Vertex-Normal N=(nx, ny, nz): Normals are used to differentiate the front- and back-face, and for other processing such as lighting. 64 | \item 65 | Texture T=(s, t): In computer graphics, we often wrap a 2D image to an object to make it seen realistic. A vertex could have a 2D texture coordinates (s, t), which provides a reference point to a 2D texture image. 66 | 67 | \end{itemize} 68 | \end{itemize} 69 | 70 | \item Pixel vs. Fragment: 71 | 72 | Pixels refers to the dots on the display. A pixel is 2-dimensional, with a (x, y) position and a RGB color value . 73 | 74 | A fragment is 3-dimensional, with a (x, y, z) position. The (x, y) are aligned with the 2D pixel-grid. The z-value (not grid-aligned) denotes its depth. 75 | 76 | 77 | Fragments are produced via interpolation of the vertices. Hence, a fragment has all the vertex's attributes such as color, fragment-normal and texture coordinates. 78 | 79 | 80 | \item Pipeline: 81 | \begin{itemize} 82 | \item Vertex Processor 83 | \item Rasterizer 84 | \item Fragment Processor 85 | \item Output Merging 86 | \end{itemize} 87 | \begin{figure}[H] 88 | \centering 89 | \includegraphics[width=0.8\textwidth]{imgs/pipeline.jpeg} 90 | 91 | 92 | \end{figure} 93 | 94 | \item Vertex Process: 95 | \begin{itemize} 96 | \item Model Transform 97 | \item View Transform 98 | \item Projection Transform 99 | \item Viewport Transform 100 | \end{itemize} 101 | 102 | \item Coordinate System: Right hand coordinate system 103 | \end{itemize} 104 | \item 105 | Visibility 106 | \begin{itemize} 107 | \item Painter's Algorithm: paint from back to front, overwrite in the framebuffer 108 | \item Z-Buffer: 109 | \begin{itemize} 110 | \item Store current min z-value for each sample position with a \textbf{depth buffer (z-buffer)} 111 | \item Fastest way: \textbf{draw from front to back} 112 | \item Algorithm: 113 | \begin{figure}[H] 114 | \centering 115 | \includegraphics[width=0.9\textwidth]{imgs/z-buffer.jpg} 116 | \caption{Z-buffer} 117 | 118 | \end{figure} 119 | 120 | \end{itemize} 121 | 122 | \end{itemize} 123 | \end{itemize} 124 | \section{Basic Transformation} 125 | 126 | \begin{itemize} 127 | \item Cross Product: 128 | \begin{figure}[H] 129 | \centering 130 | \includegraphics[width=0.5\textwidth]{imgs/cross_product.jpeg} 131 | 132 | \end{figure} 133 | \item 134 | 2D Transform: 135 | \begin{itemize} 136 | \item scale: uniform, non-uniform.$\begin{bmatrix} s_x & 0 \\ 0 & s_y\end{bmatrix}$ 137 | \item reflection:$\begin{bmatrix} -1 & 0 \\ 0 & 1\end{bmatrix}$ 138 | \item rotate: $\begin{bmatrix} \cos \theta & -\sin\theta \\ \sin\theta & \cos \theta\end{bmatrix}$ 139 | \item shear: $\begin{bmatrix} 1 & a \\ 0 & 1\end{bmatrix}$ 140 | \item linear:$\begin{bmatrix} a & b \\ c & d\end{bmatrix}$ 141 | \item affine:$\begin{bmatrix} a & b &t_x\\ c & d &t_y \\ 0&0&1\end{bmatrix}$ 142 | 143 | \end{itemize} 144 | 145 | \item Homogeneous Coordinates 146 | 147 | \item Compose Transform 148 | 149 | \item 3D Rotations: 150 | \begin{itemize} 151 | \item Euler angles:roll, pitch, yaw 152 | \begin{figure}[H] 153 | \centering 154 | \includegraphics[width=0.5\textwidth]{imgs/3D_rotation.jpeg} 155 | 156 | \end{figure} 157 | \item Rodrigues' Rotation Formula: 158 | \begin{figure}[H] 159 | \centering 160 | \includegraphics[width=0.6 \textwidth]{imgs/rog_rotation.jpeg} 161 | 162 | \end{figure} 163 | \end{itemize} 164 | \end{itemize} 165 | 166 | \section{Viewing and Perspective} 167 | \begin{itemize} 168 | \item MVP transformation: 169 | \begin{itemize} 170 | \item model transformation: find a good place and arrange people 171 | \item view transformation: find a good angle to put the camera 172 | \item projection transformation: Cheese! 173 | \end{itemize} 174 | \item 175 | \textbf{View transformation}: 176 | \begin{itemize} 177 | \item $t$, up vector. $g$, view vector. $e$, eye point. 178 | \item Translation Vector: $T_{view}=[-x_e,-y_e,-z_e,1]^T$ 179 | \item Rotation Matrix: First, rotate from the origin point to the camera position and get the matrix. Second, rotate back and get the inverse matrix. 180 | \begin{figure}[H] 181 | \centering 182 | \includegraphics[width=0.9\textwidth]{imgs/view_trans.jpeg} 183 | \caption{View Transformation} 184 | 185 | \end{figure} 186 | \end{itemize} 187 | 188 | \item Orthographic projection: 189 | \begin{itemize} 190 | \item Map a cuboid into the canonical cube. 191 | \item Translation then Scale: 192 | \begin{figure}[H] 193 | \centering 194 | \includegraphics[width=0.9\textwidth]{imgs/ortho_proj.jpeg} 195 | \caption{Orthographic projection} 196 | 197 | \end{figure} 198 | 199 | \end{itemize} 200 | \item Perspective Projection: 201 | \begin{itemize} 202 | \item First, squish the frustum into a cuboid with $n\rightarrow n, f\rightarrow f$. Second, do orthographic projection. 203 | \item Induction: 204 | \begin{figure}[H] 205 | \centering 206 | \begin{minipage}[t]{0.48\textwidth} 207 | \centering 208 | \includegraphics[width=6cm]{imgs/process1.jpeg} 209 | \caption{Induction 1} 210 | \end{minipage} 211 | \begin{minipage}[t]{0.48\textwidth} 212 | \centering 213 | \includegraphics[width=6cm]{imgs/process2.jpeg} 214 | \caption{Induction 2} 215 | \end{minipage} 216 | \end{figure} 217 | 218 | \item The result: 219 | \begin{figure}[H] 220 | \centering 221 | \includegraphics[width=0.6\textwidth]{imgs/pers_proj.jpeg} 222 | % \caption{Perspective Projection} 223 | 224 | \end{figure} 225 | \end{itemize} 226 | 227 | \item Canonical Cube to Screen 228 | \begin{itemize} 229 | \item Irrelevant to $z$ 230 | \item From $[-1,1]^2$ to $[0,width]\times[0,height]^2$: 231 | \begin{figure}[H] 232 | \centering 233 | \includegraphics[width=0.6\textwidth]{imgs/viewport.jpeg} 234 | % \caption{Viewport Transformation} 235 | \end{figure} 236 | \end{itemize} 237 | 238 | \end{itemize} 239 | 240 | 241 | \section{Shading Basics} 242 | \section{Shading Basics} 243 | 244 | \begin{itemize} 245 | \item Shading Model: 246 | 247 | Gooch Shading Model: 248 | \begin{figure}[H] 249 | \centering 250 | \includegraphics[width=0.9\textwidth]{imgs/gooch_shading.jpeg} 251 | 252 | \end{figure} 253 | 254 | \item Light Sources: 255 | \begin{itemize} 256 | \item Directional Lights: no location, constant 257 | 258 | \item Punctual Lights: have a location 259 | \begin{itemize} 260 | \item Point Light: $c_{light}$ varies with the distance. 261 | \item Spotlight: project light in a circular cone. 262 | \end{itemize} 263 | \end{itemize} 264 | 265 | \item Aliasing and Anti-aliasing: 266 | \begin{itemize} 267 | \item Evaluate the point inside the triangle: by cross product. 268 | \item Incremental Triangle Traversal (faster) 269 | \end{itemize} 270 | 271 | \item \textbf{Blurring before sampling} for antialiasing 272 | 273 | But why can this work? 274 | 275 | \begin{itemize} 276 | \item Undersampling creates frequency aliases. 277 | \item Filtering = get rid of certain frequency contents 278 | \item Sampling = repeating frequency contents 279 | \item Aliasing = mixed frequency contents 280 | \item Anti-aliasing = limiting, then repeating 281 | 282 | \end{itemize} 283 | 284 | \item Anti-aliasing by \textbf{supersampling} (MSAA) 285 | \begin{itemize} 286 | \item Sample multiple locations in one pixel, then average them. 287 | \item Cons: \textbf{cost too much! no free lunch} 288 | \end{itemize} 289 | 290 | \item Transparency: The meaning of alpha $\alpha$: 291 | \begin{figure} 292 | \centering 293 | \includegraphics[width=0.8\textwidth]{imgs/alpha.png} 294 | \end{figure} 295 | 296 | 297 | 298 | \end{itemize} 299 | 300 | \section{Illumination \& Shading} 301 | \begin{itemize} 302 | \item Blinn-Phong reflectance model: 303 | \begin{itemize} 304 | \item A local illumination model: just one bounce, light $\rightarrow$ surface $\rightarrow$ viewer. 305 | \item \textbf{Shading normal is on each vertex. }Geometric normal is on the surface. 306 | \item Consisit of three kinds of light: 307 | 308 | \begin{itemize} 309 | \item Specular highlight 310 | \item Diffuse reflection 311 | \item Ambient lighting 312 | \end{itemize} 313 | 314 | 315 | \item Diffuse reflection: 316 | \begin{itemize} 317 | \item Lambert's cosine law: light per unit area is proportional to $\cos \theta = \mathbf{I} \cdot \mathbf{n}$. 318 | \item Shading \textbf{independent} of view direction. 319 | \item Lambertian shading: $$L_d=k_d(I/r^2)\max(0,\mathbf{I} \cdot \mathbf{n})\,,$$where $k_d$ is the diffuse coefficient. 320 | \end{itemize} 321 | 322 | \item Specular shading: 323 | \begin{itemize} 324 | \item Intensity \textbf{depends} on view direction: brighter when near mirror reflection direction. 325 | \item Half angle vector or bisector: 326 | $$ 327 | \mathbf{h}=\frac{\mathbf{v}+\mathbf{l}}{\|\mathbf{v}+\mathbf{l}\|} 328 | $$ 329 | \item Formula: 330 | $$ 331 | L_d=k_d(I/r^2)\max(0,\mathbf{n} \cdot \mathbf{h})^p\,. 332 | $$ 333 | $p$ larger, light more focuses. 334 | \end{itemize} 335 | 336 | \item Ambient shading: 337 | \begin{itemize} 338 | \item Shading that does \textbf{not depend} on anything. 339 | \item This is actually a fake light, just to make the effect better. 340 | \item Formula: 341 | $$ 342 | L_a = k_a I_a\,. 343 | $$ 344 | \end{itemize} 345 | 346 | \item Blinn-Phong reflection model: 347 | $$ 348 | L = L_a + L_d + L_s 349 | $$ 350 | \end{itemize} 351 | \newpage 352 | \item Shading frequencies: 353 | 354 | \begin{itemize} 355 | \item Flat shading: each triangle has just one normal vector. Not good for smooth surfaces. 356 | \item Gouraud shading (shade earch vertex): each vertex has one normal vector, then we interpolate colors from vertices across triangle. 357 | 358 | Vertex normal: average over surrounding face normals. 359 | \item Phong shading (shade each pixel): 360 | \begin{itemize} 361 | \item each pixel's normal vector is interpolated using vertex normal 362 | \item compute full shading model at each pixel 363 | \item The interpolation result should be \textbf{normalized} before used. 364 | \begin{figure}[H] 365 | \centering 366 | \includegraphics[width=0.7\textwidth]{imgs/phong_shade.png} 367 | \caption{Phong Shading} 368 | 369 | \end{figure} 370 | 371 | \end{itemize} 372 | 373 | \end{itemize} 374 | 375 | \item Recap of the graphics pipeline: 376 | \begin{itemize} 377 | \item Input: vertices in 3D space 378 | \item Vertex processing: MVP transforms, shading, texture mapping 379 | \item Triangle processing: 380 | \item Rasterization: Sampling triangle 381 | \item Fragment Processing: Z-buffer visibility tests, shading, texture mapping 382 | \item Framebuffer Operations: 383 | \end{itemize} 384 | \end{itemize} 385 | 386 | \section{Texture Mapping} 387 | 388 | \begin{itemize} 389 | 390 | \item The texture pipeline: 391 | \begin{itemize} 392 | \item Three spaces: screen space, world space, texture space 393 | \item Projector function: project the surface's location into the texture coordinate space, usually $(u,v)$ space in the $[0,1]$ range. 394 | \item Corresponder function: converting texture coordinates to texture-space locations. \textbf{Wrapping mode} is usde to deal with the condition $(u,v)$ out of range $[0,1]$. 395 | 396 | Some common corresponder function: wrap, mirror, clamp (values outside the range $[0,1]$ are clamped to this range), border (texture coordinates outside $[0,1]$ are rendered with a separately defined border color). 397 | \end{itemize} 398 | 399 | 400 | \item Interpolation across triangles: barycentric coordinates 401 | 402 | From geometric viewpoint, $\alpha=\frac{A_A}{A_A+A_B+A_C},\beta=\frac{A_B}{A_A+A_B+A_C},\gamma=\frac{A_C}{A_A+A_B+A_C}$, where $A_i$ is the corresponding area. 403 | 404 | \begin{figure}[H] 405 | \centering 406 | \includegraphics[width=0.7\textwidth]{imgs/barycentric_formula.jpeg} 407 | \end{figure} 408 | 409 | \begin{figure}[H] 410 | \centering 411 | \includegraphics[width=0.7\textwidth]{imgs/barycentric.jpeg} 412 | \caption{Barycentric coordinates} 413 | \end{figure} 414 | 415 | \item Image Texturing: Each surface point is assigned a texture coordinate $(u,v)$. 416 | 417 | \item Magnification \& Minification: 418 | \begin{itemize} 419 | \item Magnification: Size of texel $>>$ Size of pixel. Num of texel $<<$ Num of pixel. 420 | \begin{itemize} 421 | \item Nearest neighbour (jaggy) 422 | \item bilinear interpolation (blured) 423 | \item take a smaller texel (good) 424 | \end{itemize} 425 | 426 | \item Minification: Size of texel $<<$ Size of pixel. Num of texel $>>$ Num of pixel. 427 | 428 | How to solve ? NN/Linear is not good. Lower the resolution of the texture. 429 | 430 | \item Mipmap: Image Pyramid, to solve magnification and minification. 431 | 432 | Mipmap may lead to \textbf{overblur} since mipmap is \textbf{square}. 433 | \begin{figure}[H] 434 | \centering 435 | \includegraphics[width=0.7\textwidth]{imgs/mipmap.png} 436 | \end{figure} 437 | 438 | 439 | 440 | \item Anisotropic Filtering: Better than Mipmap. Sample more on the direction with higher frequency. 441 | \begin{figure}[H] 442 | \centering 443 | \includegraphics[width=0.7\textwidth]{imgs/ani_sample.png} 444 | \end{figure} 445 | \item Unconstrained Anisotropic Filtering: Can be \textbf{not square}, compared to Mipmap. 446 | 447 | \end{itemize} 448 | 449 | \item Bump Mapping: 450 | \begin{itemize} 451 | \item Three kinds of scales of features: Macro-features, Micro-features, Meso-features (mid-level). 452 | \item Bump mapping are used for Meso-features. \textbf{Adjust the shading parameters }at the pixel level. 453 | \item Key idea: \textbf{Modify the surface normal.} 454 | \item Details: a tangent frame, also called a tangent-space basis, is stored at each vertex. Store three vectors, vectex normal $n$, tanget $t$, bitangent $b$. 455 | 456 | \item One way is Blinn's methods: use a heightfield to modify the surface normal's direction 457 | \item Another way is Normal Mapping: directly store a normal map 458 | \end{itemize} 459 | 460 | \item Parallax Mapping: 461 | \begin{itemize} 462 | \item Why introduce Parallax Mapping? 463 | 464 | A problem with bump and normal mapping is that the bumps never shift location with the view angle, nor ever block each other. (no occlusion) 465 | 466 | \item The key idea of parallax mapping is to take an educated guess of what should be seen in a pixel by examining the height of what was found to be visible. 467 | 468 | \item For parallax mapping, \textbf{the bumps are stored in a heightfield texture}. 469 | \end{itemize} 470 | 471 | \item Other applications: environment map, environment lighting... 472 | \item Exercises answers: 473 | 474 | \begin{figure}[H] 475 | \centering 476 | \includegraphics[width=0.7\textwidth]{imgs/ex1.png} 477 | \end{figure} 478 | 479 | \begin{figure}[H] 480 | \centering 481 | \includegraphics[width=0.7\textwidth]{imgs/ex2.png} 482 | \end{figure} 483 | 484 | \begin{figure}[H] 485 | \centering 486 | \includegraphics[width=0.7\textwidth]{imgs/ex3.png} 487 | \end{figure} 488 | 489 | \end{itemize} 490 | 491 | \section{Geometry} 492 | 493 | \subsection{Introduction to geometry} 494 | \begin{itemize} 495 | \item Many ways to represent geometry: 496 | \begin{itemize} 497 | \item Implicit: sampling can be hard. Inside/outside tests can be easy. 498 | \item Explicit: sampling is easy. Inside/outside tests can be hard. 499 | \end{itemize} 500 | 501 | \item Implicit representations: 502 | \begin{itemize} 503 | \item Algebraic surface 504 | \item Constructive solid geometry: use $A$ and $B$, get $A\cup B$ and so on 505 | \item Distance function: TODO: understand this 506 | \item Level set methods: store a grid of values approximating function 507 | \item Fractals 508 | \end{itemize} 509 | 510 | \item Implicit representation pros and cons: 511 | \begin{itemize} 512 | \item Pros: 513 | 514 | compact description (e.g., a function) 515 | 516 | certain queries easy (inside object, distance to surface) 517 | 518 | good for ray-to-surface intersection (more later) 519 | 520 | for simple shapes, exact description / no sampling error 521 | 522 | easy to handle changes in topology (e.g., fluid) 523 | \item Cons: difficult to model complex shapes 524 | \end{itemize} 525 | 526 | \item Explicit representations: 527 | \begin{itemize} 528 | \item Point clouds 529 | 530 | \item Polygon mesh 531 | 532 | \item The wavefront object file format: a text file specifies vertices, normals, texture coordinates and their connectivities 533 | \end{itemize} 534 | 535 | \end{itemize} 536 | 537 | \subsection{Curves and Surfaces} 538 | \begin{itemize} 539 | \item Bezier curves 540 | \item de Casteljau algorithm: repeat the interpolation to find the point 541 | \item Algebraic formula: Bernstein form. At each $t$, the summation of Bernstein polynomials is $1$. 542 | \begin{figure}[H] 543 | \centering 544 | \includegraphics[width=0.7\textwidth]{imgs/bezier.jpeg} 545 | \end{figure} 546 | \item Properties: 547 | \begin{figure}[H] 548 | \centering 549 | \includegraphics[width=0.7\textwidth]{imgs/bezier1.jpg} 550 | \end{figure} 551 | 552 | \item Piecewise Bezier curves: High order bezier curves are hard to control. Instead, we chain many low-order Bezier curve. 553 | 554 | $C_0$ continuity: $a_n=b_0$ 555 | 556 | $C_1$ continuity: $a_n=b_0=\frac{1}{2}(a_{n-1}+b_1)$ 557 | 558 | \item Bezier surface: TODO: understand this 559 | 560 | \end{itemize} 561 | 562 | \section{Geometry: Mesh} 563 | 564 | 565 | \begin{itemize} 566 | \item Topology vs Geometry 567 | \begin{figure}[H] 568 | \centering 569 | \includegraphics[width=0.7\textwidth]{imgs/mesh_vs_topo.jpeg} 570 | \end{figure} 571 | 572 | \item Local Mesh Operations: flip, split, collapse 573 | \item Global Mesh Operations: upsampling, downsampling, sampling same number of triangles 574 | 575 | \item Loop Subdivision: 576 | \begin{itemize} 577 | \item split each triangle into four 578 | \item Update for new vertices: $3/8*(A+B)+1/8*(C+D)$ 579 | \begin{figure}[H] 580 | \centering 581 | \includegraphics[width=0.7\textwidth]{imgs/update_new.jpeg} 582 | \end{figure} 583 | \item Update for old vertices: 584 | \begin{figure}[H] 585 | \centering 586 | \includegraphics[width=0.7\textwidth]{imgs/update_old.jpeg} 587 | \end{figure} 588 | 589 | \end{itemize} 590 | 591 | \item Catmull-Clark Subdivision: 592 | \begin{itemize} 593 | \item Each subdivision step: 594 | 595 | Add vertex in each face 596 | 597 | Add midpoint on each edge 598 | 599 | Connect all new vertices 600 | 601 | \item Update rules: 602 | \begin{figure}[H] 603 | \centering 604 | \includegraphics[width=0.7\textwidth]{imgs/cc_subdivide.jpeg} 605 | \end{figure} 606 | \end{itemize} 607 | 608 | \item Mesh Simplification: reduce number of mesh elements while maintaining overall shape 609 | 610 | \item Collapsing an edge: 611 | \begin{itemize} 612 | \item Quadric error metrics: new vertex should minimize its sum of square distance to previously related triangle planes 613 | 614 | \item Idea: compute edge midpoint, measure quadric error 615 | 616 | \item Better idea: choose point that minimizes quadric error 617 | \item Iteratively collapse edges 618 | 619 | Which edges? Assign score with quadric error metric* 620 | \begin{itemize} 621 | \item 622 | 623 | approximate distance to surface as sum of distances to planes containing triangles 624 | \item 625 | iteratively collapse edge with smallest score 626 | \item 627 | greedy algorithm.. great results 628 | \end{itemize} 629 | \end{itemize} 630 | 631 | 632 | \end{itemize} 633 | 634 | 635 | \section{Ray Tracing} 636 | \textbf{Note that this part is not well written.} 637 | \begin{itemize} 638 | \item Ray Casting: 639 | 640 | 1. Generate an image by casting one ray per pixel 641 | 642 | 2. Check for shadows by sending a ray to the light 643 | 644 | \item Recursive (Whitted-Style) Ray Tracing: 645 | \begin{figure} 646 | \centering 647 | \includegraphics[width=0.7\textwidth]{imgs/ray_trace.jpeg} 648 | \end{figure} 649 | 650 | \item Ray-Surface Intersection 651 | \begin{itemize} 652 | \item Ray Equation: 653 | \item Ray intersection with sphere: 654 | \item Ray intersection with implicit surface: 655 | 656 | \item Ray intersection with triangle: 657 | 658 | \item Ray intersection with plane: 659 | 660 | \item Moller Trumbore algorithm: 661 | \end{itemize} 662 | 663 | \item Accelerating Ray-Surface Intersection: 664 | \begin{itemize} 665 | \item Bounding Volumes 666 | \item Uniform Spatial Partitions 667 | \item Spatial Partitions: 668 | \item Object Partitions: 669 | \end{itemize} 670 | 671 | 672 | 673 | \end{itemize} 674 | 675 | 676 | 677 | \end{document} 678 | -------------------------------------------------------------------------------- /CS337-计算机图形学/计算机图形学-复习.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS337-计算机图形学/计算机图形学-复习.pdf -------------------------------------------------------------------------------- /CS339-计算机网络/MapReduce.md: -------------------------------------------------------------------------------- 1 | # Paper Reading: MapReduce 2 | 3 | Paper title: : MapReduce: Simplifified Data Processing on Large Clusters 4 | 5 | ## 基本框架 6 | 7 | Section 1是引言。 8 | 9 | Section 2 介绍了基础的MapReduce模型。 10 | 11 | Section 3 描述了谷歌在他们的cluster中实现的MapReduce。 12 | 13 | Section 4 描述了一些MapReduce的改进。 14 | 15 | Section 5 做了一些性能测试实验。 16 | 17 | Section 6 探索了MapReduce在谷歌的使用,作为production indexing system的基础。 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /CS339-计算机网络/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: 授课教师:申丽萍,赵世振 3 | --- 4 | 5 | # CS339-计算机网络 (英文) 6 | 7 | 这门课的教材用的是《计算机网络:自顶向下》。全部学完内容还是很多的。 8 | 9 | 10 | 我平时没怎么认真学,但是考前花了三四天把所有slides和作业题都过了一遍,书也大致浏览了一遍,对于整个计算机网络(应用层、传输层、网络层、链接层)有了一个比较清晰的全局认知,细细想来,受益匪浅。 11 | 12 | 期间做了一些总结和笔记,记录在此。 13 | 14 | -------------------------------------------------------------------------------- /CS339-计算机网络/exam_example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/exam_example.pdf -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/1.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/10.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/11.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/12.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/13.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/14.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/15.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/16.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/17.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/18.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/19.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/2.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/20.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/21.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/22.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/23.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/3.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/4.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/5.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/6.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/7.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/8.png -------------------------------------------------------------------------------- /CS339-计算机网络/imgs/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/imgs/9.png -------------------------------------------------------------------------------- /CS339-计算机网络/mapreduce-slides.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/mapreduce-slides.pdf -------------------------------------------------------------------------------- /CS339-计算机网络/quiz总复习.md: -------------------------------------------------------------------------------- 1 | # 计算机网络 小测(quiz)复习 2 | 3 | 整理者:Yanjie Ze 4 | 5 | 开始日期:2022.1.12 6 | 7 | 考试日期:2022.1.14 8 | 9 | 10 | 11 | # Chapter 1 Introduction 12 | 13 | 1. Lower layers can change implementation without affecting upper layers as long as the interface between layers remains the same. (T) 14 | 15 | 2. **Computer Network is collection of autonomous computers interconnected by a single technology where single technology means protocol layering. (F)** 16 | 17 | 3. LAN and WAN only differs in the network scale. (F) 18 | 19 | 解释:LAN一般连接在同一个地方、同一个建筑里的设备,WAN可以跨地区。 20 | 21 | 4. The end-to-end delay of 10 pipelining packets equals sum of the end-to-end delay of each packet. (F) 22 | 23 | 5. TDM is suitable for Circuit switching, whereas ATDM is for packet switching (with packet scheduling in router input/output port queuing) (T) 24 | 25 | 6. Protocol layering gains a lot and loses nothing. (F) 26 | 27 | 7. Given a 3kHz telephone line with signal-to-noise ratio of 30 dB, the maximum capacity is approximately 30kbps. (T) 28 | 29 | 30 | 31 | 8. **Layers four and five of the Internet protocol stack are implemented in the end systems but not in the routers in the network core. (T)** 32 | 33 | 解释:第四层和第五层是transport layer和application layer,都只在end host里实现。 34 | 35 | 9. The capacity of a channel is only constrained by its physical bandwidth. (F) 36 | 37 | 10. A protocol is always implemented in software. (F) 38 | 39 | 40 | 41 | # Chapter 2 Application Layer 42 | 43 | 1. Consider an HTTP Web server using persistent connections. Suppose the server spawns a separate process for each client that connects to the server. Then each of these spawned processes will have different server port numbers. (F) 44 | 45 | 2. Applications using UDP service are always unreliable. (F) 46 | 47 | 不一定,如果上层是reliable的应该就可以吧 48 | 49 | 3. Since HTTP is stateless, it cannot offer personalized services for different users. (F) 50 | 51 | 不对,可以用cookie。 52 | 53 | 4. FTP is out of band, as it uses separate channels to send control and data messages. (T) 54 | 55 | 5. Email uses push protocols. (F) 56 | 57 | 不对,both push and pull。 58 | 59 | 6. Unlike UDP, TCP can provide a throughput guarantee. (F) 60 | 61 | 不能保证吧,因为reliable data transfer,flow control,congestion control。 62 | 63 | 7. DNS can offer load balancing service. (T) 64 | 65 | 因为DNS server收到很多请求的时候,会把请求转给其他server。 66 | 67 | 8. HTTP always runs on top of TCP. (F) 68 | 69 | 也可以用UDP? 70 | 71 | 9. In the client-server model, if a server fails, its clients should always be notified. (F) 72 | 73 | 也可以不notify咯 74 | 75 | 10. On the same server, two sockets can bind to the same port. (F) 76 | 77 | 不能,但是可以在accept的时候同时生成两个socket对应一个port 78 | 79 | 80 | 81 | 甚至还有问答题: 82 | 83 | 1. What is UDP hole punching? 84 | 85 | 用来穿过NAT的。 86 | 87 | 2. What happens when you ping some IP? 88 | 89 | 3. What is ARP storm? 90 | 91 | ARP,address resolution protocol,请求IP地址的对应mac地址,所以需要broadcast 92 | 93 | 4. **How to emulate a router in Mininet?** 94 | 95 | 5. **Can Mininet emulate a high-speed network?** 96 | 97 | 6. **How does Mininet emulate a host?** 98 | 99 | 7. **How does Mininet emulate link delay/bandwidth/packet loss?** 100 | 101 | 102 | 103 | # Chapter 3 Application Layer 104 | 105 | 1. Suppose that the last SampleRTT in a TCP connection is equal to 1 sec. Then timeout for the connection will necessarily be set to a value >= 1 sec. (T) 106 | 107 | 对的,因为time out的时间要至少大于等于RTT的时间,实际上time out value = RTT + 4D。 108 | 109 | 2. Except for packet loss, network congestion can also cause the timer time-out. (T) 110 | 111 | 3. The timer is used to detect packet loss. Duplicate acks can be caused by setting the timer too long. (T) 112 | 113 | 是的,receiver可能在time out之前发多个ack,但是sender还在等待。 114 | 115 | 4. Sequence number space is the bigger the better. (F) 116 | 117 | 不能,seq#更大会让header更大的。 118 | 119 | 5. Suppose that host A wants to send data over TCP to host B, and host B wants to send data to host A over TCP. Two separate TCP connections - one for each direction - are needed. (F) 120 | 121 | 不需要吧,好像是双向的 122 | 123 | 6. TCP will crowd out UDP when congestion occurs. (F) 124 | 125 | UDP是有包就发,所以会crowd out TCP 126 | 127 | 7. Fair sharing network bandwidth reduces average TCP flow completion time. (F) 128 | 129 | 增加? 130 | 131 | 8. Using sequence numbers can help handle duplicated acks in rdt2.1. (T) 132 | 133 | 对的,这就是rdt2.2啊 134 | 135 | 9. Rdt2.1 cannot be used in practical network systems, as it cannot handle packet loss. In this sense, Rdt3.0 is always better. (F) 136 | 137 | 不是always 138 | 139 | 10. Error correction code is always prefered to error detection code. (F) 140 | 141 | 不是always。 142 | 143 | Detection VS Correction: 144 | 145 | - detection+重传在error not expected的时候用,在有burst error的时候用,在重传的损耗不是很大的时候用 146 | - correction相反。 147 | 148 | 149 | 150 | # Chapter 4 Network Layer 151 | 152 | 1. **CIDR could be used for any contiguous IP network to aggregate route entries. (F)** 153 | 154 | 不对,需要前缀的后缀能合并 155 | 156 | 2. NAT uses port number to multiplex IP address, therefore violates the independence layering principle. (T) 157 | 158 | 对的 159 | 160 | 3. LSR advertise smaller LS messages, so it is better than DVR for large network. (F) 161 | 162 | DVR是局部的,对于大网络来说应该更好 163 | 164 | 4. For an IP address, routers in different level can have different masks for it. E.g., the IP prefix 59.78.0.0/16 is divided into 8 subnets, and then the subnet 59.78.32.0/19 is further divided into 4 subnets. The entries of hierarchical routing table for the IP address 59.78.46.80 are: 59.78.0.0/16, 59.78.32.0/19, 59.78.40.0/21. (T) 165 | 166 | 5. IPv6 is more efficient than IPv4 because IPv6 header is smaller than IPv4 header. (F) 167 | 168 | 错的,IPv4: **20+ Byte**header IPv6: **40 byte**header 169 | 170 | 6. Within block of IP addresses 202.120.50.0~202.120.63.255, 202.120.50.0~202.120.53.0 could be assigned to a company in need of 1020 IP addresses. (F) 171 | 172 | 7. Intra-AS and inter-AS routing algorithms have different routing policies. (T) 173 | 174 | 8. OSPF uses LSR and Hierarchical Routing to find the least-cost path, whereas BGP uses DVR, together with local policies, to find a good path instead of best path, with explicit AS path to avoid count-to-infinity problem. (T) 175 | 176 | 9. LSR collects global topology information whereas DVR only collects local information, so LSR has no convergence problem. (F) 177 | 178 | 不对,有震荡。 179 | 180 | 10. Internet uses packet switching for the routers to store and forward the packets. The router's buffer is usually designed big enough to store the incoming packets, but when network congestion happens, the buffer can be full and the packets can be dropped and lost. (T) 181 | 182 | 蛮对的 183 | 184 | 11. Internet uses Hierarchical Routing to save routing table size and reduce update traffic. (T) 185 | 186 | 蛮对的 187 | 188 | 12. Tracert uses ICMP to get "TTL expired" error-reporting message from each hop to extract their IP addresses and evaluate the RTT. (T) 189 | 190 | 蛮对的 191 | 192 | 13. IP service is simple and unreliable, complicated features are implemented in the end hosts. This conforms to the End-to-End Principle. (T) 193 | 194 | 蛮对的 195 | 196 | 14. CIDR is designed to deal with the shortage of IPv4 addresses, whereas VLSM is designed to solve the problem of routing table explosion. (F) 197 | 198 | 好像反了 199 | 200 | 15. Most routers in Internet support broadcast/multicast routing. (F) 201 | 202 | Router不应该支持broadcast,这应该是在子网里做的。 203 | 204 | 205 | 206 | # Chapter 5 Link Layer 207 | 208 | 1. If we can guarantee reliable data transfer at the link layer, then the end-to-end reliability can be also guaranteed. (F) 209 | 210 | 上面的层也有可能不可靠 211 | 212 | 2. Suppose the following bit string is received by the data link layer from the network layer: 01110111101111101111110. Then the resulting string after bit stuffing is 0111011110111110011111010. (T) 213 | 214 | 遇到5个1就加0 215 | 216 | 3. Since CSMA performs carrier sensing before data transfer, the possibility of packet collision becomes smaller. That is why CSMA attains higher throughout than ALOHA. (T) 217 | 218 | 4. A full-duplex point-to-point ethernet link does not require CSMA/CD. (T) 219 | 220 | 没有碰撞了都 221 | 222 | 5. Given two hosts A and B. A's IP is 111.111.111.111/24, and B's IP is 222.222.222.222/24. Suppose that A's ARP table is empty at the beginning. If A wants to talk to B, A needs to generate an ARP request first to acquire B's MAC address. (F) 223 | 224 | 6. Compared with a hub, a switch can reduce a LAN's collision region. (T) 225 | 226 | 是的,link layer层面 227 | 228 | 7. If we divide a switch into two VLANs, then the two VLANs need to connect to a router in order to communicate. (T) 229 | 230 | 是的 231 | 232 | 8. L2 switches are plug and play, using self-learning to construct switch tables. In contrast, L3 switches require manual configuration. (T) 233 | 234 | 是的 235 | 236 | 9. We should avoid building network topologies with cycles, because of the ARP storm. (F) 237 | 238 | 不会的,可以RPF来阻止ARP Storm。 239 | 240 | 10. The MAC layer is always implemented in NIC, while the transport layer is always implemented in software. (F) 241 | 242 | always是不对的,但是有反例吗? 243 | 244 | # Chapter 6 WIFI 245 | 246 | 1. The mac and physical layer characteristics of a wireless network should not affect the design of transport layer and application layer protocols. (F) 247 | 248 | 2. Different modulation schemes give different throughput. For example, the throughput of QAM16 is 4 times the throughput of BPSK. Hence, we should always prefer QAM16 to BPSK in wireless communication. (F) 249 | 250 | 这两个啥玩意?好像没讲 251 | 252 | 3. The exposed terminal problem could reduce the wireless network throughput. (T) 253 | 254 | 4. The RTS-CTS scheme allows senders to reserve channels and avoid collisions of data frames. Hence, enabling RTS-CTS will improve network throughput. (F) 255 | 256 | 不一定improve,如果packet比较小的话overhead也比较大 257 | 258 | 5. When a mobile node moves to a foreign network, one addressing approach is to let the foreign network advertise to all other networks that the mobile node is resident in its network. Compared to this approach, the IP-in-IP tunneling approach is easier to support millions of mobile nodes. (T) 259 | 260 | 261 | -------------------------------------------------------------------------------- /CS339-计算机网络/作业整理/solution for chap1.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/作业整理/solution for chap1.docx -------------------------------------------------------------------------------- /CS339-计算机网络/作业整理/solutions for chap2.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/作业整理/solutions for chap2.docx -------------------------------------------------------------------------------- /CS339-计算机网络/作业整理/solutions for chap3-.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/作业整理/solutions for chap3-.doc -------------------------------------------------------------------------------- /CS339-计算机网络/作业整理/solutions for chap4.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/作业整理/solutions for chap4.doc -------------------------------------------------------------------------------- /CS339-计算机网络/作业整理/solutions for chap5+6.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS339-计算机网络/作业整理/solutions for chap5+6.doc -------------------------------------------------------------------------------- /CS339-计算机网络/作业整理/~$lutions for chap5+6.doc: -------------------------------------------------------------------------------- 1 | ze yanjie ze yanjieUsers/yanjieze/Documents/code/SJTU_Course_N -------------------------------------------------------------------------------- /CS339-计算机网络/知识点总复习.md: -------------------------------------------------------------------------------- 1 | # CS339 Computer Network: A Review 2 | 3 | 授课老师:申丽萍,赵世振(英文班) 4 | 5 | 整理者:[Yanjie Ze](http://yanjieze.com) 6 | 7 | 开始日期:Jan 4, 2021 8 | 9 | 考试日期:Jan 14, 2021 10 | 11 | 12 | 13 | # Chapter 1 Introduction 14 | 15 | | 五层结构 | 属于 | 16 | | ----------------- | ---------- | 17 | | application layer | user level | 18 | | transport layer | OS | 19 | | network layer | OS | 20 | | data link layer | OS/NIC | 21 | | physical layer | NIC | 22 | 23 | 24 | 25 | - **Local Area Networks** 26 | - Apart from scale, LANs distinguish themselves from other networks by (generally) using **broadcast** technology, 27 | 28 | - **Metropolitan Area Networks** 29 | - **Wide Area Networks** 30 | - **Internetworks** 31 | - 把LAN用WAN连起来,再把WAN互相连起来 32 | 33 | 34 | 35 | - Bandwidth (Hz):the range of frequencies transmitted without being strongly attenuated. 36 | - The **baud rate** is the number of samples or symbols per second sent over the channel. 37 | - The **bit rate** is the amount of information per second sent over the channel. 38 | - **Throughput / the real data rate**: rate (bits/sec) at which bits transferred between sender/receiver 39 | 40 | 41 | 42 | - **Nyquist's theorem** 43 | $$ 44 | maximum\ data\ rate=2H\log_2V 45 | $$ 46 | 47 | 48 | - **Shannon's theorem** 49 | $$ 50 | maximum\ data\ rate=H\log_2(1+S/N) 51 | $$ 52 | 53 | $$ 54 | S/N (dB)=10\log_{10}S/N 55 | $$ 56 | 57 | 58 | 59 | Multiplexing: 60 | 61 | - FDM 62 | - TDM 63 | - CDMA 64 | 65 | 66 | 67 | Switching: 68 | 69 | - **Circuit switching** (connection oriented) 70 | - **Message switching** 71 | - **Packet switching** (packet switching) 72 | - **Virtual Circuit switching** 73 | - Datagram 74 | 75 | # Chapter 2 Application Layer 76 | 77 | ## 2.1 Principles of network applications 78 | 79 | - Application architecture 80 | - Client-server 81 | - P2P 82 | - hybrid of client-server and P2P 83 | - Skype: centralized server to find address of remote party, then client-client connection 84 | - Sockets:进程与计算机网络之间的接口 85 | - transport service一些指标 86 | - data loss 87 | - delay 88 | - throughput 89 | - security 90 | - Internet transport services 91 | - TCP 92 | - connection-oriented: 需要先建立连接 93 | - reliable transport 94 | - flow control: 发送的消息不会overwhelm接收方(对于接收方) 95 | - congestion control: 控制网络不会拥堵(对于网络) 96 | 97 | - UDP 98 | - use packet-switch 99 | - unreliable data transfer 100 | - Process identifier = IP address + port number 101 | 102 | ## 2.2 DNS 103 | 104 | - DNS (Domain Name System): map `www.sjtu.edu.cn` --> `202.120.2.119` 105 | - distributed, hierarchical database 106 | - **root name servers** 107 | - TLD (top-level domains) 108 | - Local name server: Client needs to be configured with local name server manually or via DHCP. 109 | - 找到DNS name的方法:**iterated query** 110 | - 先local DNS server,然后让local DNS server去找:root DNS server,TLD DNS server,authoritative DNS server 111 | - 找到DNS name的方法:**recursice query** 112 | - 先找local DNS server,然后local DNS sever找root DNS server,然后root DNS server找TLD DNS server,然后TLD DNS server找authoritative DNS server。 113 | 114 | 115 | 116 | ## 2.3 Web and HTTP 117 | 118 | - WWW: client/server model with **http** 119 | - 首先用DNS把url转换成IP address 120 | - 建立tcp connection 121 | - 发送http request 122 | - 等待http response 123 | - fetch embedded resources 124 | - 清除闲置的tcp connection 125 | - HTTP: Hyper Text Transfer Protocol 126 | - 使用TCP,先建立TCP连接,然后用http发送请求 127 | - http是stateless的:不维持状态 128 | - cookies:server在client那里drop一个cookie,保存着server state。然后每次client发消息,就把之前的cookie一起发给server。相当于给client配了一个id,然后server可以在数据库里记录client的情况 129 | - HTTP Performance: Page Load Time (PLT) 130 | - Round Trip Time (RTT): time for a small packet to travel from client to server and back. 一个来回叫一个RTT 131 | - Page Load Time (PLT): 132 | - one RTT to initiate TCP connection 133 | - one RTT for HTTP request and first few bytes of HTTP 134 | - file transmission time 135 | - **total = 2RTT + transmit time** 136 | - Nonpersistent HTTP: 137 | - one object sent over one TCP connection,每次发都要新建一个新的tcp connection 138 | - PLT = N*RTT + transmit time 139 | - Ways to decrease PLT 140 | - 同时并行发多个http请求 141 | - 尽量用persistent http 142 | - move content closer to client 143 | - SPDY,一种更快的web protocol 144 | - web cache (proxy server) 145 | - 目标:不用server,加个cache就行 146 | - browser直接发request到cache,如果有救拿,没有的话cache再向server请求 147 | - cache acts as both client and server 148 | - conditional GET:cache在发GET给server的时候,加个modify的date,如果date不一样,那server就返回新的data。否则就不用返回新data,回一个304 not modified。 149 | - content delivery networks:client接收完内容后,再把内容发给其他server和cache。这样下次别人要用可以直接拿cache和server里的。 150 | 151 | 152 | 153 | ## 2.4 FTP 154 | 155 | - Client-server model 156 | - 有两种connection,分开的: 157 | - TCP control connection,是persistent的 158 | - TCP data connection,每个文件都要新开一个connection,是non-persistent 159 | - FTP server maintains "state": current directory, earlier authentication 160 | 161 | 162 | 163 | ## 2.5 Electronic Mail 164 | 165 | email是怎么做到receiver不在的时候我们的mail也能发到呢? 166 | 167 | - 四个部分 168 | - user agents 169 | - mail servers 170 | - transfer protocol (SMTP) ,服务器之间发送email 171 | - access protocol (POP3, IMAP),从服务器拿取email 172 | 173 | 174 | 175 | ## 2.6 P2P applications 176 | 177 | - P2P挑战: 178 | 179 | - No servers on which to rely: Communication must be peer-to-peer and self-organizing, not client-server. 必须自己调度! 180 | 181 | - Limited capabilities: How can one peer deliver content to all other peers? 一个人要发很多人怎么办? 182 | 183 | - Decentralized indexing: How will peers find content,find each other? 怎么找到其他人? 184 | 185 | - Participation incentives: Why will peers help each other? 为什么要互相帮助? 186 | - Distributed Hash Table (DHT) 187 | - Circular DHT: 每个peer只知道后继节点的ID. $ID(peer)=hash(IP, port)$ 188 | - key look up: 平均$O(N)$的复杂度 189 | - key look up with shortcuts: 每个peer也维持一些shortcut,可以降到$O(logN)$ 190 | - **DHT Finger Table:** chap2-2, P25 191 | - peer leave and join: 每个peer记住它后面两个节点,定时ping一下看看在不在,第一个节点走了的话,就让第二个节点把它的后面节点发过来。 192 | 193 | - BitTorrent Protocol 194 | - 选一个要接收的文件,和**tracker**请求peer list,然后和peer们进行传输 195 | - **tit-for-tat:** 一报还一报。过程: 196 | 1. alice给bob乐观地来点加速,alice成为bob的top 4 197 | 2. bob回报alice,bob也成为alice的top 4 198 | - Trackerless BitTorrent: 用DHT来标记文件和peer 199 | 200 | 201 | - P2P Case study: Skype 202 | - hierarchical overlay with **SuperNodes** 203 | - 问题:alice和bob都在NAT之后 204 | - 解决方法: 205 | - Alice and Bob connectwith their SNs. 206 | - Relay is chosen. Each peer initiates session with relay. 207 | - Peers can now communicate through NATs via relay. 208 | 209 | 210 | 211 | ## 2.7 Socket programming with TCP/UDP 212 | 213 | - 基础: 214 | 215 | - 首先,server和client得有一个socket 216 | - socket是用port number和IP进行区分 217 | 218 | - 什么是socket:a door between application process and end-endtransport protocol (UDP or TCP) 应用层和传输层的桥梁 219 | 220 | - 需要connection的socket(TCP): 221 | 222 | 223 | 224 | - 不需要connection的socket(UDP): 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | # Chapter 3 Transport Layer 233 | 234 | transport layer在每个end-host上还是有的,但是在router上没有。 235 | 236 | 237 | 238 | ## 3.1 Transport-layer services 239 | 240 | - TCP和UDP的比较,如下图所示。主要考虑几个点,有无connection,是否reliable,是否限制msg长度,是否有flow/congestion control 241 | 242 | 243 | 244 | - Transport **Segment**: 这玩意叫segment(在运输层),到网络层就叫packet,到链接层就叫frame 245 | 246 | 247 | 248 | 249 | 250 | ## 3.2 Multiplexing and demultiplexing 251 | 252 | - Ports: server的port选的比较well known,client的port选的比较ephemeral(随意?) 253 | 254 | - Upward multiplexing和downward multiplexing,看个图就明白了 255 | 256 | 257 | 258 | - Multiplexing/demultiplexing: 先把所有socket的数据都合起来发出去,再在接收方那里解开,分到不同的socket。 259 | 260 | - 带connection的demux,TCP socket:带一个四元组,src IP and port, dst IP and port 261 | - 不带connection的demux,UDP socket: 带一个二元组,dst IP, dst port 262 | 263 | 264 | 265 | ## 3.3 Connectionless transport: UDP 266 | 267 | UDP, User Datagram Protocol 268 | 269 | - 此处可以回顾一下UDP socket (2.7) 270 | 271 | - UDP是”best effort“,可能lost,error,out of order。可以在**application layer**加reliability。 272 | 273 | - UDP segment的形式:除了data还加了4个部分。 274 | 275 | 276 | 277 | - **Why “UDP has better control over what data is sent and when” ?** 因为不用建立connection吧。 278 | 279 | - UDP checksum: 先把所有数据相加,如果溢出了把1加到最低位。然后checksum就是取反。 280 | 281 | - Why UDP? 282 | 283 | - no connection establishment (which can add delay) 284 | - no retransmission (which can add delay) 285 | - simple: no connection state at sender, receiver 286 | - small segment header: 8 bytes 287 | - no flow control and congestion control: UDP can blast away as fast as desired 288 | 289 | 290 | 291 | ## 3.4 Principles of reliable data transfer 292 | 293 | 这一节只介绍单向数据传输(unidirectional)。 294 | 295 | ### 3.4.1 rdt1.0 296 | 297 | 如图。假设了底层信道是可靠的,所以no error control。假设了接受者可以完全接收,因此no flow control。 298 | 299 | 300 | 301 | 302 | 303 | ### 3.4.2 rdt2.0 304 | 305 | 假设底层信道有可能把packet中的bit弄反了(但是没有lost) 306 | 307 | - sender的FSM加了一个状态 308 | - 发送的时候加了checksum来detect error 309 | - receiver通过checksum来发送ACK或NAK。 310 | 311 | 312 | 313 | 314 | 315 | **致命缺陷:** 316 | 317 | - ACK/NAK坏了怎么办?可能会导致retransmission(重传),进而导致duplicate 318 | 319 | 320 | 321 | **处理duplicate:** 322 | 323 | - 如果ACK/NAK坏了,sender重传 324 | - sender给每个pkt加上sequence number 325 | - 接收方丢掉duplicate的包 326 | 327 | 由此,引出rdt2.1。 328 | 329 | 330 | 331 | ### 3.4.3 rdt2.1: sender, handles garbled ACK/NAKs 332 | 333 | Sender / Receiver 334 | 335 | 加了0和1作为seq number 336 | 337 |
338 | 339 |
340 | 341 | 342 | 343 | ### 3.4.4 rdt2.2: a NAK-free protocol 344 | 345 | 把NAK换成上次正确接收的ACK,即duplicate ACK。 346 | 347 | 348 | 349 | ### 3.4.5 rdt3.0: channels with errors and loss 350 | 351 | 新的假设:可能会丢包(data or ACK)(之前是只假设了会error) 352 | 353 | 方法:sender为ACK**等一段时间**,如果没等到就retransmit。用#seq防止duplicate。 354 | 355 | 356 | 357 | 可以具体看chap3-2 P21的几种丢包情况。 358 | 359 | 1. 正常情况 360 | 2. 丢了packet 361 | 3. 丢了ACK 362 | 4. timeout时间设置的短了,提前重发 363 | 364 | 365 | 366 | ### 3.4.6 **RDT概括** 367 | 368 | - rdt1.0没考虑会出错 369 | - rdt2.0考虑了传的包可能出错,但没考虑ACK也出错。 370 | 371 | - rdt2.1给ACK也加了状态,防止ACK出错 372 | - rdt2.2把NAK去掉了,直接用duplicate ACK判断 373 | - rdt3.0增加time out,考虑丢包情况 374 | 375 | 376 | 377 | 378 | 379 | ### 3.4.7 Pipelining Protocols 380 | 381 | 之前的几个协议都是stop and wait类型,效率比较低。 382 | 383 | - Go-back-N:一次传N个,如果有一个error了,回退到这个包重传 384 | 385 | - $W_s=2^n-1, W_r=1$ 386 | - 接收方丢弃所有失序分组 387 | - 优点:接收方只需要缓存一个包就行,不需要缓存失序分组 388 | 389 | - Selective-repeat:只重传那些没有正确ACK的包 390 | 391 | - $W_s=W_r=2^k/2=2^{k-1}$ 392 | 393 | - 发送方和接收方都维持相同大小的window size。接收方把接收到的都buffer住。 394 | 395 | - **Selective-repeat的一个dilemma:** 见中文书P150或ppt chap3-2 30页。因此必须要求window size $\leq$ sequence number size / 2,更严格来说: 396 | $$ 397 | sending\ window + receiving\ window \leq MAX\ SEQ+1 398 | $$ 399 | 400 | 401 | 402 | 403 | ### 3.4.8 Error Control 404 | 405 | 三种error: 406 | 407 | - bit error: **error detection, acknowledgment and retransmission, error correction** 408 | - packet loss: **timer and retransmission** 409 | - duplicate packet/out-of-order: **sequence number** 410 | 411 | 412 | 413 | 两种error control的方法: 414 | 415 | - Error Detection and Retransmission 416 | 417 | - Forward Error Correction 418 | 419 | - Error Detection Codes之**Parity Checking** 420 | 421 | - Error Detecting Codes之**Checksum** 422 | 423 | - Error Detecting Codes之**CRC code** 424 | 425 | - r阶的G(x),就append r个0到数据后面 426 | - 然后除以G(x),得到remainder 427 | - 然后把r个0替换成remainder,就可以传输了 428 | - 传输的时候receiver除一下G(x),如果有remainder说明有error了 429 | 430 | - Error-Detecting Codes之**hamming code** 431 | 432 | - 只能修正one bit error 433 | 434 | - 有点复杂,就是填入k个bit在第$2^k$的位置,然后每个bit是一个parity check,具体和谁parity呢?看下图吧。 435 | 436 | 437 | 438 | - 那么,可以竖过来传,每个msg都传一个bit,依次传。这是因为**hamming code只能修正一个error,如果有burst error就不行了,竖过来传可以把error分散开**。 439 | 440 | 441 | 442 | error control的实际应用: 443 | - Error Detection and Retransmission 444 | - CRC在link layer广泛使用 445 | - checksum在IP layer用的多,但是这个比较弱 446 | - parity很少用 447 | - Forward Error Correction 448 | - hamming code在error rate低的时候用 449 | - Convolutional codes and LDPC在wireless data link layer广泛使用 450 | 451 | 452 | 453 | Detection VS Correction: 454 | 455 | - detection+重传在error not expected的时候用,在有burst error的时候用,在重传的损耗不是很大的时候用 456 | - correction相反。 457 | 458 | 459 | 460 | ### 3.4.9 Flow Control 461 | 462 | 主要两种方法,一种叫停等,就是一次发一个。一种叫滑窗,就是加了pipeline。用fraction of time sender busy sending来衡量utility。 463 | 464 | - Stop and Wait: 465 | $$ 466 | U_{sender}=\frac{L/R}{RTT+L/R} 467 | $$ 468 | 469 | - Sliding Window: 470 | $$ 471 | U_{sender}=\frac{num_{pipeline}\times L/R}{RTT+L/R} 472 | $$ 473 | 474 | 475 | 476 | 477 | ## 3.5 Connection-oriented transport: TCP 478 | 479 | - TCP segment structure 480 | 481 | 482 | 483 | - TCP seq number: 当前发的data的number 484 | 485 | - TCP ACK number:当前请求的data的number 486 | 487 | - TCP checksum: checks the header, the data, and a pseudo header. 488 | 489 | 490 | 491 | - TCP client/server life cycle 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | - TCP reliable data transfer 500 | 501 | - fast retrainsmit: If sender receives 3 duplicate ACKs, it will resend segment before timer expires 502 | 503 | - TCP timer management:我们怎么确定TCP time out的时间? 504 | 505 | - 解决方法:用dynamic algorithm。这里加上4D使得time out的时间略大于RTT。 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | - flow control 514 | - sender won’t overflow receiver’s buffer by transmitting too much, too fast 515 | - Window Size Announcement 516 | 517 | 518 | 519 | ## 3.6 Principles of congestion control 520 | 521 | congestion control: open loop, closed loop 522 | 523 | - Congestion Avoidance:提前预测,及时避免,主要两种方法 524 | 525 | - host centric:TCP congestion control 526 | - Router-centric: warning bit, choke packet, load shedding 527 | 528 | - **AIMD**: Additive Increase, Multiplicative Decrease 529 | - MD: decrease window by factor of 2 when loss,减少的时候一下子除以2 530 | - AI: additive increase until packet loss,增加的时候一个个加 531 | 532 | - Explicit Congestion Notification:直接通知堵塞的packet的sender 533 | 534 | 535 | 536 | ## 3.7 TCP congestion control 537 | 538 | 丢包判断: 539 | 540 | 1. time out 541 | 2. 连续3个duplicate的ACK 542 | 543 | 544 | 545 | - TCP Tahoe/Reno implements **AIMD** to limit the sending rate. 546 | 547 | - Sender uses **packet loss** as the network congestion signal. 548 | 549 | - TCP use a Congestion Window (CongWin) next to the window granted by the receiver. 550 | - The actual window size is the minimum of the two. 551 | - Self-clocking: The CongWin size should be adjusted frequently, to match the networking carrying capacity 552 | 553 | 554 | 555 | TCP congestion algorithm: 下图中我们可以看到TCP Reno和TCP Tahoe的区别。 556 | 557 | 558 | 559 | 560 | 561 | TCP throughput: 562 | 563 | - Roughly: 564 | $$ 565 | throughput=\frac{CongWin}{RTT} Bytes/sec 566 | $$ 567 | 568 | - AIMD ignoring slow start: 569 | $$ 570 | Average Throughput=0.75\frac{CongWin}{RTT} Bytes/sec 571 | $$ 572 | 573 | - Throughput in terms of loss rate: 574 | $$ 575 | Average Throughput=\frac{1.22MSS}{RTT\sqrt{L}} Bytes/sec 576 | $$ 577 | 578 | TCP fairness: 579 | 580 | - if K TCP sessions share same bottleneck link of capacity R, each would have average rate of R/K 581 | 582 | 583 | 584 | # Chapter 4 Network Layer 585 | 586 | ## 4.1 Introduction 587 | 588 | - IP是hourglass,连接transport layer和link layer 589 | - 在每个router上都有network layer,主要做以下几个功能 590 | - routing: determine route from source to dest; determine the output link 寻路 591 | - forwarding/switching: move packets from router’s input to appropriate router output 发送 592 | - congestion control: drop packets, update routing table 拥塞控制 593 | - **其中,routing是确定dst address,forward是发出去** 594 | - IP service model 595 | - **datagram:** Individually routed packets. Hop-by-hop routing. 596 | - **Unreliable:** Packets might be dropped. 597 | - Best effort 598 | - connectionless 599 | 600 | 601 | 602 | ## 4.2 Virtual circuit and datagram networks 603 | 604 | 有两种subnet。 605 | 606 | datagram subnet: 607 | 608 | - 不需要提前设置路线 609 | - 需要完整的dst和src 610 | - 每个包都是独立地发出去的,可能经过的router不一样 611 | - 所以某个router坏了没有影响 612 | - 但是服务质量和congestion control比较难 613 | 614 | 另外一个叫virtual-circuit subnet,与之相反。 615 | 616 | 617 | 618 | router根据dst来forward。 619 | 620 | - forwarding table: 用**longest prefix matching** 621 | 622 | - VC forwarding table: 不是用dst来forward,而是用VC number来进行forward. 623 | 624 | 625 | 626 | 627 | 628 | ## 4.3 What’s inside a router 629 | 630 | - Four parts: input and output port, routing processor and switching fabric. 631 | 632 | - Two key router functions: 633 | 634 | - run **routing** protocol (RIP, OSPF, BGP) 635 | 636 | - **forwarding** datagrams from incoming to outgoing link 637 | 638 | - Three types of switching fabrics 639 | 640 | - memory 641 | - bus 642 | - Crossbar 643 | 644 | - Input/output port: 需要queuing。需要buffer the packet。buffer equal to: (with N flows) 645 | $$ 646 | \frac{RTT\cdot C}{\sqrt{N}} 647 | $$ 648 | 649 | 650 | 651 | 652 | ## 4.4 IP: Internet Protocol 653 | 654 | - IP datagram format 655 | 656 | - **IP Fragmentation & Reassembly** 657 | 658 | - Network links haveMaximum Transmission Unit (MTU) 659 | - 如果datagram太大了,先拆开发,再重组 660 | - “reassembled” at final destination 661 | - IP header bits used to identify related fragments 662 | 663 | - IPv4 addressing 664 | 665 | - 特殊的IP: 666 | 667 | - 全0:自己 668 | - 全1:在local network 广播 669 | - network+全1:在distant network广播 670 | 671 | - **Subnetting**: 672 | 673 | - classful IP不够用了,所以得subnet 674 | - VLSM,Variable Length Subnet Mask 675 | - IP address = subnet id + host id 676 | - subnet mask: to indicate the subnet portion which is arbitrary length. 比如**223.1.1.72/26** 677 | - 具体怎么分?两个原则:1. **The two ports connected by a link share a same subnet** 2. **For routers, two ports buildup a subnet** 678 | - **CIDR,Classless InterDomain Routing** 679 | - CIDR: Assign class C addresses *in contiguous blocks*of 256 addresses so that multiple entries in routing table can be **aggregated** into one (reduced) 680 | - 就是用3个bit来组子网,合起来的时候直接合就行 681 | - 如果有hole,可以加一个longer prefix把那个hole单独拎出来 682 | 683 | - **ISP怎么获得a block of addresses?** ICANN: Internet Corporation for Assigned Names and Numbers with 5 Regional Internet Registry (RIR) 684 | 685 | - **host怎么获得IP address?** **DHCP**: **Dynamic Host Configuration Protocol**: dynamically get address from as server 686 | 687 | 688 | 689 | - **NAT: Network Address Translation** 690 | 691 | - 用NAT translation table,把WAN的IP+port转换成LAN的IP+port 692 | - NAT is controversial! 693 | - violates independence layering principle. 694 | - violates end-to-end argument 695 | - address shortage should instead be solved by IPv6 696 | - NAT traversal problem,三个解决方法: 697 | - statically configure NATto forward incoming connection requests at given port to server 698 | - automate static NAT port map configuration 699 | - **relaying**,就像skype一样,加一个中间商,分别让别人连上它。 700 | 701 | - **ICMP: Internet Control Message Protocol**, used by hosts & routers to communicate network-level information 702 | 703 | - fragmentation needed 704 | - TTL expired 705 | 706 | - IPv6: 707 | 708 | - Initial motivation: 32-bit address space soon to be completely allocated. 32bit不够用!改成128bit,即16byte了 709 | - Additional motivation: header format helps speed processing/forwarding 格式要改! 710 | - *Tunneling:* IPv6 carried as payload in IPv4 datagram among IPv4 routers,用IPv4把IPv6包起来。 711 | 712 | 713 | 714 | ## 4.5 Routing algorithms 715 | 716 | Routing algorithm: finds the least-cost/shortest path 717 | 718 | 几个分类:local/global/static/dynamic 719 | 720 | - **Link State Routing (LSR)**, 先获得整个网络的路径信息,然后再算出最短路径 721 | 722 | - **Dijkstra** 723 | - 问题:可能会有oscillations 724 | 725 | - **Distance Vector Routing** 726 | 727 | - **Bellman-Ford**,从邻居那里拿来table,用公式 728 | $$ 729 | d_{x}(y)=\min_V \{c(x,v)+d_v(y)\} 730 | $$ 731 | 732 | 733 | - 问题:**count to infinity**. 比如,如果原来在的A突然不在了,他的邻居们就有可能开始无限叠加... 734 | 735 | 736 | 737 | **DVR和LSR的区别总结:** 738 | 739 | 740 | 741 | 742 | 743 | **Hierarchical Routing**: 744 | 745 | - “autonomous systems” (AS): aggregate routers into regions,correspond to an administrative domain. Assigned an unique 16/32 bit number. 746 | - intra-AS/interior gateway routing should find the least cost path as best as possible 747 | - inter-AS/exterior gateway routinghas to deal with a lot of politics. Routers do not automatically use the routes they find, but have to check manually whether it is allowed. 748 | 749 | 750 | 751 | **Inter-AS和Intra-AS的不同:** 752 | 753 | - Policy: 754 | - Inter-AS: admin wants control over how its traffic routed, and who routes through its net. (untrusted) 755 | - Intra-AS: single admin, so no policy decisions needed (trusted) 756 | - Scale: hierarchical routing saves table size, reduced update traffic 757 | - Performance: 758 | - Intra-AS: can focus on performance 759 | - Inter-AS: policy may dominate over performance 760 | 761 | 762 | 763 | ## 4.6 Routing in the Internet 764 | 765 | - Intra-AS protocol: 766 | - RIP, Routing Information Protocol (RFC 2453) 767 | - **DVR** 768 | - distance metric: # of hops, Limits networks to 15 hops **(16 =∞to avoid count-to-infinity)** 769 | 770 | - OSPF, Open Shortest Path First (RFC 2328) 771 | - **LSR** 772 | - hierarchical OSPF in large domains. 773 | 774 | - IGRP: Interior Gateway Routing Protocol 775 | 776 | - Inter-AS protocol: 777 | - BGP: Border Gateway Protocol (RFC 4271) 778 | - DVR with explicit AS path (==loop free) 779 | 780 | 781 | 782 | 783 | ## 4.7 Broadcast and multicast routing 784 | 785 | broadcasting: 786 | 787 | - flooding:接收后转发给邻居。问题是: cycle和storm 788 | - controlled flooding: 789 | - node keeps track of pckt IDs already brdcsted 790 | - **reverse path forwarding (RPF):** only forward pckt if it arrived on shortest path between node and source,利用最小生成树来发包 791 | - spanning tree 792 | 793 | 794 | 795 | 796 | 797 | # Chapter 5 Link Layer 798 | 799 | ## 5.1 Introduction and services 800 | 801 | 两种link: 802 | 803 | - Point-to-point 804 | - broadcast 805 | 806 | 807 | 808 | - framing 809 | - reliable date transfer between adjacent nodes (回顾tcp是end-to-end的) 810 | - link access for shared medium 811 | 812 | 813 | 814 | Framing Techniques: 815 | 816 | - Character count,在每个fram开头加个count 817 | - Flag bytes with byte stuffing,类似于c语言中的转义符 818 | - Starting and ending flags with bit stuffing 819 | 820 | 821 | 822 | framing: 823 | 824 | - byte stuffing,加esc pattern 825 | - bit stuffing,每连续5个1就加一个0。结尾是6个1 826 | 827 | 828 | 829 | Full-duplex, half-duplex: 830 | 831 | 是否能在同一时刻双向传输。 832 | 833 | 834 | 835 | ## 5.2 Error detection (review) 836 | 837 | Error correction: 838 | 839 | - checksum只能纠正一个bit 840 | - CRC可以纠正少于r+1个bit 841 | 842 | 843 | 844 | 845 | 846 | ## 5.7 HDLC and PPP 847 | 848 | 两个point2point的data link protocol 849 | 850 | - HDLC – High-Level Data Link Control 851 | - A pretty old, but widely used protocol for point-to-point connections. **bit-oriented.** 852 | - 支持flow control 853 | - 支持error control 854 | 855 | - PPP – The Point-to-Point Protocol 856 | - Internet standard (RFC1661 1662 1663), is used in the Internet for a variety of purposes, including router-to-router traffic and home user-to-ISP traffic. **byte-oriented** 857 | - HDLC改版,没有flow control和error control 858 | 859 | 860 | 861 | ## 5.3 Multiple/Medium access Control 862 | 863 | **Multiple/Medium access Control用来处理在broadcast link上的collision problem。** 864 | 865 | 毕竟在link上,很大可能有多个包同时占用。 866 | 867 | 三种方法: 868 | 869 | - Channel Partitioning (static) 870 | 871 | - TDM, FDM, CDM 872 | 873 | - **Random Access (dynamic)** 874 | 875 | - pure ALOHA,数据准备好就传输, P(success by given node)=0.18 876 | 877 | - slotted ALOHA,分成time slot来传输,P(success by given node)=0.36 878 | 879 | - CSMA, Carrier Sense Multiple Access 880 | 881 | - **Problem with Aloha**: a node’s transmission decision is independent of other nodes’ activities,没有考虑其他node 882 | - CSMA: listen before transmit 883 | - 如果channel空闲,就传 884 | - 否则就等 885 | - p-persistent, 1-persisnet, nonpersisent的区别:以多少概率执行 886 | 887 | - CSMA/CD,with **collision detection** 888 | 889 | - 先sense channel再发 890 | - 如果发了之后collision了,发送一个jam signal,然后用binary exponential backoff来retransmit. 891 | - after mth collision, NIC chooses K at random from {0,1,2,…,2^m-1}. **NIC waits K· 2τor K · 512 bit times, then retransmit.** 892 | - After ten collisions, choose K from {0,1,2,3,4,…,1023} 893 | - 就是exponentially地增长等的时间。 894 | 895 | - **Minimum Frame Length** is set so that the farthest collision gets back before transmission finished 896 | $$ 897 | \frac{F_{min}}{B}\geq 2\tau=2\frac{l}{v} 898 | $$ 899 | 900 | - “Taking turns” (dynamic) 901 | 902 | - channel partition在high load时好,random access在low load时好,taking turns结合两者优点 903 | - collision free protocol: 904 | - **the basic bit-map protocol** Principle: Each contention period consists of exactly N slots, station j may announce that it has a frame to send by inserting a 1 bit into slot j. After all N slots have passed by, each station has complete knowledge of which stations wish to transmit. At that point, they begin transmitting in numerical order. 905 | - **The binary countdown protocol**: In the contention period each station broadcasts its number (bit by bit), and stops as soon as it detects a higher-numbered contender. 每个人从自己的最高bit开始传。 906 | - polling,轮询,master node让slave node轮流传 907 | - token passing,传递一个token,谁有token谁传 908 | 909 | 910 | 911 | ## 5.4 Link-layer Addressing 912 | 913 | Each adapter in LAN has 48 bit, permanent, globally unique MAC address. 914 | 915 | mac地址,独一无二,天生就有 916 | 917 | 918 | 919 | mac address是可移动的,但IP不是,换了一个区域就变了。 920 | 921 | 922 | 923 | 为什么要用mac地址? 924 | 925 | - link layer不是只用ip protocol 926 | - 设备移动的话ip每次都得换 927 | - 如果只用ip,每次接收frame都得弄到network layer 928 | 929 | 930 | 931 | **ARP, (Address Resolution Protocol)** 932 | 933 | - 把IP地址转换到MAC地址 934 | 935 | 936 | 937 | ARP就是把IP转到MAC,然后才能把包发出去,但是什么时候需要ARP request呢? 938 | 939 | 940 | 941 | ## 5.5 Ethernet 942 | 943 | 广泛使用的LAN技术 944 | 945 | 946 | 947 | Ethernet使用CSMA/CD技术 948 | $$ 949 | efficiency=\frac{1}{1+5t_{prop}/t_{trans}} 950 | $$ 951 | $t_{prop}$是两个adapter之间的传播时间,$t_{trans}$是传输一个最大长度的以太网帧的时间。 952 | 953 | 954 | 955 | ## 5.6 switch and VLAN 956 | 957 | - selectively forward 958 | - Self-learning 959 | 960 | 961 | 962 | 交换机和路由器的区别: 963 | 964 | - 路由器使用网络层(IP转发)进行转发,交换机使用链路层(mac地址)进行转发。 965 | - 交换机是plug and play,即插即用的。而路由器需要人为配置IP地址。 966 | - 967 | 968 | **Use switch to reduce the collision region (CR)** 969 | 970 | 交换机可以用来消除碰撞。 971 | 972 | 973 | 974 | **Use router to reduce the broadcasting region and connect with Internet.** 975 | 976 | 977 | 978 | Virtual LANs: motivation 979 | 980 | 981 | 982 | ## 5.8 MPLS 983 | 984 | Multiprotocol label switching 985 | 986 | 987 | 988 | ## 5.9 A day in the life of a web request 989 | 990 | 991 | 992 | # Chapter 6 WIFI 993 | 994 | 两个挑战: 995 | 996 | - wireless link 997 | - mobility 998 | 999 | ## 6.1 Introduction 1000 | 1001 | - 无线主机 host 1002 | - base station 1003 | - wireless link 1004 | 1005 | ## 6.2 Wireless links, characteristics 1006 | 1007 | 和有线网络的区别: 1008 | 1009 | - 信号强度递减 1010 | - 来自其他源的干扰 1011 | - 多径传播 1012 | 1013 | 1014 | 1015 | SNR,信噪比,越大越好 1016 | 1017 | BER,bit error rate,越小越好 1018 | 1019 | 1020 | 1021 | 一些特征: 1022 | 1023 | - hidden terminal problem 1024 | - signal attenuation 1025 | 1026 | 1027 | 1028 | **CDMA:** 1029 | 1030 | - encoded signal = (original data) X (chipping sequence) 1031 | - decoding: inner-product of encoded signal and chipping sequence 1032 | 1033 | 1034 | 1035 | 1036 | 1037 | ## 6.3 IEEE 802.11 wireless LANs (“Wi-Fi”) 1038 | 1039 | 1040 | 1041 | CSMA/CA, CSMA with collision avoidance 1042 | 1043 | - avoid data frame collisions completely using small reservation packets! 1044 | - 先发电包看看堵不堵?发个RTS 1045 | - 然后BS,base station,发个CTS告诉他可以send 1046 | 1047 | 1048 | 1049 | RTS: request-to-send (RTS) 1050 | 1051 | CTS: clear-to-send 1052 | 1053 | 1054 | 1055 | ## 6.4 Cellular Internet Access 1056 | 1057 | • architecture 1058 | 1059 | • standards (e.g., 3G, LTE) Mobility 1060 | 1061 | ## 6.5 Principles: addressing and routing to mobile users 1062 | 1063 | - let routing handle it: routers advertise permanent address of mobile-nodes-in-residence via usual routing table exchange. 1064 | - 1065 | 1066 | ## 6.6 Mobile IP 1067 | 1068 | 1069 | 1070 | ## 6.7 Handling mobility in cellular networks 1071 | 1072 | 1073 | 1074 | ## 6.8 Mobility and higher-layer protocols 1075 | 1076 | -------------------------------------------------------------------------------- /CS359-计算机体系结构/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS359-计算机体系结构/.DS_Store -------------------------------------------------------------------------------- /CS359-计算机体系结构/review(上).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS359-计算机体系结构/review(上).pdf -------------------------------------------------------------------------------- /CS359-计算机体系结构/review(下).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS359-计算机体系结构/review(下).pdf -------------------------------------------------------------------------------- /CS386-数字图像处理/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS386-数字图像处理/.DS_Store -------------------------------------------------------------------------------- /CS386-数字图像处理/2021秋-数字图像处理复习.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS386-数字图像处理/2021秋-数字图像处理复习.pptx -------------------------------------------------------------------------------- /CS410-人工智能/ai_review_map_yanjieze.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Markmap 8 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /CS410-人工智能/imgs/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS410-人工智能/imgs/1.png -------------------------------------------------------------------------------- /CS410-人工智能/imgs/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS410-人工智能/imgs/2.png -------------------------------------------------------------------------------- /CS410-人工智能/imgs/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS410-人工智能/imgs/3.png -------------------------------------------------------------------------------- /CS410-人工智能/imgs/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS410-人工智能/imgs/4.png -------------------------------------------------------------------------------- /CS410-人工智能/imgs/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS410-人工智能/imgs/5.png -------------------------------------------------------------------------------- /CS410-人工智能/imgs/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS410-人工智能/imgs/6.png -------------------------------------------------------------------------------- /CS410-人工智能/my_hw3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS410-人工智能/my_hw3.pdf -------------------------------------------------------------------------------- /CS410-人工智能/my_hw4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS410-人工智能/my_hw4.pdf -------------------------------------------------------------------------------- /CS499-计算机科学中的数学基础/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS499-计算机科学中的数学基础/.DS_Store -------------------------------------------------------------------------------- /CS499-计算机科学中的数学基础/RandomGraph.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS499-计算机科学中的数学基础/RandomGraph.pdf -------------------------------------------------------------------------------- /CS499-计算机科学中的数学基础/hard_problem.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS499-计算机科学中的数学基础/hard_problem.pdf -------------------------------------------------------------------------------- /CS499-计算机科学中的数学基础/review(上).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS499-计算机科学中的数学基础/review(上).pdf -------------------------------------------------------------------------------- /CS499-计算机科学中的数学基础/review(下).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/CS499-计算机科学中的数学基础/review(下).pdf -------------------------------------------------------------------------------- /MA238-离散数学/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/MA238-离散数学/.DS_Store -------------------------------------------------------------------------------- /MA238-离散数学/notes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/MA238-离散数学/notes.pdf -------------------------------------------------------------------------------- /MA238-离散数学/作业13.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/MA238-离散数学/作业13.pdf -------------------------------------------------------------------------------- /MA238-离散数学/作业13参考解答.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/MA238-离散数学/作业13参考解答.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: 作者:迮炎杰,SJTU CS 19级 3 | --- 4 | 5 | # SJTU CS Course Notes 6 | 7 | Notes and Reviews written by [Yanjie Ze](https://github.com/YanjieZe) 8 | 9 | Some notes may not be viewed directly in the website. If necessary, download the [repo](https://github.com/YanjieZe/SJTU\_Course\_Notes) and view all. 10 | 11 | ## Course List 12 | 13 | ### 大三课程 14 | 15 | * CS337 计算机图形学 16 | * 由于是开卷考试,整理了90%以上的课内内容. 17 | * Well Organized. 18 | * CS410 人工智能 19 | * 包括所有考点以及大纲,整理详细。 20 | * 包含树状图进行整理。 21 | * CS339 计算机网络 22 | * 包括所有考点,整理详细。 23 | * CS240 计算机伦理学 24 | * 简要归纳授课内容。 25 | * 包括一个期末大作业(论文)。 26 | * CS236 云计算技术 27 | * Survey 28 | 29 | ### 大二课程 30 | 31 | * CS499 计算机科学中的数学基础 32 | * 整理了课程内容与证明 33 | * 整理了部分难题 34 | * TH029 毛泽东思想和中国特色社会主义理论体系概论 35 | * 整理了大纲、可能考的辨析题与问答题。 36 | * CS214 算法与复杂性(英文班) 37 | * 整理了常用算法 38 | * MA238 离散数学 39 | * 整理了关键内容,涵盖数理逻辑、集合论、图论、**群论**。 40 | -------------------------------------------------------------------------------- /SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Table of contents 2 | 3 | * [SJTU CS Course Notes](README.md) 4 | * [大三](da-san/README.md) 5 | * [CS410-人工智能](da-san/cs410-ren-gong-zhi-neng/README.md) 6 | * [知识点总复习](da-san/cs410-ren-gong-zhi-neng/ai-review.md) 7 | * [CS339-计算机网络](CS339-计算机网络/README.md) 8 | * [知识点总复习](CS339-计算机网络/知识点总复习.md) 9 | * [小测验总复习](CS339-计算机网络/quiz总复习.md) 10 | * [CS386-数字图像处理](da-san/cs386-shu-zi-tu-xiang-chu-li.md) 11 | * [CS337-计算机图形学](da-san/cs337-ji-suan-ji-tu-xing-xue.md) 12 | * [CS240-计算机伦理学](da-san/cs240-ji-suan-ji-lun-li-xue/README.md) 13 | * [知识点复习](da-san/cs240-ji-suan-ji-lun-li-xue/review.md) 14 | * [大二](da-er/README.md) 15 | * [CS214-算法与复杂性](da-er/cs214-suan-fa-yu-fu-za-xing.md) 16 | * [CS359-计算机体系结构](da-er/cs359-ji-suan-ji-ti-xi-jie-gou.md) 17 | * [CS499-计算机科学中的数学基础](da-er/cs499-ji-suan-ji-ke-xue-zhong-de-shu-xue-ji-chu.md) 18 | * [MA238-离散数学](da-er/ma238-li-san-shu-xue/README.md) 19 | * [知识点总复习](da-er/ma238-li-san-shu-xue/notes.md) 20 | * [TH029-毛概](da-er/th029-mao-gai/README.md) 21 | * [复习要点与辨析题与问答题](da-er/th029-mao-gai/fu-xi-yao-dian-yu-bian-xi-ti-yu-wen-da-ti.md) 22 | -------------------------------------------------------------------------------- /TH029-毛概/2021毛概.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/TH029-毛概/2021毛概.docx -------------------------------------------------------------------------------- /TH029-毛概/复习要点与辨析题与问答题.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/TH029-毛概/复习要点与辨析题与问答题.pdf -------------------------------------------------------------------------------- /da-er/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: CS萌新成长时 3 | --- 4 | 5 | # 大二 6 | 7 | -------------------------------------------------------------------------------- /da-er/cs214-suan-fa-yu-fu-za-xing.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: 授课教师:高晓沨 3 | --- 4 | 5 | # CS214-算法与复杂性 6 | 7 | 复习文件为pdf格式,链接点击[这里](../CS214-%E7%AE%97%E6%B3%95%E4%B8%8E%E5%A4%8D%E6%9D%82%E6%80%A7/algorithm.pdf)。 8 | -------------------------------------------------------------------------------- /da-er/cs359-ji-suan-ji-ti-xi-jie-gou.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: 授课教师:沈艳艳 3 | --- 4 | 5 | # CS359-计算机体系结构 6 | 7 | 上半部分复习pdf:[链接](../CS359-%E8%AE%A1%E7%AE%97%E6%9C%BA%E4%BD%93%E7%B3%BB%E7%BB%93%E6%9E%84/review%EF%BC%88%E4%B8%8A%EF%BC%89.pdf) 8 | 9 | 下半部分复习pdf:[链接](../CS359-%E8%AE%A1%E7%AE%97%E6%9C%BA%E4%BD%93%E7%B3%BB%E7%BB%93%E6%9E%84/review%EF%BC%88%E4%B8%8B%EF%BC%89.pdf) 10 | -------------------------------------------------------------------------------- /da-er/cs499-ji-suan-ji-ke-xue-zhong-de-shu-xue-ji-chu.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: 授课教师:龙环 3 | --- 4 | 5 | # CS499-计算机科学中的数学基础 6 | 7 | 上半部分:[链接](../CS499-%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%A7%91%E5%AD%A6%E4%B8%AD%E7%9A%84%E6%95%B0%E5%AD%A6%E5%9F%BA%E7%A1%80/review%EF%BC%88%E4%B8%8A%EF%BC%89.pdf) 8 | 9 | 下半部分:[链接](../CS499-%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%A7%91%E5%AD%A6%E4%B8%AD%E7%9A%84%E6%95%B0%E5%AD%A6%E5%9F%BA%E7%A1%80/review%EF%BC%88%E4%B8%8B%EF%BC%89.pdf) 10 | -------------------------------------------------------------------------------- /da-er/ma238-li-san-shu-xue/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: 授课教师:丁宁 3 | --- 4 | 5 | # MA238-离散数学 6 | 7 | 全部复习笔记:[链接](../../MA238-%E7%A6%BB%E6%95%A3%E6%95%B0%E5%AD%A6/notes.pdf) 8 | 9 | 也提供了Markdown格式,可在线浏览。 10 | -------------------------------------------------------------------------------- /da-er/ma238-li-san-shu-xue/notes.md: -------------------------------------------------------------------------------- 1 | # MA238 离散数学 2 | 3 | 迮炎杰,2021年6月 4 | 5 | MA238 离散数学 由两部分组成: 6 | 7 | - 数理逻辑与集合论 8 | - 图论与代数结构 9 | 10 | # Part1 数理逻辑与集合论 11 | 12 | # 2.5 对偶式 13 | 14 | 将合取和析取反一下,把T和F反一下。 15 | 16 | # 2.6 范式(命题逻辑部分) 17 | 18 | 主析取范式和主合取范式互相转换: 19 | 20 | - 这一部分只可意会,注意极小项和极大项的性质 21 | 22 | # 5.3 范式(谓词逻辑部分) 23 | 24 | 前束范式:量词都在前面 25 | 26 | Skolem标准形: 27 | 28 | - 一种是存在量词都在全称量词的右边(这种也叫存在前束范式) 29 | - 另一种是直接消去存在量词 30 | 31 | # 5.5 推理演算 32 | 33 | 1. 全称量词消去规则 34 | 2. 全称量词引入规则 35 | 3. 存在量词消去规则 36 | 4. 存在量词引入规则 37 | 38 | # 9.3 集合的运算 39 | 40 | 广义并:就是把一个集合的元素拿出来求并 41 | 42 | 广义交:类似广义并。 43 | 44 | 幂集: 45 | $$ 46 | P(A)=\{x|x\subseteq A\} 47 | $$ 48 | 49 | 50 | # 10.4 关系的性质 51 | 52 | 存在非空集合,既不是自反的,又不是非自反的。但是不存在非空集合,既是自反的,又不是非自反的。 53 | 54 | 对称性和反对称性,既可以同时满足,也可以同时不满足。 55 | 56 | # 10.5 关系的闭包 57 | 58 | 自反,对称,传递 59 | 60 | **定理**10.5.12: 对非空集合A上的关系R,有 61 | 62 | 1. rs(R)=sr(R) 63 | 2. rt(R)=tr(R) 64 | 3. st(R)$\subseteq$ts(R) 65 | 66 | 速记方法:有自反的可以交换,st属于ts 67 | 68 | # 10.6 等价关系和划分 69 | 70 | 自反、对称、传递的关系。 71 | 72 | **求等价关系的步骤**: 73 | 74 | - 先求有多少种划分 75 | - 有一种划分就是一种等价关系 76 | 77 | # 10.8 偏序关系 78 | 79 | **线性序**:也称全序。 80 | 81 | **全序**:任何两个元素都有关系。 82 | 83 | **良序**:对偏序集$$,如果A的任何非空子集都有最小元,则称$\leq$为良序关系,称该集为良序集。 84 | 85 | **定理**10.8.6: 一个良序集一定是一个全序集。(反之不一定) 86 | 87 | 定理10.8.7: 一个有限的全序集一定是良序集。 88 | 89 | # Part2 图论与代数结构 90 | 91 | # 2.3 欧拉道路与回路 92 | 93 | ## 欧拉回路的充要条件 94 | 95 | G中各结点的度数为偶数。 96 | 97 | ## 欧拉道路的充要条件 98 | 99 | 只有2个度数为奇数的点。 100 | 101 | # 2.3 哈密尔顿道路与回路 102 | 103 | ## H道路充分条件 104 | 105 | 1. 106 | $$ 107 | \forall v_i,v_j \in G, d(v_i)+d(v_j)\geq n-1 108 | $$ 109 | 110 | ## H回路充分条件 111 | 112 | 1. 113 | $$ 114 | \forall v_i,v_j \in G, d(v_i)+d(v_j)\geq n 115 | $$ 116 | 2. 117 | $$ 118 | \forall v_i\in G, d(v_i)\geq \frac n2 119 | $$ 120 | 3. 121 | $$ 122 | G:\forall v_i, v_j(不相邻), d(v_i)+d(v_j)\geq n 123 | $$ 124 | 125 | $$ 126 | 则G存在H回路的充要条件为G+(v_i,v_j)有H回路。 127 | $$ 128 | 129 | 130 | 131 | # 3.6 Huffman树 132 | 133 | 134 | 135 | # 3.7 最短树 136 | 137 | ## Kruskal算法 138 | 139 | 过程: 140 | 141 | 1. 初始化一个空的树 142 | 2. 挑一个全局最短的边 143 | 3. 如果加上这条边没有回路,就加上吧。顺便在原图中去掉 144 | 4. 重复2和3,直到树的边为n-1。 145 | 146 | ## Prim算法 147 | 148 | 基本思想:利用树的邻边进行扩展而不是全局最小。 149 | 150 | # 8.2 群、群的基本性质 151 | 152 | 群: 153 | 154 | - 结合律 155 | - 单位元 156 | - 幺元 157 | 158 | 阿贝尔群: 159 | 160 | - 满足交换律的群 161 | 162 | 群G的子群的充要条件: 163 | 164 | - 运算封闭 165 | - 有单位元,且等于G的单位元 166 | - 任意元素有逆元,且等于G中的逆元 167 | 168 | 子群判断定理: 169 | 170 | - 对于G的非空子集H,H是G的子群的充要条件是:任意a,b属于H,$ab^{-1}$也属于H。 171 | 172 | # 8.3 循环群 群的同构 173 | 174 | 循环群: 175 | $$ 176 | G==\{ a^k| k \in Z\} 177 | $$ 178 | a称为G的生成元。 179 | 180 | 181 | 182 | 定理8.3.1: 183 | 184 | - 若$O=\infty$, 生成元只有$a$或$a^{-1}$ 185 | - 若$O=n$,生成元有$\varphi(n) $个(欧拉函数,小于n且与n互素的元素个数)。 186 | 187 | 188 | 189 | 同构: 190 | $$ 191 | f(ab)=f(a)*f(b) 192 | $$ 193 | 194 | # 8.4 变换群和置换群 195 | 196 | **变换群**:非空集合A的所有一一变换关于变换的乘法所作成的群叫做A的一一变换群,用E(A)表示,E(A)的子群叫做变换群。 197 | 198 | **置换群**:当A是一个有限集合时,例如A={1,2,...,n},A中的一个一一变换称为一个n元置换,由置换构成的群叫置换群。 199 | 200 | 我们用$S_n$来表示这n!个n元置换的集合。 201 | 202 | **n元置换群和n次对称群**:$S_n$对于置换乘法构成群,称为n次对称群。$S_n$的子群称为n元置换群。 203 | 204 | 轮换:$\sigma(i_j)=i_{j+1}$ 205 | 206 | 207 | 208 | 定理:任何置换都可以表示为不相交轮换的乘积。 209 | 210 | 定理:任何一个轮换都可以表示为对换的乘积。 211 | 212 | 将一个置换表示称对换的乘积后,它所含的对换数: 213 | $$ 214 | N(\sigma)=\sum_{j=1}^k(l_i-1) 215 | $$ 216 | **Caley定理**:任意群G与一个变换群同构。 217 | 218 | 219 | 220 | **交错群**:n次对称群$S_n$中所有偶置换的集合,对于$S_n$中的置换乘法构成子群,记为$A_n$,称为交错群。$|A_n|=\frac 12 n!$ 221 | 222 | 223 | 224 | 225 | 226 | # 8.5 陪集和群的陪集分解 227 | 228 | 左陪集:设H是群G的一个子群,对任意的$a\in G$,集合 229 | $$ 230 | aH=\{ah|h\in H\} 231 | $$ 232 | 称为子群H在G中的一个左陪集。 233 | 234 | 235 | 236 | **定理**:G是有限群,H是G的一个子群,$G=a_1H\cup a_2H\cup...\cup a_kH$,且他们不相交。 237 | 238 | 239 | 240 | Lagrange定理: 241 | $$ 242 | |G|=\sum |Ag_i|=\sum |A|=|A|\cdot|I| 243 | $$ 244 | 245 | 246 | 元素的阶:$a\in G$, $n$为使得$a^n=1$的最小正整数,$o(a)=n$。 247 | 248 | 249 | 250 | 引理:任意g属于G,o(g)=2,则G为阿贝尔群。 251 | 252 | 引理:任何素数阶群都是阿贝尔群。 253 | 254 | # 8.6 正规子群与商群 255 | 256 | 正规子群:aH=Ha 257 | 258 | 商群:$<\frac GN, *>$ 259 | 260 | 261 | 262 | 263 | 264 | -------------------------------------------------------------------------------- /da-er/th029-mao-gai/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: 授课教师:刘伟 3 | --- 4 | 5 | # TH029-毛概 6 | 7 | 笔记为2021年秋季学期。 8 | 9 | 提供了Markdown文件以及pdf文件。 10 | 11 | pdf:[链接](../../TH029-%E6%AF%9B%E6%A6%82/%E5%A4%8D%E4%B9%A0%E8%A6%81%E7%82%B9%E4%B8%8E%E8%BE%A8%E6%9E%90%E9%A2%98%E4%B8%8E%E9%97%AE%E7%AD%94%E9%A2%98.pdf) 12 | -------------------------------------------------------------------------------- /da-er/th029-mao-gai/fu-xi-yao-dian-yu-bian-xi-ti-yu-wen-da-ti.md: -------------------------------------------------------------------------------- 1 | # 毛概复习 2 | 3 | 迮炎杰,2021年6月 4 | 5 | # 脉络梳理 6 | 7 | (需要做到看着小点可以回忆起内容) 8 | 9 | (重点看教材第1、2、5、8、10、14章) 10 | 11 | ## 1. 毛泽东思想 12 | 13 | - 萌芽,形成,趋于成熟的过程 14 | - 萌芽:《中国社会各阶级的分析》《湖南农民运动考察报告》 15 | - 形成:在《中国红色政权为什么能够存在》《井》《星》中提出 **农村包围城市,武装夺取政权** 16 | - 趋于成熟:《中国革命和中国共产党》(首次提出新民主主义) 《新民主主义论》《共产党人发刊词》《论联合政府》 17 | - 1945年党的七大,写入党章 18 | - 继续发展,关于社会主义革命和社会主义建设:《论十大关系》《论人民民主专政》《关于正确处理人民内部矛盾的问题》等等 19 | - 毛泽东思想活的灵魂是什么,意义 20 | - 实事求是,独立自主,群众路线 21 | - 毛泽东思想的历史地位: 22 | - 马克思主义中国化的第一个重大理论成果 23 | - 中国革命和建设的科学指南 24 | - 中国共产党和中国人民的宝贵精神财富 25 | - 新民主主义革命理论 26 | - 解决中国革命问题的基本前提:认清中国国情 27 | - 主要矛盾:帝国主义与中华民族的矛盾,封建主义与人民大众的矛盾 28 | - 近代中国革命的性质:资产阶级民主革命 29 | - 进入新民主主义革命的标志:五四运动 30 | - 根本任务:推翻三座大山 31 | - 革命对象 32 | - 革命动力 33 | - 新民主主义理论的核心问题:无产阶级的领导权 34 | - 新民主主义革命性质:资产阶级民主主义革命 35 | - 三个基本纲领:政治,经济,文化 36 | - **三大法宝**:统一战线,武装斗争,党的建设 37 | - 毛泽东:“统一战线和武装斗争,是战胜敌人的两个基本武器。” 38 | - 新民主主义革命道路的内容以及意义:农村包围城市,武装夺取政权的道路 39 | - 社会主义改造理论 40 | - 新民主主义社会的性质 41 | - 新民主主义社会的五种经济成分 42 | - 新民主主义社会的三种主要经济成分 43 | - 两个转变(七届二中全会) 44 | - 过渡时期的总路线和总任务:一化三改 45 | - 三大改造内容 46 | - 农业三个阶段 47 | - 资本主义工商业改造的方法 48 | - 手工业 49 | - 社会主义改造的历史经验: 50 | - 坚持社会主义工业化建设与社会主义改造并举 51 | - 采取积极引导、逐步过渡的方式 52 | - 用和平方法进行改造 53 | - 三大改造的意义:标志着长达数千年的阶级剥削制度的结束和社会主义基本制度的确立。 54 | - 确立社会主义基本制度的重大意义:制度基础,中国特色社会主义制度的重要前提 55 | - 社会主义建设道路初步探索 56 | - 理论成果:三个 57 | - 《论十大关系》:提出“调动一切积极因素为社会主义事业服务” 58 | - 《关于正确处理人民内部矛盾》:论述了社会主义社会矛盾 59 | 60 | ## 2. 中国特色社会主义理论体系 61 | 62 | - 邓小平理论 63 | - 形成过程:十二大提出“中国特色社会主义”,十三大形成轮廓,南方谈话成熟,十五大正式提出“邓小平理论”并写入党章,1999年入宪 64 | - 主要内容 65 | - 三个代表 66 | - 科学发展观 67 | - 习近平新时代中国特色社会主义思想 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | # 可能会出辨析题 78 | 79 | ## 1. 新民主主义革命的动力包括无产阶级,农民阶级,城市小资产阶级,民族资产阶级? 80 | 81 | 1. 城市小资产阶级是无产阶级的可靠同盟者。城市小资产阶级,包括广大的知识分子、小商人、手工业者和自由职业者,同样受帝国主义、封建主义、官僚资本主义的压迫。因此,城市小资产阶级同样是中国革命的动力。 82 | 2. 民族资产阶级也是。具有 **两面性**: 83 | - 受到帝国主义和封建主义的压迫,有矛盾 84 | - 经济上与帝国主义和封建主义有联系,没有彻底反帝反封建的勇气,在革命的关键时刻表现出明显的动摇性。 85 | 86 | ## 2. 新民主主义社会不是一个独立的社会形态,而是由新民主主义向社会主义转变的过渡性社会形态。 87 | 88 | 1. 在新民主主义社会中,存在五种经济成分,即: 89 | - 社会主义性质的国营经济 90 | - 半社会主义性质的合作社经济 91 | - 农民和手工业者的个体经济 92 | - 私人资本主义经济 93 | - 国家资本主义经济 94 | 95 | 2. 其中: 96 | - 国家资本主义经济是私人资本主义经济向社会主义国营经济过渡的形式。 97 | - 半社会主义性质的合作社经济是个体经济向社会主义集体经济过渡的形式。 98 | 99 | 3. 所以,主要经济成分有三种,社会主义经济,个体经济,资本主义经济。 100 | 101 | 102 | 103 | ## 3. 1956年三大改造完成,我国经济结构发生了根本变化,社会主义公有制成为我国社会的经济基础,标志着长达数千年的阶级剥削制度的结束和社会主义基本制度的确立。 104 | 105 | 106 | 107 | ## 4. 改革开放理论:改革是中国的第二次革命。改革作为一次新的革命,不是也不允许否定和抛弃我们建立起来的社会主义基本制度,它是社会主义基本制度的自我完善和发展。 108 | 109 | 110 | 111 | # 可能会出的论述题 112 | 113 | ## 1. 全面深化改革 114 | 115 | 必要性: 116 | 117 | - 顺应当今世界发展大势的必然选择(世界) 118 | - 解决中国现实问题的根本途径(中国) 119 | - 关系党和人民事业前途命运,关系党执政地位和执政基础。(党和人民) 120 | 121 | 怎么做: 122 | 123 | - 必须坚持党对改革的集中统一领导(党的领导) 124 | - 必须坚持改革沿着中国特色社会主义方向前进(中特社方向) 125 | - 必须坚持改革往有利于维护社会公平正义、增进人民福祉的方向前进(公平与人民) 126 | - 必须坚持社会主义市场经济的改革方向(市场经济) 127 | 128 | ## 2. 正确处理全面深化改革中的重大关系 129 | 130 | 处理好: 131 | 132 | - 解放思想和实事求是的关系 133 | - 顶层设计和摸着石头过河的关系 134 | - 整体推进和重点突破的关系 135 | - 单子要大和步子要稳的关系 136 | - 改革、发展、稳定的关系 137 | - 改革是经济社会发展的强大动力 138 | - 发展是解决一切经济社会问题的关键 139 | - 稳定是改革发展的前提 140 | 141 | 详细解说见书P249。 142 | 143 | 144 | 145 | ## 3. 推动构建人类命运共同体 146 | 147 | 怎么做?五点。 148 | 149 | 核心:**建设持久和平、普遍安全、共同繁荣、开放包容、清洁美丽的世界** 150 | 151 | - 政治上,相互尊重、平等协商 152 | - 安全上,以对话解决争端、以协商化解分歧 153 | - 经济上,贸易投资自由化便利化 154 | - 文化上,尊重世界文明多样性 155 | - 生态上,坚持环境友好。 156 | 157 | 158 | 159 | ## 4. 四个自信的内容和关系 160 | 161 | 内容: 162 | 163 | - 坚持道路自信,就是要**坚信中国特色社会主义道路是实现社会主义现代化的必由之路,是创造人民美好生活的必由之路。**只有毫不动摇地坚持和发展中国特色社会主义道路,才能实现“两个一百年”奋斗目标,实现中华民族伟大复兴的中国梦。 164 | 165 | - 坚持理论自信,就是要**坚信中国特色社会主义理论体系是指导党和人民沿着中国特色社会主义道路实现中华民族伟大复兴的正确理论,是立于时代前沿、与时俱进的科学理论。**只有始终不渝地坚持和发展中国特色社会主义理论体系,才能不断推进马克思主义中国化,确保中国特色社会主义沿着正确方向奋勇前进。 166 | 167 | - 坚持制度自信,就是要坚信**中国特色社会主义制度是当代中国发展进步的根本制度保障,是具有鲜明中国特色、明显制度优势、强大自我完善能力的先进制度。**只有毫不动摇地坚持和发展中国特色社会主义制度,才能为实现“两个一百年”奋斗目标提供坚强政治保障。 168 | 169 | - 坚持文化自信,就是要坚信**中国特色社会主义文化是面向现代化、面向世界、面向未来的,民族的科学的大众的先进文化,是中国人民胜利前行的强大精神力量。**只有坚持文化自信,大力弘扬社会主义核心价值观,**弘扬以爱国主义为核心的民族精神和以改革创新为核心的时代精神,**才能不断增强全党全国各族人民的精神力量,为全面建成小康社会、实现中华民族伟大复兴的中国梦提供强大精神支撑。 170 | 171 | 关系: 172 | 173 | - 文化自信是基础和源泉,体现党、国家、民族的主体自信 174 | - 理论自信是灵魂,体现真理自信,价值自信,逻辑自信 175 | - 制度自信是根本,实质和核心是客体自信 176 | - 道路自信是表征,来源于文化自信,根植于理论自信,服务于制度自信 177 | 178 | 179 | 180 | ## 5. 推动新型国际关系(5点) 181 | 182 | - 坚决维护国家核心利益,把维护国家主权、安全、发展利益作为外交工作的出发点和落脚点。(国家利益) 183 | - 要在和平共处五项原则的基础上发展同世界各国友好合作。(原则) 184 | - 积极参与**全球治理体系改革和建设**,秉持**共商共建共享的全球治理观**。(全球) 185 | - 加强涉外法律工作,完善涉外法律法规体系。(法律) 186 | - 把互相尊重、公平正义、合作共赢理念体现在政治、经济、文化、安全等对外合作的方方面面,推动构建人类命运共同体。(人类命运共同体) 187 | 188 | image-20210616170741465 189 | 190 | 191 | 192 | ## 6. 脱贫攻坚取得成就的原因(5-7点即可) 193 | 194 | - 党的领导,提供坚强政治保证和组织保证 195 | - 以人民为中心, 坚定不移走共同富裕道路 196 | - 发挥社会主义制度集中力量办大事的优势 197 | - 精准扶贫方略 198 | - 调动广大群众积极性、主动性、创造性 199 | - 坚持求真务实,较真碰硬 200 | - 弘扬团结互助美德,营造全社会扶贫的氛围 201 | 202 | image-20210616170814078 203 | 204 | 205 | 206 | ## 7. 如何开展党史教育?(四个自信) 207 | 208 | 209 | 210 | image-20210616172657357 211 | 212 | image-20210616170954618 213 | 214 | 215 | 216 | ## 8. 脱贫攻坚(4点) 217 | 218 | - 全民共享:人人享有,各得其所 219 | - 全面共享:共享经济、政治、文化、社会、生态文明等各方面成果 220 | - 共建共享:共同建设,共同享有 221 | - 渐进共享:共享发展有一个从低级到高级、从不均衡到均衡的过程 222 | 223 | image-20210616171012552 224 | 225 | 226 | 227 | ## 9. 统筹两个大局(4点) 228 | 229 | 内容:一个是中华民族伟大复兴的战略全局,一个是世界百年未有之大变局 230 | 231 | 怎么做? 232 | 233 | - 概括:把握战略机遇,培养国内市场,加强对外开放,统筹发展与安全 234 | 235 | - **在统筹“两个大局”中加快构建新发展格局,必须把握重要战略机遇期。(把握机遇)**习近平总书记指出:“当今世界正经历百年未有之大变局,但时与势在我们一边,这是我们定力和底气所在,也是我们的决心和信心所在。同时,必须清醒看到,当前和今后一个时期,虽然我国发展仍然处于重要战略机遇期,但机遇和挑战都有新的发展变化,机遇和挑战之大都前所未有,总体上机遇大于挑战。”这就要求我们,必须牢牢把握中华民族伟大复兴的战略全局,始终围绕这一战略全局来谋划各项工作,把工作重心聚焦到完成“十四五”规划所提出的构建新发展格局的各项任务上来,积极畅通国内大循环;必须全面、辩证地审视世界百年未有之大变局,敏锐把握世界形势、国际格局、大国关系、国际秩序等的深刻变化及其对我国发展的复杂影响,继续拓展和深化与国际大循环的紧密联系;必须敏锐把握中华民族伟大复兴战略全局和世界百年未有之大变局的内在关系,主动谋划,积极作为,充分发挥我国对促进世界和平发展的重要作用;审慎评估世界百年未有之大变局对中华民族伟大复兴战略全局带来的风险和挑战,既准备好防范风险的先手,又准备好应对和化解风险挑战的高招,推动国内国际双循环相互促进。基于此,党的十九届五中全会强调,“增强机遇意识和风险意识,立足社会主义初级阶段基本国情,保持战略定力,办好自己的事,认识和把握发展规律,发扬斗争精神,树立底线思维,准确识变、科学应变、主动求变,善于在危机中育先机、于变局中开新局”。 236 | 237 | - 在统筹“两个大局”中加快构建新发展格局,**必须培育强大国内市场。(国内)**近年来,逆全球化、保护主义、单边主义抬头,加之新冠肺炎疫情给各国带来严重冲击,世界经济陷入低迷,传统国际循环活力明显减弱。我国加入世贸组织后形成的市场和资源“两头在外”的发展模式面临新的挑战。同时,我国已经成为世界第二大经济体,人均国内生产总值已经突破1万美元,拥有1亿多市场主体、4亿多中等收入人口、14亿人口的超大规模内需市场,正处于新型工业化、信息化、城镇化、农业现代化快速发展阶段,投资需求潜力巨大,人民对美好生活的要求不断提高。由于内外发展环境正在发生深刻变化,我们必须统筹中华民族伟大复兴战略全局和世界百年未有之大变局,从外部大变局的“变”中认识和把握动荡变革期,做到科学应对,趋利避害;从国内战略全局的“势”中看到自身发展的优势和潜能,把扩大内需放在更加优先、更加突出的位置,做到主动引导,发掘潜力,激发活力,充分发挥国内超大规模市场优势,通过繁荣国内经济、畅通国内大循环、培育国内大市场,为我国经济发展增添新的动力,开辟新的空间。习近平总书记强调,“构建新发展格局的关键在于经济循环的畅通无阻”“要建立起扩大内需的有效制度,释放内需潜力,加快培育完整内需体系,加强需求侧管理,扩大居民消费,提升消费层次,使建设超大规模的国内市场成为一个可持续的历史过程”。 238 | - 在统筹“两个大局”中加快构建新发展格局,必须**实行更高水平对外开放(对外开放)。**首先,坚持国内国际双循环相互促进。新发展格局决不是关起门来封闭运行的单循环,而是通过发挥内需潜力,使国内市场和国际市场更好联通的双循环,更好利用国内国际两个市场、两种资源,实现更加强劲可持续的发展,同时为世界发展创造更多的机遇。其次,让中国市场成为世界的市场。新发展格局强调以国内大循环为主体,把中国市场当做基本立足点。但是,这决不意味着中国要自我封闭,而是要大力激发国内市场的内生动力,最大限度展现其对世界的吸引力,为世界各国创造更丰富、更有利、更方便的投资机会和营商环境,在更大规模和程度上使中国市场成为世界大市场不可分割的组成部分,让中国市场成为世界的市场、共享的市场、大家的市场。再次,以国际循环提升国内大循环的效率和水平。强调国内国际双循环相互促进,有一个前提,那就是始终把国内大循环放在优先的位置、基础的位置,再以国际循环来促进和巩固。正如习近平总书记所指出的:“构建新发展格局,实行高水平对外开放,必须具备强大的国内经济循环体系和稳固的基本盘。要塑造我国参与国际合作和竞争新优势,重视以国际循环提升国内大循环效率和水平,改善我国生产要素质量和配置水平,推动我国产业转型升级。” 239 | 240 | - 在统筹“两个大局”中加快构建新发展格局,**必须统筹发展和安全(发展与安全)。**构建新发展格局离不开安全的发展环境。当前,我国的发展环境日趋复杂,安全问题的综合性、复杂性明显增强,传统安全威胁和非传统安全威胁相互交织。我国在发展中面临的风险和挑战将越来越复杂和严峻,而且可能会持续较长的一个时期。面对复杂多变的国际环境和艰巨繁重的改革发展的任务,要构建新发展格局,必须树牢安全发展理念,更加自觉地统筹中华民族伟大复兴战略全局和世界百年未有之大变局。我们既要善于从世界大变局中洞察我国发展面临的风险和挑战,又要敏锐把握我国国内发展中面临的安全问题和隐患;既要善于运用我国发展成果夯实维护国家安全的基础,又要积极主动塑造对我国有利的外部环境;既要打好防范和抵御风险的有准备之战,也要打好化险为夷、转危为机的战略主动战。当前和今后一个时期,必须坚持总体国家安全观,实施国家安全战略,维护和塑造国家安全,统筹传统安全和非传统安全,把安全发展贯穿国家发展各领域和全过程,筑牢国家安全屏障。党的十九届五中全会明确提出,“要加强国家安全体系和能力建设,确保国家经济安全,保障人民生命安全,维护社会稳定和安全”。统筹好发展和安全两件大事,建设更高水平的平安中国,必将为加快构建新发展格局营造良好的安全环境。 241 | 242 | 243 | 244 | ## 10. 关于党性和党的宗旨 245 | 246 | - 中国共产党的性质:中国共产党是中国[工人阶级](https://baike.baidu.com/item/工人阶级)的先锋队,同时是中国人民和[中华民族](https://baike.baidu.com/item/中华民族)的先锋队,是[中国特色社会主义](https://baike.baidu.com/item/中国特色社会主义)事业的领导核心。 247 | - 三个代表:中国共产党代表中国先进[生产力](https://baike.baidu.com/item/生产力)的发展要求,代表中国先进文化的前进方向,代表中国最广大人民的根本利益。 248 | - 党的最高理想和最终目标是:实现[共产主义](https://baike.baidu.com/item/共产主义)。 249 | - 本质特征:中国共产党的领导是中国特色社会主义最本质的特征。 250 | - 宗旨:中国共产党的宗旨是全心全意为人民服务。 251 | 252 | -------------------------------------------------------------------------------- /da-san/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: 炼丹科学家在路上 3 | --- 4 | 5 | # 大三 6 | 7 | -------------------------------------------------------------------------------- /da-san/cs240-ji-suan-ji-lun-li-xue/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: 授课教师:李超 3 | --- 4 | 5 | # CS240-计算机伦理学 6 | 7 | 写了一个对于课程内容的回顾,对于写期末论文有一定帮助。 8 | -------------------------------------------------------------------------------- /da-san/cs240-ji-suan-ji-lun-li-xue/review.md: -------------------------------------------------------------------------------- 1 | # CS240 计算机伦理学:A Review 2 | 3 | Yanjie Ze 4 | 5 | # 1 伦理学的挑战 6 | 7 | - 神令论 8 | - 决定论 9 | - 宿命论 10 | - 严格决定论 11 | - 非严格决定论 12 | - 休谟法则 13 | - 事实判断,价值判断 14 | - 不能不加说明地从“是”推导出“应当” 15 | - 道德主观主义 16 | 17 | # 2 有哪些针对价值和行为的指导理论? 18 | 19 | - 边沁的思想 20 | - 功利主义,注重结果 21 | - 目的论 22 | - 康德的思想 23 | - 义务论,注重义务 24 | - 强调绝对命令,人人都能够遵守的 25 | - 亚里士多德的思想 26 | - 美德是中道 27 | - 注重成为怎么样的一个人 28 | - 价值和善 29 | - 内在善:固有性质为善 30 | - 工具善:不因其固有性质,而在乎其与善间接相关 31 | - 功利主义和利己主义 32 | 33 | # 3 伦理分析中层原则 34 | 35 | 1. 显见义务论 36 | 37 | 2. 应该蕴含能够 38 | 3. 合理地彼此要求 39 | 40 | - 合理综合法 41 | 42 | # 4 计算机伦理与专业责任 43 | 44 | 1. 技术内在价值 45 | 2. 技术与人的关系 46 | 3. 计算机职业伦理 47 | 48 | 49 | 50 | - 技术伦理研究:policy vacuum,政策真空 51 | 52 | - 预警原则 53 | - 计算机的无意识力量 54 | - 计算机行业应当体现广义的关怀 55 | 56 | 57 | 58 | 如何面对不完备的伦理准则。 59 | 60 | 61 | 62 | # 默默无闻的工作就像地下的潜流,于无声处使大地变成绿洲。——托马斯·卡莱尔 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /da-san/cs337-ji-suan-ji-tu-xing-xue.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: 授课教师:盛斌 3 | --- 4 | 5 | # CS337-计算机图形学 6 | 7 | 由于是开卷考试,整理了非常详细的pdf版本的笔记:[链接](../CS337-%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6-%E5%A4%8D%E4%B9%A0.pdf) 8 | 9 | 希望对同学们复习有帮助。 10 | -------------------------------------------------------------------------------- /da-san/cs386-shu-zi-tu-xiang-chu-li.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: 授课教师:盛斌,卢宏涛 3 | --- 4 | 5 | # CS386-数字图像处理 6 | 7 | 内容较多,复习时候直接看上课ppt就可以。 8 | 9 | 附带一份期末考点的ppt:[链接](../CS386-%E6%95%B0%E5%AD%97%E5%9B%BE%E5%83%8F%E5%A4%84%E7%90%86/2021%E7%A7%8B-%E6%95%B0%E5%AD%97%E5%9B%BE%E5%83%8F%E5%A4%84%E7%90%86%E5%A4%8D%E4%B9%A0.pptx) 10 | -------------------------------------------------------------------------------- /da-san/cs410-ren-gong-zhi-neng/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: 授课教师:杨旸 3 | --- 4 | 5 | # CS410-人工智能 6 | 7 | 这门课由于内容比较多,做了十分详细的内容整理,可在线浏览。(但是比计算机网络稍微少一点!) 8 | 9 | 10 | -------------------------------------------------------------------------------- /da-san/cs410-ren-gong-zhi-neng/ai-review.md: -------------------------------------------------------------------------------- 1 | # AI-review 2 | 3 | ## CS410人工智能:A Review by [Yanjie Ze](http://yanjieze.com) 4 | 5 | Start from Jan 2, 2022 6 | 7 | 注:十分感谢课程助教谢瑜璋提供大纲,以供同学们复习。本复习笔记基于大纲进行内容完善。 8 | 9 | ## 目录 10 | 11 | [TOC] 12 | 13 | 14 | 15 | ## 第一部分 人工智能概念 16 | 17 | 1.人工智能(AI,Artificial Intelligence)的定义 18 | 19 | * 课件lecture1第5页:人工设计程序,让机器可以像人一样智慧地行动 20 | * 更具体的定义在lecture1第7页,分为四个维度: 21 | * thinking humanly 22 | * Thinking rationally 23 | * Acting humanly 24 | * Acting rationally 25 | 26 | 2.图灵测试 27 | 28 | 目的:设计测试以验证计算机是否真的具有智能 29 | 30 | 3.代理人、理智(rational)行为、理智的代理人(agent) 31 | 32 | 见课件lecture1第11页 33 | 34 | 要了解代理人的定义、理智行为的定义、判断标准 35 | 36 | * **Rational behavior**: doing the right thing 37 | * **The right thing**: that which is expected to maximize goal achievement, given the available information 38 | * Doesn't necessarily involve thinking – e.g., blinking reflex – but thinking should be in the service of rational action 39 | * **Agent**: An agent is an entity that perceives and acts. 40 | 41 | Agent的组成:课件lecture2a-1第10页,PEAS 42 | 43 | * Performance measure 44 | * Environment 45 | * Actuators 46 | * Sensors 47 | 48 | 4.环境 49 | 50 | agent所处的各种类别的环境,对建模方式和算法的使用有很大的影响,各种环境的定义见lecture2第13页、14页 51 | 52 | * Fully observable (vs. partially observable): An agent's sensors give it access to the complete state of the environment at each point in time. 53 | * Deterministic (vs. stochastic): The next state of the environment is completely determined by the current state and the action executed by the agent. (If the environment is deterministic except for the actions of other agents, then the environment is strategic) 54 | * Episodic (vs. sequential): The agent's experience is divided into atomic "episodes" (each episode consists of the agent perceiving and then performing a single action), and the choice of action in each episode depends only on the episode itself. 55 | 56 | ## 第二部分 解决问题的方法:搜索答案 57 | 58 | ### 1. 搜索问题的建模方式 59 | 60 | 需要明确搜索空间的状态、初始状态、转移模型、动作、目标、路径耗散,通过明确以上定义与状态空间的大小来建模搜索问题 61 | 62 | 可以参考第一次作业的第三题和课件lecture2b-1 12页 63 | 64 | * 一个problem由4个部分构成: 65 | * Initial state 66 | * actions 67 | * goal test 68 | * path cost 69 | * solution:A solution is a sequence of actions leading from the initial state to a goal state 70 | 71 | *** 72 | 73 | 例题1:假如我们现在有一个长度为 _M_ 个格子、宽度为 _N_ 个格子的棋盘,盘子中有一些障碍物、形成了一个迷宫。有两个机器人希望根据他们的位置让他们尽快相遇(相遇指的是让两个机器人处在同一个格子里即可,不需要让他们面对面朝向)。机器人在一个行动单位内可以沿着自己朝向的方向移动到一个相邻的格子内、或者旋转自己朝向的方向 90_◦_。 74 | 75 | (1)请将该问题形式化,我们需要如何简单地定义该问题的状态(state)? 76 | 77 | (2)对于该状态而言,你定义的状态其状态空间有多大(size)? 78 | 79 | (3)继续形式化该问题,描述该问题的行动、目标测试、路径耗散(简单描述即可)。 80 | 81 | (4)如果使用搜索算法解决该问题,请给出一个启发函数 _h_,该启发函数满足可接受性。 82 | 83 | 答: 84 | 85 | (4)启发函数 _h_ 需要满足可接受性,指每个状态到最终目标花费的实际时间成本需要高于其启发式函数值。因此可以设计启发函数 _h_ 为两个机器人的曼哈顿距离或者欧氏距离,由于机器人一次只能移动到相邻格子、不能斜着移动,因此两个机器人之间的最短距离会大于等于其曼哈顿距离与欧氏距离。除此以外,还需要考虑机器人转向的时间成本,因此实际到达目标花费的时间成本会大于等于启发函数 _h_。 86 | 87 | 注:**启发函数**: 88 | 89 | * 可接受性:admissible,即 $h(n)\leq h^*(n)$,$h^*(n)$为从n到达终点的实际cost 90 | * 一致性:consistent,即$h(n)\leq c(n,a,n') + h(n')$,$n'$是$n$的后继节点。直观理解,三角形两边之和大于第三边,从n到达终点的cost肯定得 小于等于 $n'$到终点的cost再加上 $n$到$n'$的cost。 91 | 92 | *** 93 | 94 | ### 2. 比较搜索算法 95 | 96 | 可以从算法的完备性、最优性、时间复杂度、空间复杂度来比较,要理解以上定义。我们作业里也有相关的问题,第一次作业里有比较BFS、UCS、DFS的题目。 97 | 98 | *** 99 | 100 | 例题2:比较宽度优先算法(BFS)一致代价搜索(UCS)、深度优先算法(DFS)的优劣。 101 | 102 | 答:可以比较三种算法的完备性、最优性、复杂度等角度比较。BFS 算法时完备的、单位代价的情况下时最优的,但是需要保存所有产生的节点值、空间复杂度高;UCS 算法对于一般性的步骤代价而言是最优的;BFS 与 UCS 算法的时间空间复杂度均为 $O(b^d)$。DFS 算法不是完备的、也不能保证最优性,但是只需要存储一条从根节点到叶节点的路径、以及该路径上每个节点上所有未被扩展的兄弟节点即可,当一个节点被扩展,当它的所有节点都被探索过后该节点就从内存中删除、空间复杂度低,为 _O_(_bm_),其中 _m_ 为最大深度。 103 | 104 | *** 105 | 106 | 评价一个搜索算法的标准: 107 | 108 | * 完备性。如果有解,是否能找到? 109 | * 时间复杂度、空间复杂度 110 | * 最优性。是否能找到最优解? 111 | 112 | BFS,UCS,DFS的比较: 113 | 114 | * BFS, breadth first search。是最优的。但是需要保存所有节点,空间复杂度高。时间、空间复杂度$O(b^d)$。 115 | * UCS, uniform cost search。扩展cost最小的节点。时间复杂度$O(b^d)$。 116 | * DFS, depth first search。不完备(因为有可能遇到深度无限的情况)。不最优。但空间复杂度低,为$O(bd)$,其中d是最大深度。时间复杂度也是$O(b^d)$。 117 | 118 | ### 3. 无信息搜索 119 | 120 | 包含:DFS、BFS、UCS、深度限制搜索、深度迭代搜索等,这一部分肯定是很重要的,可以出小题也可以出大题 121 | 122 | 从lecture2b-1第20页开始,要理解以上算法的过程,然后从完备性、最优性、时间复杂度、空间复杂度等角度比较优劣。如果有不理解的地方,可以参考canvas上的教材,上面对每个算法都描述得很详细。 123 | 124 | * BFS, breadth first search。是最优的。但是需要保存所有节点,空间复杂度高。时间、空间复杂度$O(b^d)$。 125 | * 优点:可以找到最短路径 126 | * 缺点:要存储很多节点 127 | * UCS, uniform cost search。扩展cost最小的节点。时间复杂度$O(b^d)$。 128 | * DFS, depth first search。不完备(因为有可能遇到深度无限的情况)。不最优。但空间复杂度低,为$O(bd)$,其中d是最大深度。时间复杂度也是$O(b^d)$。 129 | * 完备性:当space是无限的时候不完备,有限的时候完备。 130 | * Depth limited search。加上了深度限制的DFS。 131 | * Iterative deepening search。对深度限制$l$进行depth limited search的迭代。 132 | * 先用depth=1的DFS,再depth=2的DFS,..... 133 | * 优点:linear memory, $O(bm)$。并且可以保证找到minimal depth的节点。 134 | 135 | ### 4. 有信息搜索 136 | 137 | (1)算法包含:贪婪搜索、A\*搜索等 138 | 139 | 从lecture 2b-1第52页开始,要理解以上算法的过程 140 | 141 | **A\*算法最优性的证明不要求记忆** 142 | 143 | (2)要理解有信息与无信息搜索的区别在哪里,可以参考第二次作业的第一题 144 | 145 | (3)启发函数:理解启发函数的定义、作用,理解启发函数的可接受性(admissible)和一致性(consistency),理解启发函数的比较(哪个启发函数更“好”) 146 | 147 | Lecture2b-1第52-62页 148 | 149 | *** 150 | 151 | **例题3**:(重要) 152 | 153 | 证明以下结论(仅需要简单说明证明思路即可,不用写太多): 154 | 155 | (1)BFS 搜索算法是 UCS 搜索算法的特殊情况。 156 | 157 | (2)UCS 搜索算法是 A\*算法的特殊情况。 158 | 159 | (3)运行 A\*算法时,若启发式函数 _h_ 满足一致性,那么在启发式搜索算法的搜索树中每条路径的子节点的 _f_ 值大于等于其父节点。 160 | 161 | (4)若启发式函数 _h_ 满足一致性,那么它也会满足可接受性。 162 | 163 | 答: 164 | 165 | (4) 166 | 167 | 我们可以选取任意一个节点 _G_,那么其他节点都会有一条到 _G_ 的最短路径。如果我们选取任意一条最短路径上距离 _G_ 一个步骤的某个节点 _n_1,那么我们根据启发式函数的一致性,会有 _h_(_n_1) _<_= _h_(_G_) + _c_(_n_1\*, G, a\*)。如果我们用 _h\*\*∗_ 来表示某点到终点的实际最小代价,那么就会有h(n1) <= h\*(n1), 即 _n_1 可以满足启发函数的可接受性。之后我们再将 _n_1 不断扩展,对于距离 168 | 169 | _G_ 最短距离有两个步骤的节点 _n_2,我们用类似的方法可以得到 _h_(_n_2) _<_= _h_(_n_1) + _c_(_n_2\*, n_1_, a\*) _<_= _h\*\*∗_(_n_1) + _c_(_n_2\*, n_1_, a\*) = _h\*\*∗_(_n_2)。注意:_h_ 是我们估计当前节点到终点的代价,所以一般默认终点的 _h_(_G_) = 0。有同学提出如果 h 为一个常数的话,比如 h=1000,有可能会满足一致性而不满足可接受性。不过一般我们默认终点的 _h_(_G_) = 0,所以该命题仍然是成立的。 170 | 171 | *** 172 | 173 | #### 4.1 算法 174 | 175 | * Best-fit search: 使用一个evaluation function $f(n)$给每个node。按$f(n)$降序排列,先遍历$f(n)$比较高的。 176 | * 特殊情况: greedy best-frist search,A\* search 177 | * Greedy best-first search:$f(n)=h(n)$,h是启发函数,是从n到达终点的cost的估计。 178 | * 完全性:no。可能会stuck在loop里 179 | * 时间:$O(b^m)$,但是好的启发函数能有较好的提升。 180 | * 空间:$O(b^m)$,需要记住所有的node。 181 | * 最优性:no。 182 | * A\* search: $f(n)=g(n)+h(n)$ 183 | * $g(n)$: cost so far to reach n 184 | * $h(n)$: estimated cost from n to goal (启发函数) 185 | * $f(n)$: estimated total cost of path through $n$ to goal 186 | * **启发函数**: 187 | * 可接受性:admissible,即 $h(n)\leq h^*(n)$,$h^*(n)$为从n到达终点的实际cost 188 | * 一致性:consistent,即$h(n)\leq c(n,a,n') + h(n')$,$n'$是$n$的后继节点。直观理解,三角形两边之和大于第三边,从n到达终点的cost肯定得 小于等于 $n'$到终点的cost再加上 $n$到$n'$的cost。 189 | * **定理**:如果$h(n)$是admissible的,A\*就是optimal的。 190 | * 完全性:yes 191 | * 时间:exponential 192 | * 空间:all nodes 193 | * 最优性:yes 194 | 195 | #### 4.2 有信息搜索和无信息搜索的区别 196 | 197 | 无信息搜索是指我们不知道接下来要搜索的状态哪一个更加接近目标的搜索策略,因此也常被成为盲目搜索。有信息搜索需要访问启发式函数 _h_(_n_) 来估算从当前节点到目标的解代价,从而衡量哪一个状态更加接近目标状态,并优先对该状态进行搜索,因此与无信息搜索相比往往能够更加高效得解决问题。 198 | 199 | #### 4.3 **启发函数的比较** 200 | 201 | * Dominace: 如果$h_2(n)\geq h_1(n)$(且他们都是admissibale的)对于所有n,则$h_2$ dominates $h_1$ 202 | 203 | $\Rightarrow$ 说明$h_2$比$h_1$好 204 | 205 | ### 5. 局部搜索 206 | 207 | #### 5.1 理解局部搜索与系统搜索(包括有信息与无信息搜索)的区别在哪里,参考第二次作业第一题 208 | 209 | *** 210 | 211 | 解答: 212 | 213 | (1)扩展新节点:在扩展节点时,系统搜索算法需要考虑当前节点在整个搜索空间中产生的所有可能的新状态,并将所有可能的新状态加入查询队列。但是局部搜索算法通常从当前状态出发,移动到附近的某个节点,并将改变后的新状态加入队列。 214 | 215 | (2)路径:系统搜索算法一般需要储存从根节点到叶子结点的每一条路径,每一条路径可以视为问题的一个可能解。而局部搜索算法一般不存储路径,只关注叶子结点最终的状态。 216 | 217 | (3)复杂性:系统搜索算法一般时间复杂性和空间复杂度都较高。对于相同规模的问题,局部搜索算法需要扩展的节点较少、且一般不需要储存路径,故一般时间复杂性和空间复杂性都要低一些。 218 | 219 | (4)适用范围:系统搜索算法可以用于探索问题的所有解或者证明命题是否成立,而局部搜索算法一般用于最优化问题。 220 | 221 | *** 222 | 223 | #### 5.2 算法包括:爬山法、模拟退火算法、局部束搜索、遗传算法,从lecture3-1第5页开始到第40页 224 | 225 | #### 5.3 爬山法:理解爬山法过程、爬山法可能会遇到怎样的问题 226 | 227 | * 过程:更新为neighbour中value最大的那个,直到找到一个局部最优 228 | * 问题:局部最优不一定是全局最优 229 | * 改良: 230 | * random restart 231 | * simulated annealing 232 | 233 | #### 5.4 模拟退火算法:是对爬山法的改良,“退火”的目的是什么,过程中选择“坏”移动的概率与哪些因素有关 234 | 235 | * 当next state比current state差的时候,只以$e^{\Delta E/T}$的概率转移到next state 236 | 237 | (感觉这玩意和epsilon-greedy其实差不多) 238 | * 选择坏移动的概率与\_\_\_有关: 239 | * 温度(一开始为tmax,逐渐降温) 240 | * 相对于当前的状态坏多少 241 | 242 | #### 5.5 局部束搜索(local beam search):关注k个状态,而不是一个状态 243 | 244 | * 开始的时候选k个状态,同时搜索。(和并行差不多的感觉) 245 | 246 | #### 5.6 遗传算法:遗传算法中的定义(lecture3-1第29页)、有哪些步骤(第32页)、每个步骤的目的是什么 247 | 248 | * 一些定义: 249 | * Individual 250 | * Population:由individual组成 251 | * Fitness:进行优化的target function,每个individual都有 252 | * Trait:possible aspect of an indiviual 253 | * Genome: Collection of all chromosomes (traits) for an individual 254 | * 步骤: 255 | 1. 初始生成population 256 | 2. evaluate fintness 257 | 3. 判断终止条件,没有的话选择parents 258 | 4. 进行crossover, mutation 259 | 5. 生成新的后代 260 | 6. 回到第2步 261 | 262 | ### 6. 对抗搜索 263 | 264 | #### 6.1 解决对抗搜索的算法 265 | 266 | MiniMax算法,理解算法的流程,课件lecture4第14页到23页,可以结合Tic-Tac-Toe这个例子和第二次作业的第三题来看,看懂了过程就行。 267 | 268 | **其实就是递归。** 269 | 270 | * 完全性:yes 271 | * 最优性:yes 272 | * 时间复杂度:$O(b^m)$,b是legal moves的个数,m是最大深度 273 | * 空间复杂度:$O(bm)$。因为是DFS。 274 | 275 | #### 6.2 Alpha-beta剪枝 276 | 277 | 在算法过程中,alpha代表什么,beta代表什么(课件lecture4第38页)。在算法运行过程中,何时需要比较节点与alpha、beta值的大小关系?何时需要剪枝?除此以外,Alpha-beta剪枝还具有一些性质(课件lecture第45页)。 278 | 279 | *** 280 | 281 | 例题4: 282 | 283 | 我们的 minimax 搜索树如图1所示。 284 | 285 | (1)假如我们的 **a** 节点是 **max** 节点,请问最后 **a** 节点会得到怎样的值? 286 | 287 | 答:a=32。 288 | 289 | (2)假如我们使用 _α β_ 剪枝法进行 minimax 树的搜索,搜索过程中会从左至右访问相关节点,且 **a** 节点是 **max** 节点。算法运行过程中会访问多少个节点(包括字母标号的节点与数字标号的叶节点、忽略重复访问)?同时,请写下各节点的访问顺序(例如顺序:**”a - c - f - 43”**) 。 290 | 291 | 使用α−β 剪枝法进行minmax 树的搜索,过程中我们需要维护α(当前搜索路径上目前max 得到的最好结果)与β(当前搜索路径上min 的最好结果),并且在适当的时候剪枝。在运行到min 节点n 时,会检查当前节点下子树返回的值与当前节点的α 值,如果子树返回的值小于α 值,说明该min 节点遍历所有子树后得到的值一定小于α 值,可以断定在第n-1 步max做决定的时候不会让min 有这种机会。因为在n-1 步,上层的max 就知道存在着一个策略D,使得value 值为.,max 可以忽略n 所在的子树。同理,在max 节点,我们会检查子树返回的值与当前节点的β 值,如果大于β 即剪去该节点与其子树。 292 | 293 | 在搜索过程中,刚开始的过程与常规的minmax 树相同,我们用类似于DFS 的算法对搜索树进行访问。我们会依次访问a - c - f - 43 - 12 - g - 32 - 31。此时我们可知e 节点的值为32,由此在a 节点处,其维护的α 值为32。之后我们会再访问b、d、20、23 节点,此时我们可以推定d 节点的值为23。那么当我们重新返回b 节点时,可知b 节点的取值必须小于等于23,也就是小于该节点得到的α 值。那么此时b 节点所在的整个分枝会被剪掉,算法直接返回b 的上一层,也就是a 节点。 294 | 295 | 算法总共会访问12 个节点,顺序为a - c - f - 43 - 12 - g - 32 - 31 - b - d - 20 - 23。 296 | 297 | ![](../../CS410-人工智能/imgs/1.png) 298 | 299 | *** 300 | 301 | ### 7. CSP问题 302 | 303 | #### 7.1 回溯算法:课件lecture5第18页,回溯的目的、算法流程,看懂了过程就行 304 | 305 | Backtracking search = DFS + two improvements 306 | 307 | * Idea 1: One variable at a time 308 | * Idea 2: Check constraints as you go 309 | 310 | #### 7.2 给元素安排值的顺序:most constrained variable,minimum remaining values(第29页) 311 | 312 | * Most constrained variable: choose the variable with the fewest legal values 313 | * a.k.a. minimum remaining values (MRV)heuristic 314 | * Most constraining variable: choose the variable with the most constraints on remaining variables. 对于其他变量限制最多的,就是影响最大的 315 | * Least constraining value: The one that rules out the fewest values in the remaining variables。使得其他的变量的可选value减少最少的value,就是对于其他变量影响最少的。(这个应该需要在更新的时候算一下其他变量的变化) 316 | 317 | #### 7.3 前向检查:前向检查的目的(第32页),前向检查的内容(弧相容性),前向检查的算法(AC3算法,44页开始)。关于AC3算法,可以参考第二次作业的第四题,重点是理解过程。 318 | 319 | * forward checking的idea 320 | * Keep track of remaining legal values for unassigned variables 321 | * Terminate search when any variable has no legal values 322 | * 但是,forward checking不能很早地detect failure 323 | * Arc consistency: 324 | * X $\rightarrow$ Y is consistent iff for every value _x_ of _X_ there is some allowed _y_ 325 | * Arc consistency detects failure earlier than forward checking 326 | * AC3: Enforce Arc Consistency of Entire CSP 327 | 1. 先给第一个着色 328 | 2. 然后把所有指向这个点的其他邻居的arc加入队列。 329 | 3. 出队,更新他们的feasible variable 330 | 4. 每当有一个点的feasible variable改变,都要把所有指向这个点的邻居的arc加入队列。 331 | * arc consistency的局限性:这是一个local的操作,可能会全局上并没有解!看61页的图。 332 | * 注意几个要点:(a)每个约束条件都需要形成两条弧,我们要分别检查其相容性(b)对于一条弧Xi → Xj ,我们需要满足的条件是对于Xi 值域中的任意值,Xj 值域中都存在符合约束的值(c)在完成检查弧Xi → Xj 后,如果Xi 值域有变化,需要添加指向Xi 的弧进入搜索队列,例如Xk → Xi 将被加入搜寻队列,但是Xi → Xk 无需加入。并且如果需要新添加的弧已经在搜索队列中了,就无须再次添加(d)在检查X1 → X2 的时候,由于D1 发生了变化,所以要将以X1 为终点的弧加入搜索列中,由于x1 → x2 已经被检查过了,故已经从搜索列中被去除,需要重新添加进入搜索列。 333 | 334 | #### 7.4 弧相容性:定义(第37页) 335 | 336 | * X $\rightarrow$ Y is consistent iff for every value _x_ of _X_ there is some allowed _y_ 337 | 338 | 339 | 340 | ## 第三部分 知识表示、自动推理 341 | 342 | ### 8. 一阶逻辑(first-order logic) 343 | 344 | 也叫propositional logic,命题逻辑 345 | 346 | #### 8.1 定义,在课件lecture7a第3页 347 | 348 | * Declarative 349 | * compositional 350 | * context-independent 351 | * Limited expressive power。不能表示比较复杂的逻辑关系。 352 | 353 | #### 8.2 逻辑符号,在课件lecture7a第7页,要能看懂 354 | 355 | * constant 356 | * Predicate 357 | * function 358 | * variable 359 | * connective 360 | * equality 361 | * quantifier 362 | 363 | ### 9. 知识表示 364 | 365 | #### 9.1 定义:课件8b第7页 366 | 367 | * 把知识转化为计算机可接受的符号,并以某种形式描述出来。如图表结构、语法树、规则匹配模式、树形或网状表达等 368 | * 知识表示就是知识的符号化过程。即把相关问题的知识加以形式化描述,表示成为便于机器(计算机)存储、管理和调用的某种数据结构模式 369 | 370 | #### 9.2 常见的知识表示系统:语义网络(课件23-24页)、专家系统(43页)、知识图谱(第65页),对以上概念做了解即可 371 | 372 | * 语义网络:语义网络结构共使用了三种图形符号:框、带箭头及文字标识的线条和文字标识线。分别称为: 373 | * 节点 374 | * 弧 375 | * 指针 376 | * 专家系统:两部分组成,知识库与推理引擎。它根据一个或者多个专家提供的知识和经验,通过模拟专家的思维过程,进行主动推理和判断,解决问题。 377 | * 知识图谱:知识图谱(Knowledge Graph)以结构化的形式描述客观世界中概念、实体及其之间的关系,将互联网的信息表达成更接近人类认知世界的形式,提供了一种更好地组织、管理和理解互联网海量信息的能力。 378 | 379 | ### 10. 不确定性知识与推理:贝叶斯网络 380 | 381 | #### 10.1 概率基础知识:在课件9a-1上,包括概率定义、贝叶斯公式、联合概率定义、条件独立定义 382 | 383 | #### 10.2 贝叶斯网络中的联合概率因子分解:课件9b-1第11-14页 384 | 385 | * 把一个联合概率用条件概率和chain rule分解一下就行。 386 | 387 | #### 10.3 马尔可夫毯定义、包含哪些节点:第16页 388 | 389 | * 包含父节点,子节点,子节点的co-parent 390 | * The Markov blanket of a node being the minimal set of nodes that isolates it from the rest of the graph. 391 | 392 | #### 10.4 贝叶斯网络中的条件独立判断:第20页。课件中和作业中涉及的例子都比较简单,如果想得到普适性的方法、研究较复杂网络结构中的条件独立关系可以参考该材料:http://web.mit.edu/jmn/www/6.034/d-separation.pdf 393 | 394 | * 父节点固定,使得2个子节点互相独立 395 | * A->B->C,B节点固定,使得AC独立 396 | * A,B是C的父节点,固定C,使得A、B相关 397 | 398 | #### 10.5 贝叶斯网络的推理:精确推理(消元法、信念传播、树算法),近似推理(贝叶斯网络采样)。课堂与作业主要涉及消元法与贝叶斯网络采样两部分。 399 | 400 | #### 10.6 消元法:课件36-47页,第三次作业第三题最后一问,重点是理解清楚过程。 401 | 402 | 第三次作业第三题的分析: 403 | 404 | (1)用链式法则乘起来就行 405 | 406 | (2)把一个变量的Markov毯中的变量固定 407 | 408 | (3)主要掌握三种结构,cascade, common parent, V-structure,已经在10.4部分阐述 409 | 410 | (4)消元法,就是把要消的变量改写,换成一个函数。 411 | 412 | #### 10.7 贝叶斯采样:课件lecture10的62页开始,包含先验采样、拒绝采样、似然采样、吉布斯采样四种。四种采样方式都要理解清楚完整的过程与概率计算。具体如何计算应当按照课件上标注的算法来。 413 | 414 | 一些重点:拒绝采样(何时拒绝、拒绝以后的操作)、似然采样(证据变量如何处理、likelihood如何计算)、吉布斯采样(何时采样、证据变量如何处理、采样哪些节点、条件概率如何计算)。建议把第三次作业第四题的解答看明白,肯定就理解清楚完整的采样过程了。 415 | 416 | 1. 先验采样:sample $x\_i$ from $P(X_i|Parents(X_i))$ 417 | 2. 拒绝采样:sample $x\_i$ from $P(X_i|Parents(X_i))$,并且如果不满足evidence则直接返回,重新采样(相当于做了个剪枝?) 418 | 3. 似然采样:拒绝采样并没有用到evidence这个先验,因此我们考虑似然采样。 419 | * 初始w=1 420 | * 如果x是evidence,$w=w\times P(x|parent(x))$ 421 | * 如果x不是evidence,sample $x\_i$ from $P(X_i|Parents(X_i))$ 422 | * 最后返回sample和weight,这个weight就是每个sample的weight 423 | 4. 吉布斯采样: 424 | * 维持一个状态,其中evidence是fixed 425 | * 每次采样需要考虑马尔科夫毯之类的节点,用条件概率算(看上去复杂一点,但也不难) 426 | * 每尝试一个状态就是一次采样 427 | 428 | ### 11. 不确定性知识与推理:HMM(时间上的概率推理) 429 | 430 | 这一块课件上的内容和算法都比较难,公式也很多,我们不会考察具体的算法中如何进行计算。能把涉及到的概念和作业题目理解即可。 431 | 432 | #### 11.1 HMM中的建模方式、基本概念:课件11第6页 433 | 434 | * 一些定义 435 | * observation space 436 | * transition probability $p(y\_t|y\_{t-1})$ 437 | * start probability $p(y\_1)$ 438 | * Emission probability $p(x\_t|y\_t)$ 439 | * 三个问题: 440 | * evaluation:给定HMM和sequence x,算sequence x的概率。用forward算法。 441 | * decoding:给定HMM和sequence x,算能够最大化sequence x的y的概率。用Viterbi,forward-backwarf算法。 442 | * 443 | 444 | #### 11.2 评价HMM中某个序列出现的概率:前向、后向算法 445 | 446 | - 一些定义 447 | - observation space 448 | - transition probability $p(y_t|y_{t-1})$ 449 | - start probability $p(y_1)$ 450 | - Emission probability $p(x_t|y_t)$ 451 | - 三个问题: 452 | - evaluation:给定HMM和sequence x,算sequence x的概率。用forward算法。 453 | - decoding:给定HMM和sequence x,算能够最大化sequence x的y的概率。用Viterbi,forward-backward算法。 454 | 455 | 456 | ### 11.2 评价HMM中某个序列出现的概率:前向、后向算法 457 | 458 | - forward:先用条件概率展开(主要通过图来看这些变量的关系),然后化简一下并用之前的定义的变量替代就行(emission probability, transition probability)。前向概率的定义得大概背一下:alpha包含了$x_1,...,x_{t}$和$y_{t}^k$的概率。就是给定1到t的显状态,求t时刻隐状态的概率。 459 | 460 | 461 | 462 | - backward: 给出一整个sequence x,计算$y_t=1$的概率。先分成两段,forward和backward。forward用之前的公式代替一些,backward用一个变量代替一下。 463 | 464 | 465 | 466 | ![](../../CS410-人工智能/imgs/2.png) 467 | * backward: 给出一整个sequence x,计算$y\_t=1$的概率。先分成两段,forward和backward。forward用之前的公式代替一些,backward用一个变量代替一下。 468 | 469 | ![](../../CS410-人工智能/imgs/3.png) 470 | 471 | - 第3次作业第5题 472 | 473 | #### 11.3 根据给定的明状态解码相应的隐状态:维特比算法,lecture 11 P37 474 | 475 | - 给定$x_1, x_2, x_T$, 我们想要找到使得$P(y|x)$最大化的$y=y_1, ..., y_T$ 476 | 477 | - 定义维特比概率: 478 | 479 | 480 | 481 | ## 第四部分 机器学习 482 | 483 | ### 12. 机器学习基础概念(课件12-1,这一块主要是要理解的概念) 484 | 485 | 1. 机器学习定义:第5页到第10页,理解即可、不要求完整记忆 486 | * “A computer program is said to learn from experience E with respect to some task T and some performance measure P, if its performance on T, as measured by P, improves with experience E.” 487 | 2. 机器学习分类:第21页,无监督学习、有监督学习、强化学习,他们给自的定义是什么、他们之间如何区分,我们课堂内讲的机器学习算法可以归入他们哪一类 488 | 3. 训练集、测试集:第24页,各自的定义、用来完成什么样的任务 489 | 4. 浅层学习(传统机器学习)与深度学习:第44-50页,深度学习的显著特征是什么 490 | * 浅层学习:linear regression, support vector machine, artificial neural network (with one hidden layer) 491 | * 深度学习:ANNs with more than one hidden layers,convolutional NNs, recurrent NNs, deep belief net, auto-encoders 492 | * 深度学习: automatic feature extraction 493 | 5. Bias-variance平衡:第59页,bias、variance代表什么,他们与什么因素有关 494 | * ![](../../CS410-人工智能/imgs/4.png) 495 | * bias: The bias is an error from erroneous assumptions in the learning algorithm. High bias can cause an algorithm to miss the relevant relations between features and target outputs (underfitting). 496 | * variance: The variance is an error from sensitivity to small fluctuations in the training set. High variance can cause an algorithm to model the random noise in the training data, rather than the intended outputs (overfitting). 497 | * The 3rd term is called the irreducible error, resulting from noise in the problem itself. 498 | 6. 模型泛化能力:第60页,通过结构风险最小化(SRM,Structural Risk Minimization)控制泛化能力 499 | 7. 正则化:64页与73页,L1与L2正则化是什么,他们适合用来完成什么样的任务 500 | * Using the L2 norm pulls directly towards the origin. 501 | * While using the L1 norm pulls towards the coordinate axes, i.e. it tries to set some of the coordinates to 0. 502 | * This second approach can be useful in a feature-selection setting. 503 | * L1正则化就是在loss function后边所加正则项为L1范数,加上L1范数容易得到稀疏解(0比较多)。L2正则化就是loss function后边所加正则项为L2范数的平方,加上L2正则相比于L1正则来说,得到的解比较平滑(不是稀疏),但是同样能够保证解中接近于0(但不是等于0,所以相对平滑)的维度比较多,降低模型的复杂度。 504 | 8. 交叉验证:留出法、留一法、k折交叉验证的区别(69-71页) 505 | * 留出法 (held-out data) 506 | * 从训练数据里拿10%-20%作为held-out data 507 | * 这一部分不是用来最终测试的,是模型在训练后,在held-out data做一下测试,选test error最小的模型 508 | * K-fold Cross Validation 509 | * 把训练数据分为k份,每次随机选一份用来测试,其他k-1份用来训练 510 | * 重复k次,最后选择具有average test error最小的。 511 | * Leave-One-Out (LOO) Cross-Validation 512 | * k-fold cross validation的特殊情况,每次只挑出一个作为test,所以一共重复n次。 513 | * 当n比较小的时候使用 514 | 9. 特征选择:原因(78页) 515 | * Some algorithms scale (computationally) poorly with increased dimension,维度更高计算更慢 516 | * Irrelevant features can confuse some algorithms,无关特征迷惑算法 517 | * Redundant features adversely affect regularization,冗余特征影响泛化性 518 | * Removal of features can increase (relative) margin (and generalization),移除可提高泛化性 519 | * Reduces data set and resulting model size,缩小数据集规模和模型规模 520 | 10. 过拟合、欠拟合的定义,如何解决过拟合与欠拟合问题(参考第四次作业第一大题的解答) 521 | 522 | 机器学习模型的过拟合:我们通过机器学习建立的模型对于训练数据拟合过当,导致其在训练集上的表现很好、但是在测试集与新数据上的表现较差。 523 | 524 | - 一般而言,导致机器学习模型过拟合的原因有: 525 | 526 | (a) 训练数据噪声过大、导致模型学习了太多与任务无关的信息; 527 | 528 | (b) 输入的数据样本不平衡,例如训练样本中绝大部份样本为标签为‘0’的负样本,导致模型学习到太多与单一类别相关的特征。 529 | 530 | (c) 设计的模型相对于数据量而言过于复杂、同样导致模型学习了太多无关信息; 531 | 532 | 533 | 534 | 535 | - 针对以上的原因,我们可以提出以下措施来避免过拟合: 536 | 537 | (a) 针对数据:获得更多的训练数据,从而减小噪声的影响,例如对于图像分类的问题,可以将某一张图像进行平移、旋转等方式扩充数据集,也可以通过GAN 来合成大量新数据(见课件lecture 14 第119 页)。 538 | 539 | (b) 针对数据:提供数据的质量,例如检查数据的正确性、标签的正确性、尽量保证标签类别的平衡。 540 | 541 | (c) 针对数据:对原始数据的特征进行特征选择(feature selection,见课件lecture 12 第77页),通过各种方法删除原始数据中的冗余特征。 542 | 543 | (d) 针对模型结构:可以尝试限制模型的复杂度,例如减少神经网络模型的网络层数、神经元个数等,降低决策树模型中的树的深度等。 544 | 545 | (e) 针对模型参数:对模型加入加入正则化方法(regularization,见课件lecture 12 第73 页):给模型的参数加入一定的正则化约束或者增大正则化的系数,通过正则化限制模型的复杂程度。 546 | 547 | (f) 针对训练:在训练过程中进行交叉验证(cross validation,见课件lecture12 第68 页),通过验证来检测过拟合现象、选择模型与参数。在训练过程中加入early stopping 机制(见课件13第33 页),限制神经网络训练的epoch 数目。 548 | 549 | 550 | 551 | 552 | - 机器学习模型的欠拟合:我们通过机器学习建立的模型在训练集上未学习到足够的特征与规律,从而使得模型在训练集与测试集上表现都很差。欠拟合现象的一般原因与过拟合现象相反,因此,我们可以通过以下方法来避免欠拟合的现象: 553 | 554 | (a) 针对数据:当特征不足或者现有特征与样本标签的相关性不强时,模型容易出现欠拟合,因此可以通过特征组合等方式,形成新的特征。 555 | 556 | (b) 针对模型结构:简单模型的学习能力较差,可以通过增加模型的复杂度来使得模型有更强的拟合能力。 557 | 558 | (c) 针对模型参数:正则化是用来防止过拟合的,但当模型出现欠拟合现象时,则需要有针对性地减小正则化系数。 559 | 560 | ### 13. 神经网络(课件13-1) 561 | 562 | (1)感知机的结构、神经网络的结构与神经网络中参数更新的方式:课件8-15页,结合第四次作业第二题,最好把完整的参数更新过程自己推一遍、加深理解 563 | 564 | (2)CNN:在图像(CV)领域应用非常成功 565 | 566 | (3)RNN:适合处理时序性数据,原始RNN可能会遇到梯度衰减或者梯度爆炸任务,LSTM解决了这个问题 567 | 568 | CNN与RNN这一块只需要简单了解即可、不要求推导。CNN与RNN这一块五花八门的模型(比如ResNet、VGG)啥的也不需要记忆。 569 | 570 | ### 14. 无监督学习(课件14) 571 | 572 | 1. 无监督学习任务举例:聚类、降维、自监督学习 573 | 574 | 2. 层次化聚类、Kmeans聚类、DBSCAN聚类的比较(参考作业) 575 | 576 | - 层次化聚类:$O(n^3)$。 577 | 578 | - 优点:简单直观,可解释性好,不需要提前假设任何超参数。 579 | - 缺点:时间复杂度高;对于噪声非常敏感 580 | 581 | - Kmeans: $O(ikn)$。 582 | 583 | - 优点:算法整体非常简单,时间复杂度小于层次化聚类;并且对于凸优化效果好。 584 | - 缺点:算法中一些超参数难以决定(cluster 数目k);cluster 的初始中心点位置的选取对于算法结果很重要;噪声对算法结果影响大;不能处理离散太大的分类;不能处理非凸数据集。 585 | - 过程:先随机放k个cluster中心,然后给每个point归入一个中心,然后再算新的中心的位置 586 | 587 | - DBSCAN: $O(n^2)$, 对于n 个点,需要通过计算其他点与该点的距离来确定该点是否为core point 588 | 589 | - 优点:对于噪声的容忍强,可以处理非凸集合,不用提前定义cluster 的数目k; 590 | 591 | - 缺点:要提前定义半径ϵ 与点数目minpts 等超参数。除此以外,dbscan 用固定参数识别聚类,但当聚类的稀疏程度不同时,相同的判定标准可能会破坏聚类的自然结构,即较稀的聚类会被划分为多个类或密度较大且离得较近的类会被合并成一个聚类。 592 | 593 | - 算法过程:几个需要知道的概念:directly density-reachable, density-reachable, density-connected, core point condition 594 | 595 | 596 | 597 | 3. PCA降维的目的、主元的选择标准 598 | - 是什么:Unsupervised technique for extracting variance structure from high dimensional datasets. 599 | - 主元:Principal Components (PC) are orthogonal directions that capture most of the variance in the data. First PC is direction of maximum variance. Subsequent PCs are orthogonal to 1st PC and describe maximum residual variance. 600 | 601 | ### 15. 强化学习(课件15) 602 | 603 | 1. 强化学习完成了定义、完成了什么任务 604 | 605 | 2. 马尔可夫过程(MDP)的定义(第12页),value/utility的定义,policy的定义 606 | 607 | 3. 马尔可夫决策过程:理解value iteration和policy iteration的计算过程,这一块很难,但是我们没有出相关的作业,可以在网上找个例子结合起来看。 608 | 609 | - Value iteration的计算:先初始化每个点的value。在每一轮迭代中,根据24页的公式计算每个点新的value。迭代结束后用22页上部分的公式计算每个点应当采用的最优策略 610 | 611 | - Policy iteration的计算:先初始化每个点的value。每一轮迭代中,根据28页上方的公式计算每个点的utility(value),这一步也被称为policy evaluation。然后根据课件27页的公式计算每个点在该轮迭代中应该采样的policy,这一步也被称为policy improvement。在结束迭代以后得到每个点的policy选择。 612 | 613 | 4. 用神经网络进行强化学习:了解即可 614 | 615 | 616 | 617 | 618 | -------------------------------------------------------------------------------- /da-san/cs410-ren-gong-zhi-neng/imgs/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/da-san/cs410-ren-gong-zhi-neng/imgs/1.png -------------------------------------------------------------------------------- /da-san/cs410-ren-gong-zhi-neng/imgs/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/da-san/cs410-ren-gong-zhi-neng/imgs/2.png -------------------------------------------------------------------------------- /da-san/cs410-ren-gong-zhi-neng/imgs/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/da-san/cs410-ren-gong-zhi-neng/imgs/3.png -------------------------------------------------------------------------------- /da-san/cs410-ren-gong-zhi-neng/imgs/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/da-san/cs410-ren-gong-zhi-neng/imgs/4.png -------------------------------------------------------------------------------- /da-san/cs410-ren-gong-zhi-neng/imgs/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/da-san/cs410-ren-gong-zhi-neng/imgs/5.png -------------------------------------------------------------------------------- /da-san/cs410-ren-gong-zhi-neng/imgs/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/da-san/cs410-ren-gong-zhi-neng/imgs/6.png -------------------------------------------------------------------------------- /元学习笔记.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YanjieZe/SJTU_Course_Notes/b5e3b2061f763c8e55d91fc767ce1dfa09a4d611/元学习笔记.pdf --------------------------------------------------------------------------------