> 2021年05月03日信息消化 ### 每天学点机器学习 #### Neural Network Applications ##### Examples and Intuitions I  因此,我们通过使用一个小型的神经网络,而不是使用一个实际的AND门来构建计算机中的一个基本操作。神经网络也可以用来模拟所有其他的逻辑门。 > So we have constructed one of the fundamental operations in computers by using a small neural network rather than using an actual AND gate. Neural networks can also be used to simulate all the other logical gates. ###### 随堂小测  ##### Examples and Intuitions II The $Θ^{(1)}$ matrices for AND, NOR, and OR are: $$ AND: \theta^{(1)} = [-30\ 20\ 20] \\ NOR: \theta^{(1)} = [10\ -20\ -20] \\ OR: \theta^{(1)} = [-10\ 20\ 20] $$  ###### 随堂小测  ##### Multiclass Classification 为了将数据分为多个类别,我们让我们的假设函数返回一个值的向量。假设我们想把我们的数据分为四个类别中的一个。我们将用下面的例子来看看这种分类是如何进行的。该算法将一张图片作为输入,并对其进行相应的分类: > To classify data into multiple classes, we let our hypothesis function return a vector of values. Say we wanted to classify our data into one of four categories. We will use the following example to see how this classification is done. This algorithm takes as input an image and classifies it accordingly:  ###### 随堂小测  ### 每天学点算法 #### 螺旋打印给定矩阵 | given matrix in spiral form This problem was asked by Amazon. Given a N by M matrix of numbers, print out the matrix in a clockwise spiral. For example, given the following matrix: ```python # Python3 program to print # given matrix in spiral form # https://www.geeksforgeeks.org/print-a-given-matrix-in-spiral-form/ def spiralPrint(m, n, a): k = 0 l = 0 ''' k - starting row index m - ending row index l - starting column index n - ending column index i - iterator ''' while (k < m and l < n): # Print the first row from # the remaining rows for i in range(l, n): print(a[k][i], end=" ") k += 1 # Print the last column from # the remaining columns for i in range(k, m): print(a[i][n - 1], end=" ") n -= 1 # Print the last row from # the remaining rows if (k < m): for i in range(n - 1, (l - 1), -1): print(a[m - 1][i], end=" ") m -= 1 # Print the first column from # the remaining columns if (l < n): for i in range(m - 1, k - 1, -1): print(a[i][l], end=" ") l += 1 # Driver Code a = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18]] R = 3 C = 6 # Function Call spiralPrint(R, C, a) # This code is contributed by Nikita Tiwari. ``` ### 其他值得阅读 #### 对努力的新理解 原文:[A new understanding of effort](https://www.scotthyoung.com/blog/?ck_subscriber_id=739575748) Effort as Opportunity Cost 这里的意思是,大脑有许多不同的功能中心。在你脑袋后面的部分,称为枕叶,处理视觉。在侧面,有音频处理和语言理解。 > The idea here is that the brain has many different functional centers. The part at the back of your head, called the occipital lobe, processes vision. At the side, there’s audio processing and language comprehension. #### 每个开发者都应该看到的令人印象深刻的源代码 原文:[Impressive Source Codes That Every Developer Should See](https://medium.com/swlh/impressive-sources-codes-that-every-developer-should-see-b68028b36da5) ##### Apollo 11 Guidance Program 阿波罗11号是首次成功地将人类送上月球的任务。阿波罗指导计算机(AGC)只有4千字节的物理内存,为控制航天器提供支持。AGC的软件是用AGC汇编语言编写的,存储在一个特殊的只读存储器中,称为*绳索存储器*。 > Apollo 11 was the first successful mission that sent humans to the moon. Apollo Guidance Computer (AGC) which had only 4 kilobytes of physical memory provided support for controlling the spacecraft. Software for the AGC was written in AGC assembly language and was stored into a special read-only memory called *rope memory*. There were scanned copies of the source code uploaded to the [internet](https://www.ibiblio.org/apollo/ScansForConversion/) some time ago. Thereafter, someone converted several modules into text files and uploaded them into a Github [repository](https://github.com/chrislgarry/Apollo-11). 阿波罗工程团队付出了巨大的努力,通过用汇编语言编写大量的代码行来达到这样一个惊人的成就。在1960年代,编程比现在更难。因为,在那个时候,编程语言的抽象程度较低。此外,程序员必须编写超级优化的代码以有效地使用硬件。 > The Apollo engineering team put a huge effort to reach such an amazing achievement by writing a lot of code lines in assembly language. In 1960s programming was harder than nowadays. Because, at that time, programming languages had a lesser level of abstraction. Besides, programmers had to write super-optimized codes to efficiently use hardware.  ##### Quake III Arena Quake III Arena是由id Software开发的第一人称射击游戏。它是在90年代开发的,当时3D游戏行业刚刚开始使用id Tech 3游戏引擎的旅程。当时的硬件资源非常有限,不像现在这样。因此,游戏开发者不得不编写精心优化的代码来渲染图形元素。许多游戏编程计算需要矢量归一化概念,这就带来了反平方根计算的要求。如前所述,开发者必须为这些计算机图形相关工作选择最有效的算法。因此,Quake III Arena团队使用了一种非常聪明的方法来进行快速的反平方根计算,如下面使用位级计算。 > Quake III Arena is a first-person shooter game developed by id Software. It was developed in the 90s when the 3D gaming industry just started its journey using the id Tech 3 game engine. At that time the hardware resources were very limited unlike nowadays. Therefore, game developers had to write carefully optimized code for rendering graphical elements. Many game programming calculations require the vector normalization concept that brings up the requirement of inverse square root calculation. As mentioned, developers had to choose the most efficient algorithms for these computer graphics related works. Therefore, the Quake III Arena team used a very clever approach for fast inverse square root calculation like below using bit-level computations. ##### GNU Compiler Collection C编程语言就像现代计算之父,因为它通过提供一个良好的人类可读的抽象水平,非常接近硬件。事实上,GNU C编译器是引导式的。换句话说,它是通过使用编译器引导概念在C编程语言本身中编写的。我注意到我所见过的最长的C源代码文件(可能有比这个更长的C源代码文件,但这是我看到的),来自Github上的GNU编译器集的代码库。 > The C programming language is like the father of modern computing because it resides very closer to the hardware also by offering a good human-readable abstraction level. Indeed, the GNU C compiler is bootstrapped. In other words, It is written in the C programming language itself by using the compiler bootstrapping concept. I noticed the longest C source file I ever saw (There can be longer C source files than this one out there, but this is the one I saw) from the codebase of GNU Compiler Collection on Github. ##### Chromium 流行的网络浏览器,如谷歌浏览器、微软Edge和Opera,都是基于Chromium开源项目,它有两个主要的依赖性。Blink渲染引擎是Webkit团队从KHTML/KJS的分叉中开发的WebCore库的分叉,以及Chromium项目团队开发的v8 JavaScript引擎。毋庸置疑,Chromium的代码库非常庞大,它也有很多第三方模块,比如gRPC和Skia。然而,Chromium团队以一种很好的方式组织了所有的组件。他们将用户界面相关的逻辑和内部功能逻辑明智地分开,以便在整个项目中实现非常好的可维护性因素。 > Popular web browsers such as Google Chrome, Microsoft Edge, and Opera are based on Chromium open source project which has two major dependencies: Blink rendering engine which is a fork of the WebCore library which was developed by the Webkit team from a fork of KHTML/KJS, and v8 JavaScript engine which is developed by the Chromium project team. Undoubtedly, Chromium codebase is very large and it is having a lot of third-party modules as well such as gRPC and Skia. However, the Chromium team structured all the components in a great manner. They have separated user interface related logic and internal functions logic wisely to achieve very good maintainability factors throughout the entire project. ##### Gitk 现在,Git几乎可以帮助每个软件开发团队管理编码历史和版本。Git最初是由Linux内核的创始人Linus Torvalds制作的。事实上,Git的代码库由一个神奇的作品组成,这就是Gitk的源文件。Gitk是一个GUI应用程序,可以帮助我们直观地浏览提交内容。我们可以用下面的CLI命令来检查两个提交的区别。 > Nowadays, Git helps almost every software development team to manage the coding history and versions. Git was initially made by the founder of the Linux kernel, Linus Torvalds. Indeed, Git's codebase consists of a magical piece of work which is Gitk’s source file. Gitk is a GUI application that helps us to visually navigate through commits. We can use the following CLI command to check the difference between two commits. ```bash $ git diff ``` 但是,Gitk允许我们如此快速地看到修改,因为它是一个可视化工具。Gitk 的整个源代码只有一个[文件](https://github.com/git/git/blob/master/gitk-git/gitk)。它是用Tcl脚本语言编写的,使用的是Tk UI-toolkit,这是Tcl的一个扩展。他们只用一个源文件就实现了整个GUI应用,而且还选择了一种动态编程语言来加快GUI应用的开发,这是一项伟大的工作。 But, Gitk allows us to see modifications so fast because it is a visual tool. Gitk’s whole source code is just one [file](https://github.com/git/git/blob/master/gitk-git/gitk). It is written in Tcl scripting language using Tk UI-toolkit which is an extension of Tcl. They have done great work by implementing an entire GUI app with just a single source file also by selecting a dynamic programming language for quicker GUI application development. ### 一些收获 - "在做不重要的事情上浪费的精力比在做没有效率的事情上浪费的精力多。消除是优化的最高形式"。"More effort is wasted doing things that don’t matter than is wasted doing things inefficiently. Elimination is the highest form of optimization."