关于算法:COMP222解答

COMP222 - 2022 - First CA AssignmentIndividual courseworkAsteroids-like GameAssessment InformationAssignment Number 1 (of 2)Weighting 12%Assignment Circulated Friday 4 February 2022Deadline Monday 28 March 2022, 17:00Submission Mode ElectronicLearning outcome assessed 2. An appreciation of the fundamental concepts associatedwith game development: game physics, game arti-ficial intelligence, content generation; The ability to implement a simple game using anexisting game enginePurpose of assessment To implement a simple 3D game using a game enginelibraryMarking criteria The marking scheme can be found in Section 3Submission necessary in order Noto satisfy Module requirements?Late Submission Penalty Standard UoL PolicyI enforce a “no error policy” in this module: If your code does not compile,your mark will be capped at 40%. Thus, you may get a higher mark for anincomplete solution than for an advanced sketch.1Figure 1: Before shooting asteroid Figure 2: After shooting asteroidObjectivesThis assignment requires you to implement a simple 3D game using the jMonkeyEnginelibrary. Optionally, you can use Unity 3D or Unreal Engine.Basic Game DescriptionThe objective of this assignment is to implement a game inspired by the classic arcade game“Asteroids”, see, for example, https://en.wikipedia.org/wiki...(video_game)and https://www.youtube.com/watch...The game is played on a rectangular “field” bounded by walls from above, below, left andright (the original game has no walls, but your game has). The game objects (“asteroids”)are positioned inside the field and can “float” in a linear movement (by translation). Whenan asteroid collides with a wall or another asteroid, it “bounces” (changes direction accordingto Newton Laws without gravity). A player controls a spaceship that is able to “fly” insidethe field and to “shoot” bullets. When a bullet strikes an asteroid, the asteroid “breaks”into a few smaller asteroids (at least 2 ) that float in directions and speeds different than thedirection and speed of the original (broken) asteroid. An asteroid can break into smaller onesat most 5 times, i.e. when an asteroid of minimum size gets shot by a bullet, the asteroiddisappears (is removed from the field). The player wins when all asteroids are removed fromthe field. The player loses when an asteroid collides with the spaceship.Figure 1 shows an example of the the game’s setup, i.e. within a field bounded by 4 walls,there exist 3 asteroids (large green balls) “floating” according to the blue vectors (arrows),as well as 1 spaceship (blue triangle) shooting towards one asteroid (red dashed line). Figureshows the effect of the bullet hitting an asteroid, i.e. it is removed from the game andreplaced by two smaller asteroids (smaller red balls) that float towards different directionsand speeds than the removed greed ball.2Marking SchemeThe assignment is split in a number of steps. Every step gives you some marks. You donot have to implement them in any particular order. Also, the steps below describe whatis expected from you in a bit more detail. It is up to you if you implement the followingfunctionalities using your game engine’s internal functions, or if you write your own functionsto do so. Neither choice will be favored with extra points.Step 1: Modeling the environment (10%)Model the playing field (4 walls), the asteroids and the spaceship. You can either use a 3Dmodeling tool like Blender or use the shapes of the game engine you implement the gamein. You must put at least 3 asteroids on the field, and exactly one spaceship. Make surethat the playing field is relatively large, i.e. if the size of the field does not facilitate smoothgameplay, marks will be removed.Step 2: Keyboard interaction (20%)In this step you should implement the control of the spaceship from input given by the humanplayer. Preferably the player should use the keyboard. However, using other input methods,such as the mouse, is not disallowed. The step is further divided into smaller sub-steps.Step 2.1: Implementing “fly” (15% / 20%)In this step you should implement the “flying” of the spaceship. The spaceship has someinitial direction and has its initial speed equal to 0. Assuming you take input from thekeyboard, you assign 4 buttons: button “forwards” increases the speed of the spaceshipalong the current direction; button “backwards” decreases the speed of the spaceship alongthe current direction; button “rightwards” rotates clockwise the direction of the spaceshipwith some fixed angular speed; button “leftwards” rotates counter-clockwise the direction ofthe spaceship with some fixed angular speed.Step 2.2: Implementing “shoot” (5% / 20%)In this step you should implement the “shooting” of the spaceship. Assuming you take inputfrom the keyboard, you assign 1 button “shoot” which releases a bullet from the positionof the spaceship and along the current direction of the spaceship. The speed of the bulletshould be relatively fast (at least faster than the spaceship). The amount of bullets is foryou to decide. The interaction of the bullet with the asteroids is described below in Step3.3.3Step 3: Physics 30% totalThe purpose of this step is to model the physical interaction of the game entities. The stepis further divided into smaller sub-steps.Step 3.1: Implementing “float” (5% / 30%)In this step you should implement the “floating” of the asteroids. They move linearlyaccording to a given initial direction and speed.Step 3.2: Implementing “bounce” (10% / 30%)In this step you should implement the “bouncing” of the asteroids. When an asteroidcollides with a wall, it should reflect off the wall. When two (or more) asteroids collide witheach other, they should reflect off each other. The bouncing should follow Newton’s Lawsand should not take gravity into account, because supposedly the game takes place in outerspace. When an asteroid collides with the spaceship, the player loses.Step 3.3: Implementing “break” (15% / 30%)In this step you should implement the “breaking” of the asteroids. An asteroid “breaks” intosmaller ones after it has collided with a bullet. “Breaking” means that the original asteroidis removed from the game and is replaced by 2 (or more) smaller asteroids. The direction andspeed of the smaller asteroids should be different than that of the removed asteroid. (I don’tpose any other restriction, it’s up to you how the smaller asteroids behave.) Also, breakingof an asteroid should be done at most 5 times, otherwise the game will never end. I.e. whenan asteroid of minimum size breaks, it is removed and not replaced by any asteroid(s).Step 4: Gameplay (20%)Add a visible points count and some kind of game levels. The point system is up to you todefine, for example every hit of a bullet with some asteroid gives 1 point, or you can have aspoints the percentage of bullets used to bullets that have hit asteroids. To get full marks forthis steps, you should have at least 2 levels and it should be clear when the player progressesto the higher level. Moreover, it is important that the levels have increasing difficulty. Howthis is achieved is again up to you, e.g. higher levels can have more asteroids, or fasterasteroids, or break into more asteroids, or can break more times, or combinations of theseoptions.Step 5: Creativity (20%)You can see that the marks for the steps described above add up to 80%. In order toget 20% extra you need to be creative and implement some nice features. Below are someideas: use textures, sound effects, lighting, power-up packs (making the spaceship immune4to impact with asteroids, or even able to function as a bullet itself), implement some systemon acquiring bullets, etc. Also, the above specifications do not define what happens if thespaceship or a bullet hits the wall. Typically, they should simply stop at the point of collision.However, you can be more creative here, and implement a weird bounce, or that they canexit the field from the point of collision and re-enter from the opposite side (like the originalgame).Deadlines and How to Submit Deadline for submitting the first assignment is Monday 28 March 2022, 17:00 Submission is via Canvas accessible fromhttps://liverpool.instructure... All submission must contain the source code, the executable, the necessary files for theruntime execution and a report.For jMonkeyEngine submissions you are advised to export your project (File →Export Project → To ZIP) and submit the ZIP file. Please ensure that the files yousubmit can be loaded into jMonkeyEngine.For Unity and Unreal Engine you are advised to build & export your game so thatit runs independently of these platforms; instructions are found online. To submit thecode you have scripted, copy it to a txt file. Please ensure that your submitted gameis playable.Please submit the report in the form of document (in pdf-format) containing acheck list indicating whether the above marking points have been implemented successfully.In the extra features part of the checklist, describe the features you haveimplemented.

January 2, 2023 · 7 min · jiezi

关于算法:MATH3161-matlab求解

THE UNIVERSITY OF NEW SOUTH WALESSCHOOL OF MATHEMATICS AND STATISTICSMATH3161/MATH5165–OPTIMIZATIONCLASS TEST 1TERM 1, 2020(1) TIME ALLOWED – 50 Minutes(2) TOTAL NUMBER OF QUESTIONS – 4(3) ANSWER ALL QUESTIONS(4) THE QUESTIONS ARE NOT OF EQUAL VALUE(5) ALL STUDENTS MAY ATTEMPT ALL QUESTIONS. MARKS GAINED ON ANYQUESTION WILL BE COUNTED. GRADES OF DISTINCTION AND HIGH DIS-TINCTION WILL REQUIRE SATISFACTORY PERFORMANCE ON ALL QUES-TIONS, INCLUDING STARRED QUESTIONS(6) THIS PAPER MAY BE RETAINED BY THE CANDIDATEAll answers must be written in ink. Except where they are expressly required pencils mayonly be used for drawing, sketching or graphical work.MATH3161/MATH5165–OPTIMIZATION CLASS TEST 1 Page 2 ...

January 2, 2023 · 2 min · jiezi

关于算法:MA117科学家分析

MA117 Programming for Scientists: Project 2 Deadline: 12pm, Friday 18th March 20221MA117 Project 2: Root FindingAdministrative Details• This project is the second of the three assignments required for the assessment in this course. It is tobe submitted by 12pm, Friday 18th March 2022. Details of the method of the submission via the Tabulasystem have been described in the lecture notes and are also available on the course web page.• This assignment will count for 35% of your total grade in the course.• The automated submission system requires that you closely follow instructions about the format ofcertain files; failure to do so will result in the severe loss of points in this assessment.• You may work on the assignment during the lab session, provided you have completed the other tasksthat have been set. You can always use the work areas when they are not booked for teaching. If youare working on the assignment on your home system you are advised to make regular back-up copies(for example by transferring the files to the University systems). You should note that no allowancewill be made for domestic disasters involving your own computer system. You should make sure wellahead of the deadline that you are able to transfer all necessary files to the University system and thatit works there as well.• The Tabula system will be open for the submission of this assignment starting from 28th February 2022.You will not be able to test your code for correctness using Tabula but you can resubmit your workseveral times, until the deadline, if you find a mistake after your submission. A later submission alwaysreplaces the older one, so you must re-submit all files.• Remember that all work you submit should be your own work. Do not be tempted to copy work; thisassignment is not meant to be a team exercise. There are both human and automated techniques todetect pieces of the code which have been copied from others. If you are stuck, then ask for assistancein the lab sessions. TAs will not complete the exercise for you, but they will help if you do notunderstand the problem, are confused by an error message, need advice on how to debug the code,require further explanation of a feature of Java or similar matters.• If you have more general or administrative problems e-mail me immediately. Always include the coursenumber (MA117) in the subject of your e-mail.MA117 Programming for Scientists: Project 2 Deadline: 12pm, Friday 18th March 202221 Formulation of the ProblemFinding the roots of a function is a classical and extremely well-known problem which is important in manybranches of mathematics. In Analysis II, you have probably seen that it is often easy to prove results aboutthe existence of roots. For example, using the Intermediate Value Theorem, you should easily be able toprove that the function ( ) = − cos has a root in the interval [0,1]. On the other hand, calculating anexact value for this root is impossible, since the equation is transcendental.Root finding is a classic computational mathematical problem, and as such there are many algorithms whichone may use to approximate the roots of a function. In this project, you will write a program which uses theSecant algorithm. 1.1 Secant FractalsOne of the most fascinating aspects of this problem arises from a very simple question: given two startingpositions !, " ∈ ℂ, which root does the sequence produced by Secant converge towards? It turns out thatthe answer to this question is very hard!Figure 1 shows two examples of how we might visualise this for the polynomial, − 1. Recall thatthe roots of this polynomial are % for = 1,2,3 (i.e. the third roots of unity). Each of the threecolours represents one of these roots. In the left-hand figure, we colour each point depending on which rootthe method converges to. The right-hand figure is the same, asides from the fact that we make the colourdarker as the number of iterations it takes to get to the root (within a tolerance) increases. The resultingimages are examples of fractals, which you have undoubtedly seen before.MA117 Programming for Scientists: Project 2 Deadline: 12pm, Friday 18th March 20223Figure 1: An example of fractals for the function, − 1 in thesquare with bottom left-corner −1 − and width 2.Don’t worry if all of this seems quite difficult – the main aim of the assignment is for you to successfullyimplement the Secant scheme. Most of the code to deal with drawing and writing the images will be givento you.1.2 SummaryYour task then involves several distinct elements. You will:• write a class to represent complex numbers• write a class to represent a polynomial in ℂ[]• implement the Secant method to find the roots of the polynomial• investigate some interesting fractals and plot some pictures!2 Programming instructions, classes in your code and hintsOn the course web page for the project, you will find the following files, which should serve as templates andshould help you to start with the project. As with the previous projects, the files have some predefinedmethods that are either complete or come with predefined names and parameters. You must keep all namesof public objects and methods as they are in the templates. Other methods have to be filled in correctlyand it is up to you to design them properly. Where a method returns a value, a placeholder will exist to returnzero or an empty class. The files define three basic classes for your project:• Complex.java: represents points ∈ ℂ;• Polynomial.java: represents polynomials in ℂ[];• Secant.java: given two initial Complex points !, " close to the root calculate the correspondingroot of Polynomial by Secant, if possible;− 1 1Re(z)− 11Im( z)− 1 1Re(z)MA117 Programming for Scientists: Project 2 Deadline: 12pm, Friday 18th March 20224• Project2.java: will generate a fractal similar to the one pictured above in a square.These classes are documented in more detail in the following sections. You should complete them in theorder of the following sections, making sure to carefully test each one with a main function.2.1 ComplexComplex is the simplest of the classes you will need to implement and will represent complex numbers. Infact, it bears a striking resemblance to the CmplxNum class you (hopefully) implemented in week 14.They are not identical however, so you should carefully when incorporating your solution to that into thisnew class.2.2 PolynomialThe Polynomial class is designed to represent a polynomial. As such, it containscoeff, an array of Complex coefficients which define it. It is assumed that coeff[0] corresponds to !,coeff[1] to " and so forth. To complete this class, you will have to: ...

January 2, 2023 · 11 min · jiezi

关于算法:PHAS0061分析

PHAS0061 Problem Sheet 3Please submit by 4pm on 8th March. How can it be argued that irreversible macroscopic behaviour, characterised by the second lawof thermodynamics and uncertain predictions of future behaviour, can arise in a world governedby reversible deterministic Newtonian mechanics? Use diagrams in your answer.Construct the probabilities of reaching points m = 0,±1,±2 in a symmetric random walk ofsteps starting from the origin where a particle becomes stuck at m = ±2 upon its first visit.[Hint, this can most easily be done with simple arithmetic or a probability branching diagram].Show that the probability of reaching one of these sticking points after precisely n steps isP (n) = 2?n/2 for n = 2, 4, 6, 8 and zero otherwise. Show that the mean number of steps takenup to sticking is 13/4. Confirm that if this pattern holds for all n then the probability ofsticking is unity if we wait long enough and once again determine the mean number of stepstaken up to sticking.In the ‘Ehrenfest Urn’ problem, a particle moves randomly on a grid of positions x = ma,with m an integer in the range ?L ≤ m ≤ L, and with timestep . The probability, when atposition m, of a step to the right m → m + 1 is T+(m) = 12(a) Evaluate the coefficientsM1?4 of the Kramers–Moyal equation for this process.(b) Take the continuum limit a → 0, → 0, L → ∞ such that a2/ → 2D and La2 → 22,where D and are constants, to show that the Fokker–Planck equation describing theevolution of the pdf p(x, t) is(c) At large times, such anOrnstein–Uhlenbeck process may be described by the time-independentpdf p(x,∞) = (2pi2)?1/2 exp(?x2/22). Verify that this expression satisfies the Fokker-Planck equation.(d) Roughly sketch the time evolution of the Gibbs entropy of a system undergoing an Orn-stein–Uhlenbeck process with initial condition p(x, 0) = (2)1 for ≤ x ≤ with. ...

January 2, 2023 · 2 min · jiezi

关于算法:CS-486686

CS 486/686 Assignment 3Winter 2022(135 marks)Blake VanBerloDue Date: 11:59 PM ET on Wednesday, March 23, 2022Changes v1.1: Small changes to hyperparameters in Q2.2a and Q2.b. Fixed some typos. v1.2: Fixed typos in function names v1.3: Instructions to calculate average cross entropy loss1CS 486/686 Winter 2022 Assignment 3Academic Integrity StatementIf your written submission on Learn does not include this academic integrity statement withyour signature (typed name), we will deduct 5 marks from your final assignment mark.I declare the following statements to be true: The work I submit here is entirely my own. I have not shared and will not share any of my code with anyone at any point. I have not posted and will not post my code on any public or private forum or website. I have not discussed and will not discuss the contents of this assessment with anyoneat any point. I have not posted and will not post the contents of this assessment and its solutionson any public or private forum or website. I will not search for assessment solutions online. I am aware that misconduct related to assessments can result in significant penalties,possibly including failure in the course and suspension. This is covered in Policy 71:https://uwaterloo.ca/secretar...Failure to accept the integrity policy will result in your assignment not being graded.By typing or writing my full legal name below, I confirm that I have read and understoodthe academic integrity statement above.?Blake VanBerlo 2022 v1.3 Page 2 of 12CS 486/686 Winter 2022 Assignment 3Instructions Submit any written solutions in a file named writeup.pdf to the A3 Dropbox on Learn.If your written submission on Learn does not contain one file named writeup.pdf, wewill deduct 5 marks from your final assignment mark. Submit any code to Marmoset at https://marmoset.student.cs.u...Grades for the programming component are determined by the unit tests in the “As-signment 3 (Final)” project on Marmoset The “Assignment 3 (Week 1)” and “As-signment 3 (Week 2)” projects contain ungraded public test suites meant to help youdebug, and they are only temporarily available. No late assignment will be accepted. This assignment is to be done individually. I strongly encourage you to complete your write-up in LaTeX, using this source file.If you do, in your submission, please replace the author with your name and studentnumber. Please also remove the due date, the Instructions section, and the Learninggoals section. Thanks! Lead TAs:– Question 1: Xuejun Du (xuejun.du@uwaterloo.ca)– Question 2: Sharhad Bashar (sharhad.bashar@uwaterloo.ca)The TAs’ office hours will be scheduled on MS Teams.Learning goalsDecision Trees Compute the entropy of a probability distribution. Trace the execution of the algorithm for learning a decision tree. Determine valid splits for real-valued features. Apply overfitting prevention strategies for decision trees.Neural networks Implement a multilayer perceptron Implement the backpropagation algorithm including the forward and backward passes Understand and interpret performance metrics in supervised learningBlake VanBerlo 2022 v1.3 Page 3 of 12CS 486/686 Winter 2022 Assignment 31 Decision Trees (35 marks) ...

January 2, 2023 · 5 min · jiezi

关于算法:MACM-203解码

MACM 203 Assignment 6Spring 2022This assignment is due Tuesday March 8th at 10pm. Upload your solutions to Crowdmark.Write your solutions as a single Matlab Live Script and export the script to PDF.Write the course number and assignment number as the title of the Matlab Live Script,followed by the table of contents, and then create a section for each part of the question.Keep in mind that your assignment, including the source code, is a document that willbe read in order to be marked. It has to be very clear and properly formatted.Your Matlab code must be general enough to solve any other instance of the same problemwithout modification. That is, if you are asked to run your code on some data that arespecified in the assignment, then your code must run on any similar data set (or solveany similar problem) without modification.Assignments should be written individually. You can discuss in groups, but you have towrite your assignment yourself. In case of plagiarism SFU policies will be applied.PreambleThis week’s assignment focuses on linear optimization.Question 1 (20 marks)In the current semester, the Top of the Mountain University (TMU) offers C courseslabelled 1, 2, . . . , C. The enrollment (number of students) in each course is given in therow vector E. That is, E(i) is the number of students taking course i. Each course has afinal exam.The university is about to schedule the final exams, and it hires you as a consultant todesign an optimal schedule of the exams. TMU students like to write their exams earlyon in the examination period, as writing exams at earlier dates effectively extends thelength of the semester break that follows after the exam period. The exams are written inS different time slots numbered 1, 2, . . . , S and scheduled in that order. The waiting timeperceived by one student when writing an exam is the number of the slot in which theexam is written (any slot 1 exam has waiting time 1, any slot 2 exam has waiting time 2,etc.) Therefore a course with enrollment of e students that has the exam scheduled inslot s generates waiting time e · s.Certain pairs of courses can not have their exams scheduled in the same slot becausethere are students taking both courses. This information is represented by matrix A which1is C × C upper triangular matrix with zeros on the main diagonal, such that A(i, j) = 1if courses i and j can not have exams in the same slot, and A(i, j) = 0 otherwise.The objective of the optimal schedule is to minimize the total waiting time, which isthe sum of waiting times of all courses, subject to the scheduling constraints defined inthe previous paragraph.Example. Suppose that C = 3, E = [37, 29, 51], S = 2 andA =0 0 10 0 00 0 0 .That is, courses 1 and 3 have scheduling conflict, and there are no other conflicts. Theoptimal solution is to schedule exams 2 and 3 into slot 1, and exam 1 into slot 2, atthe total waiting time 37 · 2 + 29 · 1 + 51 · 1 = 154. Another feasible solution is toschedule exams 1 and 2 into slot 1, and exam 3 into slot 2, at the total waiting time37 · 1 + 29 · 1 + 51 · 2 = 168. This solution is not optimal since the total waiting time isnot minimized.Part (a)Given C, S, E, A as above, write MATLAB code that finds an optimal schedule. Youcan assume that the problem is solvable (feasible solutions exist). As a first test of yourcode, use it to solve the example given above.Hints: ...

January 2, 2023 · 4 min · jiezi

关于算法:pat-1004dfs

简略搜寻题,次要相熟python语法。通过字典,一个父结点对应多个儿子结点,进行贮存。代码: mp={}mm=0#记录最大层数record=[0 for i in range(101)]def dfs(s,level): global mm if level>mm: mm=level if s not in mp:#没得儿子的 record[level]+=1 return for i in mp[s]: dfs(i,level+1)n,m=map(int,input().split())if n==0: exit()for i in range(m): s=input().split() fa=s[0] mp[fa]=[] for j in s[2:]: mp[fa].append(j)dfs("01",0)for i in range(mm): print(record[i],end=" ")print(record[mm])

December 29, 2022 · 1 min · jiezi

关于算法:AIGC用于智能写作的技术综述达观数据

导语图1. ChatGPT生成的对于智能写作的介绍 智能写作指应用自然语言解决技术来主动生成文本内容。这种技术通过剖析给定语料库,学习文本的构造和语法,而后利用这些信息来生成新的文本。智能写作能够用来疾速生成高质量的文本内容,并且能够用来实现诸如文章写作、报告生成和摘要提取等工作。 图1为咱们介绍了智能写作的基本概念,而令人意想不到的是,这一段介绍的作者竟是AI自身!这一段AI主动生成的“自我介绍”既富裕逻辑条理,又论述了正确的常识,这便是当下最炽热的AIGC技术的威力! 什么是AIGC?AIGC,即AI-generated Content,基于AI的内容生产,它是利用人工智能进行内容创作的形式,它被认为是继PGC(Professionally-generated Content)、UGC(User-generated Content)之后的新型内容创作形式。AIGC在文本、图像和音视频等多畛域都正在高速倒退,近年来诞生了许多主打AIGC的创作体验平台,用户能够输出一句话让AI合成一张与形容关联的图片,或者更为常见的是输出一句文章的形容,或仅仅是一句故事的结尾,让AI替你实现文章的续写。智能写作在咱们的日常办公中具备相当好的落地前景,例如新闻写作、诗歌春联、故事写作、广告文案、金融报告、行政文书等办公场景,这些场景都有相干智能写作产品失去利用,能够看到智能写作技术可能为包含资讯、金融、广告、政法等各行各业的从业者提供便捷且高质量的文本写作服务,帮忙人们更快地了解和剖析简单的信息,从而帮忙人们更好地做出决策,产生重要的价值。这所有生产力进步的愿景正在逐渐成为事实,背地起因是技术的倒退和晋升,下图为笔者整顿的AIGC用于智能写作的相干技术倒退脉络。图2. 文本写作的相干重要技术 文本写作技术在很长一段时间里以RNN Seq2Seq为主,倒退缓慢,而当Transformer模型构造问世后,这一畛域的技术倒退迅速暴发,围绕着Transformer的文本写作技术喷涌而出,包含微软亚洲研究院、谷歌AI、Facebook AI、OpenAI等诸多国内出名钻研机构都纷纷投入,先后诞生了UniLM(2019)、MASS(2019)、T5(2020)、BART(2020)、GPT系列(2018-2022)等多个影响力显著的研究成果。本文将沿着这条技术倒退脉络,从传统的智能写作到现在的前沿钻研为读者做具体的论述,并为大家介绍达观数据的智能写作产品实际。 智能写作相干技术背景01工作定义 在深刻理解相干技术之前,咱们先对文本写作工作进行一个数学上的形式化定义。文本写作工作的外围是生成一个字符串组成的序列Y = (y1,...,yi,...,yn ),其中yi∈,是一个给定的词汇表。在大多数状况下,文本写作须要以输出作为条件进行生成,输出的数据可能是文章主题,或者是文章的结尾句等等,咱们用X示意输出。基于以上定义,文本写作工作建模能够示意为P(Y|X)  = P(y1,...,yi,...,yn |X),其中P示意概率分布函数。 02数据集 写作工作公开的评测数据集,在英文上有CommenGen、ROCStories、WritingPrompts等若干数据集,而在中文上有Couplets、AdvertiseGen等若干数据集,数据集的概述见表1。表1. 文本写作工作相干评测数据集 03评测指标 文本写作工作需要量身定制的指标可能对技术的优劣进行评测,通常写作的好坏会从四个角度进行度量: 晦涩度(fluency):生成文本的晦涩水平;真实性(factuality):生成文本在多大程度上反映了语境;语法(grammar):生成文本的语法正确性;多样性(diversity):生成的文本是否具备不同的类型或款式。通常此类工作的评测最好的形式当属人工,然而人工评测的老本微小,为此,业界设计了以下几种主动评测的量化指标,这些指标通常是量化生成文本和参考文本之间的类似度。比拟罕用的有基于词汇和基于语义的类似度度量。 3.1 基于词汇基于词汇的度量是掂量单词或短语单元的重合度,而后聚合到整体句子级类似度,包含: BLEU-n,计算生成文本和参考文本的n-gram单元的重合度,最为宽泛应用的是BLEU和BLEU-2Self-BLEU,用来掂量生成文本的多样性,即在多条不同的生成文本之间计算BLEU值,Self-BLEU越小则多样性越强;ROUGE-n,同样是计算生成文本和参考文本的ngram单元的重合度,不同点在于BLEU是重合n-gram数/生成文本n-gram数,而ROUGE是重合n-gram数/参考文本n-gram数,因而能够看做召回版本的BLEU;Perplexity(PPL)和Reverse PPL,PPL是在参考文本上训练语言概率模型,而后用它计算生成文本的概率,概率越高则示意生成文本越晦涩;而Reverse PPL则是在生成文本上训练语言概率模型,而后反过来计算参考文本的概率,概率越高则示意生成文本越多样。3.2 基于语义相比基于词汇的形式,基于语义能够把字面不类似而语义类似的状况也纳入考量,是一种更贴近人工评测的形式,这其中包含:dssm,利用深层语义类似模型别离将生成文本和参考文本映射到一个低维语义示意空间,并计算生成文本向量和参考文本向量的间隔;BERTscores、BERTr、YiSi等,近年来涌现的基于预训练模型的评测办法,利用BERT的embedding示意代替n-gram,计算生成文本和参考文本的相似性。 04重要技术脉络图3. 文本写作的相干重要技术图3列举了文本写作畛域中局部影响力较大的相干技术。在很长一段时间里文本写作是以基于RNN的Seq2Seq模型为支流技术,如图4所示,其由两个RNN网络组成,第一个RNN是编码器,第二个RNN是解码器。模型先以循环单元将输出文本编码到隐向量,后再通过循环单元程序逐字解码,程序解码时将上一单元输入和上一单元隐向量同时作为解码器的输出。RNN Seq2Seq生成的文本品质通常欠佳,时常伴有语法错误或语意不明的问题,次要起因是其逐字程序编码解码过程引起的误差传递和放大。 图4. RNN Seq2Seq模型示意图 图5. Transformer模型 随着2017年Transformer模型构造(见图5)的问世,世人惊叹于其弱小的捕获超长距离依赖的特色示意能力,并且因为Transformer能够并行处理序列的个性,训练效率相比RNN也大幅晋升,于是文本写作算法钻研投入也极速地向Transformer歪斜,随之孕育而生了一系列的预训练模型(见表2),时至今日曾经成为文本写作技术的支流前沿代表。下文将为读者重点一一论述。 表2. 文本写作的相干预训练模型概述 AE=自编码;AR=自回归;SLM=规范语言模型;CTR=受损文本重建;NSP=下一句预测;FTR=全文重建。 前沿技术介绍当下文本写作的支流前沿技术是从不同类型、结构组件和预训练任务中衍化的若干种预训练模型。本节内容将为读者做重点介绍。 01UniLM UniLM的全称是Unified Language Model,是2019年微软亚洲研究院提出的生成式BERT 模型,和传统的Seq2Seq不同的是,它只用了BERT,没有Decoder局部。它汇合了L2R-LM(ELMo,GPT),R2L-LM(ELMo)、BI-LM(BERT)以及Seq2Seq-LM几个其余模型训练的形式,所以叫Unified模型。图6. UniLM模型概览 UniLM的预训练分为三个局部,Left-to-Right、Bidirectional以及Seq-to-Seq(见图6)。对于这三种形式,不同点只是Transformer的mask矩阵的改变而已: 对于Seq-to-Seq,前一句对后一句的Attention被mask,这样一来前一句只能关注到本身,但不能关注到后一句;后一句每个词向其之后的Attention被mask,只能关注到其之前的词;对于Left-to-Right,Transformer的Attention只关注这个词自身以及后面的词,前面的词不做关注,所以mask矩阵是下三角矩阵;对于Bidirectional,Transformer的Attention关注所有的词,并且蕴含NSP工作,和本来的BERT一样。在UniLM的预训练过程中,三种形式各训练1/3的工夫,相比原始BERT,其增加的单向LM预训练增强了文本示意能力,而其增加的Seq-to-Seq LM预训练也使UniLM可能很好地胜任文本生成/写作的工作。02T5T5的全称是Text-to-Text Transfer Transformer,是2020年谷歌提出的模型构造,其总体思路是用Seq2Seq文本生成来解决所有上游工作:如问答、摘要、分类、翻译、匹配、续写、指代消解等。这个形式可能使所有工作共享雷同的模型,雷同的损失函数和雷同的超参数。 图7. T5思维框架 T5的模型构造是基于多层Transformer的Encoder-Decoder构造。与其余模型的次要区别是,GPT系列是仅蕴含Decoder构造的自回归语言模型(AutoRegressive LM),BERT是仅蕴含Encoder的自编码语言模型(AutoEncoder LM)。图8. T5预训练指标示例 T5的预训练分为无监督和有监督两个局部: 1.无监督局部 无监督局部是采纳相似BERT的MLM办法,不同的是BERT是mask单个词,而T5是mask一段间断的词,也就是text span。被mask的text span只用单个mask字符替换,也就是说对于mask后的文本而言,mask的序列长度也是不可知的。而在Decoder局部,只输入被mask的text span,其它词对立用设定的<X>、<Y>、<Z>符号替换。这样做有三个益处,其一是加大了预训练难度,显然预测一个长度未知的间断text span是比预测单个词更难的工作,这也使得训练的语言模型的文本示意能力更有普适性,在品质较差的数据上的微调适应性更强;其二是对于生成工作而言输入的序列就是长度未知的,T5的预训练很好适配了这一个性;另一个益处是缩短了序列长度,使得预训练的老本得以升高。T5所采纳的这种预训练任务也被称为CTR(Corrupted Text Reconstruction,受损文本重建)。 2.有监督局部 有监督局部采纳GLUE和SuperGLUE中蕴含的机器翻译、问答、摘要、分类四大类工作。外围是Fine-tune时把这些数据集和工作合在一起作为一个工作,为了可能实现这一点它的思路是给每个工作设计了不同的prefix,与工作文本一起输出。举例说翻译工作,把英语的“That is good.”翻译为德语,那么训练时就输出“translate English to German: That is good. target: Das ist gut.”,而预测时则输出“translate English to German: That is good. target:”,模型输入预测“Das ist gut.”。其中“translate English to German:”便是为此项翻译工作增加的prefix。 ...

December 29, 2022 · 3 min · jiezi

关于算法:全国中文纠错大赛达观冠军方案分享多模型结合的等长拼写纠错

参加工作中文拼写查看工作是中文自然语言解决中十分具备代表性和挑战性的工作,其本质是找出文本段落中的错别字。这项工作在各种畛域,如公文,新闻、财报中都有很好的落地利用价值。而其工作的艰难水平也赋予了它十分大的钻研空间。达观数据在CCL2022汉语学习者文本纠错评测较量的赛道一中文拼写查看(Chinese Spelling Check)工作中获得了全国冠军,赛道二中文语法纠错(Chinese Grammatical Error Diagnosis)工作中取得了亚军。本文基于赛道一中文拼写查看工作的内容,对较量过程中采纳的一些办法进行分享,并介绍较量采纳的技术计划在达观智能校对零碎中的利用和落地。赛道二中文语法纠错的获奖计划曾经分享在达观数据官网公众号中。 本次中文拼写查看的工作是检测并纠正中文文本中的拼写错误(Spelling Errors)。拼写工作包含:音近,形近,音形兼近。特点是谬误内容与被替换内容长度雷同,这也意味着输出语句与输入语句的长度雷同。图1 音近字谬误示例 在上述图1形容的案例中,输出句中的“干”是一处近音字的谬误应用,应被替换为正确的“赶”,从而失去输入句子。 图2多字谬误示例 这种工作在理论利用中会遇到一些艰难。1. OOV(out of vocabulary)的问题会重大影响模型成果。首先,模型不可能纠错出没有在训练中见过的表达方式;其次,模型会因为在训练中没有见过相干实体而将他们错纠。2. 如上图2所示,当一个句子存在多处谬误(糊涂两个字都错了),纠错时会受到上下文的影响,也就是受到其余谬误的影响导致难以纠错胜利。 纠错零碎如图3所示,纠错零碎顾名思义是以一个零碎流程的形式进行纠错工作。咱们的零碎为串联式,共有五个步骤。首先,咱们对根底模 型进行预训练和微调,而后进行多轮纠错式推理,第三步是应用训练好的困惑度模型进行误召回查看,第四步则是应用实体纠错办法对于相干实体再次审核,最初应用精度很高但召回较低的Ngram语言模型进行再一次的补充。具体内容的介绍将会在该模块下逐个开展。 图3 拼写纠错计划流程图拼音编码根底模型  图4 拼音编码模型构造 不同于惯例的BERT模型,这次工作中,咱们增强了模型对属于文本拼音的辨认,这样能够针对性高空对近音字问题。如图4所示,除了惯例的Embedding Layer,也就是字符的编码外,咱们还退出了拼音输入。咱们借鉴了DCN (Wang et al., 2021)中采纳的编码方法,每一个拼音组合首先会被编码成一个举世无双的整数,输出模型中。而后,将拼音通过Convolutional layer后的矩阵与文本通过Embedding Layer之后的矩阵相加,再输出到Attention中,以此强化拼音编码在模型中的权重。不同于DCN中只在Embedding阶段将拼音编码与字符编码相组合,咱们借鉴了DeBERTa (He et al., 2020)中所提及的Disentangled attention办法,此过程将在每一次的Transformer encoder中进行反复。在模型训练方面,咱们借鉴cbert (Liu et al., 2021)中文拼写查看模型,在大规模语料中进行训练和微调,对于无标注数据则采纳混同集主动生成数据的办法进行结构。cbert是基于混同集结构的bert模型,因为咱们须要大量未标注数据来扩充模型训练的数据量,应用混同集来生成纠错谬误对变得尤为要害。而cbert所表述的办法与咱们的要求统一,所以咱们采纳了该办法。在除了拼音编码的局部之外,模型其余结构和base bert (Devlin et al., 2019)的构造雷同。共有12个transformer层,hidden units的大小为768,attention head共有12个。而输入层则是拼接了一个输出维度为768,输入维度为单词数量的全连贯层。最终再应用Softmax计算出每个备选单词的概率。 多轮纠错零碎图5 多轮纠错计划模型构造 在中文拼写查看畛域,解决同一句话存在多个谬误的问题始终是一项重要的挑战。其起因是存在谬误的上下文会对预测产生影响。在之前的工作中,CRASpell (Liu et al., 2022)通过在训练时随机在错字四周生成新的错字来模仿单句多错字的环境,但这种办法也会对数据的实在散布产生影响。个别的Transformer类纠错模型,会在每个地位返回其概率最大的字,如果存在多个错字,也将一并返回。而咱们对此提出了多轮纠错的办法。如上图5所示,具体来说,如果一句话中存在多个谬误,在模型预测阶段,咱们每次只选取预测谬误概率最高的字,将其更正后放回原句,再进行第二轮的纠错,直到不再呈现新的谬误的句子。图6 多轮纠错-每一轮纠错后果示例 以上方图6为例,第一轮纠错模型将“珈”纠错成“蒻”字,在第二轮再把“草头弱”纠错成“咖”,最初因为“咖”对于上下文的补充,原本无奈纠出的“琲”也被以十分高的概率胜利纠错成“啡”。该办法将所有单句多错字问题转换成了单句单错字问题,使得训练与预测的工作更具备一致性,散布更加对立,并且没有抛弃任何输出信息。 困惑度缩小误召回误召回问题同样是中文拼写查看中面临的挑战。因为纠错工作实质是选取地位上概率最高的字,所以会不断呈现”用正确的字替换正确的字“的状况。咱们通过比照句子批改前后的困惑度来缩小误召回的状况 (Bao, 2021)。 该办法次要由以下几个步骤组成: 针对一句话,将每个字顺次[MASK]。例如:我在吃饭。将被MASK成四个sequence:[MASK]在吃饭,我[MASK]吃饭,我在[MASK]饭,我在吃[MASK]。将上述四个句子通过tokenizer编码后输出进模型。返回所有[MASK]字符对于原字的预测概率。一整句话也就变成:[P1, P2, ..., Pn]为这组概率计算一个整体分数:故此,socre较大的句子较socre较小的句子更为不通顺。 图7 句子困惑度示例 上述图7中的例子显示,模型将“我晓得他很忙,没有工夫跟我分割。”误纠成“我晓得他很忙,没有工夫跟我练习。”,因为输出句自身就是通顺的句子,所以困惑度并未因而回升,这个误召回的状况也就能够被胜利缩小。该办法对于纠错的整体性有着针对性的进步,会缩小呈现句子局部纠错正确但未全副纠错正确的状况,弊病是对于字符级别的纠错性能可能带来损失。 实体纠错当错字呈现在诸如人名、地名、作品名的实体上时往往惯例的纠错模型计划很难达到优异的体现,因为纠错模型的学习工作里不蕴含辨识实体的能力,而语料也不能笼罩所有可能的实体名,所以未免会呈现在实体上的错纠或漏纠。 图8 实体纠错示例 以上方图8为例,第一条样例是把日本的地名[绳文杉]错纠成[绳文彬],这是因为模型不具备绳文杉是个地名的常识,而[文彬]的字词组合在模型输入中概率更高;第二条样例是漏纠了[格得战记]的谬误,正确的作品名是[格德战记],这是因为模型学习语料中没有笼罩这个作品名称。为了解决实体误纠、漏纠的问题,咱们训练了命名实体辨认模型,模型构造是以Bert base (Devlin et al., 2019)加CRF的序列标注模型。预测时将实体词典和命名实体辨认模型进行肯定策略排布。 ...

December 29, 2022 · 2 min · jiezi

关于算法:如何撰写一份完善的数据标注规则文档

在数据标注我的项目中规定文档是必不可少的,该文档是标注团队和算法团队达成统一规范的一份协定,让咱们来看看数据标注规定文档有哪些要点,以及如何撰写一份欠缺的文档。 需要背景 您的算法团队务必要论述数据标注的AI利用需要背景和指标,这样一来,标注团队能够更好地了解为什么要这样标注而防止诸多了解一致,比如说,您心愿您的主动驾驶AI可能准确地辨认路线上的汽车和行人,而且您须要预测被遮挡的物体边界,这就为前面的标注内容做好了铺垫,为什么须要”脑补“标注以及为什么2D突围框要紧贴指标…… 标注范畴 算法团队要表白分明本人的技术需要不能仅仅停留在口头上,必须将所有细节落到白纸黑字上,标注团队能够很分明地通过文档随时查问标注细节,防止忘记和脱漏,哪些指标是须要被标注的,而那些是不须要的,请在标注范畴中阐明标签的品种和废除数据,这里是一份模仿的标注范畴文档供您进行参考。 规范文档范畴阐明 这份范畴阐明文档仅是长期模仿的一个参考样例,理论标注过程中,该文档应该更全面,比方对于标签的阐明最好有配图从而让标注团队打消歧义,在标注范畴和不标注范畴中尽可能定义所有非凡状况。 标注阐明 标注阐明是您定义如何应用标注工具对数据进行标注的过程,咱们以激光点云标注为例,您至多应该阐明标注的精密度,因为激光点云出于设施的限度,通常无奈齐全捕捉到物体边界,这时候您必须阐明标注工具应该紧贴点云标注,或者通过常识或标准对指标的尺寸进行”脑补“,在上文中咱们提到,您的需要背景当中该当阐明这种状况的起因,因为您的AI模型须要对指标的尺寸进行预测,所以标注团队也会牢记这一点。 疑难问题文档 通过疑难问题文档以问答的模式收集标注过程中的所有非凡状况解决是必要的,这为标注团队节俭了很多工夫。很多时候,您的内部人员在测试标注时,曾经发现了许多标注阐明无奈齐全笼罩到的边界状况,尽管您可能曾经在标注阐明中提到了,然而疑难问题局部更适宜口语化表白,问答的模式也有助于标注团队也能更好地了解其含意,这里是一份对于交通灯数据标注我的项目的模仿的疑难问题文档供您参考。 数据标注的疑难问答文档 验收规范 数据标注实现后,您将对数据进行查验以确认是否合乎您的规范,标注团队也会根据此规范做为品质治理的根底,这将有助于标注团队匹配最适宜的质检计划,您须要阐明您的验收形式,全检或是随机抽样查看、抽样检查的比例以及所需达到的准确率、查看的最小元素(以图片为单位或是以标注元素为单位),用一个指标检测标注的案例举例来说:您须要抽样检查30%的图片,以2D边界框作为最小元素,边界框准确率应达到98%。 交付格局 当数据标注团队实现了所有数据标注流程,须要将数据进行返回时,通常状况下标注团队须要对数据集格局进行解决,您须要提供残缺的交付格局样例并阐明每个字段的含意,这里有一份很简略的模仿的JSON文件供您参考: {"img": "1.jps", // 图片名称"anno_tags": ["apple","banana","orange"], // 分类标签"valid": True, // 图片是否蕴含无效信息} 为了减速您的AI迭代,请抉择冰山数据 当初越来越多的AI公司正在为数据标注而苦恼,从而抉择与业余的第三方公司进行单干,冰山数据是一家全球化的数据标注公司,帮忙企业一站式提供AI数据服务,包含各种类型的数据采集和数据标注服务,咱们通过自营+寰球联盟的模式提供各类数据标注专家从而满足各种丰盛的数据标注类型,同时咱们也打造了高度流程自动化的数据标注平台,从而让简单的数据标注流程变地更简略。 明天起,抉择与冰山数据单干并晋升您的AI迭代速度,请通过冰山数据官方网站分割咱们。

December 29, 2022 · 1 min · jiezi

关于算法:CS257系统架构

CS257 Advanced Computer ArchitectureCoursework Assignment1 IntroductionThe purpose of this coursework is to give you some hands-on experience in codeoptimisation. By the time that you read this you will have encountered a varietyof code optimisation techniques including loop unrolling and vectorisation.2 SubmissionYour submission will consist of two parts: Optimised Code (70%)A piece of C code based on the initial implementation provided. This Ccode will be assessed with respect to your selection and understanding ofoptimisations, functional correctness, i.e., producing the right answer, andexecution speed.Written Report (30%)A report (3 pages maximum, excluding references) detailing your designand implementation decisions. Your report will be evaluated with respectto your understanding of code optimisation techniques and the optimisationsyou attempted. This means that your report should explain:(a) which optimisations you used/didn’t use;(b) why your chosen optimisations improve performance; and(c) how your chosen optimisations affect floating-point correctness.Given that you may apply many different optimisations, a sensible approachis to build your solution incrementally, saving each partial solution and documentingthe impact of each optimisation you make. This means that it is inyour interest to attempt as many different optimisations, or combinations ofoptimisations as you can.You may discuss optimisation techniques with others but you are not allowedto collaborate on solutions to this assignment. Please remember that theUniversity takes all forms of plagiarism seriously.1Introduction to ACACGSACSCGS is a conjugate gradient proxy application for a 3D mesh. The simulationwill execute for either a fixed number of timesteps, or alternatively untilthe residual value falls below a given threshold. This is done for a given meshsize, which is passed in at runtime through command line arguments.In this proxy application, a force is applied to each edge boundary of thecuboid, which is then propagated throughout the mesh. As each time steppasses, the force is dissipated within the mesh, until the amount of residual issignificantly small that the simulation stops (as there is no more calculations toperform), or a set number of time steps have passed.In addition to providing numeric solutions, the code can also generate visualswhich depict the pressure within the mesh throughout the simulation run.Creating the visualisations relies on two optional packages, Silo and VisIt, whichare available on the DCS systems.Figure 1: Pressure Matrix Visualisation2Compiling and Running the CodeThe code includes a makefile to build the program. You can compile all of thecode using the command make. You may modify the makefile if you wish to,but please ensure you include it with your submission. If you do not include amakefile, then the default one will be used.While the DCS machines do include a version of gcc, it is preferable to use amore recent version. On the DCS systems, you can make version 9 the defaultby using the ‘module load gcc9’ command. Once this is loaded you can simplytype ‘make’ to build the code, which will create an executable named ‘acacgs’in the directory.To run the code, you need to provide the three dimensions for the meshas three parameters to the executable. For example to execute the providedcode on a small 10x10x10 mesh you would enter ‘./acacgs 10 10 10’. On mysystem the output for the code is below. This information is also stored in afile, which is named after the wallclock date and time of when the program wasfirst executed (for example, 2022 01 26 12 00 00.txt).===== Final Statistics =====Executable name: ./acacgsDimensions: 10 10 10Number of iterations: 149Final residual: 2.226719e-92=== Time ==Total: 1.126600e-02 secondsddot Kernel: 8.390000e-04 secondswaxpby Kernel: 1.087000e-03 secondssparsemv Kernel: 9.123000e-03 seconds=== FLOP ==Total: 9.536000e+06 floating point operationsddot Kernel: 5.960000e+05 floating point operationswaxpby Kernel: 8.940000e+05 floating point operationssparsemv Kernel: 8.046000e+06 floating point operations=== MFLOP/s ==Total: 8.464406e+02 MFLOP/sddot Kernel: 7.103695e+02 MFLOP/swaxpby Kernel: 8.224471e+02 MFLOP/ssparsemv Kernel: 8.819467e+02 MFLOP/sDifference between computed and exact = 1.110223e-15You will find more detailed instructions to build the code in the README.mdfile, including flags to turn on verbose mode, which will output details for eachtimestep in the simulation, and flags for enabling visualisation.34.1 Visualisation GenerationTo enable visualisation outputs, you must build your code using ‘make SILO=1’.This will then compile your code in a way which produces files suitable forvisualisation in VisIt. If you are working remotely and want to visualise thecoursework, it will be quicker and easier for you to copy the files to your localmachine, then utilise VisIt on the local machine to visualise the cuboid. Beforeyou make the program, make sure you load the SILO module (module loadcs257-silo).When the program is ran with visualisations, each timestep will produce aSILO file within a directory named after the wallclock date and time (for example:01 26 12 00 00). In this directory will be a collection of .silo files,each named outputXXXX.silo, where XXXX represents the timestep it relates to.Once the program has finished, these can be utilised in Visit. To do so,load the VisIt module (module load cs257-visit) and open VisIt using thecommand visit. From here, you will get 2 windows. The smaller, skinner oneis the control window and is used to manage everything that will be displayed.The larger window is the display window. In the control window, select Open,and navigate to the directory with the SILO files. You should then be able toselect these SILO files.Now that the SILO files have been loaded, we can now draw some givenvariables. To do this, click on the Add and select a mode and a variable thatshould be viewed. One of the nicest ones to use is Volume and either x nodalor p nodal. When you have finished adding elements, click on Draw. This willgenerate an image in the display window, that can be dragged around so thatthe cuboid can be viewed from different angles. The control window has a playbutton, which will run through each timestep.Visualisations are nice to have, but for performance purposes we turn them offas they write a significant amount fo data to disk.Table 1: Visualisation Data File Sizesx y z Cells Approximate Data Size10 10 1000 4MB25 25 15,625 39MB50 50 125,000 301MB100 100 1,000,000 2.4GB200 200 8,000,000 19.3GBThere is the potential to go significantly over your DCS disk quota withlarge meshes. I recommend that you do not exceed 30x30x30 for producingvisualisations on the DCS machines. If you are developing your solution onyour personal machine then you may wish to produce larger visualisations.4Hardware DetailsOn a linux system, you can read the processor information using the command“cat /proc/cpuinfo”. This will provide full details on the cpu in the machine,including the CPU model, number of cores, the clock frequency and supportedextensions. I strongly recommend taking a look at this on your developmentmachine.For the purposes of assessment, your code will be run on a DCS machinewith 6 cores. The output from /proc/cpuinfo for a single core can be seen below:processor : 5vendor_id : GenuineIntelcpu family : 6model : 158model name : Intel(R) Core(TM) i5-8500 CPU @ 3.00GHzstepping : 10microcode : 0xcacpu MHz : 799.987cache size : 9216 KBphysical id : 0siblings : 6core id : 5cpu cores : 6apicid : 10initial apicid : 10fpu : yesfpu_exception : yescpuid level : 22wp : yesflags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmovpat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gbrdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopologynonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmxsmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbepopcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm3dnowprefetch invpcid_single intel_pt ssbd ibrs ibpb stibp tpr_shadow vnmiflexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcidrtm mpx rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 dtherm ida aratpln pts hwp hwp_notify hwp_act_window hwp_epp md_clear spec_ctrlintel_stibp flush_l1dbogomips : 6000.00clflush size : 64cache_alignment : 64address sizes : 39 bits physical, 48 bits virtualpower management:Machines matching this specification are available in the cs257 queue of the5Batch Compute System in the Department. You will learn how to use thissystem during the lab sessions, so there will be time to get used to it.How will my code be tested for performance?Your submission will be tested on a range of input sizes to evaluate how robustyour performance improvements are. It is recommended that you try testingyour solution on inputs that are not cubes to see if there are any weaknesses inyour optimisation strategies. The 7-pt stencil option will not be used for testingyour code.Your code will be executed five times for each problem size on the targethardware. The highest and lowest runtimes will be discarded, and the mean ofthe three remaining values will be taken as your runtime for that problem size.RulesYour submitted solution must:• Compile on the DCS workstations.Your submitted solution must not:• Use instruction sets not supported by the DCS machines.• Require additional hardware e.g., GPUs• Add relaxed math options to the compile line, e.g., -ffast-math. Note:Manual use of approximate math functions is acceptable.Where do I start?This can seem like a daunting project, but we can break it down into a numberof steps.Compile and run the code as provided. This is a quick easy check to makesure your environment is setup correctly.Read the code. Start in main.c and follow it through. The functionsare well documented with Doxygen comments. Don’t panic - you are notexpected to understand the physics in the code.Measure the runtime of the code for reference purposes.Figure our where the most intensive sections of code are.Develop a small optimisation.Run the code and review the impact of your changes.Repeat steps 5 and 6 until you have exhausted your performance ideas.6Instructions for SubmissionYour solution should be submitted using Tabula. Please ensure that your codeworks on DCS machines prior to submission.Submission deadline: Noon, Wednesday 16th March 2022.Files required: A single file named coursework.zip which should containall of your code at the top-level (i.e. no subdirectories) and the report file as aPDF.

December 28, 2022 · 8 min · jiezi

关于算法:COMP534-预测

COMP534 Lab session21/02/2022 This is an example you can use to work through loading, fixing, plotting, and predictingon some data. The instructions may not be exact, and the snippets of code may havesmall errors – be prepared to search for what seems to be missing. I have suggested using PyCharm as a python development environment, but feel free to useanything else you are more familiar with. I also suggest conda as a package and environmentmanager, but it is not the only option. ...

December 28, 2022 · 9 min · jiezi

关于算法:CSC-B07软件设计

CSC B07 Software DesignExercise 31 Logistics Due date: 11:59pm Thursday 19 November 2015 Group size: Individual Topics: Design PatternsFor the rules and procedures for the exercises, including how to submit, please see the Exercises page of thecourse website.2 What to do for this exercise Your individual svn repository now contains a new directory called E3. It contains the starter code forthis exercise. Checkout and study the starter code.Complete/implement Java classes Product, Shopper, and PriceWatchWebsite that obey the specifi-cations below and the descriptions in the starter code.To submit your work, add and commit your changes to your repository.Do not commit the files and directories generated by Eclipse, such as bin, doc, .project, etc. Markswill be deducted if you submit these.Specifications for Product, Shopper, and PriceWatchWebsiteYour task is to implement Product, Shopper, and PriceWatchWebsite classes.3.1 Class ProductA Product has a name, a price, and a store. Class Product is an Observable and has these methods: A constructor. Getters for name, price, and store. A method changePrice that changes the price of a Product and notifies all its observers. Hint: Thinkcarefully of how you can use the class PriceChange provided in the starter code. A method toString that returns a String of the form:PRODUCT at STORE costs PRICE.\nwhere PRODUCT, PRICE, and STORE are the name, price, and store of the product. In the return String,the price should be formatted to 2 decimal places. Here is an example of formatting a string in Java(see documentation for String.format):String priceFormatted = String.format("%s costs %.2f", name, price);13.2 Class ShopperA Shopper has a name. Class Shopper is an Observer and has these methods: A constructor. A getter for name. An update method that prints a message when a Product that the Shopper is observing changes. Themessage is of the form:SHOPPER: price change of PRODUCT on DATE at STORE to PRICE.\nwhere SHOPPER, PRODUCT, DATE, STORE, and PRICE are the shopper’s name, product’s name, date andtime of price change, store, and new price (to 2 decimal places). Note that DATE is the date andtime when the price change occurred, not when this information was received by Shopper.DATE should be formatted according to the standard described in the documentation ofJava class Date. Hint: Think carefully of how you can use the class PriceChange provided in the startercode.3.3 Class PriceWatchWebsiteA PriceWatchWebsite has a URL. Class PriceWatchWebsite is an Observer and an Observable, and hasthese methods: A constructor. A getter for URL. A method update that prints a message when an object that the website is observing changes. Themessage is of the form:You are subscribed to URL.Price change of PRODUCT on DATE at STORE to PRICE.\nwhere URL, PRODUCT, DATE, STORE, and PRICE are the website’s url, product’s name, date and time ofprice change, store, and new price (to 2 decimal places) respectively. DATE is formatted exactly asdescribed above.This method also notifies its observers of the change.ChecklistHave you. . . tested your code on the lab computers using Java 1.7? run checkstyle on all of your code? committed the correct files in the correct directory? verified that your changes were committed using svn list and svn status? checked the pre-marking results, made any necessary changes, and re-committed if necessary?

December 28, 2022 · 3 min · jiezi

关于算法:CSI-2120原则原理

Partie Concurrente (Go) 8 pointsIn the Go version of your project, we ask you to concurrently run the DBSCAN algorithm on partitionsof the Trip Record data. To create these partitions, you will divide the geographical area into a grid ofNxN. The following figure illustrates the case of a partition made of 4x4 cells:Pour la version Go de votre projet, nous vous demandons d’exécuter, de façon concurrente, l’algorithmeDBSCAN sur des partitions des données de courses de taxis. Afin de créer ces partitions, vous devezsubdiviser le secteur géographique en une grille de NxN cellules. L’exemple ci-dessous montre unepartition composée de 4x4 cellules :In this case you would then have to run 16 concurrent DBSCAN threads. The first step will therefore beto assign each GPS coordinate to its partition. This is the Map step. But since you will have to combineall your results, you need to slightly expand each of your cell by adding an eps value around it. This waythe clusters of adjacent cells will eventually intersect.For example if you have a grid cell delimitated by the GPS points (xmin, ymin) and (xmax,ymax), you willaccept all points located inside the expanded cell (xmin- , ymin- ) and (xmax+ , ymax + ). This means thatsome points will be assigned to more than one partition (refer to figure on the next page).Once the clusters identified in each partition using DBSCAN, the last step will be to combine the resultsto produce a global clustering. This is the Reduce step. CSI 2120 page 8_Avec une subdivision telle que montrée à la page précédente, vous auriez à lancer 16 fils concurrentsDBSCAN. La première étape sera donc d’attribuer chaque coordonnée GPS à sa partition. Toutefois,puisque ces résultats seront éventuellement combinés, vous devrez élargir chacune des cellules en yajoutant une valeur eps de tous les côtés. De cette façon, les groupes de cellules adjacentes pourrontéventuellement s’intersecter.Par exemple, si vous considérez une cellule délimitée par les points GPS (xmin, ymin) et (xmax,ymax), vousaccepterez tous les points à l’intérieur de la cellule élargie (xmin- , ymin- ) et (xmax+ , ymax + ).Conséquemment, certains points se retrouveront à l’intérieur de deux partitions.Une fois les groupements de points identifiés dans chacune des partitions, la dernière étape consistera àcombiner les résultats afin de produire un groupement global.Algorithme généralThe parallel DBSCAN algorithm proceeds then as follows:Map the data into overlapping partitions (the overlap with other partitions must be at leastequals to eps along its border)Apply the DBSCAN algorithm over each partition.Reduce the results by collecting the clusters from all partitions. Intersecting clusters must bemerged.This algorithm is based on the MapReduce pattern, widely used in concurrent programming.We already explained Step 1. For Step 2, you simply use the regular DBSCAN algorithm but, veryimportant: you must not use the same IDs in different partitions. In the regular algorithm, new clustersare assigned a label that corresponds to the current cluster count, here you have to add an offset thatwill make sure you will not have duplicate labels. For example, for a new cluster in partition (i,j), theoffset could be (10 000 000 i + 1 000 000 j), assuming there are less than 1000000 clusters perpartition. CSI 2120 page 9_What about Step 3? The principle is simple: we have clusters for each individual partition but since onecluster can cover more than one partition, the intersecting clusters have to be merged. To do so, we justhave to consider the points that belong to two adjacent partitions (i.e. the ones located inside the addedmargin around the cell), if this point is associated with two clusters (one from each grid cell), then thesetwo clusters must be merged. However, in this part of the comprehensive assignment, you do not have toprogram this step. We will leave to a later exercise…L’algorithme parallèle du DBSCAN procède comme suit :Distribuer les données à travers les partitions. Ces partitions doivent s’intersecter d’une valeur aumoins égale à epsilon.Appliquer l’algorithme DBSCAN sur chaque partition.Réduire les résultats par la collecte de tous les groupements de toutes les partitions; les groupesen intersection doivent être fusionnés.Cette approche se base sur le modèle MapReduce largement utilisé en programmation concurrente.L’Étape 1 a déjà été expliqué dans la section précédente. Pour l’Étape 2, il s’agit de simplement utiliserl’algorithme DBSCAN sur chacune des partitions. Mais, il est important de ne jamais utiliser le mêmeidentificateur (ID) de groupes à travers les différentes partitions. Dans la version régulière del’algorithme, chaque nouveau groupement se voit attribuer un ID égal au décompte courant du nombrede groupements. Ici, chaque partition ajoutera une constante à ce nombre afin de ne pas dupliquer lesIDs. Par exemple, pour la partition (i,j), cette constante pourrait être (10 000 000 i + 1 000 000 j);cette formule sera valide si les partition contiennent moins de 1000000 de groupements.Qu’en est-il de l’Étape 3? Le principe est simple : nous avons obtenu les groupements pour chacune despartitions mais certains groupes s’étendent sur plus d’une partition. Pour ce faire, il suffit de considérerles points appartenant à plus d’une partition (c’est-à-dire ceux situés sur les régions d’intersection entrepartitions). Si un de ces points est associé avec deux groupements différents (un dans chaque cellule)alors ces deux groupements doivent être fusionnés. Toutefois, dans cette partie du projet intégrateur,cette étape n’a pas à être programmée. Laissons cela à un exercice ultérieur…Le producteur et le consommateurWe ask you to implement a concurrent version of the DBSCAN algorithm that will be based on theproducer-consumer pattern.The producer will be in the main thread and will simply send jobs to a channel; each job being aclustering to be done on one partition of the data. The job instance will include a slice of GPScoordinates and the value of the parameters required to execute the DBSCAN algorithm on this set ofpoints (minPts, eps, offset).All the jobs are processed by a certain number of consumers, each running in its own thread. When aconsumer is done with one job, it then consumes the next job. When there is no more job to consume,then all consumer threads terminate. Remember that your implementation must include Step 1 and Step 2 but you do not implement Step 3.Nous vous demandons de réaliser la version concurrente de l’algorithme DBSCAN en vous basant sur lepatron de design producteur/consommateur.Le producteur devra être dans le fil principal et sera simplement chargé d’envoyé les tâches à réaliser àun channel. Ici, une tâche (job) correspond à l’application du DBSCAN sur les données d’une partition.L’instance d’une tâche doit donc contenir un slice de coordonnées GPS et les valeur requise pourexécuter l’algorithme sur cet ensemble de points, soient minPts, eps, et la valeur constante pour les IDs.Toutes ces tâches sont traitées par un certain nombre de consommateurs, chacun s’exécutant dans sonpropre fil. Lorsqu’une tâche est terminée, la tâche suivante est consommée. Lorsqu’il n’y a plus detâches à effectuer, alors tous les fils consommateurs se terminent.Rappelez-vous que seules les Étapes 1. et 2. sont à réaliser. L’étape 3. n’est pas à faire.ExpérimentationIn order to determine the optimal configuration for your concurrent algorithm, we ask you to performthe following experiments and report the execution time for each case: N=2 and 4 consumer threads N=4 and 4 consumer threads N=4 and 10 consumer threads N=10 and 4 consumer threads N=10 and 10 consumer threads N=10 and 50 consumer threads N=20 and 10 consumer threads N=20 and 50 consumer threads N=20 and 200 consumer threadsAlso specify the operating system and the specifications of your processor (including the number ofcores). You can also add your own experiences with other configuration settings.For all your experiments, use eps=0.0003 and minpts=5Afin de déterminer la configuration optimale pour votre algorithme concurrent, nous vous demandonsd’effectuer les expériences suivantes : N=2 et 4 fils consommateurs N=4 et 4 fils consommateurs N=4 et 10 fils consommateurs CSI 2120 page 11_ N=10 et 4 fils consommateurs N=10 et 10 fils consommateurs N=10 et 50 fils consommateurs N=20 et 10 fils consommateurs N=20 et 50 fils consommateurs N=20 and 200 fils consommateursPour chacune de ces expériences vous devez spécifier le temps d’exécution ainsi que le systèmed’exploitation et les spécifications du processeur de la machine utilisée (incluant le nombre de cœursprésents dans ce processeur). Vous pouvez aussi expérimenter d’autres configurations.Pour toutes vos expériences, utiliser eps=0.0003 et minpts=5.En plus de votre code source bien commenté, vous devez aussi soumettre un document donnant lesrésultats des expériences que vous avez réalisées. Remettre aussi les fichiers montrant l’affichage à laconsole obtenu pour les différentes exécutions de votre programme.

December 28, 2022 · 7 min · jiezi

关于算法:COMP3223解密算法

Toni Lassila Due 07/03/2022School of ComputingUniversity of LeedsCryptography (COMP3223)Coursework 1 Submit electronically through Minerva by Monday 7th March 09:00amExercise 1: Eve intercepts the following cryptotext and the information that the plaintext is in English, encoded with the26-character alphabet (a = 0, b = 1, etc.), and encrypted with the Vigenere cipher:a) Write a short program (e.g. in Python) that reads the cryptotext y and computes the Index of Coincidence:IC(y) = 1n(n − 1)Xa∈BH(a)(H(a) − 1),where H(a) is the absolute frequency of the letter a ∈ B in the string y and n is the length of the string. Includethe source code of your program in your answer. [3 marks]b) Divide the cryptotext into d columns yd,i by taking every dth letter starting from the ith letter. Compute IC(yd,i)for key lengths d = 1, 2, 3, 4, 5 and columns i = 1, . . . , d. [2 marks]c) Apply the index of coincidence -test to the values of IC(yd,i) and deduce what is the most likely key length d usedin the Vigenere cipher. [2 marks]Exercise 2: Let G be any group with finitely many elements. Prove that there exists a positive integer m such that for allelements a ∈ G we haveam = a ◦ a ◦ . . . ◦ a | {z }m times= e,where e is the neutral element of G. [6 marks]Exercise 3: Alice and Bob use a block cipher such as DES for secure communication.a) The 3DES cipher involves three rounds of DES applied successively with a total key length of 168 bits. Explain why4DES using four rounds of DES does not increase the security compared to 3DES when the attacker has access toa known plaintext-ciphertext pair and explain the method of attack. [4 marks]b) Alice and Bob use DES in the cipher block chaining (CBC) mode. Suppose that during transmission, one bit in thei’th ciphertext block Ciis flipped. How many plaintext blocks will be affected during decryption and how? Justifyyour answer by appealing to the definition of the CBC operation mode. [3 marks][TOTAL: 20 marks]Page 1 of 1 ...

December 27, 2022 · 2 min · jiezi

关于算法:COMP26020图形方法

COMP26020 - Lab exercise for Part III (Compilers)Register Allocation using Graph ColouringBackgroundComputer programs, regardless of the programming language, often use many more variablesthan the number of variables that can fit in all CPU registers. When a program is compiled forexecution on a given processor, the compiler needs to consider what variables will stay inregisters and for how long. If we think that moving data from the memory takes several cycles,there is a performance benefit if the compiler can minimise such transfers. How to do this? Bydoing some ‘clever’ register allocation, for example, by making sure that the most frequentlyused variables are placed in registers.To understand the problem, consider the following piece of code:In this piece of code, the programmer has used 9 variables. However, does this mean that 9registers are needed? To find the answer, let us define the notion of a live range. For any givenvariable, there is a live range that starts from the point where a value is assigned to this variableand lasts until the last time this particular value is used. Note that if a new value is assigned tothe same variable, a new live range starts. For example, a value for r2 is defined in instruction 2.The last time it is used is in instruction 5, hence, the live range is between 2 and 5. However, ifinstruction 4 was r2=z, the live range would be from 2 to 3 and another live range would start atinstruction 4 and end at instruction 5.To practice, you may want to find all live ranges of the code above. The answer is given:r1:[1,9], r2:[2,5], r3:[3,8], r4:[4,5], r5:[5,7], r6:[6,7], r7:[7,8], r8:[8,9], r9:[9,9].Live ranges are important because they indicate how many values need to be live at any giveninstruction. For example, the live ranges above tell us that at instruction 6 four values need to belive. Clearly, the maximum number of values that need to be live at any instruction indicateshow many registers we need to have so that all values (live ranges) can be placed in registers.However, most importantly, live ranges can guide register allocation: two live ranges that do notoverlap or interfere can use the same register. For example, with the live ranges above, r2 andr6 can share the same register as the corresponding values are needed (or are ‘live’) at differentparts of the code. Different algorithms have been developed to find how to allocate different liveranges to registers. This problem is known as register allocation. It is an NP-complete problem,which means that most of the different solutions proposed over the years are based onheuristics. For additional information you can find more in Chapter 13 of the ‘Engineering aCompiler’ recommended textbook:Among the different approaches, register allocation using graph colouring is a commonapproach. In register allocation using graph colouring, live ranges are used to create aninterference graph. In this graph, every live range corresponds to a node. There is an edgebetween two nodes if the live ranges overlap. Then, register allocation becomes equivalent tothe problem of graph colouring. This is a well-known graph theory problem where the aim is tocolour all nodes of the graph so that two adjacent nodes do not share the same colour. Typicallythe goal is to find the smallest number of colours. Every colour corresponds to a register and thecolour of a node corresponds to the register that should be used for a particular live range.There are various algorithms to colour a graph. Here, we are going to focus on a simplealgorithm, which is known as top-down colouring. The algorithm works as follows: ...

December 27, 2022 · 5 min · jiezi

关于算法:ENSC462数字工程

ENSC462: SPECIAL TOPICS IN ADVANCED DIGITAL SYSTEMS ENGINEERING© Anita Tino 2022 1Lab3: Auto-Adjust Brightness ControllerObjective: Design an auto-adjust brightness core. Students will develop a Serial Peripheral Interface (SPI)controller to interface the FPGA (master device) to an ambient light sensor chip. The Zedboard’s LEDs willauto adjust their illumination based on the lighting conditions applied to the sensor chip. Students will useBus Functional Models (BFM) and testbenches to verify their design thoroughly, and on the day of theirdemo, test that their design is correct using the physical sensor chip.Fig. 1 (a): Structural Overview of a SPI Controller (Wikipedia) Fig. 1 (b): Timing Diagram of the SPI protocol (Wikipedia) ...

December 27, 2022 · 10 min · jiezi

关于算法:COMP27112视学计算

Introduction to Visual ComputingCoursework Assignment 1Simple ShadingTim MorrisIntroductionThe aim of this exercise is to render a spinning, shaded cuboid on screen. You’ll need a webbrowser to display the output and a simple text editor1 to create the html files you’ll need.This and the other pieces of coursework are each worth 7.5% of the unit’s assessment, thismeans you should spend no more than about 7.5 hours (a day?) on each one.Getting StartedThe following code will set up a basic webpage for using three.js. Type it into your chosentext editor, save it as an html or htm file and load it into a browser. You should see verylittle – a blank page with no title. This skeleton will also be the starting point of the lab 2exercise. Note that if you copy and paste this, the quotation marks will change and thehyphen will be removed, so the code won’t work.<html><head><style> body { margin 0; overflow: hidden; }</style></head><body><script type = “module”>import * as THREE from“https://web.cs.manchester.ac....”; ...

December 27, 2022 · 5 min · jiezi

关于算法:CMSC-678机器学习算法

Assignment 2CMSC 678 — Introduction to Machine LearningDue Wednesday March 9th, 11:59 AMItem SummaryAssigned Monday February 21Due Wednesday March 9thTopic Loss Functions and Multiclass Classification (I)Points 95 (+15 Extra Credit)In this assignment you will become comfortable with the math of loss-based optimization; and implement,experiment with, and compare multiple types of multiclass classifiers.You are to complete this assignment on your own: that is, the code and writeup you submit must beentirely your own. However, you may discuss the assignment at a high level with other students or on thediscussion board. Note at the top of your assignment who you discussed this with or what resources youused (beyond course staff, any course materials, or public Piazza discussions).The following table gives the overall point breakdown for this assignment.Theory App.: ClassificationQuestion 1 2 3 4 5Points 20 35 5 35 15 (EC)This handout may be lengthy, but think of it as both a tutorial and assignment. I provide a lot of explanationand re-summarizing of course concepts.What To Turn In Turn in a PDF writeup that answers the questions; turn in all requested code and modelsnecessary to replicate your results. Turn in models by serializing the learned models and parameters; yourprogramming language likely natively supports this (e.g., Python’s pickle, or Pytorch’s own format). Besure to include specific instructions on how to build/compile (if necessary) and run your code. Answer thefollowing questions in long-form. Provide any necessary analyses and discussion of your results.How To Submit Submit the assignment on the submission site under “Assignment 2.”https://www.csee.umbc.edu/cou...Be sure to select “Assignment 2.”1Theory ...

December 27, 2022 · 9 min · jiezi

关于算法:COMP3411智能算法

COMP3411/9814 Artificial IntelligenceTerm 1, 2022Assignment 1 – Search and Constraint SolvingDue: Friday 11 March, 10:00 pmMarks: 20% of final assessment for COMP3411/9814 Artificial IntelligencePart 1 - SearchQuestion 1: Search Algorithms for the 15-PuzzleIn this question you will construct a table showing the number of states expandedwhen the 15-puzzle is solved, from various starting positions, using four differentsearches:(i) Uniform Cost Search (with Dijkstra’s Algorithm)(ii) Iterative Deepening Search(iii) A*Search (using the Manhattan Distance heuristic)(iv) Iterative Deepening A* SearchGo to theWebCMS. Under “Assignments” you will find Prolog Search Code“prolog_search.zip”. Unzip the file and change directory to prolog search, e.g.unzip prolog_search.zipcd prolog_searchStart prolog and load puzzle15.pl and ucsdijkstra.pl by typing[puzzle15].[ucsdijkstra]. ?Then invoke the search for the specified start10 position by typingstart10(Pos),solve(Pos,Sol,G,N),showsol(Sol).When the answer comes back, just hit Enter/Return. This version of Uniform CostSearch (UCS) uses Dijkstra’s algorithm which is memory efficient, but is designed toreturn only one answer. Note that the length of the path is returned as G, and the totalnumber of states expanded during the search is returned as N.a) Draw up a table with four rows and five columns. Label the rows as UCS, IDS, A*and IDA*, and the columns as start10, start12, start20, start30and start40. Run each of the following algorithms on each of the 5 start states: ...

December 27, 2022 · 7 min · jiezi

关于算法:YOLOv5全面解析教程②如何制作训练效果更好的数据集

撰文 | Fengwen, BBuf 本文次要介绍 One-YOLOv5 应用的数据集格局以及如何制作一个能够取得更好训练成果的数据集。本节教程的数据集规范局部翻译了 Ultralytics/YOLOv5 wiki 中对数据集相干的形容(https://github.com/ultralytic...) 。 代码仓库地址:https://github.com/Oneflow-In... 本系列教程原文点击 https://start.oneflow.org/one...可达(放弃动静更新教程和源码解读和修复一些bug)。 1 数据集构造解读1. 创立dataset.yaml COCO128是官网给的一个小的数据集 由COCO(https://cocodataset.org/#home)数据集前 128 张图片组成。这128幅图像用于训练和验证,判断 YOLOv5 脚本是否可能过失常进行。 数据集配置文件 coco128.yaml (https://github.com/Oneflow-In...) 定义了如下的配置选项: # YOLOv5 by Ultralytics, GPL-3.0 license# COCO128 dataset https://www.kaggle.com/ultralytics/coco128 (first 128 images from COCO train2017) by Ultralytics# Example usage: python train.py --data coco128.yaml# parent# ├── one-yolov5# └── datasets# └── coco128 ← downloads here (7 MB)# train and val data as 1) directory: path/images/, 2) file: path/images.txt, or 3) list: [path1/images/, path2/images/]# 训练和验证图像的门路雷同train: ../coco128/images/train2017/ val: ../coco128/images/train2017/# number of classesnc: 80 # 类别数# class names 类名列表names: ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush']# Download script/URL (optional) 用于主动下载的可选下载命令/URL 。download: https://ultralytics.com/assets/coco128.zip留神:如果是自定义数据集的话按本人需要批改这个yaml文件。次要批改以下两点。 ...

December 24, 2022 · 2 min · jiezi

关于算法:移除数组中的元素

移除数组中的元素,双指针算法,利用元数组元素笼罩的形式,利用指针挪动到指定的元素,即可一次便当实现var a=[1,2,3,4,5] var t=3var remove=(nums,t)=>{ for(var f=0,s=0;f<nums.length;f++){ if(nums[f]!=t){ nums[s]=nums[f] s++ } } return nums.slice(0,s)}var c=remove(a,t)console.log(c)

December 24, 2022 · 1 min · jiezi

关于算法:移除数组中的元素

移除数组中的元素,双指针算法,利用元数组元素笼罩的形式,利用指针挪动到指定的元素,即可一次便当实现var a=[1,2,3,4,5] var t=3var remove=(nums,t)=>{ for(var f=0,s=0;f<nums.length;f++){ if(nums[f]!=t){ nums[s]=nums[f] s++ } } return nums.slice(0,s)}var c=remove(a,t)console.log(c)

December 24, 2022 · 1 min · jiezi

关于算法:CS-166量化计算

CS 166: Quantum Computation Instructor: Sandy IraniHomework 7Due: February 25, 2022 Suppose x ∈ {0, . . . , N ? 1}, where N is a power of 2. Let x1x2 · · · xn be the binaryrepresentation of the integer x.(a) Express the state resulting from applying QFTN to the state |x〉.(b) Now suppose that y ∈ {0, . . . , N?1}. Let y1y2 · · · yn be the binary representationof the integer y. Express the output of the circuit below as a function of y:(c) Put your answers together for the first two parts of this problem to express theoutput of the following circuit as a function of x.(d) Now express the output of the following circuit. In order to describe the outputof QFT?1, think about what input to QFT would produce the state that is theinput to QFT?1 in the circuit.1Give the 6-qubit state after each gate in the circuit below is applied. Express the stateusing ket notation. All phases (including ?1) should be expressed as x, where x isan integer and = e2pii/26.Consider the Period Finding Algorithm for function f : {0, . . . , N ? 1} → {0, . . . ,M ?1}, where f(y) = 5x mod M . M = 12 and N = 16.(a) What is the current state of the algorithm after step 3? The state after step 3 is:1√NN?1∑y=0|y〉|f(y)〉.You need to express this state using the specific values of M , x,and N givenabove. Since this may be a bit tedious to do by hand, you are welcome to writea program to do the calculation for you.(b) If the second register is measured, then what are the possible outcomes?3(c) Suppose you measure the second register and the outcome is the largest of all thepossible outcomes. Then what is the state after measurement?M = 337123, and x = 29680.(a) Verify that x is a square root of 1 mod M . You can use a calculator, but writedown in your solution the condition you are checking.(b) Use x to factor M . Show enough work to indicate that you know how to applythe algorithm to factor M . You can use a gcd calculator if you like.Consider the result of measuring the first register from your circuit in Lab 7.(a) What are the possible outcomes from measuring first register and which outcomesallow you to recover the period of 2s mod 15?(b) After determining the period of 2s mod 15, then how would you use that infor-mation to factor 15?

December 22, 2022 · 2 min · jiezi

关于算法:以数据驱动的自动驾驶时代还有多远丨曼孚科技

主动驾驶行将来到数据驱动时代。 在经验了硬件(激光雷达)、软件(多传感器交融)等技术革新后,主动驾驶迎来了第三波浪潮。 去年,除造车新权势外,国内一批主机厂吉利、上汽、广汽等,纷纷加大了主动驾驶数据标注业务投入。到往年,其估算曾经在几十万元的根底上翻了十余倍。 随着主动驾驶数据标注需要暴涨,数据标注的市场将迎来新的红利期,在将来5-10年都将呈向荣之势。 而作为主动驾驶数据标注的从业者,该考虑一个事实问题——如何解决主动驾驶数据标注的「需要波峰」? 国内主动驾驶解决问题有个习惯,那就是堆料。 堆硬件、堆芯片、堆人力.....。到头来,只求量而不求质的倒退路线,使得问题不仅没有改良,反而安全事故更加频发。 进入数据驱动时代,对于主动驾驶数据供给有余的行业痛点,人力沉积已难以为继,只有技术革新才是走出困局的正确路径。 于是,越来越多的主机厂开始布局本人的数据中台,洽购内部供应商的数据标注工具,实现外部的数据闭环成为车企们的支流路线。 某些车企也开始效仿特斯拉的数据获取形式,通过收集客户理论驾驶中各场景的数据,学习推测客户的思维逻辑,以确保有短缺的数据进行系统优化。 为何车企对数据如此看重? 这一点从数据在整个主动驾驶研发中表演的角色便可通晓。 家喻户晓,数据贯通了人工智能的整个生命周期,从数据获取、筹备、模型训练、部署到模型评估都有它的影子。 因而,数据就是主动驾驶的外围增量,车企迫切需要一个残缺的数据驱动解决方案。 主动驾驶等级越高,对数据服务的要求越高。无论是数据需求量的增长、场景的裁减还是数据类型的变革,无不在走漏一点,“数据服务行业要为主动驾驶提供更业余、智慧性的解决方案。” 实际上,数据服务企业始终在翻新。从最早的单机标注工具、数据标注平台,至现阶段的智能数据标注平台。 纵观市场,有许多较为优质的数据服务企业,但专为主动驾驶提供数据服务解决方案的企业却寥寥无几,曼孚科技就是其中的一家。 曼孚科技自成立以来,始终秉承为主动驾驶客户提供高质量、场景化AI训练数据服务的理念。 产研团队上,曼孚科技星散了来自人工智能畛域的多位出名专家学者与谷歌、阿里、网易等科技行业顶尖人才,具备弱小的商业剖析、数据服务业余背景,以及先进的数据标注技术与丰盛的实战经验。 服务体系上,曼孚科技继续为主动驾驶客户提供定制化数据服务解决方案,解决项目管理缺口的难题,做到服务内容与理论需要的无缝符合。 标注工具上,曼孚科技自研的MindFlow SEED平台具备三大标注模式以及四维标注工具,全面笼罩计算机视觉、自然语言解决、语音交互等利用场景。提供图像(2D框、旋转2D框、多边形、关键点、多段线、曲线、3D框、椭圆、日形框等)、语音(ASR转写)、文本(OCR转写)、3D点云(单帧、间断帧、点云交融、点云语义宰割)等多种自定义标注计划。 曼孚科技已与百余家主动驾驶企业达成深度单干。用户包含世界顶级Tier1厂商、一线科技公司、支流算法公司、造车新权势等。 现阶段,主动驾驶市场对点云数据需要一劳永逸,曼孚科技深谙其道,一直优化降级点云标注工具,使得MindFlow SEED平台对3D点云标注效率与数据产出品质方面均处于国内领先地位。 将来,曼孚科技将持续加大主动驾驶数据标注研发投入,满足主动驾驶数据多样性需要供应, 成为主动驾驶企业合格的数据合作伙伴,为主动驾驶智能化建设与商业化落地保驾护航,赋能主动驾驶企业用数据发明更大价值。

December 22, 2022 · 1 min · jiezi

关于算法:COMP9311解答

COMP9311 22T1: Assignment 1Deadline: Fri 16:59:59 11th March (Sydney Time)Question 1 (9 marks)To better facilitate their operation of ingredient sourcing and allocation etc., Alocal restaurant group has enlisted your help in transitioning from old-schoolbook-keeping to a modern database format. They provide a summary ofrequirements as below. A supplier is a person or company identified by their supplier id and has alicense number. They are characterized by their year of founding andcountry of origin. We keep multiple emails for each supplier for reasons. A product is an ingredient used by restaurants for service. It has a uniqueproduct ID and is characterized by its weight per unit, price per unit, ashort description and availability status. A supplier offers many products, but each product is offered by onesupplier. The same product can be ordered by multiple restaurants. Werecord the delivery date whenever a product is delivered to a restaurant. A restaurant is identified by its restaurant id. We note its main cuisinetype. We record its star rating, its phone number, and a detailed addresswhich is made up of a street address, a postcode, and a country. Restaurants regularly place orders for products; a restaurant is allowed toorder multiple products. A head chef is uniquely identified by their chef license id. We store theemployment date and his/her multiple signature dishes. Each restaurantmust have one head chef. Each head chef must work for exactly onerestaurant. We also have a large group of wait staff (i.e., waiters/waitresses) across allrestaurants. Each wait staff works for a restaurant and is identified by acombination of the restaurant id and a wait staff number. For each waitstaff, we store their date of birth and start year. Each wait staff is only allowed to work for one restaurant, but a restaurantinstance may have zero or more wait staff. We record the number of waitstaff working at each restaurant. ...

December 21, 2022 · 3 min · jiezi

关于算法:CSE130系统调用

CSE130 Winter 2022 : Assignment 6 In this assignment you will use system calls to read and write files and explore directory structures. This assignment is worth 5% of your final grade. Late submissions will not be graded. Setup SSH in to one of the two CSE130 teaching servers using your CruzID Blue password: $ ssh @noggin.soe.ucsc.edu ( use Putty http://www.putty.org/ if on Windows )or $ ssh @nogbad.soe.ucsc.eduor $ ssh @olaf.soe.ucsc.eduor $ ssh @thor.soe.ucsc.edu ...

December 21, 2022 · 5 min · jiezi

关于算法:ECE-473基本介绍

ECE 473 Project Homework 7Final project deadline: your code must be submitted by Friday, February 25 at noon.Late submission will be accepted at a 2% per hour penalty until Saturday noon.Team selection deadline: February 11 at noon.In this extended homework, we ask you to explore improving a very basic Boolean satisfia-bility solver that we provide. You may work in teams, if you select and submit your teamaccording to the directions below by Friday, February 11 at noon. There will be a competitionamong submitted solvers, run on hidden problems, after the homework deadline.Provided materialsAt this time, we are making available the Python code for a basic solver and for a problemgenerator. You may begin immediately (once you have set your team) in designing better/ faster solvers and you may use any technique you dream up or read about. Your codemust be written in Python and not use any special libraries more advanced than numpy (askif you are not sure, including what functions you need from the requested library). Basicfunctionality libraries are just fine.We provide the course “local search” lecture for ideas, there is a rich but confusing researchliterature available that you can also tap, and the problem is accessible enough that yourown ideas may also help.You can generate problems of any size and timeout with the provided code.Try to solve theproblems within the default timeout provided.The code has a command line interface which can be accessed by typing the commandpython3 hw7 submssion.py --help at a Linux command line. The code can take theproblem to solve from a file or can generate the problem from command line parametersgiving the number of variables and the timeout in seconds (both have default values). Thecode can also save the generated problem to a provided file name. Finally, the command-line interface allows you to specify as many different algorithms as you like to run on theproblem, in sequence. If you prefer to run the code without the command line interface, seethe comment block at the bottom of the provided file.The code has a verbose mode that you will only want to use for quite small problems.You are encouraged to add multiple algorithms to the command line interface choices andthe code that implements it, so you can easily compare on multiple problems. A good initialgoal (and minimal project performance will not be less than this goal) would be to be able1to solve most 100 variable problems in less than 30 seconds. A loftier goal would be to solvesome 500 variable problems within a minute.Caveat: The topic of this project is local search, which cannot demonstrate that a formulais unsatisfiable, since it does not systematically explore all possibilities. There is a relatedarea of SAT solution algorithms that systematically solves the satisfiability question, butgenerally does not scale to the problems that local search can consider. If you simply do aweb search on Boolean satisfiability solvers, you will find a lot of literature on that approachthat is unlikely to help you here (key tipoffs would be mentions of the DPLL or CDCLtechniques). Systematic SAT solving has become quite important in AI and is an offshootof Boolean constraint propagation, which we will discuss briefly later in the course.What you will submitThis project has no written component beyond the requirement that your submitted programhw7 submission.py must have comments at the top of the file naming any algorithmictechnique you believe you are using (including making up a brief meaningful phrase forany innovation you have added that you found important for performance and indicatingthat it is your invention). Your code will provide a hw7 submission function filling in theprovided skeleton, that accepts a problem and returns an assignment solving the problem ifpossible.Your code must be written entirely by your team members; no outside code can be used forthis project. If you read outside code to understand an algorithm, you must put it asidebefore working with your own code. Also, you are responsible to understand how everythingyou submit is designed to work.EvaluationTop competition performers gain a grade benefit described in the syllabus. There is also aminimum standard of performance to avoid a grade penalty described in the syllabus. Thishomework is not part of the homework grade in the course. (If you have trouble achievingthe minimal level of performance, consult with our TAs and we will give you some additionalguidance. Work ahead to allow time for this. Everyone who engages this project in a timelyand substantial manner should be able to achieve the minimum standard.)We have not designed the final competition metric in full yet. It is likely to be total run timeon a hidden set of problems, with a timeout that grows with problem size. The penalty fornot solving a problem is then the timeout becoming the total run time.We hope to distribute soon an evaluator program that computes a total time for you onan associated set of problems later in the project period, and you are welcome to exchangeinformation about your performance on this program on Piazza threads. But note that itwill not guarantee anything about the final project competition.2Team selectionYou must select your team by Friday February 11 at noon (we encourage earlier/immediateteam selection so you can start to work together). Anyone not submitting a team selectionby that time will be expected to work alone.Please submit a text file containing your team members Purdue email handles (omit @pur-due.edu), one per line, with the team leader on the first line. All team members must submitthe same team with the same team leader or the team will be rejected.For example, our course leadership team (omitting UTAs for brevity here) would be de-scribed, as follows:givangong123jkim17We may process these submissions with a script; please follow the prescribed format ex-actly.Boolean satisfiabilityBoolean formulas take on truth values that depend on the values of the underlying Booleanvariables. Many practical problems can be coded as Boolean formulas where making theformula true is the goal of the practical problems. Solving the practical problem involvesfinding ways to set the underlying variables that make the formula true. A modest industryhas developed in designing effective “SAT solvers” that can handle very large formulas builtfrom very large numbers of Boolean variables.In this project, we explore just the beginning of the techniques that can be created. Weprovide a problem generator that creates large Boolean formulas that do have solutions(satisfying truth assignments to the underlying variables), and a solver that uses a simplerandom walk in the space of solutions to solve some such problems. Your challenge is tocode any idea you like to improve on this performance.Here are some relevant definitions:Variable. We assume a set of Boolean variables (e.g. A) is provided. In the code weprovide, the variables are represented by the numbers 1..n, where n is given by the parameternum variables.Literal. A Boolean literal is either a Boolean variable (e.g. A) or its negation (e.g. ?A). Inthe code we provide, a positive literal is a number 1..n and negative literal is the negationof such a number, ?1..? n.Clause. A Boolean clause is a disjunction (“or”, ∨) of three different literals, usually givenas a set: {A,B′, C} for A ∨B′ ∨C. In the program a clause is represented as a list of threeliterals, e.g. [-5,3,7].33-SAT formula. A 3-SAT formula is a set of clauses, representing the conjunction (“and”,∧) of the clauses. In the provided program, a 3-SAT formula is represented by a list ofclauses.Assignment. A Boolean assignment is choice of “true” or “false” for each Boolean variable.In the provided program, an assignment is a list or a 1-dimensional np.array with indicesin range(num variables), such that the index i stores the value of variable i+1. Note thatthe assignments are 0-referenced but the variable are numbered 1..n. The values stored inthe list are either +1 for truth or -1 for falsehood of the associated variable.Evaluation. Given an assignment, every literal, clause, and 3-SAT formula are evaluatedto either true or false. A formula is true for the assignment if all of its clauses are true.A clause is true for the assignment if at least one of its literals is true. A positive literali > 0 represents variable i being true and is true if the assignment has a +1 at 0-indexedposition i ? 1. A negative literal j < 0 represents the variable ?j being false and is true ifthe assignment has a -1 at in-indexed position j ? 1.Satisfiability. A 3-SAT formula is satisfiable if there exists some assignment under whichit evaluates to true.A provided problem generator accepts parameters num variables and num clauses andgenerates a satisfiable 3-SAT formula meeting these parameters using the representation justdescribed. The project task is to take this formula and find a satisfying assignment.Note that not every 3-SAT formula is satisfiable. Local search is essentially incapable ofdetecting unsatisfiability, and will just run forever failing to find a satisfying assignment.Systematic backtracking can detect unsatsifiability, but scales exponentially to large prob-lems. We provide code for systematic backtracking for you to evaluate and consider. Inthis project, our problem generator deliberately generates only satisfiable formulas so localsearch can assume there is a solution.Moreover, it has been established that most randomly generated 3-SAT formulas with fewerthan 4.2 clauses per variable are easily satisfied (they are under-constrained), whereas most3-SAT formulas with more than 4.2 clauses per variable are unsatisfiable, over-constrained(when drawn from typical random problem generators). For this reason, our problem gen-erator generates only 3-SAT formulas with approximately 4.2 clauses per variable. ...

December 21, 2022 · 8 min · jiezi

关于算法:COMP3011数据服务

University of Leeds School of ComputingWeb Services and Web Data COMP3011Semester 2, 2021-2022 Coursework 1 (30 marks = 30% of total module marks) Important Note: This is an individual project, NOT a team project. Each student must implement their own web API and client application. Submission Deadline: 21/03/2022 at 11:00 pm (UK time) The BriefIn this project, you will use the Django framework to implement a RESTful web API for rating professors. You will host your website on www.pythonanywhere.com (for free). You will also write a simple command line application for interacting with the API.The Web ServiceWe want to develop a RESTful web service to allow students to rate the teaching of professors in various modules on a scale from 1 to 5. The service must provide all the required web API’s to allow client applications to offer the functionality described below.The service maintains data about professors, modules, and the rating of professors by different users (students). Information about modules and professors are manually added by the admin of the service using the admin site. The admin site is automatically created by the Django web development framework. A module may be:Taught by different professors in different academic years.Taught by different professors in different semesters.Taught by more than one professor at the same time (for example each teaching some part of the module).Since an academic year spans two calendar years (e.g. 2018-19), an academic year will be given by its first year only (hence 2018-19 is given as 2018).Users of the service (students) can rate professors but cannot add or change module information. Before they can rate professors, users must register by providing a username, email, and password. Users can only rate professors when they are logged in to the service. The overall rating of a professor is the average of the professor’s rating by all users across all module instances taught by this professor. A module instance is a module taught in a certain year and semester by one or more professors. Any decimal fraction in the average is rounded to the nearest integer.A client application connected to the service will provide the user with the following options:Option 1. View a list of all module instances and the professor(s) teaching each of them. Here is an example of a possible client application output for this option. TT1, Professor T. TerribleNote that modules and professors are given unique identifiers in the web service to avoid any possible mix-up between names.Option 2. View the rating of all professors. Here is an example of a possible client application output for this option.The rating of Professor J. Excellent (JE1) is *The rating of Professor T. Terrible (TT1) is *The rating of Professor V. Smart (VS1) is **Option 3. View the average rating of a certain professor in a certain module: The rating of Professor V. Smart (VS1) in module Computing for Dummies (CD1) is *Option 4. Rate the teaching of a certain professor in a certain module instance.Note that all filtering of data and calculations should be done by the server, i.e. the client application does not process incoming data; the application simply displays the data returned by the service in a human readable format.You are required to:1.Design and implement a suitable database for the above service. You must specify all required tables, the fields of each table and their data types, and the relationships between the tables.2.Design and implement all web API’s that must be provided by the service to allow a client application to perform the functionality described in Options 1 – 4. For each API, you must specify: the purpose of the API, a URL, an HTTP method, the request data, and the response data.The Client ApplicationYou are also required to write a command line client application to interact with the API. The application should be written in Python 3 and should be able to send requests to, and process responses from, the web service. The client must support the following commands:registerThis is used to allow a user to register to the service using a username, email and a password. When the command is invoked, the program prompts the user to enter the username, email, and password of the new user. The syntax for this command is: ...

December 21, 2022 · 7 min · jiezi

关于算法:MATH-523线性模型

Generalized Linear Models MATH 523McGill University, Winter Term 2022Assignment 2 due on February 16 at noon.Q1 Lecture 5aConsider a Poisson GLM with the log link and linear predictor of the formi = 1 + 2ai, i ∈ {1, . . . n},where ai is the value of a factor predictor with two levels, such that ai = 1 fori ∈ {1, . . . n1} and ai = 0 for i ∈ {n1 + 1, . . . , n}.Suppose that at the beginning of the t-th iteration of the Fisher Scoring algorithm(formulated as iterative reweighted least squares), we get(t+1) = ((t+1)1 , (t+1)2 ) = (log y2, log y1 ? log y2),where y1 = 1n1∑n1i=1 yi, and y2 =1n2∑ni=n1+1yi.(1) Calculate the remaining part of the iteration step of the algorithm: (t+1), (t+1),z(t+1), W (t+1), D(t+1), and u(t+1).(2) Does the algorithm terminate after this iteration? Justify your answer.(3) Did the algorithm find the exact solution after this iteration? Justify your answer.Q2 Lecture 6aConsider the Gamma GLM (viz. page 2 of Lecture 3a) with a linear predictor of theformi = 1 + 2xi,where xi is the value of a continuous predictor corresponding to the ith response.(1) Calculate the standard error of ?1 using (a) the reciprocal link (g() = 1/) and(b) the identity link (g() = ).(2) Calculate the deviance. Does it depend on the link function? Explain.Q3 R excerciseConsider the data from the German General Social Survey on the number of children.This data set contains 3548 observations on the following 6 variables: child (num-ber of children), age (age of the woman in years), dur (years of education), nation(nationality of the woman; 0 = German, 1 = otherwise), god (Belief of the womanin God: 1 = Strong agreement, 2 = Agreement 3 = No definite opinion, 4 = Ratherno agreement, 5= No agreement at all 6= Never thougt about it), and univ (whetherthe woman visited university: 0 = no, 1 = yes).The dataset is available in the catdata library in R and can be loaded as follows (afterhaving installed the catdata library):Johanna G. Ne?lehováGeneralized Linear Models MATH 523McGill University, Winter Term 2022Assignment 2 due on February 16 at noon.library(catdata) ...

December 21, 2022 · 7 min · jiezi

关于算法:Transformer让ChatGPT站在肩膀上的巨人

编者按:ChatGPT以近乎狂热之势席卷了全网。在沉浸于“ChatGPT潮”的同时,让咱们也来深刻理解一下它和基石技术 - 大模型 Transformer吧。 Dale Markowitz的这篇文章为咱们深入浅出地介绍了Transformer的重要性、创新性、应用领域等。 以下是译文,Enjoy! 作者 | Dale Markowitz 编译 | 岳扬 你知据说过这句话吗?当你领有一把锤子时,所有货色看起来都像钉子。那么,在机器学习中,咱们仿佛真的发现了一个神奇的锤子,对于它来说,所有的货色都是钉子,它们被称为Transformers。 Transformers是能够被设计用来翻译文本、写诗和文章的模型,甚至能够生成计算机代码。很多备受瞩目的模型就是基于Transfomer, 如风靡全网的ChatGPT, AlphaFold 2(这个模型能够依据蛋白质的基因序列预测其构造),以及其余弱小的自然语言解决(NLP)模型,如GPT-3、BERT、T5、Switch、Meena等等。 如果你想在机器学习,特地是NLP方面跟上时代的步调,那么至多要对Transformers有肯定的理解。因而,在这篇文章中,咱们将探讨Transformers是什么,它们如何工作,以及它们为什么如此有影响力。 Transformers是神经网络架构的一种类型。简而言之,神经网络是一种十分无效的模型类型,用于剖析图像、视频、音频和文本等简单数据类型。但有不同类型的神经网络为不同类型的数据进行优化。例如,对于剖析图像,咱们通常会应用卷积神经网络[1]或 “CNNs”。其实能够说它们模拟了人脑解决视觉信息的形式。 卷积神经网络,由Wikicommons的Renanar2提供 而自2012年[2]左右开始,咱们在用CNN解决视觉问题方面曾经相当胜利,比方辨认照片中的物体、辨认人脸和手写数字。但在很长一段时间里,没有任何相似的好办法存在于语言工作(翻译、文本总结、文本生成、命名实体辨认等)的解决中。这是可怜的,因为语言是咱们人类交换的次要形式。 在2017年呈现Transformers之前,咱们应用深度学习来了解文本的形式是应用一种叫做循环神经网络或RNN的模型: RNN的图片,由Wikimedia提供 比方说,你想把一个英语句子翻译成法语。RNN会把英语句子作为输出,一次解决一个词,而后按程序输入它们的法语对应词。这里的要害是“按程序”。在语言中,单词的程序很重要,不能轻易更改。 "Jane went looking for trouble." 下面这句话与上面上面这句话的意思齐全不同。 "Trouble went looking for Jane." 因而,任何要了解语言的模型都必须捕捉到单词的程序,而递归神经网络(recurrent neural networks)通过一次解决一个单词的办法来做到这一点。 然而,RNN也存在很多问题。首先,它们在解决大型文本序列时很吃力,比方长段文本或文章。当到了一个段落的结尾时,它们会遗记结尾产生了什么。例如,一个基于RNN的翻译模型可能难以记住一个长段落的主题。 更糟的是,RNNs很难训练。它们很容易受到所谓的梯度隐没/收缩问题[3]影响(有时你只需从新开始训练,而后祷告)。更麻烦的是,因为它们是按程序解决单词,RNNs很难达到并行化。这意味着你不能通过应用更多的GPU来放慢训练,这反过来意味着你不能在所有的数据上训练它们。 01 进入Transformers的世界Transformers是由谷歌和多伦多大学的钻研人员在2017年开发的,最后是为了做翻译。但与递归神经网络(RNN)不同,Transformers能够十分无效地进行并行化操作。这意味着,如果有适合的硬件条件,你能够训练一些真正的大模型。 多大的大模型? 十分大。 如果要说一件对于 Transformers 的事件,那应该会是:将一个具备良好扩展性的模型与一个微小的数据集相结合,其后果可能会让你大吃一惊。 02 Transformers是如何工作的? 原始论文中的Transformer示意图 尽管原始论文[4]的图表有点吓人,但Transformer背地的翻新能够归结为三个次要概念。 Positional Encodings地位编码 Attention注意力 Self-Attention自注意力 2.1 Positional Encodings地位编码让咱们从第一个——地位编码开始介绍。比方说,咱们正试图将文本从英语翻译成法语。RNNs,即用AI进行文本翻译的老办法,通过按程序解决单词来了解词序。但这也是使它们难以并行化的起因。 Transformers通过一种叫做地位编码的翻新办法绕过了这个阻碍。这个想法是把你的输出序列中的所有单词(在这个例子中是一个英语句子)用它的程序给每个单词附加一个数字。因而,要给你的网络提供一个序列,如: [("Dale", 1), ("says", 2), ("hello", 3), ("world", 4)] ...

December 19, 2022 · 1 min · jiezi

关于算法:闰秒终于要取消了一文详解其来源及影响

导读 | 第27届国内计量大会发表最迟不晚于2035年勾销引入闰秒,这一音讯引起轰动。上一次闰秒产生,对Reddit、Mozilla、FourSquare等都产生了肯定的问题,其中Reddit宕机工夫超过1个半小时!本栏目特邀腾讯后盾开发工程师陶松桥,带你是深刻理解闰秒的起源及其影响,并介绍各类零碎常见的闰秒解决办法,其中会分享TencentOS Server 操作系统的解决方案。 闰秒从何而来世界上有几种计量工夫的形式: 世界时(UT1):是一种地理计量的形式,天文学家通过观测地球的自转,并将自转一周的工夫(一天)等分为86400份,每份为一秒,受潮汐等因素的影响,地球自转一周的工夫并不是恒定的,这也是造成闰秒景象的间接起因。 原子时(TAI):因为下面形容的世界时并不稳固,物理学家用更为稳固的量子计量的形式来统计工夫,1967年,国内计量大会用铯133(Cs133)原子基态的两个超精密能级之间的跃迁所对应辐射的9192631770个周期所继续的工夫定义为1秒,这个是目前最准确的工夫计量形式,其误差为1400000年一秒,根本可忽略不计。 协调世界时(UTC):又称世界规范工夫或世界协调工夫,UTC以TAI为根底,又要兼顾UT1,当UTC,和UT1之间的偏差靠近1秒时,国内地球自转和参考系服务(IERS)会提前6个月颁布下一次闰秒的工夫。 咱们将世界绝大多数中央时区的根本工夫称为协调世界时,即 UTC。它源自散布在世界一些国家的大量原子时钟。地球的自转并不是十分恒定的,有时会有一些变动,均匀自转速度会迟缓降落。这就是为什么会在 UTC 时标中插入所谓闰秒,它们可将 UTC 工夫过程调整到实在地球自转工夫。 为什么会多出这一秒呢?它的存在是因为决定昼夜更替的地球绕轴自转会在很长的一段时间内慢下来,次要是由月亮-太阳引力造成。另外,地球也受其外部(地核、地幔)和内部(气象、陆地)形成影响。目前,工夫次要由分属几个国家的 250 台原子时钟测量,这些原子钟是通过测量原子的能量转换程度工作。应用这些时钟计算 UTC,同时因为这个工夫测量原理周期性地与地球不同步,因而必须应用闰秒进行校对。另外,咱们必须思考到当初的一天比 1820 年的一天要长 2 毫秒。不出所料,地球自转缓缓就与 UTC 不同步了。 国内地球自转服务局IERS 测量的是实在地球自转,并决定何时插入闰秒。插入闰秒个别总是在某个月的最初一天进行,首选六月或十二月的 UTC 午夜工夫。过来每次增加闰秒都是在六月或十二月进行。是否增加闰秒的申明,会由 IERS 在其Bulletin C 中公布。目前,在可能增加闰秒日期前半年会颁布 Bulletin C 。 因为闰秒是在全世界同时插入,插入闰秒的本地(民用)工夫取决于本地工夫与 UTC 之间的偏差,例如:2015年7月1日产生闰秒时,在时区 UTC+8h(北京工夫) 中,闰秒会在时钟显示午夜后 8 小时的时候插入。 闰秒时计算北京工夫的规范办法为: 2015-07-01 07.59.572015-07-01 07.59.582015-07-01 07.59.592015-07-01 07.59.60 <-- 闰秒2015-07-01 08.00.002015-07-01 08.00.012015-07-01 08.00.02如果零碎时钟采纳国内原子时(TAI),并应用正确的时区,那么就会列出 23:59:60。但因为在 Unix 的 UTC 应用中不存在 23:59:60,Linux内核会采纳倒回一秒的办法在 0:00 UTC 后第一次时钟更新时插入闰秒。在本地工夫计时中,依据不同的时区偏差,比方 UTC+8h,在TencentOS Server零碎中,您会察看到以下景象: 2015-07-01 07:59:58.0002015-07-01 07:59:58.5002015-07-01 07:59:59.0002015-07-01 07:59:59.5002015-07-01 08:00:00.000 <-- 插入闰秒2015-07-01 07:59:59.0002015-07-01 07:59:59.5002015-07-01 08:00:00.0002015-07-01 08:00:00.500IERS 确定闰秒后,一些工夫流传服务还会公布闰秒告诉。这包含德国长波发射机 DCF77 和卫星巡航零碎 GPS 示例。因而,可解码从那些零碎获取信号的接收器也能够解码闰秒告诉。如果在所利用协定中蕴含闰秒信息(例如接收器传送的工夫字符串),则从那些接收器读取工夫的应用程序也能够确定闰秒告诉。请留神,工夫代码接收器只能将闰秒告诉转发到应用程序,同时正确计时。正确处理闰秒是应用程序和(/或)操作系统的工作。 ...

December 16, 2022 · 4 min · jiezi

关于算法:PGL图学习之基于UniMP算法的论文引用网络节点分类任务系列九

我的项目链接:[PGL图学习之基于UniMP算法的论文援用网络节点分类工作[系列九]](https://aistudio.baidu.com/ai...) 1.常规赛:图神经网络入门节点分类介绍(1)赛题介绍 图神经网络(Graph Neural Network)是一种专门解决图构造数据的神经网络,目前被广泛应用于举荐零碎、金融风控、生物计算中。图神经网络的经典问题次要有三种,包含节点分类、连贯预测和图分类三种,本次较量是次要让同学们相熟如何图神经网络解决节点分类问题。 在过来的一个世纪里,迷信出版物的数量每12年减少近一倍,对每一种出版物的主题及畛域进行主动分类已成为当下非常重要的工作。本次工作的指标是预测未知论文的主题类别,如软件工程,人工智能,语言计算和操作系统等。较量所选35个畛域标签已失去论文作者和arXiv版主确认并标记。 本次较量选用的数据集为arXiv论文援用网络——ogbn-arixv数据集的子集。ogbn-arixv数据集由大量的学术论文组成,论文之间的援用关系造成一张微小的有向图,每一条有向边示意一篇论文援用另一篇论文,每一个节点提供100维简略的词向量作为节点特色。在论文援用网络中,咱们已对训练集对应节点做了论文类别标注解决。本次工作心愿参赛者通过已有的节点类别以及论文之间的援用关系,预测未知节点的论文类别。 (2)数据形容 本次赛题数据集由学术网络图形成,该图会给出每个节点的特色,以及节点与节点间关系(训练集节点的标注后果已给出)。 1.1 数据集简介1.学术网络图数据: 该图蕴含164,7958条有向边,13,0644个节点,参赛者报名胜利后即可通过较量数据集页面提供edges.csv以及feat.npy下载并读取数据。图上的每个节点代表一篇论文,论文从0开始编号;图上的每一条边蕴含两个编号,例如 3,4代表第3篇论文援用了第4篇论文。图结构能够参照AiStudio上提供的基线零碎我的项目理解数据读取办法。 2.训练集与测试集: 训练集的标注数据有70235条,测试集的标注数据有37311条。训练数据给定了论文编号与类别,如3,15 代表编号为3的论文类别为15。测试集数据只提供论文编号,不提供论文类别,须要参赛者预测其类别。 具体数据介绍: | 数据集 | 简介| | -------- | -------- | | edges.csv | 边数据:用于标记论文间援用关系 | | feat.npy | 节点数据:每个节点含100维特色 | | train.csv | 训练集数据 | | test.csv | 测试集数据 | 1.图数据: feat.npy为Numpy格局存储的节点特色矩阵,Shape为(130644, 100),即130644个节点,每个节点含100维特色。其中 feat.npy能够用numpy.load(“feat.npy”)读取。edges.csv用于标记论文援用关系,为无向图,且由两列组成,没有表头。 字段阐明第一列边的初始节点第二列边的终止节点2.训练集: train.csv 字段阐明nid训练节点在图上的Idlabel训练节点的标签(类别编号从0开始,共35个类别)3.测试集: test.csv 字段阐明nid测试节点在图上的Id相干材料 飞桨PGL图学习框架飞桨PGL图学习框架根本可能笼罩大部分的图网络应用,包含图示意学习以及图神经网络。 节点分类实例分享蕴含多种援用网络模型,如GCN、GAT、GCNII、APPNP等。 UniMP模型对立消息传递模型UniMP,同时实现了节点的特色与标签传递,显著晋升了模型的泛化成果。 提交内容与格局 最终提交的submission.csv 格局如下: 字段阐明nid测试集节点在图上的idlabel测试集的节点类别特地提醒: 提交的后果必须是类别的id,不能是概率。 提交样例: nidlabel23431415……留神:选手提交的csv文件的第一行为”nid,label”,程序调转将视为有效答案。接下来每一行的两个数字顺次示意测试集提供的节点id以及对应的预测论文类别,留神给出的预测类别id要属于给定范畴值且必须是整数。提交的数据行数要与test.csv统一。 2.BaseLine代码解说2.1 代码整体逻辑读取提供的数据集,蕴含构图以及读取节点特色(用户可本人改变边的结构形式)配置化生成模型,用户也能够依据教程进行图神经网络的实现。开始训练执行预测并产生后果文件环境配置 该我的项目依赖飞桨paddlepaddle==1.8.4, 以及pgl==1.2.0。请依照版本号下载对应版本就可运行。 ...

November 30, 2022 · 13 min · jiezi

关于算法:ShareSDK-Android端权限说明

ShareSDK应用权限状况 permissions { exclude "须要去除的权限1", "须要去除的权限2"}比方须要去除掉“android.permission.READ_PHONE_STATE”权限,则间接增加如下配置即可: MobSDK { appKey "Mob开发者后盾申请的AppKey" appSecret "Mob开发者后盾申请的AppSecret" ShareSDK { devInfo { ... } } permissions { exclude "android.permission.READ_PHONE_STATE", }}QUERY_ALL_PACKAGES权限去除阐明:Android高版本(Android10以上)判断第三方平台是否装置须要应用QUERY_ALL_PACKAGES权限,如果没有这个权限ShareSDK分享、受权无奈应用,不过因为Google商店对QUERY_ALL_PACKAGES权限审核比拟严格,如您不心愿应用QUERY_ALL_PACKAGES权限,能够应用咱们提供exclude的形式去除QUERY_ALL_PACKAGES权限: MobSDK { appKey "Mob开发者后盾申请的AppKey" appSecret "Mob开发者后盾申请的AppSecret" ShareSDK { devInfo { ... } } permissions { exclude "android.permission.QUERY_ALL_PACKAGES", }}须要留神的是去除QUERY_ALL_PACKAGES权限之后,须要在Manifest中通过"queries标签"手动配置一下须要应用的第三方平台包名,相似这样: <manifest package="xxxxxx"> ......<queries> <!--WhatsApp--> <package android:name="com.whatsapp" /> <!--Facebook--> <package android:name="com.facebook.katana" /> <!--Line客户端--> <package android:name="jp.naver.line.android" /> <!--Google包名--> <package android:name="com.google.android.gm"/> <package android:name="com.google.android.gms"/> <package android:name="com.google.android.apps.plus"/> <!--Twitter--> <package android:name="com.twitter.android" /> <!--WeChat--> <package android:name="com.tencent.mm" /> <!--QQ--> <package android:name="com.tencent.mobileqq" /> <!--instagram--> <package android:name="com.instagram.android" /> <!--FacebookMessenger--> <package android:name="com.facebook.orca" /> <!--新浪微博--> <package android:name="com.sina.weibo" /> ...... </queries>......</manifest>

November 29, 2022 · 1 min · jiezi

关于算法:TVM-从入门到精通-安装-TVM-Part-1

内容一览:TVM 共有三种装置办法:从源码装置、应用 Docker 镜像装置和 NNPACK Contrib 装置。本文重点介绍如何通过源码装置 TVM。 关键词:TVM 疾速上手 源码装置 在之前的文章《TVM 中文站正式上线!最全机器学习模型部署「参考书」它来了》中,咱们整体介绍了 TVM 的重要作用,以及如何借助 TVM 中文文档,开启机器学习编译器的摸索之路。 接下来,咱们将以系列教程的模式, 具体解说 TVM 从入门到精通的学习门路,心愿每位开发者都能成为优良的机器学习编译工程师! 本篇文章中,咱们将介绍「打地基」的关键步骤--装置 TVM。 TVM 的装置可通过 3 种路径实现: 从源码装置Docker 镜像NNPACK Contrib 装置作为装置 TVM 教程的 (Part 1),本文将具体解说从源码装置的最佳实际, 并进行最大限度地灵便配置和编译。 逐渐解说如何从源码装置 TVM在各种零碎中从 0 到 1 构建和装置 TVM 软件包包含两个步骤: 从 C++ 代码中构建共享库Linux:libtvm.somacOS :libtvm.dylibWindows:libtvm.dll2.为编程语言包进行设置(如 Python 包) 下载 TVM 源代码,请拜访:https://tvm.apache.org/download 开发者:从 GitHub 获取源代码从 GitHub 上克隆源码仓库,请应用 --recursive 选项来克隆子模块。 git clone --recursive https://github.com/apache/tvm tvmWindows 用户能够关上 Git shell,并输出以下命令: git submodule initgit submodule update构建共享库咱们的指标是构建共享库: ...

November 29, 2022 · 4 min · jiezi

关于算法:PGL图学习之项目实践UniMP算法实现论文节点分类新冠疫苗项目实战助力疫情系列九

原我的项目链接:https://aistudio.baidu.com/aistudio/projectdetail/5100049?contributionType=1 1.图学习技术与利用图是一个简单世界的通用语言,社交网络中人与人之间的连贯、蛋白质分子、举荐零碎中用户与物品之间的连贯等等,都能够应用图来表白。图神经网络将神经网络使用至图构造中,能够被形容成消息传递的范式。百度开发了PGL2.2,基于底层深度学习框架paddle,给用户裸露了编程接口来实现图网络。与此同时,百度也应用了前沿的图神经网络技术针对一些利用进行模型算法的落地。本次将介绍百度的PGL图学习技术与利用。 1.1图起源与建模首先和大家分享下图学习支流的图神经网络建模形式。 14年左右开始,学术界呈现了一些基于图谱合成的技术,通过频域变换,将图变换至频域进行解决,再将处理结果变换回空域来失去图上节点的示意。起初,空域卷积借鉴了图像的二维卷积,并逐步取代了频域图学习办法。图构造上的卷积是对节点街坊的聚合。 基于空间的图神经网络次要须要思考两个问题: 怎么表白节点特色;怎么表白一整张图。第一个问题能够应用街坊聚合的办法,第二问题应用节点聚合来解决。 目前大部分支流的图神经网络都能够形容成消息传递的模式。须要思考节点如何将音讯发送至指标节点,而后指标节点如何对收到的节点特色进行接管。 1.2 PGL2.2回顾介绍PGL2.2基于消息传递的思路构建整体框架。PGL最底层是飞浆外围paddle深度学习框架。在此之上,搭建了CPU图引擎和GPU上进行tensor化的图引擎,来不便对图进行如图切分、图存储、图采样、图游走的算法。再上一层,会对用户裸露一些编程接口,包含底层的消息传递接口和图网络实现接口,以及高层的同构图、异构图的编程接口。框架顶层会反对几大类图模型,包含传统图示意学习中的图游走模型、消息传递类模型、常识嵌入类模型等,去撑持上游的利用场景。 最后的PGL是基于paddle1.x的版本进行开发的,所以那时候还是像tensorflow一样的动态图模式。目前paddle2.0曾经进行了全面动态化,那么PGL也相应地做了动态图的降级。当初去定义一个图神经网络就只须要定义节点数量、边数量以及节点特色,而后将图tensor化即可。能够自定义如何将音讯进行发送以及指标节点如何接管音讯。 上图是应用PGL构建一个GAT网络的例子。最开始会去计算节点的权重,在发送音讯的时候GAT会将原节点和指标节点特色进行求和,再加上一个非线性激活函数。在接管的时候,能够通过reduce_softmax对边上的权重进行归一化,再乘上hidden state进行加权求和。这样就能够很不便地实现一个GAT网络。 对于图神经网络来讲,在构建完网络后,要对它进行训练。训练形式和个别机器学习有所不同,须要依据图的规模抉择实用的训练计划。 例如在小图,即图规模小于GPU显存的状况下,会应用full batch模式进行训练。它其实就是把一整张图的所有节点都搁置在GPU上,通过一个图网络来输入所有点的特色。它的益处在于能够跑一个很深的图。这一训练计划会被利用于中小型数据集,例如Cora、Pubmed、Citeseer、ogbn-arxiv等。最近在ICML上发现了能够重叠至1000层的图神经网络,同样也是在这种中小型数据集上做评估。 对于中等规模的图,即图规模大于GPU单卡显存,常识能够进行分片训练,每一次将一张子图塞入GPU上。PGL提供了另一个计划,应用分片技术来升高显存应用的峰值。例如对一个简单图进行计算时,它的计算复杂度取决于边计算时显存应用的峰值,此时如果有多块GPU就能够把边计算进行分块,每台机器只负责一小部分的计算,这样就能够大大地缩小图神经网络的计算峰值,从而达到更深的图神经网络的训练。分块训练结束后,须要通过NCCL来同步节点特色。 在PGL中,只须要一行DistGPUGraph命令就能够在原来full batch的训练代码中退出这样一个新个性,使得能够在多GPU中运行一个深层图神经网络。例如在obgn-arxiv中尝试了比较复杂的TransformerConv网络,如果应用单卡训练一个三层网络,其GPU显存会被占用近30G,而应用分片训练就能够将它的显存峰值升高。同时,还实现了并行的计算减速,例如原来跑100 epoch须要十分钟,当初只须要200秒。 在大图的状况下,又回归到平时做数据并行的mini batch模式。Mini batch与full batch相比最次要的问题在于它须要做街坊的采样,而街坊数目的晋升会对模型的深度进行限度。这一模式实用于一些巨型数据集,包含ogbn-products和ogbn-papers100m。 发现PyG的作者的新工作GNNAutoScale可能把一个图神经网络进行主动的深度扩大。它的次要思路是利用CPU的缓存技术,将街坊节点的特色缓存至CPU内存中。当训练图网络时,能够不必实时获取所有街坊的最新表白,而是获取它的历史embedding进行街坊聚合计算。试验发现这样做的成果还是不错的。 在工业界的状况下可能会存在更大的图规模的场景,那么这时候可能单CPU也存不下如此图规模的数据,这时须要一个分布式的多机存储和采样。PGL有一套分布式的图引擎接口,使得能够轻松地在MPI以及K8S集群上通过PGL launch接口进行一键的分布式图引擎部署。目前也反对不同类型的街坊采样、节点遍历和图游走算法。 整体的大规模训练形式包含一个大规模分布式图引擎,两头会蕴含一些图采样的算子和神经网络的开发算子。顶层针对工业界大规模场景,往往须要一个parameter server来存储上亿级别的稠密特色。借助paddlefleet的大规模参数服务器来反对超大规模的embedding存储。 1.3 图神经网络技术1.3.1 节点分类工作 在算法上也进行了一些钻研。图神经网络与个别机器学习场景有很大的区别。个别的机器学习假如数据之间独立同散布,然而在图网络的场景下,样本是有关联的。预测样本和训练样本有时会存在边关系。通常称这样的工作为半监督节点分类问题。 解决节点分类问题的传统办法是LPA标签流传算法,思考链接关系以及标签之间的关系。另外一类办法是以GCN为代表的特色流传算法,只思考特色与链接的关系。 通过试验发现在很多数据集下,训练集很难通过过拟合达到99%的分类准确率。也就是说,训练集中的特色其实蕴含很大的噪声,使得网络不足过拟合能力。所以,想要显示地将训练label退出模型,因为标签能够消减大部分歧义。在训练过程中,为了防止标签泄露,提出了UniMP算法,把标签流传和特色流传交融起来。这一办法在三个open graph benchmark数据集上获得了SOTA的后果。 后续还把UniMP利用到更大规模的KDDCup 21的较量中,将UniMP同构算法做了异构图的拓展,使其在异构图场景下进行分类工作。具体地,在节点街坊采样、批归一化和注意力机制中思考节点之间的关系类型。 1.3.2 链接预测工作 第二个比拟经典的工作是链接预测工作。目前很多人尝试应用GNN与link prediction进行交融,然而这存在两个瓶颈。首先,GNN的深度和街坊采样的数量无关;其次,当训练像常识图谱的工作时,每一轮训练都须要遍历训练集的三元组,此时训练的复杂度和街坊节点数量存在线性关系,这就导致了如果街坊比拟多,训练一个epoch的耗时很长。 借鉴了最近基于纯特色流传的算法,如SGC等图神经网络的简化形式,提出了基于关系的embedding流传。发现独自应用embedding进行特色流传在常识图谱上是行不通的。因为常识图谱上存在简单的边关系。所以,依据不同关系下embedding设计了不同的score function进行特色流传。此外,发现之前有一篇论文提出了OTE的算法,在图神经网络上进行了两阶段的训练。 应用OGBL-WikiKG2数据集训练OTE模型须要超过100个小时,而如果切换到的特色流传算法,即先跑一次OTE算法,再进行REP特色流传,只须要1.7个小时就能够使模型收敛。所以REP带来了近50倍的训练效率的晋升。还发现只须要正确设定score function,大部分常识图谱算法应用的特色流传算法都会有成果上的晋升;不同的算法应用REP也能够减速它们的收敛。 将这一套办法利用到KDDCup 21 Wiki90M的较量中。为了实现较量中要求的超大规模常识图谱的示意,做了一套大规模的常识示意工具Graph4KG,最终在KDDCup中获得了冠军。 1.4 算法利用落地 ...

November 29, 2022 · 3 min · jiezi

关于算法:MobPush-Android-For-Unity

集成筹备注册账号应用MobSDK之前,须要先在MobTech官网注册开发者账号,并获取MobTech提供的AppKey和AppSecret,详情能够点击查看注册流程 下载.unitypackage包关上 Github 下载 MobPush-For-Unity 我的项目,下载实现后间接双击或者在Unity外面抉择关上 MobPush.unitypackage,导入相干资源和脚本到您的 Unity我的项目即可应用。 导入unitypackage全副抉择即可(其中Demo.cs 为API应用和页面示例,可删除) 批改unity 编译环境 Android 集成编译配置资源批改删掉Android目录下的 baseProjectTemplate.gradle 、launcherTemplate.gradle文件 批改unity配置应用零碎的gradle配置文件 减少MobPush的gradle配置批改baseProjectTemplate.gradle和launcherTemplate.gradle(注:此处批改为新生成的baseProjectTemplate.gradle文件和launcherTemplate.gradle文件)baseProjectTemplate.gradle1.在classpath 'com.android.tools.build:gradle'后增加mob的classpathclasspath "com.mob.sdk:MobSDK:+"2.增加MobPush须要的maven地址 maven { url "https://mvn.mob.com/android/"}3.参考示例如截图launcherTemplate.gradle1.批改launcherTemplate.gradle减少MobPush配置 apply plugin: 'com.mob.sdk'MobSDK { appKey "xxxxxxxxx" appSecret "xxxxxxxxxx" MobPush { debugLevel 4 devInfo { HUAWEI{ appId "xxxxxxxxx" } XIAOMI { appId "xxxxxxx" appKey "5581830029242" } MEIZU { appId "xxxxx" appKey "3fc6d1acc7ea4f90a0304967ee3a74ae" } OPPO { appKey "xxxxxxxx" appSecret "c850609d8a0f492f8b9eeca1189aaec2" } VIVO { appId "xxxxxx" appKey "9b01729c-6140-4ad3-ac79-4c4543e12130" } } }}2.参考示例截图 ...

November 28, 2022 · 2 min · jiezi

关于算法:PGL图学习之项目实践UniMP算法实现论文节点分类新冠疫苗项目实战助力疫情系列九

原我的项目链接:https://aistudio.baidu.com/aistudio/projectdetail/5100049?contributionType=1 1.图学习技术与利用图是一个简单世界的通用语言,社交网络中人与人之间的连贯、蛋白质分子、举荐零碎中用户与物品之间的连贯等等,都能够应用图来表白。图神经网络将神经网络使用至图构造中,能够被形容成消息传递的范式。百度开发了PGL2.2,基于底层深度学习框架paddle,给用户裸露了编程接口来实现图网络。与此同时,百度也应用了前沿的图神经网络技术针对一些利用进行模型算法的落地。本次将介绍百度的PGL图学习技术与利用。 1.1图起源与建模首先和大家分享下图学习支流的图神经网络建模形式。 14年左右开始,学术界呈现了一些基于图谱合成的技术,通过频域变换,将图变换至频域进行解决,再将处理结果变换回空域来失去图上节点的示意。起初,空域卷积借鉴了图像的二维卷积,并逐步取代了频域图学习办法。图构造上的卷积是对节点街坊的聚合。 基于空间的图神经网络次要须要思考两个问题: 怎么表白节点特色;怎么表白一整张图。第一个问题能够应用街坊聚合的办法,第二问题应用节点聚合来解决。 目前大部分支流的图神经网络都能够形容成消息传递的模式。须要思考节点如何将音讯发送至指标节点,而后指标节点如何对收到的节点特色进行接管。 1.2 PGL2.2回顾介绍PGL2.2基于消息传递的思路构建整体框架。PGL最底层是飞浆外围paddle深度学习框架。在此之上,搭建了CPU图引擎和GPU上进行tensor化的图引擎,来不便对图进行如图切分、图存储、图采样、图游走的算法。再上一层,会对用户裸露一些编程接口,包含底层的消息传递接口和图网络实现接口,以及高层的同构图、异构图的编程接口。框架顶层会反对几大类图模型,包含传统图示意学习中的图游走模型、消息传递类模型、常识嵌入类模型等,去撑持上游的利用场景。 最后的PGL是基于paddle1.x的版本进行开发的,所以那时候还是像tensorflow一样的动态图模式。目前paddle2.0曾经进行了全面动态化,那么PGL也相应地做了动态图的降级。当初去定义一个图神经网络就只须要定义节点数量、边数量以及节点特色,而后将图tensor化即可。能够自定义如何将音讯进行发送以及指标节点如何接管音讯。 上图是应用PGL构建一个GAT网络的例子。最开始会去计算节点的权重,在发送音讯的时候GAT会将原节点和指标节点特色进行求和,再加上一个非线性激活函数。在接管的时候,能够通过reduce_softmax对边上的权重进行归一化,再乘上hidden state进行加权求和。这样就能够很不便地实现一个GAT网络。 对于图神经网络来讲,在构建完网络后,要对它进行训练。训练形式和个别机器学习有所不同,须要依据图的规模抉择实用的训练计划。 例如在小图,即图规模小于GPU显存的状况下,会应用full batch模式进行训练。它其实就是把一整张图的所有节点都搁置在GPU上,通过一个图网络来输入所有点的特色。它的益处在于能够跑一个很深的图。这一训练计划会被利用于中小型数据集,例如Cora、Pubmed、Citeseer、ogbn-arxiv等。最近在ICML上发现了能够重叠至1000层的图神经网络,同样也是在这种中小型数据集上做评估。 对于中等规模的图,即图规模大于GPU单卡显存,常识能够进行分片训练,每一次将一张子图塞入GPU上。PGL提供了另一个计划,应用分片技术来升高显存应用的峰值。例如对一个简单图进行计算时,它的计算复杂度取决于边计算时显存应用的峰值,此时如果有多块GPU就能够把边计算进行分块,每台机器只负责一小部分的计算,这样就能够大大地缩小图神经网络的计算峰值,从而达到更深的图神经网络的训练。分块训练结束后,须要通过NCCL来同步节点特色。 在PGL中,只须要一行DistGPUGraph命令就能够在原来full batch的训练代码中退出这样一个新个性,使得能够在多GPU中运行一个深层图神经网络。例如在obgn-arxiv中尝试了比较复杂的TransformerConv网络,如果应用单卡训练一个三层网络,其GPU显存会被占用近30G,而应用分片训练就能够将它的显存峰值升高。同时,还实现了并行的计算减速,例如原来跑100 epoch须要十分钟,当初只须要200秒。 在大图的状况下,又回归到平时做数据并行的mini batch模式。Mini batch与full batch相比最次要的问题在于它须要做街坊的采样,而街坊数目的晋升会对模型的深度进行限度。这一模式实用于一些巨型数据集,包含ogbn-products和ogbn-papers100m。 发现PyG的作者的新工作GNNAutoScale可能把一个图神经网络进行主动的深度扩大。它的次要思路是利用CPU的缓存技术,将街坊节点的特色缓存至CPU内存中。当训练图网络时,能够不必实时获取所有街坊的最新表白,而是获取它的历史embedding进行街坊聚合计算。试验发现这样做的成果还是不错的。 在工业界的状况下可能会存在更大的图规模的场景,那么这时候可能单CPU也存不下如此图规模的数据,这时须要一个分布式的多机存储和采样。PGL有一套分布式的图引擎接口,使得能够轻松地在MPI以及K8S集群上通过PGL launch接口进行一键的分布式图引擎部署。目前也反对不同类型的街坊采样、节点遍历和图游走算法。 整体的大规模训练形式包含一个大规模分布式图引擎,两头会蕴含一些图采样的算子和神经网络的开发算子。顶层针对工业界大规模场景,往往须要一个parameter server来存储上亿级别的稠密特色。借助paddlefleet的大规模参数服务器来反对超大规模的embedding存储。 1.3 图神经网络技术1.3.1 节点分类工作 在算法上也进行了一些钻研。图神经网络与个别机器学习场景有很大的区别。个别的机器学习假如数据之间独立同散布,然而在图网络的场景下,样本是有关联的。预测样本和训练样本有时会存在边关系。通常称这样的工作为半监督节点分类问题。 解决节点分类问题的传统办法是LPA标签流传算法,思考链接关系以及标签之间的关系。另外一类办法是以GCN为代表的特色流传算法,只思考特色与链接的关系。 通过试验发现在很多数据集下,训练集很难通过过拟合达到99%的分类准确率。也就是说,训练集中的特色其实蕴含很大的噪声,使得网络不足过拟合能力。所以,想要显示地将训练label退出模型,因为标签能够消减大部分歧义。在训练过程中,为了防止标签泄露,提出了UniMP算法,把标签流传和特色流传交融起来。这一办法在三个open graph benchmark数据集上获得了SOTA的后果。 后续还把UniMP利用到更大规模的KDDCup 21的较量中,将UniMP同构算法做了异构图的拓展,使其在异构图场景下进行分类工作。具体地,在节点街坊采样、批归一化和注意力机制中思考节点之间的关系类型。 1.3.2 链接预测工作 第二个比拟经典的工作是链接预测工作。目前很多人尝试应用GNN与link prediction进行交融,然而这存在两个瓶颈。首先,GNN的深度和街坊采样的数量无关;其次,当训练像常识图谱的工作时,每一轮训练都须要遍历训练集的三元组,此时训练的复杂度和街坊节点数量存在线性关系,这就导致了如果街坊比拟多,训练一个epoch的耗时很长。 借鉴了最近基于纯特色流传的算法,如SGC等图神经网络的简化形式,提出了基于关系的embedding流传。发现独自应用embedding进行特色流传在常识图谱上是行不通的。因为常识图谱上存在简单的边关系。所以,依据不同关系下embedding设计了不同的score function进行特色流传。此外,发现之前有一篇论文提出了OTE的算法,在图神经网络上进行了两阶段的训练。 应用OGBL-WikiKG2数据集训练OTE模型须要超过100个小时,而如果切换到的特色流传算法,即先跑一次OTE算法,再进行REP特色流传,只须要1.7个小时就能够使模型收敛。所以REP带来了近50倍的训练效率的晋升。还发现只须要正确设定score function,大部分常识图谱算法应用的特色流传算法都会有成果上的晋升;不同的算法应用REP也能够减速它们的收敛。 将这一套办法利用到KDDCup 21 Wiki90M的较量中。为了实现较量中要求的超大规模常识图谱的示意,做了一套大规模的常识示意工具Graph4KG,最终在KDDCup中获得了冠军。 1.4 算法利用落地 ...

November 28, 2022 · 3 min · jiezi

关于算法:图神经网络之预训练大模型结合ERNIESage在链接预测任务应用

1.ERNIESage运行实例介绍(1.8x版本)本我的项目原链接:https://aistudio.baidu.com/aistudio/projectdetail/5097085?contributionType=1 本我的项目次要是为了间接提供一个能够运行ERNIESage模型的环境, https://github.com/PaddlePadd... 在很多工业利用中,往往呈现如下图所示的一种非凡的图:Text Graph。顾名思义,图的节点属性由文本形成,而边的构建提供了构造信息。如搜寻场景下的Text Graph,节点可由搜索词、网页题目、网页注释来表白,用户反馈和超链信息则可形成边关系。 ERNIESage 由PGL团队提出,是ERNIE SAmple aggreGatE的简称,该模型能够同时建模文本语义与图构造信息,无效晋升 Text Graph 的利用成果。其中 ERNIE 是百度推出的基于常识加强的继续学习语义了解框架。 ERNIESage 是 ERNIE 与 GraphSAGE 碰撞的后果,是 ERNIE SAmple aggreGatE 的简称,它的构造如下图所示,次要思维是通过 ERNIE 作为聚合函数(Aggregators),建模本身节点和街坊节点的语义与构造关系。ERNIESage 对于文本的建模是构建在街坊聚合的阶段,核心节点文本会与所有街坊节点文本进行拼接;而后通过预训练的 ERNIE 模型进行音讯汇聚,捕获核心节点以及街坊节点之间的互相关系;最初应用 ERNIESage 搭配独特的街坊相互看不见的 Attention Mask 和独立的 Position Embedding 体系,就能够轻松构建 TextGraph 中句子之间以及词之间的关系。 应用ID特色的GraphSAGE只可能建模图的构造信息,而独自的ERNIE只能解决文本信息。通过PGL搭建的图与文本的桥梁,ERNIESage可能很简略的把GraphSAGE以及ERNIE的长处联合一起。以上面TextGraph的场景,ERNIESage的成果可能比独自的ERNIE以及GraphSAGE模型都要好。 ERNIESage能够很轻松地在PGL中的消息传递范式中进行实现,目前PGL在github上提供了3个版本的ERNIESage模型: ERNIESage v1: ERNIE 作用于text graph节点上;ERNIESage v2: ERNIE 作用在text graph的边上;ERNIESage v3: ERNIE 作用于一阶街坊及起边上;次要会针对ERNIESageV1和ERNIESageV2版本进行一个介绍。 1.1算法实现可能有同学对于整个我的项目代码文件都不太理解,因而这里会做一个比较简单的解说。 外围局部蕴含: 数据集局部data.txt - 简略的输出文件,格局为每行query \t answer,可作简略的运行实例应用。模型文件和配置局部ernie_config.json - ERNIE模型的配置文件。vocab.txt - ERNIE模型所应用的词表。ernie_base_ckpt/ - ERNIE模型参数。config/ - ERNIESage模型的配置文件,蕴含了三个版本的配置文件。代码局部local_run.sh - 入口文件,通过该入口可实现预处理、训练、infer三个步骤。preprocessing文件夹 - 蕴含dump_graph.py, tokenization.py。在预处理局部,咱们首先须要进行建图,将输出的文件构建成一张图。因为咱们所钻研的是Text Graph,因而节点都是文本,咱们将文本示意为该节点对应的node feature(节点特色),解决文本的时候须要进行切字,再映射为对应的token id。dataset/ - 该文件夹蕴含了数据ready的代码,以便于咱们在训练的时候将训练数据以batch的形式读入。models/ - 蕴含了ERNIESage模型外围代码。train.py - 模型训练入口文件。learner.py - 分布式训练代码,通过train.py调用。infer.py - infer代码,用于infer出节点对应的embedding。评估局部build_dev.py - 用于将咱们的验证集批改为须要的格局。mrr.py - 计算MRR值。要在这个我的项目中运行模型其实很简略,只有运行下方的入口命令就ok啦!然而,须要留神的是,因为ERNIESage模型比拟大,所以如果AIStudio中的CPU版本运行模型容易出问题。因而,在运行部署环境时,倡议抉择GPU的环境。 ...

November 27, 2022 · 3 min · jiezi

关于算法:MobPush-Android-快速集成

开发工具:Android Studio 集成形式:Gradle在线集成 安卓版本反对:minSdkVersion 19 集成筹备注册账号应用PushSDK之前,须要先在MobTech官网注册开发者账号,并获取MobTech提供的AppKey和AppSecret,详情能够点击查看注册流程 MobPush后盾配置注册MobTech账号后,须要在MobTech后盾进行相干信息的配置,详情能够点击查看具体配置信息 MobPush流程图 增加配置在我的项目Gradle文件中注册MobSDKbuildscript { repositories { // 1.增加MobSDK Maven地址 maven { url "https://mvn.mob.com/android" }}dependencies { // 2.注册MobSDK classpath "com.mob.sdk:MobSDK2:+"}} 在我的项目App Module的Gradle文件中增加插件和扩大// 调用MobTech SDKapply plugin: 'com.mob.sdk'MobSDK { appKey "替换为MobTech官网申请的appkey" appSecret "替换为MobTech官网申请的appkey对应的appSecret" MobPush {}}`在gradle.properties中增加代码`MobSDK.spEdition=FP回传用户隐衷受权后果(submitPolicyGrantResult)为保障您的App在集成MobSDK之后可能满足工信部相干合规要求,您应确保App装置首次冷启动且获得用户浏览您《隐衷政策》受权之后,调用MobSDK.submitPolicyGrantResult回传隐衷协定受权后果。 反之,如果用户不批准您App《隐衷政策》受权,则不能调用MobSDK.submitPolicyGrantResult回传隐衷协定受权后果。 请参考链接合规指南 /** * com.mob.MobSDK.class * 回传用户隐衷受权后果 * @param isGranted 用户是否批准隐衷协定 */ public static void submitPolicyGrantResult(boolean isGranted)示例代码 注:调用地位开发者能够本人指定,只需在应用SDK性能之前调用即可,强烈建议开发者在终端用户点击利用隐衷协定弹窗批准按钮后调用。 `MobSDK.submitPolicyGrantResult(true);

November 26, 2022 · 1 min · jiezi

关于算法:ELEX-4618面向对象设计

ELEX 4618: Object Oriented Design Lab 6Craig Hennessey 12/12/2021 1Lab 6 – Asteroids1 IntroductionIn this lab, inheritance will be used to implement a simplified version of the game Asteroids.2 Design Problem2.1 AsteroidsThe simplified game of Asteroids will have a number of game elements including the player ship, theasteroids and missiles fired by the ship to destroy the asteroids. All objects will inherit from the same gameobject and share many of the same characteristics. The ship position (X/Y) will be controlled by thejoystick, the same as the Etch-A-Sketch game. Asteroids will randomly appear at the top of the screen anddrift at a random angle and speed downwards. By pushing (and/or holding) a button on the controller, theship can fire missiles upwards towards the asteroids.The player begins the game with 10 lives. If an asteroid collides with the ship, both the player and asteroidlose a life (life = life - 1). If an asteroid or missile collides with the side of the display, they both lose a life.If an asteroid and missile collide, both lose a life and the player score increases by 10 points.The CAsteroidGame class will inherit from CBase4618 for the update/draw/run methods and the canvasimage. The class should contain a vector for asteroids and one for missiles as well as the other game relatedmember variables. In update, loop over the vector of asteroids and missiles to detect collisions anddetermine remaining lives, then loop over again and remove any objects with lives <= 0. Finally, loop overthe remaining objects to draw.2.1.1 CGameObjectAll objects will be 2D circles, having a radius, position, and velocity. Missiles will be small and fast, theship will be a medium size and positioned according to the joystick, and asteroids will be a random sizewith random speed and direction. A helpful technique for random sizes is to get a random number between0 and 1 ((float)rand() / (float)RAND_MAX) which can then be scaled and offset to get any range ofnumbers desired.class CGameObject {protected:Point2f _position;Point2f _velocity;int _radius;int _lives;public:void move();bool collide(CGameObject &obj);bool collide_wall(Size board);void hit();int get_lives() { return _lives; }void set_lives(int lives) { _lives = lives; }void set_pos(Point2f pos) { _position = pos; }Point2f get_pos() { return _position; }void draw(Mat &im);}; ...

November 26, 2022 · 5 min · jiezi

关于算法:COMP222-Asteroids-Game

COMP222 - 2022 - First CA AssignmentIndividual courseworkAsteroids-like GameAssessment InformationAssignment Number 1 (of 2)Weighting 12%Assignment Circulated Friday 4 February 2022Deadline Monday 28 March 2022, 17:00Submission Mode ElectronicLearning outcome assessed 2. An appreciation of the fundamental concepts associatedwith game development: game physics, game arti-ficial intelligence, content generation; The ability to implement a simple game using anexisting game enginePurpose of assessment To implement a simple 3D game using a game enginelibraryMarking criteria The marking scheme can be found in Section 3Submission necessary in order Noto satisfy Module requirements?Late Submission Penalty Standard UoL PolicyI enforce a “no error policy” in this module: If your code does not compile,your mark will be capped at 40%. Thus, you may get a higher mark for anincomplete solution than for an advanced sketch.1Figure 1: Before shooting asteroid Figure 2: After shooting asteroidObjectivesThis assignment requires you to implement a simple 3D game using the jMonkeyEnginelibrary. Optionally, you can use Unity 3D or Unreal Engine.Basic Game DescriptionThe objective of this assignment is to implement a game inspired by the classic arcade game“Asteroids”, see, for example, https://en.wikipedia.org/wiki...(video_game)and https://www.youtube.com/watch...The game is played on a rectangular “field” bounded by walls from above, below, left andright (the original game has no walls, but your game has). The game objects (“asteroids”)are positioned inside the field and can “float” in a linear movement (by translation). Whenan asteroid collides with a wall or another asteroid, it “bounces” (changes direction accordingto Newton Laws without gravity). A player controls a spaceship that is able to “fly” insidethe field and to “shoot” bullets. When a bullet strikes an asteroid, the asteroid “breaks”into a few smaller asteroids (at least 2 ) that float in directions and speeds different than thedirection and speed of the original (broken) asteroid. An asteroid can break into smaller onesat most 5 times, i.e. when an asteroid of minimum size gets shot by a bullet, the asteroiddisappears (is removed from the field). The player wins when all asteroids are removed fromthe field. The player loses when an asteroid collides with the spaceship.Figure 1 shows an example of the the game’s setup, i.e. within a field bounded by 4 walls,there exist 3 asteroids (large green balls) “floating” according to the blue vectors (arrows),as well as 1 spaceship (blue triangle) shooting towards one asteroid (red dashed line). Figureshows the effect of the bullet hitting an asteroid, i.e. it is removed from the game andreplaced by two smaller asteroids (smaller red balls) that float towards different directionsand speeds than the removed greed ball.2Marking SchemeThe assignment is split in a number of steps. Every step gives you some marks. You donot have to implement them in any particular order. Also, the steps below describe whatis expected from you in a bit more detail. It is up to you if you implement the followingfunctionalities using your game engine’s internal functions, or if you write your own functionsto do so. Neither choice will be favored with extra points.Step 1: Modeling the environment (10%)Model the playing field (4 walls), the asteroids and the spaceship. You can either use a 3Dmodeling tool like Blender or use the shapes of the game engine you implement the gamein. You must put at least 3 asteroids on the field, and exactly one spaceship. Make surethat the playing field is relatively large, i.e. if the size of the field does not facilitate smoothgameplay, marks will be removed.Step 2: Keyboard interaction (20%)In this step you should implement the control of the spaceship from input given by the humanplayer. Preferably the player should use the keyboard. However, using other input methods,such as the mouse, is not disallowed. The step is further divided into smaller sub-steps.Step 2.1: Implementing “fly” (15% / 20%)In this step you should implement the “flying” of the spaceship. The spaceship has someinitial direction and has its initial speed equal to 0. Assuming you take input from thekeyboard, you assign 4 buttons: button “forwards” increases the speed of the spaceshipalong the current direction; button “backwards” decreases the speed of the spaceship alongthe current direction; button “rightwards” rotates clockwise the direction of the spaceshipwith some fixed angular speed; button “leftwards” rotates counter-clockwise the direction ofthe spaceship with some fixed angular speed.Step 2.2: Implementing “shoot” (5% / 20%)In this step you should implement the “shooting” of the spaceship. Assuming you take inputfrom the keyboard, you assign 1 button “shoot” which releases a bullet from the positionof the spaceship and along the current direction of the spaceship. The speed of the bulletshould be relatively fast (at least faster than the spaceship). The amount of bullets is foryou to decide. The interaction of the bullet with the asteroids is described below in Step3.3.3Step 3: Physics 30% totalThe purpose of this step is to model the physical interaction of the game entities. The stepis further divided into smaller sub-steps.Step 3.1: Implementing “float” (5% / 30%)In this step you should implement the “floating” of the asteroids. They move linearlyaccording to a given initial direction and speed.Step 3.2: Implementing “bounce” (10% / 30%)In this step you should implement the “bouncing” of the asteroids. When an asteroidcollides with a wall, it should reflect off the wall. When two (or more) asteroids collide witheach other, they should reflect off each other. The bouncing should follow Newton’s Lawsand should not take gravity into account, because supposedly the game takes place in outerspace. When an asteroid collides with the spaceship, the player loses.Step 3.3: Implementing “break” (15% / 30%)In this step you should implement the “breaking” of the asteroids. An asteroid “breaks” intosmaller ones after it has collided with a bullet. “Breaking” means that the original asteroidis removed from the game and is replaced by 2 (or more) smaller asteroids. The direction andspeed of the smaller asteroids should be different than that of the removed asteroid. (I don’tpose any other restriction, it’s up to you how the smaller asteroids behave.) Also, breakingof an asteroid should be done at most 5 times, otherwise the game will never end. I.e. whenan asteroid of minimum size breaks, it is removed and not replaced by any asteroid(s).Step 4: Gameplay (20%)Add a visible points count and some kind of game levels. The point system is up to you todefine, for example every hit of a bullet with some asteroid gives 1 point, or you can have aspoints the percentage of bullets used to bullets that have hit asteroids. To get full marks forthis steps, you should have at least 2 levels and it should be clear when the player progressesto the higher level. Moreover, it is important that the levels have increasing difficulty. Howthis is achieved is again up to you, e.g. higher levels can have more asteroids, or fasterasteroids, or break into more asteroids, or can break more times, or combinations of theseoptions.Step 5: Creativity (20%)You can see that the marks for the steps described above add up to 80%. In order toget 20% extra you need to be creative and implement some nice features. Below are someideas: use textures, sound effects, lighting, power-up packs (making the spaceship immune4to impact with asteroids, or even able to function as a bullet itself), implement some systemon acquiring bullets, etc. Also, the above specifications do not define what happens if thespaceship or a bullet hits the wall. Typically, they should simply stop at the point of collision.However, you can be more creative here, and implement a weird bounce, or that they canexit the field from the point of collision and re-enter from the opposite side (like the originalgame).Deadlines and How to Submit Deadline for submitting the first assignment is Monday 28 March 2022, 17:00 Submission is via Canvas accessible fromhttps://liverpool.instructure... All submission must contain the source code, the executable, the necessary files for theruntime execution and a report.For jMonkeyEngine submissions you are advised to export your project (File →Export Project → To ZIP) and submit the ZIP file. Please ensure that the files yousubmit can be loaded into jMonkeyEngine.For Unity and Unreal Engine you are advised to build & export your game so thatit runs independently of these platforms; instructions are found online. To submit thecode you have scripted, copy it to a txt file. Please ensure that your submitted gameis playable.Please submit the report in the form of document (in pdf-format) containing acheck list indicating whether the above marking points have been implemented successfully.In the extra features part of the checklist, describe the features you haveimplemented.

November 26, 2022 · 7 min · jiezi

关于算法:ECE414求解问题

ECE414HW 8 For this problem, set your Matlab path to use the angdiff function from the text toolbox, not theMatlab toolbox. Use Matlab to write your own drivepoint program using the start given in class. Showyour code. Show a plot of the path for combinations in the table below. You will have 2 plots. Copyplots from Matlab, paste into a Word document, and adjust size to fit the two plots to a line. Adjustyour axes using the following Matlab command:axis([min(xpath(:))-0.1*abs(min(xpath(:))) ... max(xpath(:))+0.1*abs(min(xpath(:))) ... min(ypath(:))-0.1*abs(min(ypath(:))) ... max(ypath (:))+0.1*abs(min(ypath (:)))])a)[xgoal ygoal] [xinit yinit angint][5 5] [3 5 pi][3 5 –pi+0.01]b) Provide a complete explanation why the paths are different. It may help to print out some variablesthe first time through the while loop.c) Show a plot of the path for combinations in the table below. Copy plots from Matlab, paste into aWord document, and adjust size to fit the two plots to a line. Adjust your axes using the command givenin part a:[xgoal ygoal] [xinit yinit angint][5 5][8 5 –pi+0.01][8 5 0][8 5 pi/2][8 5 -pi/2][0 0][4 -3 pi/4][4 5 0][-2 -3 pi/2][3 -6 -pi/2]

November 26, 2022 · 1 min · jiezi

关于算法:PGL图学习之图神经网络ERNIESageUniMP进阶模型系列八

PGL图学习之图神经网络ERNIESage、UniMP进阶模型[系列八]原我的项目链接:fork一下即可:https://aistudio.baidu.com/aistudio/projectdetail/5096910?contributionType=1 相干我的项目参考:(其余图神经网络相干我的项目见主页) 对于图计算&图学习的基础知识概览:前置知识点学习(PGL)[系列一] https://aistudio.baidu.com/aistudio/projectdetail/4982973?contributionType=1 图机器学习(GML)&图神经网络(GNN)原理和代码实现(前置学习系列二):https://aistudio.baidu.com/ai... 图学习【参考资料1】词向量word2vec https://aistudio.baidu.com/ai... 图学习【参考资料2】-常识补充与node2vec代码注解 https://aistudio.baidu.com/ai... 1.Open Graph Benchmark(OGB) 1.1 OGB概述如何进一步推动图学习的钻研呢?从历史上看,高质量和大规模的数据集在推动钻研中施展了重要的作用,例如计算机视觉畛域的IMAGENET、MS COCO,自然语言解决畛域的GLUE BENCHMARK、SQUAD,语言解决畛域的LIBRISPEECH、CHIME等。然而,以后在图学习钻研中罕用的数据集和评估程序可能会对将来的倒退产生负面影响。 以后基准数据集存在的问题: 与理论利用中的图相比,大多数罕用数据集都十分小。例如宽泛应用的Cora、Citeseer、Pubmed数据集,在节点分类工作中只用2700至20000个节点。因为在这些小型数据集上宽泛开发了模型,因而大多数模型都无奈扩大到较大的图;其次,较小的数据集很难去严格地评估须要大量数据的模型,例如图神经网络(GNNs)。没有对立且通常遵循的试验协定。不同的钻研采纳本人的数据集划分、评估指标和穿插验证协定,因而比拟各种钻研报告的问题具备挑战性。另外,许多钻研应用随机宰割来生成train /test sets,这对于真实世界的利用是不事实的或无用的,并且通常导致过于乐观的性能后果。因而,迫切需要一套残缺的事实世界基准测试套件,该套件将来自不同畛域的各种大小的数据集组合在一起。数据拆分以及评估指标很重要,因而能够以统一且可反复的形式掂量进度。最初,基准测试还须要提供不同类型的工作,例如节点分类,链接预测和图分类。OGB就这样应运而生。 凋谢图谱基准 (OGB) 是图机器学习的基准数据集、数据加载器和评估器的汇合。数据集涵盖各种图形机器学习工作和理论利用。OGB旨在提供涵盖重要图机器学习工作、多样化数据集规模和丰盛畛域的图数据集。 论文链接:https://arxiv.org/abs/2005.00687OGB官网:https://ogb.stanford.edu/GitHub地址:https://github.com/snap-stanf... Graph ML Tasks: 涵盖了三个根本的图机器学习工作:节点属性预测,链接属性预测,图属性预测。Diverse scale: 小型图形数据集能够在单个 GPU 中解决,而中型和大型图形可能须要多个 GPU 或奇妙的采样/分区技术。分为small、medium、large三个规模,具体为small:超过10万个节点和超过100万条边;medium:超过100万个节点或超过1000万条边;large:大概1亿个节点或10亿条边。Rich domains: 图数据集来自从迷信畛域到社会/信息网络的不同畛域,还包含异构常识图谱。nature:蕴含生物网络和分子图;society:蕴含学术图和电子商务网络;information:蕴含常识图谱等。看一下 OGB 当初蕴含的数据集和数据集的统计明细: 1.2 OGB数据集简介1.2.1 OGB节点属性预测ogbn-products:亚马逊产品独特购买网络。 节点代表在Amazon销售的产品,两个产品之间的边示意产品是一起购买的。节点特色是通过从产品描述中提取词袋特色来生成的,而后进行主成分剖析将维度减小到100。预测工作:在多类别分类设置中预测产品的类别,其中有47个顶级类别用于指标标签。数据集划分:应用销售排名(受欢迎水平)将节点划分为训练/验证/测试集,依据产品的销售排名对产品进行排序,并应用前10%作为训练集,而后应用前2%作为验证集,其余用于测试集。ogbn-proteins:蛋白质关联网络 节点代表蛋白质,边示意蛋白质之间不同类型的有生物学意义的分割。所有的边都具备8维特色,其中每个维度示意单个关联类型的强度,值在0到1之间。这些蛋白质来自8个物种。预测工作:在一个多标签二元分类零碎中预测蛋白质性能的存在,该零碎中总共有112种标签须要预测。通过112个工作的ROC-AUC分数的平均值来掂量性能。数据集宰割:依据蛋白质起源的物种,将蛋白质节点分成训练/验证/测试集。试验中为了简略起见,应用传入边的均匀边缘特色作为节点特色。 ogbn-arxiv:论文援用网络 每个节点都是一篇Arxiv论文,每条有向边示意一篇论文援用了另一篇论文。每篇论文都有一个128维的特征向量,它是通过对题目和摘要中单词的嵌入进行均匀失去的。预测工作:预测Arxiv论文的次要类别,这是一个40类的分类问题。数据集宰割:思考一个基于论文发表日期的事实数据宰割。倡议将2017年及以前发表的论文作为训练集,将2018年发表的论文作为验证集,将2019年当前发表的论文作为测试集。试验中为了简略起见,将有向图转换为无向图。从上面的后果能够看出,摸索如何思考边缘方向信息以及节点工夫信息(例如论文发表的年份)以进步预测性能将是富有成效的。 ogbn-papers100M:论文援用网络 MAG(Microsoft Academic Graph)索引的1.11亿篇论文的有向引文图。此数据集的数量级比任何现有的节点分类数据集大。预测工作:预测在Arxiv中发表的论文的子集的主题畛域。有172个Arxiv主题畛域,这使预测工作成为172类分类问题。数据集宰割:思考一个基于论文发表日期的事实数据宰割。倡议将2017年及以前发表的论文作为训练集,将2018年发表的论文作为验证集,将2019年当前发表的论文作为测试集。试验中为了简略起见,将有向图转换为无向图。从上面的后果能够看出,SGC重大拟合有余,表明应用更具表现力的GNNs可能会同时改善训练和测试准确性。 ogbn-mag:异构微软学术图(MAG) 由Microsoft Academic Graph (MAG)的一个子集组成的异构网络。它蕴含四种类型的实体(论文、作者、机构和钻研畛域),以及连贯两种类型实体的四种有向关系。每一篇论文具备128维的特色。预测工作:依据给定的内容、参考文献、作者和作者的附属关系来预测每篇论文的会议地点。ogbn-mag中共有349个不同的会议地点,这使得该工作成为349类分类问题。数据集宰割:遵循雷同的基于工夫的策略。用2018年之前发表的所有论文的训练模型,并用2018年和2019年当前发表的论文别离验证和测试模型。对于GCN和GRAPHSAGE,试验中在同构子图上利用模型。从上面的后果能够看出吗,利用图的异构性质对于在这个数据集上获得良好的性能是至关重要的。 1.2.2 OGB链接属性预测ogbl-ppa:蛋白质关联网络 节点示意来自58个不同物种的蛋白质,边示意蛋白质之间的生物学上有意义的关联。每个节点都蕴含一个58维的one-hot特征向量,该向量批示相应蛋白质所来自的物种。预测工作:在给定训练边的状况下预测新的关联边。评估基于模型对positive测试边胜过negative测试边的等级。具体来说,针对3,000,000个随机采样的negative边对验证/测试集中的每个positive边进行排名,并计算排名在第K位或更高(Hits@K)的positive边的比率。发现K=100是评估模型性能的一个很好的阈值。数据集宰割:依据边的生物学吞吐量分为训练/验证/测试边。试验后果如下所示,GNN训练成果不佳表明,仅靠GNN无奈捕捉的地位信息对于适应训练边并取得有意义的节点嵌入可能至关重要。 ogbl-collab:作者单干网络 每个节点代表一个作者,边示意作者之间的单干。 所有节点都具备128维特色,这些特色是通过均匀作者发表的论文的词嵌入取得的。所有边都与两种类型的元信息相关联:年份和边缘权重,代表当年发表的单干论文的数量。预测工作:依据给定的过来单干来预测将来的作者单干关系。评估指标相似于ogbl-ppa,心愿该模型将实在合作的等级高于虚伪合作。 具体来说,在100,000个随机采样的negative合作中对每个实在合作进行排名,并计算排名在K位或更高(Hits@K)的positive边的比率。在初步试验中,发现K=50是一个很好的阈值。数据集宰割:依据工夫拆分数据,以便在合作举荐中模仿理论利用。具体来说,将直到2017年的单干作为训练边,将2018年的单干作为验证边,并将2019年的单干作为测试边。试验后果如下图,值得注意的是,MATRIXFACTORIZATION能够达到近乎完满的训练后果,然而即便利用大量的正则化解决,也无奈将良好的后果转移到验证和测试拆分中。总体而言,摸索将地位信息注入GNN并开发更好的正则化办法是富有成果的。 ogbl-ddi:药品交互网络 节点代表FDA批准的或试验药物,边代表药物之间的相互作用,并且能够解释为一种景象,其中将两种药物合用的联结成果与预期的药物彼此独立起作用的成果有很大不同。预测工作:在已知药物相互作用的根底上预测药物相互作用。评估指标与ogbl-collab类似,心愿该模型将实在药物相互作用的排名高于非相互作用药物对。具体来说,在大概100,000个随机采样的negative药物相互作用中对每个实在药物相互作用进行排名,并计算在K位或更高(Hits@K)处排名的positive边缘的比率。在初步试验中,发现K = 20是一个很好的阈值。数据集宰割:开发了一种蛋白质-靶标拆分,这意味着依据那些药物在体内靶向的蛋白质来拆分药物边缘。试验后果如下所示,乏味的是,GNN模型和MATRIXFACTORIZATION办法都比NODE2 VEC取得了显著更高的训练后果。然而,只有GNN模型能力在某种程度上将这种性能传递给测试集,这表明关系信息对于使模型推广到看不见的交互作用至关重要。 ...

November 26, 2022 · 6 min · jiezi

关于算法:技术解读-TuGraph图分析引擎技术剖析

导语图剖析引擎又称图计算框架,次要用来进行简单图剖析,是一种可能全量数据集运行疾速循环迭代的技术,实用场景包含社区发现、基因序列预测、重要性排名等,典型算法有PageRank、WCC、BFS、LPA、SSSP。 TuGraph图数据管理平台社区版已于2022年9月在Github开源,本文将对TuGraph图剖析引擎的技术进行分析。(图1.1 图剖析引擎) 1 TuGraph图剖析引擎概览TuGraph的图剖析引擎,面向的场景次要是全图/全量数据分析类的工作。借助TuGraph的 C++ 图剖析引擎 API ,用户能够对不同数据起源的图数据疾速导出一个待处理的简单子图,而后在该子图上运行诸如BFS、PageRank、LPA、WCC等迭代式图算法,最初依据运行后果做出相应的对策。 在TuGraph中,导出和计算过程均能够通过在内存中并行处理的形式进行减速,从而达到近乎实时的解决剖析,和传统办法相比,即防止了数据导出落盘的开销,又能应用紧凑的图数据结构取得计算的现实性能。 依据数据起源及实现不同,可分为Procedure、Embed和Standalone三种运行模式。其中Procedure模式和Embed模式的数据源是图存储中加载图数据,别离实用于Client/Server部署,以及服务端间接调用,后者多用于调试。 Standalone模式的数据源是TXT、二进制、ODPS文件等内部数据源,可能独立于图数据存储间接运行剖析算法。 TuGraph图计算零碎社区版内置6个根底算法,商业版内置了共34种算法。涵盖了图构造、社区发现、门路查问、重要性剖析、模式开掘和关联性剖析的六大类罕用办法,能够满足多种业务场景须要,因而用户简直不须要本人实现具体的图计算过程。 算法类型中文算法名英文算法名程序名门路查问广度优先搜寻Breadth-First Searchbfs单源最短门路Single-Source Shortest Pathsssp全对最短门路All-Pair Shortest Pathapsp多源最短门路Multiple-source Shortest Pathsmssp两点间最短门路Single-Pair Shortest Pathspsp重要性剖析网页排序Pagerankpagerank介数核心度Betweenness Centralitybc置信度流传Belief Propagationbp间隔核心度Closeness Centralityclce个性化网页排序Personalized PageRankppr带权重的网页排序Weighted Pagerank Algorithmwpagerank信赖指数排名Trustranktrustranksybil检测算法Sybil Ranksybilrank超链接主题搜寻Hyperlink-Induced Topic Searchhits关联性剖析均匀会聚系数Local Clustering Coefficientlcc独特街坊Common Neighborhoodcn度数关联度Degree Correlationdc杰卡德系数Jaccard Indexji图构造直径预计Dimension EstimationdeK核算法K-corekcorek阶团计数算法Kcliqueskcliquesk阶桁架计数算法Ktrussktruss最大独立集算法Maximal independent setmis社区发现弱连通重量Weakly Connected Componentswcc标签流传Label Propagation AlgorithmlpaEgoNet算法EgoNeten鲁汶社区发现Louvainlouvain强连通重量Strongly Connected Componentsscc监听标签流传Speaker-listener Label Propagation Algorithmslpa莱顿算法Leidenleiden带权重的标签流传Weighted Label Propagation Algorithmwlpa模式开掘三角计数Triangle Countingtriangle子图匹配算法Subgraph Isomorphismsubgraph_isomorphism模式匹配算法Motifmotif表1.1 TuGraph内置算法 2 性能介绍2.1 图剖析框架图剖析框架作为图剖析引擎的“骨架”,能够联结多种模块无效的耦合协同工作。个别分为预处理、算法过程、后果剖析三个阶段。 预处理局部用于读入数据及参数进行图构建及相干信息的存储统计,并整顿出算法过程所需的参数及数据。 算法过程会依据失去的数据通过特定的算法进行逻辑计算,并失去后果数据。后果剖析局部依据失去的后果数据进行个性化解决(如取最值等),并将重要的信息写回和打印输出操作。 2.2 点边筛选器点边筛选器作用于图剖析引擎中的 Procedure 和 Embed 模式。对于图存储数据源可依据用户须要和理论业务场景对图数据进行筛查,抉择无效的点边进行图构造的构建。2.3 一致性快照TuGraph 中的 Procedure 和 Embed 模式可能提供数据“快照”,即建设一个对指定数据集的齐全可用拷贝,该拷贝包含相应数据在某个工夫点(拷贝开始的工夫点)的镜像。因为 OLAP 的操作仅波及读操作而不波及写操作,OlapOnDB 会以一种更紧凑的形式对数据进行排布,在节俭空间的同时,进步数据拜访的局部性。2.4 块状读写模块块状读写模块作用于图剖析引擎中的 Standalone 模式,用于对不同内部数据源的数据进行高效读入,同时也蕴含对外部算法解决后的图数据后果写回。2.5 参数模块参数模块作用于剖析引擎中的 Standalone 模式,用于对图的个别信息(如数据起源,算法名称,数据输出、输入门路,顶点个数等)以及依据不同数据起源、不同算法所配置的不同信息参数进行承受和整顿,传输给图算法及各个模块,同时将最终后果模块化展现。 ...

November 25, 2022 · 1 min · jiezi

关于算法:CE-484动物分析

ECE 484/584 - ANTENNAS AND PROPAGATIONWinter Term 2022 Project #2 (due Tuesday, Feb. 22) This project consists of two parts: Plot the horizontal (normalized) radiation patterns for day and night (in linear and polar form) for the AM radiostation KOAC (550KHz), as well as the radiation patterns for the radio stations KEX (1190KHz) in Portlandand KUGN (590 KHz) in Eugene. The necessary information about antenna phasing, spacing, and orientationis given in the lecture notes and in the diagrams attached below.Design a wire dipole antenna together with a matching network to match the antenna to a 300W twin-lead wire.Specifications: design frequency f = 144MHz ...

November 25, 2022 · 2 min · jiezi

关于算法:CS265网络协议解答

CS265 Computer Networking: Programming Problem 1Due: Thursday, February 24, 2022 at 11:59PM.DescriptionIn this assignment you are to develop a chat program that uses the UVMPM protocol, which is described athttp://ceskalka.w3.uvm.edu/26... A UVMPM server socket is availablefor connections from within the UVM domain1at 132.198.11.122.You can use whatever programming language and socket library you wish. However, your assignmentmust be gradeable, in the sense that we need to be able to test it. This means you should write your clienteither (1) with a command line interface runnable on silk3, or (2) designed with a GUI interface runnableon a recent “vanilla” installation of OSX or Windows. In case (2) you should definitely test your code ona UVM computer lab machine to ensure it works properly for testing- and obviously this option requiresmore work and should only be pursued if you are interested, there are no additional points for a GUIversion. In any case your application should prompt the user for signin, and subsequently allow users tolist other users, message other users, and to sign off.The interface you develop should be appealing to use and not “expose” any details of the UVMPMprotocol, which should be managed by your code. An example of a command line interface interaction,and the corresponding UVMPM traffic, is provided below for guidance.User AccountsYou have been preassigned a user account on the UVMPM server at 132.198.11.12– your username isyour UVM netid, and your password is your netid backwards. In addition, the server supports user accountstest1 through test10, all with password p001.What to SubmitPlease submit all source code, as well as a README file if necessary with any relevant instructions aboutcompiling and/or using your client.Grading CriteriaYour submissions will be graded on the following criteria:• Syntactic correctness (does your code parse correctly): 20%• Functional correctness (does your code do the right thing?): 75%, with partial credit given for partialsolution.• Style (program structure, formatting, commenting): 5%1You will need to be on silk or running UVM VPN.2Our UVMPM server source code is available in the public CS265 git repo- see Supplemental Materials on bb for the repo URL.3Note that Python 3 is installed on silk.1ExamplesHere is an example of a command-line user interface you could emulate.$ ./client.pyPlease enter the server hostname or IPv4 address: 132.198.11.12Please enter the server port number: 12000Please enter a username: test1Please enter a password: p099Incorrect username and/or password.Please enter a username: test1Please enter a password: p001You are now authenticated.Choose an option: ...

November 25, 2022 · 3 min · jiezi

关于算法:数据治理必读|基于Dataphin快速建设高质量数据支撑业务发展

数据品质是数据建设和治理中十分重要的一环。所有的数据利用,不论是用于反对业务发展的数据库,还是用于反对商业决策,或者用于机器学习和人工智能等高级利用,实现数据价值的前提是数据自身是高质量、牢靠的,高质量的数据,能够撑持业务疾速倒退。 数据品质的好坏,间接影响着业务的发展,上面是一些简略的示例:  良好的数据品质 数据撑持业务顺利开展,如更准确的用户偏好,通过举荐进步用户的消费额;更实时的物流信息,优化物流调配和配送效率;更精确的仓储信息,优化仓储补货和治理等及时精确的数据,能够反对高效的商务决策 蹩脚的数据品质 业务发展碰壁,如无奈正确开具发票,导致无奈走财务流程;注销了谬误的用户联系方式,导致货物无人接管等数据谬误导致业务决策出错最好的机器学习算法,遇到数据品质有余时,后果也不如人意数据品质问题的起源泛滥,业务方面(不足对立的治理标准,导致指标定义不同等)、治理方面(短少欠缺的组织和体系撑持,各环节不能高效协同等)、技术计划(设计和开发脱节,数据采集建设过程呈现各类问题等)都可能导致数据品质变差。 因而在数据建设过程中,数据治理的重要性日益突出。系统地解决数据品质问题,须要从多方面进行优化。Dataphin数据品质能够帮忙组织积淀业务规定,并通过技术进行自动化的品质校验,同时反对告警、大盘等治理性能,助力企业解决数据品质问题,取得高质量数据来更好反对业务倒退。 发展数据治理,首先要建设「全局视角」全域数据品质是指对客户全场景/全数据源下的数据罕用的数据场景,都能够进行数据品质监控,本次降级反对了大部分罕用场景和计算源,并继续扩大中。Dataphin以后可能对客户在数据处理中罕用到的数据引擎、数据源和数据对象进行数据品质的监控,具体反对的列表如下: 丰盛的规定模板,让管理工作「化繁为简」Dataphin数据品质,反对对数据表进行完整性、唯一性、及时性、有效性、一致性、稳定性、自定SQL等7种品质模版,以及其分类下24个模版共计100+不同监控指标的品质规定校验,7种品质模版分类介绍如下: *这里仅针对模版的整体能力进行阐明,每一个分类下都有更多的模版和利用场景,详见Dataphin产品手册 产品能力速览 1、品质大盘 品质大盘能够展现以后全局的校验规定状况和异常情况,有助于管理员疾速发现整体问题,安顿排查工作。 2、模版治理 模版分为零碎内置模版和自定义模版,零碎模版开箱即用,能够用来疾速创立品质规定。如果组织内有通用的需要(如:用户年龄区间有效性、财务数据准确性等),能够积淀为通用的模版,用于业务品质规定的疾速创立。通过模版治理能够查看品质以后所有的模版信息。 3、品质规定 反对给品质监控对象(如表、数据源)配置品质规定,并设置告警阈值和规定强弱;配置调度后就能够定时或者追随数据更新来主动触发品质的校验工作,实现后主动生成品质报告,并依据校验状况实现告警、阻断等后续操作。 4、校验记录 校验记录能够查看每次校验规定执行的具体后果和详情,是每天检查数据品质和解决品质问题最罕用的入口。Dataphin品质的校验记录,具体的记录了每次品质规定校验的工夫、状态和执行详情,便于进行日常检查和谬误排查。 5、数据源治理 数据源除了要进行数据品质检测工作外,还要进行日常的业务撑持。为了避免数据品质工作影响到日常业务,反对对单个数据源反对的最大品质并行度进行管制,当达到品质最大并行度时,新调度的品质规定会进入排队期待状态,以爱护业务的失常发展。

November 25, 2022 · 1 min · jiezi

关于算法:ECON100-Macroeconomics探讨

Syllabus1: MacroeconomicsCourse InformationMacroeconomicsECON-100-001Spring 2022Runs from January 10th 2022 – April 25th 2022Online lecture sessions: Tuesdays and Fridays, 8:10am to 9:25am Eastern Time.Instructor InformationPreferred Communication Method: Canvas, email and Zoom meetingsResponse time: email messages will be responded within two business days.Instructor Bio: Prof. Martinez-Covarrubias studied his MSc at the University of Birmingham inEngland and received his PhD from the University of Limerick in Ireland. He has more than 10years' experience as a lecturer and senior lecturer. He has taught numerous - and a wide range of-economic modules including Macroeconomics at graduate and undergraduate level in Europe.He has supervised several Masters and PhD theses. He has published books and several articlesin leading international journals, such as Regional Studies. His research interests focus oneconomics of innovation and technological change, industrial economics, economic integrationand public policy. He has presented numerous international conferences and keynote speeches.As practitioner, he held senior roles in national civil services in Mexico and Ireland. He advisesthe European Commission with its international development co-operation program with AfricanCountries in areas of Science, Technology and Innovation.Teaching Assistants (TA) Information:Nguyen, Nghia (Nick). nn3647a@american.edu Cimiluca, Mark. mc0551a@american.eduSpaulding Bingaman, sb2941a@student.american.edu (SI Leader) ...

November 25, 2022 · 12 min · jiezi

关于算法:CSC-452-Syscalls

CSC 452 – Project 2: SyscallsDue: Sunday, February 20, 2022, by 11:59pmProject DescriptionWe know from our description of the kernel that it provides fundamental operations that help us tointeract with resources. These system calls include things like read, write, open, close, and fork. Withaccess to the source code for the Linux kernel, we have the ability to extend the kernel’s standardfunctionality with our own.In this assignment we will be creating a simple interface for passing small text messages from one userto another by way of the kernel.How it Will WorkThere will be a userspace application called osmsg that allows a user to send and receive short textmessages. To send a message the user will issue a command like:osmsg -s jmisurda “Hello world”which will queue up a message to be sent to the user jmisurda when they get their messages with thefollowing command:osmsg -rThis would output something like the following:abc123 said: “Hello world”Notice that this is more like email than instant messages, due to the fact that the recipient needs toexplicitly request their messages. If there is more than one message waiting to be received, they will allbe displayed at once. A message is discarded from the system after it has been read.Syscall InterfaceThe osmsg application will do the sending and receiving of messages via two new system calls, whichyou will implement. The syscalls should look like the following:asmlinkage long sys_csc452_send_msg(const char __user *to, const char __usermsg, const char __user from)This function sends a single message given the three string parameters. The return value should be 0 forsuccess, and a negative number on error.2asmlinkage long sys_csc452_get_msg(const char __user to, char __user msg,char __user *from)This function takes the recipient’s username as an input, and then returns via the two other parametersthe message and sender. Notice that this only returns one message, but there may be many messages todeliver. The return value should be used to indicate if there are more messages to receive: 1 means tocall the function again, 0 means that there are no more to deliver, and a negative number indicates anerror. The msg and from pointers need to be pointing to space allocated in the user program’s addressspace.ImplementationThere are two halves of implementation, the syscalls themselves, and the osmsg program.For the syscalls, have them modify a linked list of messages. Memory in the kernel can be allocated bykmalloc() You can make the nodes of the linked list structures with fixed sized fields. Make the fieldsreasonably-sized however.Because this is a memory resident data structure, the messages will not survive a reboot. This is fine.You may want to make a shell script to add a lot of messages quickly into the VM.Setting up the Kernel SourceDownload the new Virtual Machine image from the website and follow these steps to configure: ...

November 24, 2022 · 8 min · jiezi

关于算法:6CCE3ROB-分析报告

Department of EngineeringRobotics Systems: 6CCE3ROB/7CCEMROS COURSE WORK 1 br>ROBOT LINKAGE ANALYSIS AND KINEMATICS 1 Introduction The pace of population ageing is much faster than that in the past with an increasing numberof individuals suffer from mobility challenges. The major barrier for such individuals toaccomplish their daily physical activities is the ability to stand from a sitting position. This group coursework is to generate an analysis report on the design of a robot that couldprovide effective assistance to overcome the mobility challenge for the elderly and personswith disabilities. A group report can be submitted by a group representative but with a frontcover page stating each person’s task and responsibility in the group work. Each member ofthe group needs to submit one page per person to describe own contributions, results,achievements, and experience learned. ...

November 24, 2022 · 3 min · jiezi

关于算法:CS-486-解题想法

CS 486CS 486/686 Assignment 2Winter 2022(130 marks)Blake VanBerloDue Date: 11:59 PM ET on Wednesday, March 2, 2022Changes v1.1: in Q2 description, updated probability of unintended action to (1?)/3 - v1.2:in Q2 description, updated example for robot transition probabilities1CS 486/686 Winter 2022 Assignment 2Academic Integrity StatementIf your written submission on Learn does not include this academic integrity statement withyour signature (typed name), we will deduct 5 marks from your final assignment mark.I declare the following statements to be true: The work I submit here is entirely my own. I have not shared and will not share any of my code with anyone at any point. I have not posted and will not post my code on any public or private forum or website. I have not discussed and will not discuss the contents of this assessment with anyoneat any point. I have not posted and will not post the contents of this assessment and its solutionson any public or private forum or website. I will not search for assessment solutions online. I am aware that misconduct related to assessments can result in significant penalties,possibly including failure in the course and suspension. This is covered in Policy 71:https://uwaterloo.ca/secretar...Failure to accept the integrity policy will result in your assignment not being graded.By typing or writing my full legal name below, I confirm that I have read and understoodthe academic integrity statement above.Blake VanBerlo 2022 v1.2 Page 2 of 11CS 486/686 Winter 2022 Assignment 2Instructions Submit any written solutions in a file named writeup.pdf to the A2 Dropbox on Learn.If your written submission on Learn does not contain one file named writeup.pdf, wewill deduct 5 marks from your final assignment mark. Submit any code to Marmoset at https://marmoset.student.cs.u...Grades for the programming component are determined by the unit tests in the “As-signment 2 (Final)” project on Marmoset The “Assignment 2 (Weeks 1 & 2)” and“Assignment 2 (Week 3)” projects contain ungraded public test suites meant to helpyou debug, and they are only temporarily available. No late assignment will be accepted. This assignment is to be done individually. I strongly encourage you to complete your write-up in LaTeX, using this source file.If you do, in your submission, please replace the author with your name and studentnumber. Please also remove the due date, the Instructions section, and the Learninggoals section. Thanks! Lead TAs:– Question 1: Kelechi Ogueji (kelechi.ogueji@uwaterloo.ca)– Question 2: Steven Lawrence (steven.lawrence@uwaterloo.ca)The TAs’ office hours will be scheduled on MS Teams.Learning goalsInference in Bayesian Networks Define factors. Manipulate factors using the operations restrict, sum out, multiply andnormalize. Trace the execution of and implement the variable elimination algorithm for calculatinga prior or a posterior probability given a Bayesian network.Inference in Hidden Markov Models Construct a hidden Markov model given a complex scenario. Perform filtering and smoothing by executing the forward-backward algorithm.Blake VanBerlo 2022 v1.2 Page 3 of 11CS 486/686 Winter 2022 Assignment 2Independence and Inference in Bayesian Networks(30 marks)Recall that random variables X and Y are conditionally independent, given a thirdvariable Z if and only if:P (X|Y ∧ Z) = P (X|Z) (1)P (Y |X ∧ Z) = P (Y |Z) (2)P (X ∧ Y |Z) = P (X|Z)P (Y |Z) (3)Show that Equation 3 follows from Equations 1 and 2. Justify each step of your proof.Hint: you may find some of the probability rules from Lecture 6 to be useful.Marking Scheme: (6 marks) (4 marks) Correct proof (2 marks) Each step is justifiedNot all the random variables in a Bayesian networks are always required to answer aprobabilistic query. In fact, all variables that are not ancestors of query variables orevidence variables are irrelevant to the query. Let Q = {Q1, . . . , Qm} be the set ofquery variables and e = {e1, . . . , en} be the set of evidence variables. Prove that theVariable Elimination Algorithm (VEA) returns the same distribution for some queryP (Q|E) if all irrelevant variables are pruned from the Bayesian network.Hint: try a direct proof. Show that a particular ordering of hidden variable eliminationresults in the same final distribution returned by the normalization operation.Marking Scheme: (10 marks)(8 marks) Correct proof(2 marks) Proof is succinct and easy to understandBelow is a Bayesian network that appears in a recent review of uncertainties in Bayesiannetworks with discrete variables Rohmer, (2020). The network is a probabilistic modelof brain cancer diagnosis. Note that the example is meant to be illustrative, as thenetwork is simple and the conditional probability tables are fictional. The randomBlake VanBerlo 2022 v1.2 Page 4 of 11CS 486/686 Winter 2022 Assignment 2variables are defined below:Random Variable DefinitionMC Metastatic cancerB Brain tumourCT CT scan is positive for brain tumourSH Severe headacheISC Increased serum calciumC Patient falls into comaExecute the Variable Elimination Algorithm to determine the probability that a pa-tient has a brain tumour, given that their blood work shows an increased calciumconcentration, and they do not report having severe headaches. Eliminate variablesin reverse alphabetical order. For example, you would eliminate MC before ISC andCT before C.You may denote False as 0 and True as 1. First, define your factors and write themin tabular format. For example, write a factor containing random variables A and Bas follows:f1(A, B):A B Value0 0.61 0.40 0.81 0.4Write out each VEA operation, along with the factor that is produced by the operation.For example, if you were to restrict f1(A,B) to A = 0, you would write:?Blake VanBerlo 2022 v1.2 Page 5 of 11CS 486/686 Winter 2022 Assignment 2Restrict f1(A, B) to A=0 to produce f2(B).f2(B):B Value0.60.4Hint: before you start executing VEA, apply what you proved in part (b) of thisquestion to simplify the problem.Marking Scheme: (14 marks) (4 marks) Initial factor definition (6 marks) Correct VEA operations (2 marks) Correct final answer (2 marks) Correct formatting of factors and VEA operationsBlake VanBerlo 2022 v1.2 Page 6 of 11CS 486/686 Winter 2022 Assignment 2Robot Localization as a Hidden Markov Model(100 marks)You will implement the forward backward algorithm to perform inference in a complex gridenvironment. We will model the robot’s interactions with the environment as a hiddenMarkov model (HMM). Given a description of the environment, you will implement thetransition and sensor probability distributions. You will also implement forward recursion,backward recursion, and the Forward-Backward Algorithm (FBA). The goal is to apply FBAto infer the robot’s location at some timestep, given a series of actions and observations.2.1 The Robot EnvironmentLet’s consider a complex robot localization problem. This problem is similar to an examplein one of our course textbooks: “Artificial Intelligence: a Modern Approach” by Russell andNorvig (see Figure 1). In the 3rd edition, check out section 15.3.2, page 582, Figure 15.7. Inthe 4th edition, check out section 14.3.2, page 477, Figure 14.7.Figure 1: The robot grid environment from “Artificial Intelligence: a Modern Approach”. Therobot is in state 31.A robot is in a grid environment and it has a correct map of the environment. We will use(y, x) or (row, column) to refer to each cell. y is the row value starting with y = 0 at thetop. x is the column value starting with x = 0 at the left.The robot has four available actions: Up, Right, Down, and Left. Each action is intendedto move the robot by 1 cell in the corresponding direction. Unfortunately, the robot’snavigational system is broken. When it executes an action, it will move in the intendeddirection with probability . The robot moves in one of the other directions with probability(1 ? )/3. For example, if = 0.85, and the robot executes the Right action, it will moveright with probability 0.85, left with probability 0.05, up with probability 0.05, and rightwith probability 0.05. If the robot is in a cell adjacent to a wall and it moves in the directionof that wall, it remains in the same location. As an example, consider the grid environmentin Figure 2: if the robot is in state 0 and tries to move right, then it transitions to state 1with probability 0.85, state 7 with probability 0.05, and stays in state 0 with probability 0.1(because moving left or up results in the robot remaining stationary).Blake VanBerlo 2022 v1.2 Page 7 of 11CS 486/686 Winter 2022 Assignment 2(a) The current state (b) The robot’s belief of its current stateFigure 2: Visualization of a grid environment. Each empty cell is a possible location that therobot can be in. The red cell denotes the current location of the robot. The grid environment withthe robot’s belief of its location overlaid onto each empty cell. The darker the green, the higherthe probability that the robot assigns to that cell.The robot’s task is to determine its current location. To do this, the robot will make useof four noisy sensors that report whether there is an inner or outer wall in each of the fourdirections (up, right, left, down). At each time step, the robot receives a sensor reading,which is an integer in {0, 1}. If we convert the integer to a 4-bit binary number, then eachbit gives the presence (bit 1) or absence (bit 0) of a wall in the up, right, down, and leftdirections respectively. For example, the integer 9 corresponds to the binary number 1001.The leftmost digit 1 indicates that there is a wall above the agent. The second digit 0 fromthe left indicates that there is no wall to the right of the agent. The third digit 0 from theleft indicates that there is no wall below the agent. The rightmost digit 1 indicates thatthere is a wall to the left of the agent.Each sensor is noisy and flips the bit with a probability of 0 ≤ ? ≤ 1. The errors occurindependently for the four sensor directions. For instance, suppose that the correct sensorreading is 1001 and the actual sensor reading is 1110. The sensors were correct in onedirection and incorrect in three directions. The probability of observing this sensor readingis (1? ?)?3.The robot starts at an unknown location. At time step 0, we will assume a uniform distri-bution over all the empty cells.We can model the robot’s situation as a HMM. Figure 3 gives a Bayesian network represent-ing the scenatio. The states correspond to the location of the robot and the observationsBlake VanBerlo 2022 v1.2 Page 8 of 11CS 486/686 Winter 2022 Assignment 2correspond to the 4-bit sensor reading. Since the robot has the choice of selecting differentactions, the robot’s next state depends on the current state and the action taken duringthe current timestep. So the transition probability distribution is P (Sk+1|Sk ∧ Ak). Thesensor probability distribution is P (Ok|Sk). Both can be specified given the above problemdescription.S0 S1 S2 St?2 St?1A0 A1 A2 At?2. . . . . .. . .. . .O0 O1 O2 Ot?1 Ot?1Figure 3: A Bayesian network representing the HMM for the robot localization problem with ttimesteps2.2 Locating the Robot with FBAYou will implement the forward backward algorithm (FBA) to perform inference in the robotenvironment introduced above.We have provided four python files. Please read the detailed comments in the provided filescarefully.env.py: Contains a base Environment class. Do not change this file.grid env.py: Contains a GridEnvironment class that extends the base Environment,implementing the dynamics from the robot environment. You mustimplement the create_trans_probs() and create_obs_probs()methods in the GridEnvironment class. Do not change thefunction signatures. Do not change anything else in this file!fba.py: Contains empty functions for FBA operations. You will implementall of the functions in this file. Do not change the functionsignatures.robot.py: Provides a demonstration of how to define a GridEnvironment objectand visualize the robot’s state and belief. Feel free to change this fileas you desire.Blake VanBerlo 2022 v1.2 Page 9 of 11CS 486/686 Winter 2022 Assignment 2Please complete the following tasks.Implement the empty functions in grid_env.py and fba.py. Zip and submit thesetwo files on Marmoset.Marking Scheme: (90 marks)Unit tests: create_trans_probs(1 public test + 4 secret tests) * 3 marks = 15 marks create_obs_probs(1 public test + 4 secret tests) * 3 marks = 15 marks forward_recursion(1 public test + 4 secret tests) * 4 marks = 20 marks backward_recursion(1 public test + 4 secret tests) * 5 marks = 25 marks? fba(1 public test + 4 secret tests) * 3 marks = 15 marksOnce you have implemented the functions, you can play with the robot environment.In robot.py, we have provided some code to create the robot environment. Add thecode for running FBA, and then run the code to complete the following activities.We highly recommend using the provided visualize_state() and visualize_belief()functions to visualize the robot’s location and the robot’s beliefs.(a) For each value of ? in {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8,0.9, 1.0}, execute at least 10 trials of FBA, using a different random seed for eachtrial number. So in total, you will execute at least 11 × 10 = 110 trials. In eachtrial, the robot executes the following 10 actions: Right, Right, Up, Up, Up, Up,Left, Right, Down, Right. Compute the robot’s belief distribution for its locationat the final timestep, k = 9. Use the environment from the textbook (Figure 1)Setting the initial state to 31 and = 0.85.Plot the maximum probability in the robot’s belief distribution, averaged acrosseach trial, against the value of ?. Your x-axis should be ? and your y-axis shouldbe the average of the maximum probability across the trials for each value of ?.In no more than 4 sentences, explain what your experiment indicates about theeffect of the sensor noise (?) on the robot’s confidence in its location.Marking Scheme: (5 marks) (3 marks) Reasonably correct plot.Blake VanBerlo 2022 v1.2 Page 10 of 11CS 486/686 Winter 2022 Assignment 2 (2 marks) Reasonable conclusion based on the plot.(b) For each value of in {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0}, execute at leasttrials of FBA, using a different random seed for each trial number. So in total,you will execute at least 11 × 10 = 110 trials. In each trial, the robot executesthe following 10 actions: Right, Right, Up, Up, Up, Up, Left, Right, Down, Right.Compute the robot’s belief distribution for its location at the final timestep, k = 4.Use the environment from the textbook (Figure 1) Setting the initial state to 31and ? = 0.2.Plot the maximum probability in the robot’s belief distribution, averaged acrosseach trial, against the value of . Your x-axis should be and your y-axis shouldbe the average of the maximum probability across the trials for each value of .In no more than 4 sentences, explain what your experiment indicates about theeffect of the action noise () on the robot’s confidence in its location at timestepk = 4.Marking Scheme: (5 marks) (3 marks) Reasonably correct plot. (2 marks) Reasonable conclusion based on the plot.

November 24, 2022 · 12 min · jiezi

关于算法:个推TechDay直播预告从方法论到落地应用详解企业标签体系建设要点

标签作为当下最广泛的数据资产类型之一,对企业洞察用户画像、发展精细化经营、实现智慧营销触达等具备重要的撑持作用。企业标签体系的建设并非欲速不达的,须要联合业务视角进行高屋建瓴的布局,更波及到简单的数据治理和数据资产治理等工作。 11月30日(下周三)晚19:30-20:30,个推“治数训练营”第四期将以“标签体系建设实际”为主题,为大家具体梳理企业进行标签体系建设的方法论与外围策略,深刻分享标签数据的资产化经营治理教训,解读画像标签体系的场景利用案例。

November 24, 2022 · 1 min · jiezi

关于算法:CSCI-5521机器学习

CSCI 5521: Machine Learning Fundamentals (Spring 2022)Quiz 1 (Thursday, Feb 10)Due on Gradescope at 02:00 PM, Friday, Feb 11Instructions: This quiz has 3 questions, 30 points, on 1 page. Please write your name & ID on your submission pages. (6 points) Supervised learning has a wide range of applications. For example, one can definea robot (vs non-robot) based on a number of traits. Please model the question as a two-classclassification task and answer the following questions.(a) Name two relevant features to this two-class classification task. (Any reasonable features areacceptable).(b) What are the labels in this two-class classification task?(10 points) What could we do to reduce overfitting in a polynomial regression model? Select allthe option(s) that apply.(a) Decrease polynomial degree.(b) Change to a more complex model (e.g., a model with more parameters).(c) Add new training data and keep test data the same.(d) Add new test data and keep training data the same.(e) Sample half of the original training data as new training data.(14 points) The conditional probability density functions of two classes C1 and C2 are shown inthe figure below, with P (x|C1) ~ N (0, 1) and P (x|C2) ~ N (2, 1.2).(a) Assuming the priors are equal, predict which class (C1 or C2) the data point x = 1.5 (illus-trated with the green dot) belongs to. Briefly explain why.(b) What if the priors are P (C1) = 0.9 and P (C2) = 0.1, respectively? (Note: High-levelexplanation is good, but you can use formulations if it helps explain).

November 24, 2022 · 2 min · jiezi

关于算法:CE322-算法游戏理论

CE322 Algorithmic Game TheoryAssignment 2021/22Lecturer: Maria Kyropoulou• Answer all (four) questions below.• You need to submit– one report with your answers to all questions. This should be a .pdf file named according to‘CE322 RegNumber Report.pdf’, where RegNumber should be replaced by your registrationnumber. Always conclude the answer of each task with a clearly highlighted part that containsthe final answer (after presenting the analysis). For example, if the task asks you to find Nashequilibria, you should always conclude with something like “I have identified the followingequilibrium: Player A has chosen strategy ..., Player B has chosen strategy ..., etc.”– all MATLAB (.m) files that you created in the context of this assignment, named accordingto ‘CE322 RegNumber TaskX.m’, where RegNumber should be replaced by your registrationnumber and X should be replaced by the Task number.• You can include clear pictures of clearly handwritten equations/analysis etc. (emphasis on the‘clear’ and ‘clearly handwritten’! If we can’t immediately tell what’s written there, no marks willbe awarded). However, all explanations in words should be electronically written as should bethe conclusion of your answer (see above). Also, make sure that your code is easy to follow, byadequately commenting on your code, and/or briefly describing in the report the steps you take.• Your assignment will be assessed on the quality of the files you submit –correctness, work qualityand quality of presentation– and how clearly you explain what you have done. Aim for precise andconcise answers and explanations.Question 1 [20%]Consider the following zero sum game G:A B C DX 2 0 1 4Y 1 2 5 3Z 4 1 3 2Your tasks:a. [4% ] Reduce the game as much as possible by removing any possible dominated strategies.b. [4% ] Is there a pure Nash equilibrium in the remaining game? Justify your answer.c. [12% ] Compute a mixed equilibrium using the indifference conditions of the players. Present both theequilibrium and the analysis clearly. No coding is required.1Question 2 [25%]Consider the following normal form game G. Your task is to find the correlated equilibrium that maximizesthe sum of players’ utilities, using Linear Programming in MATLAB. In your report, you needto present the equilibrium that you have computed, the linear program that you are solving (whichshould include the equilibrium conditions that are satisfied), and a screenshot of your MATLAB inputAND output. Use the following ordering of variables when constructing your MATLAB input:pXA, pXB, pXC , pY A, pY B, pY C , pZA, pZB, pZC .A B CX 10,5 0,6 0,0Y 7,7 0,0 6,0Z 0,0 7,7 5,10Question 3 [25%]Ten commuters must decide simultaneously in the morning to use route A or route B to go from home(same place for all) to work (ditto). If a of them use route A, each of them will travel for 10a + 40minutes; if b of them use route B, each of them will travel for 10b minutes. Everyone wishes to minimizehis/her commuting time. Your tasks:a. [12% ] Describe the pure Nash equilibrium (or Nash equilibria) of this ten-person game. Computethe corresponding profile of commuting times. Explicitly list all equilibrium conditions that aresatisfied.b. [6% ] What is the traffic pattern (strategies) minimizing the total travel time of all commuters (thesum of their travel times)? Describe the corresponding profile of commuting times (individualpayoffs/cost).c. [7% ] What does this mean about the Price of Anarchy of this game (assuming that the objectivefunction is the total travel time)?Question 4 [30%]Consider the following sponsored search auction instance I:• 2 slots. The top slot has a known click-through rate (CTR) ctr1 = 1 and the bottom slot has aknown click-through rate ctr3 = 0.5.• 2 advertisers. Advertiser 1 has a private value-per-click v1 = 1 and advertiser 2 has a privatevalue-per-click v2 = 0.5.• The payoff of the advertiser (let’s call them i, i = 1, 2) who is assigned to the top slot is (vi − p),where p is the price charged per-click in the top slot. The payoff of i in the bottom slot is 0.5 · vi(price 0 is charged per-click in the bottom slot).Under the Generalized Second-Price (GSP) auction rule: ...

November 24, 2022 · 5 min · jiezi

关于算法:MCD4710-Workbook

MCD4710 WorkbookJuly 22, 2020ContentsPreface 3I Programming Fundamentals 41 Expressions 51.1 Numerical Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.2 Boolean Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 Control Flow 92.1 Conditionals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.2 Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.2.1 While-Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.2.2 For-Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.2.3 Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Sequences 203.1 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203.2 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.3 Range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 Functions 245 Code Traces 316 Recursion 32II Data Structures 367 Tables and Matrices 377.1 Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377.2 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428 Graphs 458.1 Paths, cycles, and connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458.2 Spanning Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488.3 Graph Traversals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509 Stacks and Queues 52III Algorithm Analysis 5310 Invariants 5410.1 Finding Loop Invariants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54111 Computational Complexity 5911.1 Big-Oh Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5911.2 Computational Complexity of Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62IV Additional Resources 6712 Practice Exam Questions 6812.1 Discussion of Theoretical Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6812.2 Computational Complexity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6912.3 Invariants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7013 Solutions to Practice Exam Questions 7213.1 Solutions: Discussion of Theoretical Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7213.2 Solutions: Computational Complexity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7213.3 Solutions: Invariants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732PrefaceThis workbook is an additional learning resource for FIT1045 and FIT1053. This is our first semester offering aworkbook, so the workbook will grow as the semester progresses. This workbook is not sufficient for the unit. Youmust also complete lectures, workshops, and tutorials.The workbook will be useful in tutorials during time dedicated to self-directed-learning; as a tool for identifyingany gaps in your knowledge; and for providing materials with which to practice. You can use the workbook as muchor as little as is useful for you.The questions in this workbook reflect the questions you can expect to see on the in-semester tests, and the finalexam. The difficulty of the questions can be understood like so: ...

November 24, 2022 · 9 min · jiezi

关于算法:ST-302随机过程

ST 302 Stochastic Processes1 Information and Conditioning1.1 Sigma-Algebras and FiltrationsLet us recall that a -algebra is a collection F of subsets of the sample space such that(i) ;,2 F(ii) if A 2 F then also Ac 2 F (here Ac denotes the complementary set to A)(iii) if we have a sequence A1, A2, ... of sets in F , then [1i=1Ai 2 F .We say that a collection of sets generates a -algebra F if F is the smallest-algebra which contains all the sets. The trivial -algebra is the one containingonly ; and.Interpretation: We perform a random experiment. The realized outcome is anelement ! of the sample space. Assume that we are given some partial infor-mation in form of a -algebra F . If F does not contain all subsets of, we mightnot know the precise !, but we may narrow down the possibilities. We know withcertainty whether a set A 2 F either contains ! or does not contain it ?these setsare resolved by our given information.Example 1.1 We toss a coin three times, with the result of each toss being H(head) or T (tail). Our time set consists of t = 0; 1; 2; 3. The sample spaceisthe set of all eight possible outcomes. At time 0 (just before the ?rst coin toss),1we only know that the true ! does not belong to ; and does belong to, hencewe setF0 = f;;g :At time 1, after the ?rst coin toss, in addition the following two sets are resolved:AH = fHHH;HHT;HTH;HTTgAT = fTHH; THT; TTH; TTTg :We can say with certainty whether ! belongs to AH or AT . In contrast, theinformation about the ?rst coin toss only is not enough to determine with certaintywhether ! is contained e.g. in fHHH;HHTg ?for this we would have to waituntil the second coin toss. As the complement of AH is AT , and the union of AHand AT equals, we setF1 = f;;; AH ; ATg :At time 2, after the second coin toss, in addition to the sets already contained inF1, the setsAHH = fHHH;HHTg ; AHT = fHTH;HTTg ;ATH = fTHH; THTg ; ATT = fTTH; TTTgget resolved, together with their complements and unions. Altogether, we getF2 =;;; AH ; AT ; AHH ; AHT ; ATH ; ATT ; AcHH ; AcHT ; AcTH ; AcTT ;AHH [ ATH ; AHH [ ATT ; AHT [ ATH ; AHT [ ATT ...

November 23, 2022 · 11 min · jiezi

关于算法:COMP3811图形算法理论

COMP3811: Computer GraphicsCoursework 2Interactive Animated Scenes with OpenGLMarkingThis coursework determines your mark for 70 %. In case of second attempt it will be capped to theappropriate mark.Technical AssistanceReasonable questions about running OpenGL on the lab machines or feng-linux will be answeredduring office hours. Whatever platform you use, it is strongly recommended that occasionalycompile and run on the lab machines or feng-linux.Submission Instruction and Note on PlagiarismSubmission should be done through the VLE by the due date. Submissions through the SSO will beignored and result in 0 marks. Your submission should be in a single tar file that contains a reportand source code. Ideally, source should must be provided with a Makefile and must compile andrun on feng-linux. Where this is not possible, you should record a video demonstrating aspectsof your coursework, and be prepared to provide a demo, showcasing your solution.The report is basis for assessment, with the source code as supporting evidence for assertionsmade in the report. Answer all the questions and provide the explanations that are asked for.Refer to your code in explanations, but do not provide answers like: ’see source code’.You are allowed to discuss ideas with colleagues. You must program independently and not baseyour submission on any other code than was provided during the tutorials, and textures which are ina tar file called textures.tar, which is located in the coursework 2 folder on the VLE, the samefolder which contains this specification. Changing variable names in someone else’s code is not agood idea.Creation of an Interactive Animated Scene using OpenGLUsing Qt’s QGLWidget you will create an application that demonstrates the ability to render visualscenes using OpenGL.1You are free to use GLFW instead of Qt. Take into consideration that GLFW is not a GUItoolkit and does not provide means to draw UI elements out of the box. Therefore, you will need tofind a different way to provide the required UI interaction elements. The ”Dear ImGui” library is areasonable alternative, however this should nevertheless be considered an advanced choice that willresult in extra work for you.You are free, within some limits, to create a scene of your choice. Assessment will be basedon the sophistication of the scene and scene elements as well as possibilities for user interaction.The scheme below sets out minimum requirements that must be met for grading in certain bands.Grading within a band is assessed on: coding style and commenting, explanation of the designchoices and implementation in the report, and visual impact.• 40%-50%: You must create a visual scene that demonstrates a reasonable complexity throughinstancing. Examples could be a group of buildings, constructed from cubes, body shapes constructedfrom cylinders and spheres and a combination thereof. Light and material propertiesmust be chosen that allow specular and diffusive light contributions to be recognised. You areallowed to use glut objects. The report must explain your design. Your scene must deviatesubstantially from the simple scenes that were provided during the tutorials.• 50%-60%: Your scene must fulfil all requirements for the 40 %-50 % band. Your scene mustcontain at least one element of user interaction, for example, a slider to manipulate viewingangles or a dialog box to set material or light properties.• 60%-70%: Your scene must fulfil all requirements for the lower bands, as well as containan element of animation, for example rotating or spinning objects. The scene must containat least one convex object that you have constructed from polygons. The scene must containtexture mapping. Some texture images will be provided in a tar file that will be present withthe coursework brief. The ones that are provided must be used, but you are free to add yourown.• 70%-100%: Your scene must fulfil all requirements for the lower bands and contain an objectthat requires hierarchical modelling and displays motion in some of its parts. This objectitself must move in a circular path through the scene. You must use various elements ofuser interaction, for example controls to set the radius or speed of the object, dialog boxes tocontrol material properties, etc. Interaction purely by mouse of keyboard does not qualify asone of these elements. [100 marks]These bandings are indicativeIn marking we assess whether the elements are present in your cousework and assign them ascore. We will also rate how creative you were in applying these elements and apply a reweightingthat somewhat favours inventive and creative use of them in your coursework (look and feel). Theexact weighting coeefficients will be on the feedback sheet. [100 marks total] ...

November 23, 2022 · 4 min · jiezi

关于算法:COMP0143-Cryptocurrencies

COMP0143: CryptocurrenciesCoursework 2Instructions This assignment is part of the mandatory assessment of the COMP0143: Cryptocurrencies module andwill count 75% towards your final overall mark. Assignment submission is due via Moodle through the TurnItIn interface on January 12, 2022 at 16:00UK time. Late submissions will be accepted with deductions according to UCL’s late submission policy. This assignment is open note, open book, and open course resources. Students must identify sources asaccurately and fully as possible. UCL plagiarism policies will be strictly enforced. For more details, seehttp://www.ucl.ac.uk/current-... Students are not allowed to consult other people (outside of course staff) on this work. Each studenthas to work on the assignment individually. All questions have to be answers. Answers will be judged in terms of their quality, the depth of un-derstanding, and also their clarity. Explain your answers clearly, but succinctly. Partial credit may beawarded. Marks available for each question are indicated in square brackets. The assignment has amaximum of 100 marks allocated as follows:Q1 Q2 Q3 Q4 Q5 TotalMarks 20 30 15 15 20 100 marks For the submission create a single zip archive that contains: ...

November 23, 2022 · 11 min · jiezi

关于算法:PGL图学习之图神经网络GraphSAGEGIN图采样算法系列七

0. PGL图学习之图神经网络GraphSAGE、GIN图采样算法[系列七]本我的项目链接:https://aistudio.baidu.com/aistudio/projectdetail/5061984?contributionType=1 相干我的项目参考:更多材料见主页 对于图计算&图学习的基础知识概览:前置知识点学习(PGL)[系列一] https://aistudio.baidu.com/ai... 图机器学习(GML)&图神经网络(GNN)原理和代码实现(前置学习系列二):https://aistudio.baidu.com/ai... 在图神经网络中,应用的数据集可能是亿量级的数据,而因为GPU/CPU资源无限无奈一次性全图送入计算资源,须要借鉴深度学习中的mini-batch思维。 传统的深度学习mini-batch训练每个batch的样本之间无依赖,多层样本计算量固定;而在图神经网络中,每个batch中的节点之间相互依赖,在计算多层时会导致计算量爆炸,因而引入了图采样的概念。 GraphSAGE也是图嵌入算法中的一种。在论文Inductive Representation Learning on Large Graphs 在大图上的演绎示意学习中提出。github链接和官网介绍链接。 与node2vec相比较而言,node2vec是在图的节点级别上进行嵌入,GraphSAGE则是在整个图的级别上进行嵌入。之前的网络示意学习的transductive,难以从而提出了一个inductive的GraphSAGE算法。GraphSAGE同时利用节点特色信息和构造信息失去Graph Embedding的映射,相比之前的办法,之前都是保留了映射后的后果,而GraphSAGE保留了生成embedding的映射,可扩展性更强,对于节点分类和链接预测问题的体现也比较突出。 0.1提出背景现存的办法须要图中所有的顶点在训练embedding的时候都呈现;这些前人的办法实质上是transductive,不能天然地泛化到未见过的顶点。文中提出了GraphSAGE,是一个inductive的框架,能够利用顶点特色信息(比方文本属性)来高效地为没有见过的顶点生成embedding。GraphSAGE是为了学习一种节点示意办法,即如何通过从一个顶点的部分街坊采样并聚合顶点特色,而不是为每个顶点训练独自的embedding。这个算法在三个inductive顶点分类benchmark上超过了那些很强的baseline。文中基于citation和Reddit帖子数据的信息图中对未见过的顶点分类,试验表明应用一个PPI(protein-protein interactions)多图数据集,算法能够泛化到齐全未见过的图上。 0.2 回顾GCN及其问题在大型图中,节点的低维向量embedding被证实了作为各种各样的预测和图剖析工作的特色输出是十分有用的。顶点embedding最根本的根本思维是应用降维技术从高维信息中提炼一个顶点的街坊信息,存到低维向量中。这些顶点嵌入之后会作为后续的机器学习零碎的输出,解决像顶点分类、聚类、链接预测这样的问题。 GCN尽管能提取图中顶点的embedding,然而存在一些问题:GCN的根本思维: 把一个节点在图中的高纬度邻接信息降维到一个低维的向量示意。GCN的长处: 能够捕获graph的全局信息,从而很好地示意node的特色。GCN的毛病: Transductive learning的形式,须要把所有节点都参加训练能力失去node embedding,无奈疾速失去新node的embedding。 1.图采样算法1.1 GraphSage: Representation Learning on Large Graphs图采样算法:顾名思义,图采样算法就是在一张图中进行采样失去一个子图,这里的采样并不是随机采样,而是采取一些策略。典型的图采样算法包含GraphSAGE、PinSAGE等。 文章码源链接: https://cs.stanford.edu/peopl... https://github.com/williamlei... 后面 GCN 解说的文章中,我应用的图节点个数非常少,然而在理论问题中,一张图可能节点十分多,因而就没有方法一次性把整张图送入计算资源,所以咱们应该应用一种无效的采样算法,从全图中采样出一个子图 ,这样就能够进行训练了。 GraphSAGE与GCN比照: 既然新增的节点,肯定会扭转原有节点的示意,那么为什么肯定要失去每个节点的一个固定的示意呢?何不间接学习一种节点的示意办法。去学习一个节点的信息是怎么通过其街坊节点的特色聚合而来的。 学习到了这样的“聚合函数”,而咱们自身就已知各个节点的特色和街坊关系,咱们就能够很不便地失去一个新节点的示意了。 GCN等transductive的办法,学到的是每个节点的一个惟一确定的embedding; 而GraphSAGE办法学到的node embedding,是依据node的街坊关系的变动而变动的,也就是说,即便是旧的node,如果建设了一些新的link,那么其对应的embedding也会变动,而且也很不便地学到。 在理解图采样算法前,咱们至多应该保障采样后的子图是连通的。例如上图图中,右边采样的子图就是连通的,左边的子图不是连通的。 GraphSAGE的外围:GraphSAGE不是试图学习一个图上所有node的embedding,而是学习一个为每个node产生embedding的映射。 GraphSage框架中蕴含两个很重要的操作:Sample采样和Aggregate聚合。这也是其名字GraphSage(Graph SAmple and aggreGatE)的由来。GraphSAGE 次要分两步:采样、聚合。GraphSAGE的采样形式是街坊采样,街坊采样的意思是在某个节点的街坊节点中抉择几个节点作为原节点的一阶街坊,之后对在新采样的节点的街坊中持续抉择节点作为原节点的二阶节点,以此类推。 文中不是对每个顶点都训练一个独自的embeddding向量,而是训练了一组aggregator functions,这些函数学习如何从一个顶点的部分街坊聚合特色信息(见图1)。每个聚合函数从一个顶点的不同的hops或者说不同的搜寻深度聚合信息。测试或是推断的时候,应用训练好的零碎,通过学习到的聚合函数来对齐全未见过的顶点生成embedding。 GraphSAGE 是Graph SAmple and aggreGatE的缩写,其运行流程如上图所示,能够分为三个步骤: 对图中每个顶点街坊顶点进行采样,因为每个节点的度是不统一的,为了计算高效, 为每个节点采样固定数量的街坊依据聚合函数聚合街坊顶点蕴含的信息失去图中各顶点的向量示意供上游工作应用街坊采样的长处: 极大缩小计算量容许泛化到新连贯关系,集体了解相似dropout的思维,能加强模型的泛化能力采样的阶段首先选取一个点,而后随机选取这个点的一阶街坊,再以这些街坊为终点随机抉择它们的一阶街坊。例如下图中,咱们要预测 0 号节点,因而首先随机抉择 0 号节点的一阶街坊 2、4、5,而后随机抉择 2 号节点的一阶街坊 8、9;4 号节点的一阶街坊 11、12;5 号节点的一阶街坊 13、15聚合具体来说就是间接将子图从全图中抽离进去,从最边缘的节点开始,一层一层向里更新节点 ...

November 19, 2022 · 5 min · jiezi

关于算法:每日一题调整搜索二叉树中两个错误的节点

一棵二叉树本来是搜寻二叉树,然而其中有两个节点调换了地位,使得这棵二叉树不再是搜寻二叉树,请找到这两个谬误节点并返回。 已知二叉树中所有节点的值都不一样,给定二叉树的头节点 head,返回一个长度为 2 的二叉树节点类型数组 errs,errs[0] 示意一个谬误节点,errs[1] 示意另一个谬误节点。 解法一:递归 如下图对搜寻二叉树进行中序遍历,能够失去一个升序数组。如果搜寻二叉树中有两个节点调换为了地位,那么失去的数组,升序肯定被毁坏了。 如下图:如果节点 2 与节点 4 调换了地位,失去的数组中有两个逆序对。 第一个谬误节点:第一次降落的前一个节点。第二个谬误节点:最初一次降落的一个节点。 如下图:如果节点 2 与节点 5 调换了地位,失去的数组中有两个逆序对。 第一个谬误节点:第一次降落的前一个节点。第二个谬误节点:最初一次降落的一个节点。 如下图:如果节点 2 与节点 3 调换了地位,失去的数组中有一个逆序对。 数组无论有两个逆序对还是只有一个逆序对,谬误节点都满足下边的法则。 第一个谬误节点:第一次降落的前一个节点。第二个谬误节点:最初一次降落的一个节点。 class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = rightdef find_error_nodes(root: TreeNode): return inorder(root, None, None)def inorder(node, first, second): if node: first, second = inorder(node.left, first, second) if node.left and node.left.val > node.val: second = node if not first: first = node.left first, second = inorder(node.right, first, second) if node.right and node.right.val < node.val: second = node.right if not first: first = node return [first, second]解法二:非递归 ...

November 16, 2022 · 1 min · jiezi

关于算法:每日一题正数分裂

给定一个负数 1,裂开的办法有一种:(1) 给定一个负数 2,裂开的办法有一种:(1,1),(2) 给定一个负数 3,裂开的办法有一种:(1,1,1),(1,2),(3) 给定一个负数 4,裂开的办法有一种:(1,1,1,1),(1,1,2),(1,3),(2,2),(4) 给定一个负数 n,求裂开的办法数。 <font color=orange>亮点:斜率优化</font> 计划一:暴力递归 f ( pre, rest ) pre 只之前裂开的数rest 是本次要裂开的数。rest 要大于 pre。返回后果:裂开的办法数最终后果:f(1, n) 可能性剖析: 从左向右的尝试模型。 f(i,j) 依赖:f(i+1, rest - (i+1))+ ...+ f(n, n) def ways(n): return f(1, n)def f(pre, rest): if rest == 0: return 1 if rest < pre: return 0 res = 0 for i in range(pre, rest + 1): res += f(i, rest - i) return res计划二:动静布局 ...

November 9, 2022 · 1 min · jiezi

关于算法:NLP领域任务如何选择合适预训练模型以及选择合适的方案规范建议ERNIE模型首选

1.常见NLP工作信息抽取:从给定文本中抽取重要的信息,比方工夫、地点、人物、事件、起因、后果、数字、日期、货币、专有名词等等。艰深说来,就是要理解谁在什么时候、什么起因、对谁、做了什么事、有什么后果。文本生成:机器像人一样应用自然语言进行表白和写作。根据输出的不同,文本生成技术次要包含数据到文本生成和文本到文本生成。数据到文本生成是指将蕴含键值对的数据转化为自然语言文本;文本到文本生成对输出文本进行转化和解决从而产生新的文本问答零碎:对一个自然语言表白的问题,由问答零碎给出一个精准的答案。须要对自然语言查问语句进行某种程度的语义剖析,包含实体链接、关系辨认,造成逻辑表达式,而后到知识库中查找可能的候选答案并通过一个排序机制找出最佳的答案。对话零碎:零碎通过一系列的对话,跟用户进行聊天、答复、实现某一项工作。波及到用户用意了解、通用聊天引擎、问答引擎、对话治理等技术。此外,为了体现上下文相干,要具备多轮对话能力。语音辨认和生成:语音辨认是将输出计算机的语音符号辨认转换成书面语示意。语音生成又称文语转换、语音合成,它是指将书面文本主动转换成对应的语音表征。信息过滤:通过计算机系统自动识别和过滤合乎特定条件的文档信息。通常指网络有害信息的自动识别和过滤,次要用于信息安全和防护,网络内容治理等。舆情剖析:是指收集和解决海量信息,自动化地对网络舆情进行剖析,以实现及时应答网络舆情的目标。信息检索:对大规模的文档进行索引。可简略对文档中的词汇,赋之以不同的权重来建设索引,也可建设更加深层的索引。在查问的时候,对输出的查问表达式比方一个检索词或者一个句子进行剖析,而后在索引外面查找匹配的候选文档,再依据一个排序机制把候选文档排序,最初输入排序得分最高的文档。机器翻译:把输出的源语言文本通过主动翻译取得另外一种语言的文本。机器翻译从最早的基于规定的办法到二十年前的基于统计的办法,再到明天的基于神经网络(编码-解码)的办法,逐步造成了一套比拟谨严的办法体系。文本开掘:包含文本聚类、分类、情感剖析以及对开掘的信息和常识的可视化、交互式的表白界面。目前支流的技术都是基于统计机器学习的。2.如何将业务问题形象为已失去很好解决的典型问题2.1 明确业务的输出与输入令输出文本用X示意,输入标签用Y示意,则有以下粗略的分类: 2.1.1 如果Y示意某一类的概率,或者是一个定长向量,向量中的每个维度是其属于各个类的概率,且概率之和为1,则可形象为文本多分类问题。a.个别X只有一段文本。如下所示i.如情感剖析等工作。 房间 太 小 。 其余 的 都 个别 0b.如果X是2段文本(X1,X2),则是能够形象为句对分类问题。如下所示 i:如NLI等工作。 大家感觉她难看吗 大家感觉跑男难看吗? 0c.如果的每个类别的概率互相独立,即各类概率之和不为1,可形象为文本多标签分类问题。如下所示i:如用户评论分类、黄反辨认等工作。 互联网守业就如选秀 需要与服务就是价值 0 1d. 如果X有多段非文本特色输出,如整型、浮点型类型特色。则可形象为混合特色的分类问题。如下所示i:如CTR预估等工作。CTR预估* CTR预估是举荐中最外围的算法之一。 相干概念: CTR预估:对每次广告的点击状况做出预测,预测用户是点击还是不点击。CTR预估的影响因素:比方历史点击率、广告地位、工夫、用户等CTR预估相干介绍举荐算法之4——CTR预估模型2.1.2 如果X是2段文本(X1,X2),Y示意二者的类似度,可形象为文本匹配问题。如下所示喜爱 打篮球 的 男生 喜爱 什么样 的 女生 爱 打篮球 的 男生 喜爱 什么样 的 女生 1a.如语义类似度、类似问题匹配等工作。 b.文本聚类的问题能够通过文本类似度问题进行解决。 2.1.3 如果X有一段文本,Y是一个与X等长的序列,可形象为序列标注问题。如下所示海 钓 比 赛 地 点 在 厦 门 与 金 门 之 间 的 海 域 。 O O O O O O O B-LOC I-LOC O B-LOC I-LOC O O O O O Oa.如分词、POS、NER、词槽开掘等工作。 ...

November 9, 2022 · 2 min · jiezi

关于算法:每日一题包含所有字符的最小子串长度

给定字符串 str1 和 str2 ,求 str1 的子串中含有 str2 所有字符的最小子串长度。 【举例】 str1 = “abcde” ,str2 = “ac“ 因为 ”abc“ 蕴含 str2 所有的字符,并且在满足这一条件的 str1 的所有子串中,”abc“ 是最短的,返回 3. str1 = “12345” ,str2 = “344“,最小蕴含子串不存在,返回 0。 剖析: 应用 left 和 right 保护一个滑动窗口。 right 挪动的机会:窗口没有蕴含 str2 。扩充窗口。直到窗口内蕴含了 str2 所有字符。left 挪动的机会:窗口曾经齐全有蕴含 str2 ,此时窗口的长度可能不是最小。在保障窗口内蕴含str2 所有字符的前提下,减小窗口。直到 map[left] ==0 ,最左端的字符串(str1[right])的冗余曾经删除结束。综上所述,right 和 left 挪动机会,都依赖一个状态:窗口有没有蕴含 str2,咱们能够应用 int match 来保护这个状态。初始值为 match = len(str2),right 每次挪动包含 str2 字符 就须要 match -=1(当 map[str1[right]]<0 时,示意 str1 中多余的字符)。也须要存储一个 map,保留 str2 残余须要匹配字符的个数。 ...

November 8, 2022 · 1 min · jiezi

关于算法:每日一题需要排序的最短子数组长度

给定一个无序数组 arr,求出须要排序的最短子数组长度。 【例如】arr=【1,5,3,4,2,6,7】返回 4,因为只有【5,3,4,2】须要排序。 剖析: 从右向左遍历是降序的过程,用 min 记录 i 右侧的最小值。如果 arr[i] > min(此处乱序),阐明 min 的值须要放到 arr[i] 右边,用 index 记录 i 地位。找到最右边乱序的地位记录为:no_min_index从左向右遍历是升序的过程,用 max 记录 i 左侧的最大值。如果 arr[i] < max(此处乱序),阐明 max 的值须要放到 arr[i] 左边,用 index 记录 i 地位。找到最左边乱序的地位记录为:no_max_index最终后果:no_max_index - no_max_index + 1。最左边开始乱序的地位 - 最左边开始乱序的地位 + 1就是最小乱序子数组的长度。 工夫复杂度:O(N) 空间复杂度:O(1) def get_min_len(arr): if not arr: return 0 min_value = arr[-1] no_min_index = -1 for i in range(len(arr) - 2, -1, -1): if arr[i] > min_value: no_min_index = i else: min_value = min(min_value, arr[i]) if no_min_index == -1: return 0 max_value = arr[0] no_max_index = -1 for i in range(1, len(arr)): if arr[i] < max_value: no_max_index = i else: max_value = max(max_value, arr[i]) return no_max_index - no_min_index + 1

November 7, 2022 · 1 min · jiezi

关于算法:知识蒸馏相关技术模型蒸馏数据蒸馏以ERNIETiny为例

1.工作简介基于ERNIE预训练模型成果上达到业界当先,然而因为模型比拟大,预测性能可能无奈满足上线需要。间接应用ERNIE-Tiny系列轻量模型fine-tune,成果可能不够现实。如果采纳数据蒸馏策略,又须要提供海量未标注数据,可能并不具备客观条件。因而,本专题采纳支流的常识蒸馏的计划来压缩模型,在满足用户预测性能、预测成果的需要同时,不依赖海量未标注数据,晋升开发效率。文心提供多种不同大小的基于字粒度的ERNIE-Tiny学生模型,满足不同用户的需要。 注:常识蒸馏(KD)是将简单模型(teacher)中的darkknowledge迁徙到简略模型(student)中去,teacher具备弱小的能力和体现,而student则更为紧凑。通过常识蒸馏,心愿student能尽可能迫近亦或是超过teacher,从而用更少的复杂度来取得相似的预测成果。1.1 模型蒸馏原理常识蒸馏是一种模型压缩常见办法,指的是在teacher-student框架中,将简单、学习能力强的网络(teacher)学到的特色示意"常识"蒸馏进去,传递给参数量小、学习能力弱的网络(student)。在训练过程中,往往以最优化训练集的准确率作为训练指标,但实在指标其实应该是最优化模型的泛化能力。显然如果能间接以晋升模型的泛化能力为指标进行训练是最好的,但这须要正确的对于泛化能力的信息,而这些信息通常不可用。如果咱们应用由大型模型产生的所有类概率作为训练小模型的指标,就能够让小模型失去不输大模型的性能。这种把大模型的常识迁徙到小模型的形式就是蒸馏。 基本原理可参考Hinton经典论文:https://arxiv.org/abs/1503.02531 1.2 ERNIE-Tiny 模型蒸馏 模型蒸馏原理可参考论文 ERNIE-Tiny : A Progressive Distillation Framework for Pretrained Transformer Compression 2021。不同于原论文的实现,为了和开发套件中的通用蒸馏学生模型保持一致,咱们将蒸馏loss替换为Attention矩阵的KQ loss和 VV loss,原理可参考论文 MiniLM: Deep Self-Attention Distillation for Task-Agnostic Compression of Pre-Trained Transformers 2020 和 MiniLMv2: Multi-Head Self-Attention Relation Distillation for Compressing Pretrained Transformers 2021。试验表明通用蒸馏阶段和工作蒸馏阶段的蒸馏loss不匹配时,学生模型的成果会受到影响。BERT 等预训练语言模型 (PLM) 采纳了一种训练范式,首先在个别数据中预训练模型,而后在特定工作数据上微调模型,最近获得了巨大成功。然而,PLM 因其宏大的参数而臭名远扬,并且难以部署在现实生活中的应用程序中。常识蒸馏通过在一组数据上将常识从大老师转移到小得多的学生来解决这个问题。咱们认为抉择三个要害组成部分,即老师、训练数据和学习指标,对于蒸馏的有效性至关重要。因而,咱们提出了一个四阶段渐进式蒸馏框架 ERNIE-Tiny 来压缩 PLM,它将三个组件从个别级别逐步变动到特定工作级别。具体来说,第一阶段,General Distillation,在预训练的老师、个别数据和潜在蒸馏损失的领导下进行蒸馏。而后,General-Enhanced Distillation 将老师模型从预训练老师转变为微调老师。之后,Task-Adaptive Distillation 将训练数据从个别数据转移到特定于工作的数据。最初,Task-Specific Distillation 在最初阶段减少了两个额定的损失,即 Soft-Label 和 Hard-Label 损失。实证后果证实了咱们的框架的有效性和所带来的泛化增益 。试验表明 4 层 ERNIE-Tiny 在 GLUE 基准测试的根底上放弃其 12 层老师 BERT 的 98.0% 以上的性能,超过最先进的 (SOTA) 1.0% 的 GLUE 分数雷同数量的参数。此外,ERNIE-Tiny 在五个中文 NLP 工作上实现了新的压缩 SOTA,比 BERT 根底的精度高 0.4%,参数缩小 7.5 倍,推理速度放慢 9.4 倍。 ...

November 7, 2022 · 2 min · jiezi

关于算法:每日一题汉诺塔

汉诺塔:汉诺塔(又称河内塔)问题是源于印度一个古老传说的益智玩具。大梵天发明世界的时候做了三根金刚石柱子,在一根柱子上从下往上依照大小程序摞着64片黄金圆盘。大梵天命令婆罗门把圆盘从上面开始按大小程序从新摆放在另一根柱子上。并且规定,在小圆盘上不能放大圆盘,在三根柱子之间一次只能挪动一个圆盘。汉诺塔问题分三步: 将 0 ~ n -1 号圆盘从 from 柱子挪动到 other 柱子。将 n 号圆盘从 from 柱子挪动到 to 柱子。将 0 ~ n - 1 号圆盘从 other 柱子挪动到 to 柱子。 def hanoi(n): if n <= 0: return func(n, "左", "右", "中")def func(i, start, end, other): if i == 1: print("Move 1 from " + start + " to " + end) return func(i - 1, start, other, end) print("Move " + str(i) + " from" + start + " to " + end) func(i - 1, other, end, start)hanoi(3)汉诺塔游戏的要求把所有的圆盘从右边都移到左边的柱子上,给定一个整型数组arr,其中只含有1、2、3,代表所有圆盘目前的状态,1 代表左柱,2代表中柱,3 代表右柱,arr[i] 的值代表第 i + 1 个圆盘的地位。 ...

November 4, 2022 · 2 min · jiezi

关于算法:Paddle模型性能分析工具Profiler定位瓶颈点优化程序提升性能

我的项目链接,fork一下即可应用https://aistudio.baidu.com/aistudio/projectdetail/4482932?contributionType=1 Paddle模型性能剖析Profiler:定位性能瓶颈点优化程序晋升性能Paddle Profiler是飞桨框架自带的低开销性能分析器,能够对模型运行过程的性能数据进行收集、统计和展现。性能分析器提供的数据能够帮忙定位模型的瓶颈,辨认造成程序运行工夫过长或者GPU利用率低的起因,从而寻求优化计划来取得性能的晋升。 1.应用Profiler工具调试程序性能在模型性能剖析中,通常采纳如下四个步骤: 获取模型失常运行时的ips(iterations per second, 每秒的迭代次数),给出baseline数据。开启性能分析器,定位性能瓶颈点。优化程序,查看优化成果。获取优化后模型失常运行时的ips,和baseline比拟,计算实在的晋升幅度。上面是应用神经网络对cifar10进行分类的示例代码,外面加上了启动性能剖析的代码。通过这个比较简单的示例,来看性能剖析工具是如何通过上述四个步骤在调试程序性能中发挥作用。 1.1 应用cifar10数据集卷积神经网络进行图像分类import paddleimport paddle.nn.functional as Ffrom paddle.vision.transforms import ToTensorimport numpy as npimport matplotlib.pyplot as pltprint(paddle.__version__)加载数据集 cifar10数据集由60000张大小为32 * 32的彩色图片组成,其中有50000张图片组成了训练集,另外10000张图片组成了测试集。这些图片分为10个类别,将训练一个模型可能把图片进行正确的分类。 transform = ToTensor()cifar10_train = paddle.vision.datasets.Cifar10(mode='train', transform=transform)cifar10_test = paddle.vision.datasets.Cifar10(mode='test', transform=transform)组建网络 接下来应用飞桨定义一个应用了三个二维卷积( Conv2D ) 且每次卷积之后应用 relu 激活函数,两个二维池化层( MaxPool2D ),和两个线性变换层组成的分类网络,来把一个(32, 32, 3)形态的图片通过卷积神经网络映射为10个输入,这对应着10个分类的类别 class MyNet(paddle.nn.Layer): def __init__(self, num_classes=1): super(MyNet, self).__init__() self.conv1 = paddle.nn.Conv2D(in_channels=3, out_channels=32, kernel_size=(3, 3)) self.pool1 = paddle.nn.MaxPool2D(kernel_size=2, stride=2) self.conv2 = paddle.nn.Conv2D(in_channels=32, out_channels=64, kernel_size=(3,3)) self.pool2 = paddle.nn.MaxPool2D(kernel_size=2, stride=2) self.conv3 = paddle.nn.Conv2D(in_channels=64, out_channels=64, kernel_size=(3,3)) self.flatten = paddle.nn.Flatten() self.linear1 = paddle.nn.Linear(in_features=1024, out_features=64) self.linear2 = paddle.nn.Linear(in_features=64, out_features=num_classes) def forward(self, x): x = self.conv1(x) x = F.relu(x) x = self.pool1(x) x = self.conv2(x) x = F.relu(x) x = self.pool2(x) x = self.conv3(x) x = F.relu(x) x = self.flatten(x) x = self.linear1(x) x = F.relu(x) x = self.linear2(x) return x模型训练&预测 ...

November 4, 2022 · 5 min · jiezi

关于算法:在数据增强蒸馏剪枝下ERNIE30分类模型性能提升

在数据加强、蒸馏剪枝下ERNIE3.0模型性能晋升我的项目链接:https://aistudio.baidu.com/aistudio/projectdetail/4436131?contributionType=1 以CBLUE数据集中医疗搜寻检索词用意分类为例: 本我的项目首先解说了数据加强和数据蒸馏的计划,并在前面章节进行成果展现,后果预览: 模型ACCPrecisionRecallF1average_of_acc_and_f1ERNIE 3.0 Base0.802550.93171470.9082840.9198500.86120ERNIE 3.0 Base+数据加强0.79795390.9010040.928990.914780.8563ERNIE 3.0 Base+剪裁保留比0.50.798460.9512570.894970.922250.8603ERNIE 3.0 Base +剪裁保留比2/30.80920710.94153840.9053250.9230760.86614gensim装置最新版本:pip install gensim tqdm装置:pip install tqdm LAC装置最新版本:pip install lac Gensim库介绍 Gensim是在做自然语言解决时较为常常用到的一个工具库,次要用来以无监督的形式从原始的非结构化文本当中来学习到文本暗藏层的主题向量表白。 次要包含TF-IDF,LSA,LDA,word2vec,doc2vec等多种模型。 Tqdm 是一个疾速,可扩大的Python进度条,能够在 Python 长循环中增加一个进度提示信息,用户只须要封装任意的迭代器 tqdm(iterator)。目标为了程序显示的好看 中文词法剖析-LAC LAC是一个联结的词法分析模型,整体性地实现中文分词、词性标注、专名辨认工作。LAC既能够认为是Lexical Analysis of Chinese的首字母缩写,也能够认为是LAC Analyzes Chinese的递归缩写。 LAC基于一个重叠的双向GRU构造,在长文本上精确复刻了百度AI开放平台上的词法剖析算法。成果方面,分词、词性、专名辨认的整体准确率95.5%;独自评估专名辨认工作,F值87.1%(精确90.3,召回85.4%),总体略优于开放平台版本。在成果优化的根底上,LAC的模型简洁高效,内存开销不到100M,而速度则比百度AI开放平台进步了57% LAC链接:https://www.paddlepaddle.org.... !pip install --upgrade paddlenlp!pip install gensim!pip install tqdm!pip install lac 2.数据加强计划介绍数据加强工具提供4种加强策略:遮蔽、删除、同词性词替换、词向量近义词替换 !unzip ERNIE-.zip -d ./ERNIE 增加ERNIE工具包如果程序报错:能够发现提醒有一个.ipynb_checkpoints的文件。但当我去对应的文件夹找时基本看不到这个文件,所以猜想是一个暗藏文件。所以通过终端进入对应的目录:输出cd coco进入对应目录,输出ls -a显示所有文件。而后输出rm -rf .ipynb_checkpoints删除该文件。再次输出ls -a查看文件是否被删除。下载词表,词表有1.7G会花点工夫。上面以情感剖析数据样例展现demo,看看数据加强的成果。 !wget -q --no-check-certificate http://bj.bcebos.com/wenxin-models/vec2.txtpython data_aug.py "输出文件夹的目录" "输入文件夹的目录" data_aug.py脚本传参阐明shell输出: python data_aug.py -hshell输入: usage: data_aug.py [-h] [-n AUG_TIMES] [-c COLUMN_NUMBER] [-u UNK] [-t TRUNCATE] [-r POS_REPLACE] [-w W2V_REPLACE] [-e ERNIE_REPLACE] [--unk_token UNK_TOKEN] input output main positional arguments: input #原始待加强数据文件所在文件夹,带label的,一个或多个文本列 output #输入文件门路 optional arguments: -h, --help show this help message and exit -n AUG_TIMES, --aug_times AUG_TIMES #数据集数目放大n倍,output行数为input的n+1倍 -c COLUMN_NUMBER, --column_number COLUMN_NUMBER #明文文件中所要加强列的列序号,多列用逗号宰割,如:1,2 -u UNK, --unk UNK #unk 加强策略的概率 -t TRUNCATE, --truncate TRUNCATE #truncate 加强策略的概率 -r POS_REPLACE, --pos_replace POS_REPLACE #pos_replace 加强策略的概率 -w W2V_REPLACE, --w2v_replace W2V_REPLACE #w2v_replace 加强策略的概率 --unk_token UNK_TOKEN 分类问题中:举荐应用前三种即可,w2v词向量近义词替换能够不必,破费工夫太长。 ...

November 3, 2022 · 6 min · jiezi

关于算法:渲大师周年庆大放送注册即享50元新人礼包

时光荏苒,岁月如梭。人不知;鬼不觉,渲巨匠曾经陪伴大家一年了。 这一年,渲巨匠数据中心隆重开业,开启新起点。 咱们不畏挑战,勇毅前行,进一步开辟云桌面服务及渲染服务两大外围业务,不断完善产品和业务布局,致力晋升品牌知名度和产品竞争力。 此外,咱们组成了业余的技术团队,及时响应客户需要,疾速解决客户问题,为客户提供优质高效的服务,深受大家信赖。 为了感激大家的青睐,在渲巨匠一周年到来之际,咱们为大家筹备了周年庆惊喜大放送,新用户注册即享50元新人礼包。 将来,渲巨匠会持续为客户提供高性价比、高稳定性的云桌面服务及渲染服务。 感恩一路相伴,将来咱们持续同行! 1、流动内容 福利一:新人注册礼包新用户注册账号胜利,即赠送无门槛代金券5元 福利二:新人充值礼包用户首次充值1元,即赠送满减券30元(满50-20,满20-7,满10-3) 福利三:微信认证礼包用户实现微信绑定,即赠送无门槛代金券5元 福利四:实名认证礼包用户实现实名认证,即赠送无门槛代金券10元2、流动工夫2022年11月01日至2022年12月31日3、参加形式步骤一:新用户拜访渲巨匠官网:www.xuandashi.com , 点击‘’立刻注册‘’实现注册操作流程,零碎主动发放新人注册礼包(无门槛代金券5元) 步骤二:登录账号进入渲巨匠用户核心,点击左侧‘’流动治理-活动中心‘’,即可点击支付其余礼包,实现相应的操作后零碎主动发放赠品券。 4、流动阐明 1、新人注册礼包流动对象仅限未注册过渲巨匠的新用户(注册工夫在2022年10月31日之后); 2、用户实现账号注册后,新人注册礼包赠送的无门槛代金券主动发放,其余礼包到‘’活动中心‘’点击支付,实现相应的操作后主动发放,可在‘’我的奖品‘’查看到账的赠品券; 3、新人充值礼包阐明:用户实现首次充值金额1元,总计支付30元满减券,蕴含:● 满10减3    券一张● 满20减7    券一张● 满50减20  券一张 4、本次流动赠送的代金券及满减券有效期为2022-11-1 至 2022-12-31,过期则视为放弃,且不反对退款和提现;5、一次只能应用一张赠送的代金券或满减券,不可叠加应用; 6、若发现用户在流动加入过程中有任何违规行为(违规行为包含但不限于:歹意批量注册、有效手机号码、虚伪信息等)渲巨匠有权间接封停账号,并撤销该账号取得的相干赠品券; 7、如有任何问题,请征询渲巨匠在线客服; 8、本次流动最终解释权归深圳松茂科技有限公司所有。

November 2, 2022 · 1 min · jiezi

关于算法:AI绘画火了一文看懂背后技术原理

导语 | 近些年AI蓬勃发展,在各行各业都有着不同形式的利用。而AI创作艺术和生产内容无疑是今年以来最热门的话题,AI创作到底产生过什么,原理又是如何,是噱头还是会有对咱们有用的潜在利用场景呢?咱们旨在深入浅出的尝试答复这些问题。AI创作怎么火了?往年开始,文本形容主动生成图片(Text-to-Image)的AI绘画黑科技一下子变火了。很多人对AI绘画产生微小趣味是从一副AI作品的新闻开始的。这幅由MidJourney生成的数字油画加入了Colorado博览会的艺术较量,并且取得了第一名。这个事件能够设想的引起了微小的争执。(难道300刀的奖金撬起了3千亿的市场?)Jason Allen’s A.I.-generated work, “Théâtre D’opéra Spatial,” took first place in the digital category at the Colorado State Fair.Credit…via Jason AllenDisco Diffusion是往年2月爆火的AI图像生成程序,能够依据形容的场景关键词渲染对应的图片。往年4月,赫赫有名的OpenAI也公布了新模型DALL-E 2,命名来源于著名画家Dali和机器人总动员Wall-E,同样反对Text-to-Image。在年初的时候,Disco Diffusion能够生成一些有气氛感的图片,但还无奈生成粗劣的人脸,但很快到了DALL-E 2后就能够十分清晰的画出人脸了。而当初到了Stable Diffusion在创作的粗劣水平和作画速度上更上了一个新的台阶。Disco Diffusion: Mechanical arm with a paint brush and a canvas by Li Shuxing and Tyler EdlinDALL-E2: 将Johannes Vermeer 的名画“戴珍珠耳环的女孩”转换生成不同的脸孔Stable Diffusion: a beautiful painting of a building in a serene landscape2022年8月,被视为当下最强的AI创作工具Stable Diffusion正式凋谢,这无疑进一步给AI创作带来了最近的炽热。通过网站注册就能够应用,提供了不便简洁的UI,也大大降低了这类工具的应用门槛,而且效率高,图像品质好。而如果不想花钱的话,Stable Diffusion还正式开源了代码、模型和weights,在huggingface上都能够间接clone和下载,部署到GPU上就能够轻易用了。huggingface上同时也曾经有了diffusers库,能够成为调包侠间接应用,colab上也都有现成的notebook example了。也因而热度,推出Stable Diffusion的AI公司StabilityAI实现了1亿美元的种子轮融资,公司估值达到了10亿美元。Stable Diffusion开源后的搜寻热度曾经放弃两个月了和机器学习刚开始火的时候一样,AI生成技术也并不是凭空出现的。只是近一两年以来,作品的品质和计算速度日益疾速晋升,让咱们疏忽了AI绘画同样悠久的历史。历史倒退AI绘画在计算机呈现后不久就曾经开始有了最后的摸索。在70年的时候艺术家Harold Cohen就曾经发明了程序“AARON”进行绘画,而不同于当初的黑科技,过后AARON是真的去操作机械臂来画画。Harold对AARON的改良继续了很久,80年代的时候,ARRON能够尝试画三维物体,并且很快就能够画彩图了。但AARON没有开源,所以它学习的是Harold自己的形象色调绘画格调。2006年,呈现了The Painting Fool,有点相似AARON,通过观察照片提取色彩信息,应用事实中的资料进行创作,所以同样电脑程序通过学习信息就行物理绘画的形式。当初咱们说的更多的“AI创作”的概念,更多的指的是基于Deep Learning模型进行主动作图的程序,这种绘画形式得益于近些年计算机软硬件的高速倒退。2012年两位大神Andrew Ng和Jeff Dean进行了一次试验,应用1.6万个CPU和Youtube上一千万个猫脸图片用了3天训练了过后最大的深度学习网络,生成了一个猫脸。在当初看来这个后果不值一提,但对过后的CV畛域来说,是具备突破性的意义的尝试,并且正式开启了AI创作的全新方向。2006年,李飞飞传授发现了很多钻研工作在AI算法方面疏忽了“数据”的重要性,于是带头开始构建大型图像数据集 - ImageNet,也因而图像识别大赛由此拉开帷幕,三年后李飞飞团队发表了ImageNet的论文从而真正公布了ImageNet数据集,给AI创作提供了弱小的数据库。同样2006年,Geoffrey Hilton团队实现了GPU优化深度神经网络的办法,从而“深度学习”这个新名词的概念被提出,各种Neural Networks的技术手段开始一直呈现,深度学习的倒退也减速了AI在两个赛道Discriminative model和Generative model的倒退。2012年的AlexNet,2014年的VGGNet,2015年的ResNet,2016年的DenseNet都是前者的经典模型。而对于Generative model,2014年大神Ian Goodfellow提出了GAN,两个神经网络互相学习和训练,被认为是CV畛域的重大突破,通过两个神经网络的互相博弈,使得生成的数据分布更靠近实在数据分布。从此2014年的GAN、VAE以及2016年的PixelRNN/CNN成为了三类支流的Generative models。2017-2018年深度学习框架也建设成熟,PyTorch和Tensorflow成为首选框架,提供了很多图像处理的大量预训练模型,大大降低了技术门槛。2018年,Nvidia公布了Video-to-Video synthesis,它能够通过发生器、鉴别器网络等模块,合成高分辨率照片一样实在的视频,实现了把AI推向新的发明场景。GAN的大规模应用,也呈现了很多基于GAN的模型迭代和优化,2019年BigGAN的呈现让GAN的世界更弱小,由它训练生成的图像曾经无奈分辨真假了,被认为是过后最强的图像生成器。然而GAN仍然存在一些缺点,比方一些钻研中都有提到模型的稳定性和收敛较差,尤其是面对更加简单和多样的数据。更为重要的是,让生成的数据分布靠近实在数据分布,也就是靠近现有的内容的样子同样会造成一个问题,就是生成的内容是十分靠近现有内容,靠近也就是没法冲破带来艺术上的“翻新”。而2020年开始在图片生成畛域钻研更多的Diffusion model克服了这些问题。Diffusion model的外围原理就是给图片去噪的过程中了解有意义的图像是如何生成的,同时又大大简化了模型训练过程数据处理的难度和稳定性问题。所以Diffusion模型生成的图片相比GAN模型京都更高,且随着样本数量和训练时长的累积,Diffusion model展示了对艺术表白格调更好的模拟能力。2021年的比照钻研表明,在同样的ImageNet的数据库训练后的图片生成品质,应用Diffusion model失去的FID评估后果要优于过后最好的Generative models BigGAN-deep等等。正如结尾提到,往年的AI热点属于文本创作内容,而其实始终到2021年初,OpenAI公布的DALL-E其AI绘画程度也就个别,但这里开始领有的一个重要能力就能够依照文本形容进行创作。而后往年2022年,在三座大山Stable Diffusion、DALL-E 2、MidJourney生成的各种画作中,曾经引起了各种人群包含开发者、艺术家、美术工作者等等的趣味尝试和争执。Stable Diffusion的开源和简略的过滤器性能无疑将Text-to-Imagede的热点和争议推向了低潮。而很快大厂们不再只局限于图片,同时又推出了Text-to-Video的产品。Meta在刚过去的九月底发表了新的AI产品Make-A-Video,使用者能够同样应用文本的形式生产简洁和高质量的短视频,他们的阐明是零碎模型能够从文本-图片配对数据中学习这个世界的样子并从视频片段中推理没有文本状况下的世界变动。从实现场景来看也有多种应用形式,比方文本形容不同类型的场景动作、应用单张或一对图片生成变动视频、在原始视频中退出额定的元素和变动,Meta也表明了他们之后会公布demo工具。很快在十月初,Google也公布了他们新的AI产品Imagen Video,同样是应用文本生产视频的工具。Imagen Video还在研发阶段,但Google的学术论文表明了这个工具能够通过文本形容生产24 fps的分辨率在1280x768的视频,同时能够有风格化能力和物体3D旋转能力。文章还表明Imagen Video在文本内容的视频出现上也会绝对于优于DALL-E和Stable Diffusion。又没过几天,Google和Phenaki发表了另一个文本生产视频工具Phenaki,甚至能够生产2分钟以上较长的视频。Google同时也阐明了“问题数据”对于AI模型的影响和潜在的危险,公司始终致力于谨严过滤暴力和色情内容以及文化偏差等问题,因而短期内并不会开源Imagen Video模型,但咱们置信不久的未来,不论通过工具或者源代码的形式,这些cutting-edge的视频生产模型也会和图片生产模型一样很快和AI创作者们相见。既然有了Text-to-Image和Text-to-Video,那Text-to-Speech必定也要蹭一下热度。10月中旬postcast.ai公布了一段音频是跟用AI生成的跟Steve Jobs的对话火了(新闻),从语音语调上听起来真的和Steve自己没有差异,齐全不像是机器人的声音。而技术提供方play.ht在他们的网站上也上线了新的这个十分有吸引力的性能Voice Cloning,下面提供各种名人的AI合成声音。他们并没有提供更多的技术信息,但看起来他们应用了2020年上线并在2021年底凋谢的GPT3模型,同时从成果上看起来曾经十分靠近复制真人的声音了。 ...

November 2, 2022 · 1 min · jiezi

关于算法:COMP202算法复杂度分析

COMP202 Programming AssignmentComplexity of Algorithms 01 April 2022Title: Longest Range of Peaks ProblemGo to COMP202 and to Assignment:COMP202: CA2 – PROGRAMMING ASSIGNMENT 2022Notes: This assessment is worth 15% of your overall course grade.Standard late penalties apply, as per university policy.Learning outcomes covered by this CA task will also be covered withinresit exam: this prevents the need for explicit reassessment of thiscomponent. The resit exam will replace the CA component in casethis is failed.Learning outcomesThe purpose of this exercise is for you to demonstrate the following learningoutcomes and for me to assess your achievement of them.To demonstrate how the study of algorithmics has been applied in anumber of different domains.To introduce formal concepts of measures of complexity and algorithmsanalysis.To introduce fundamental methods in data structures and algorithmsdesign.Note: You will be provided with a collection of sample inputs together withcorrect answers to these inputs. You should aim at submitting your finalprogram only if it produces correct answers to all these inputs.Academic integrityThe work that you submit should be the product of yourself (alone), andnot that with any other student or outside help. Obviously I am providinga source code framework within which you will provide your own methodfor solving this problem, but the code that you write within this frameworkshould be your own code, not that obtained in collaboration with otherstudents or other outside assistance or sources.Problem DescriptionSuppose that we are given an array A[1, 2, . . . , n] containing n ≥ 3 positive,not necessary distinct, integers. We do not assume that the input arrayis sorted. We first define a notion of a peak. Any three consecutive indicesi, i+1, i+2 such that 1 ≤ i ≤ n−2 and A[i] < A[i+1] and A[i+1] > A[i+2],is called a peak; note that the inequalities are strict.A range is a collection of disjoint peaks. Formally, a range that consistsof k ≥ 1 peaks is the following collection of indices in array A: {i1, i2, . . . , ik}such that:(1) 1 ≤ i1 < i2 < · · · < ik ≤ n − 2 (indices are distinct increasing integersfrom {1, 2, . . . , n}),(2) i1+2 < i2, i2+2 < i3, · · · , ik−1+2 < ik (peaks are disjoint, i.e., indicesare separated from one another by at least 2 positions in array A),(3) Each three consecutive indices ij , ij + 1, ij + 2 (for j = 1, 2, . . . , k) forma peak, that is, A[ij ] < A[ij + 1] and A[ij + 1] > A[ij + 2] for eachj = 1, 2, . . . , k (we have k disjoint peaks)(4) For every two consecutive peaks ij , ij+1, ij+2 and ij+1, ij+1+1, ij+1+2, (for j = 1, 2, . . . , k − 1), we have the following additional condition:A[ij + 1] ≥ A[ij+1] and A[ij + 2] ≤ A[ij+1] (note weak inequalitieshere). This condition intuitively means that the east slope of the peakij , ij + 1, ij + 2 contains the base (first element ij+1) of the west slopeof the very next peak ij+1, ij+1 + 1, ij+1 + 2.If a range consists of k ≥ 1 peaks, then its length is k. The LongestRange of Peaks Problem is to find the length of the longest range of peaksin the input array A, or output 0 if there is no peak in array A.Examples:Let us consider input A[1, 6, 2, 11, 2, 10, 5, 7, 3] with n = 9. Here A[1], A[2], A[3];A[3], A[4], A[5]; A[5], A[6], A[7]; A[7], A[8], A[9] are four peaks in A. Theseare all peaks in array A. We also have the following range of length 2:A[1], A[2], A[3]; A[5], A[6], A[7]. Another range of length 2 is: A[3], A[4], A[5];A[7], A[8], A[9]. And another range of length 2 is: A[1], A[2], A[3]; A[7], A[8], A[9].Here, any of these 3 ranges is the the longest range in this instance of theproblem and so the output of the Longest Range of Peaks Problem is 2.Let us consider now input A[1, 6, 2, 2, 2, 10, 5, 7, 8, 3] with n = 10. Here,the longest range has length 3 and it is: A[1], A[2], A[3]; A[5], A[6], A[7];A[8], A[9], A[10], so the output of the Longest Range of Peaks Problem is 3.Observe, for instance, that A[1], A[2], A[3]; A[8], A[9], A[10] is not a rangebecause the condition (4) above is false, namely, A[8] = 7 is not betweenA[3] = 2 and A[2] = 6.If the input array is sorted in non-decreasing order, for instance A[1, 6, 8, 8, 10, 13],then there is no peak, and so the output of the Longest Range of Peaks Problemis 0. Similarly, if the array is sorted in non-increasing order, for instanceA[15, 11, 4, 4, 3, 3], then there is no peak, and so the output of the problemis 0.Some further examples of inputs.Suppose, for instance, that n = 13 and that the input sequence is:3 2 1 7 5 7 10 1 1 1 3 2,that is, A[1] = 1, A[2] = 3, A[3] = 2, A[4] = 1, A[5] = 7, A[6] = 5, A[7] =7, A[8] = 10, A[9] = 1, A[10] = 1, A[11] = 1, A[12] = 3, A[13] = 2. Then, thelongest range of peaks is: A[4], A[5], A[6]; A[7], A[8], A[9]; A[11], A[12], A[13]and has length 3. The output to the problem is 3.Suppose, for instance, that n = 11 and that the input sequence is:5 2 2 2 7 4 4 4 5 4,that is, A[1] = 1, A[2] = 5, A[3] = 2, A[4] = 2, A[5] = 2, A[6] = 7, A[7] =4, A[8] = 4, A[9] = 4, A[10] = 5, A[11] = 4. Then, the longest range of peaksis: A[1], A[2], A[3]; A[5], A[6], A[7]; A[9], A[10], A[11] and has length 3. Theoutput to the problem is 3.For further examples of inputs together with answers, see the text filedataTwo.txt that I provide (see explanation of the data format below). Thefile dataTwo.txt contains also solutions.The task: You should design a dynamic programming algorithm and writea procedure to implement the sequential implementation of your dynamicprogramming algorithm, that for any given input sequence of n positiveintegers (multiple identical numbers allowed) finds the length of the longestrange of peaks (or 0 if there is no peak in the sequence). Your procedureshould only output the value of the longest range of peaks or 0.Additionally, you should include a brief idea of your solution in the commentedtext in your code, describing how you derive your recursive dynamicprogramming solution first and ideas of its sequential implementation. Youshould also include a short analysis and justification of the running time ofyour procedure in terms of n. These descriptions are part of the assessmentof your solution.HintsYou are supposed to solve the Longest Range of Peaks problem by dynamicprogramming. Some exercises from the exercise list on dynamic programmingcould inspire your solution here. In your solution (described as partof the assessment) you should first define an appropriate dynamic programmingtable and then come up with a recurrence solution to the problem first,which then you should translate into a sequential solution that fills in a dynamicprogramming table in an appropriate way in your implementation.Programming LanguageYou will be using Java as the programming language.Program framework descriptionIMPORTANT: Before submitting, you must rename your file Main123456789.javawhere 123456789 is replaced with all digits of your Student ID. You alsomust rename the main public class Main123456789{ } in your file by alsoreplacing 123456789 by all digits of your Student ID.I provide a template program called Main123456789.java that you will use(without altering anything but the place to put your code) to include thecode of your procedure to solve the Longest Range of Peaks problem. Notethat you may add additional procedures outside of the procedure LongestRangeif needed.To use this template, after you write your code inside of procedure calledLongestRange, you must include in the current directory the input textfiles dataOne.txt and dataTwo.txt. Note, however, that if you need anyadditional procedures, you may include them outside of the text of theprocedure LongestRange.To compile your program in command line (under Linux/Unix) use somethinglike this (this may differ within your system):javac Main123456789.javaThen, you can run your program from command line like thisjava Main123456789 -opt1which will run the program with dataOne.txt as input file and will outputanswers (that is the values of the longest range or 0) to all instances in orderthey appear in dataOne.txt. You may use your own dataOne.txt in theformat (see below) to experiment with your program. Input file dataOne.txtmay contain any number of correct input sequences.Now, if you run the program withjava Main123456789 -opt2this will run the program with dataTwo.txt as input file. In this case,the output will be the indices of inputs from dataTwo.txt that were solvedincorrectly by your program together with percentage of correctly solvedinstances. If all instances are solved correctly, the output should be 100%.File dataTwo.txt contains the same instances as dataOne.txt, but, in additiondataTwo.txt also contains the correct, that is values of the longestranges or 0, answers to these instances. You may use dataTwo.txt to testthe correctness of your program.Description of the input data format:Input data text file dataOne.txt has the following format (this examplehas 2 inputs, each input ends with A; note the number 0 is the part of theinput format, but not part of the input sequences):0In general file dataOne.txt can have an arbitrary number of distinct inputs ofarbitrary, varying lengths. File dataOne.txt contains 50 different instancesof the problem. The first 6 instances are the same as the examples above.Observe that n is not explicitly given as part of the instance. Also 0 whichstarts each instance does not have any particular purpose; it is just formatof the input data to mark beginning of an instance.Input data text file dataTwo.txt has the following format (this examplehas again 2 inputs, each input ends with A):There ans1 (ans2, respectively) is the value of the longest range for the first(second, respectively) instance or 0 if there is no peak in those instances.File dataTwo.txt contains the same 50 instances of the problem as in filedataOne.txt but in addition has the answers. This data can be used to testthe correctness of your procedure.Again, in general file dataTwo.txt can have an arbitrary number of distinctinput sequences of arbitrary, varying lengths. It is provided by mewith correct answers to these instances.The solutions shown in dataTwo.txt are (at least) the claimed solutionsfor each sample input, computed by my program. Recall that your solutionshould print out the length of the longest range in the given sequence forthe given instance, or 0 in case if this instance contains no peaks. Note, thatyour program does not need to output this longest range of peaks.Program submissionYou must submit a single Java source code in a single file that mustbe called Main123456789.java (not the byte code), where 123456789 isreplaced with all digits of your Student ID, via CANVAS:https://https://liverpool.ins...Go to COMP202 and to Assignment: COMP202: CA2 – PROGRAMMINGASSIGNMENT 2022IMPORTANT: Before submitting, you must rename your file Main123456789.javawhere 123456789 is replaced with all digits of your Student ID. You alsomust rename the main public class Main123456789{ } in your file by alsoreplacing 123456789 by all digits of your Student ID.Your source file Main123456789.java must have the (unaltered) text ofthe template provided by me, containing the text of your procedure insidethe LongestRange method. You are allowed to include additional proceduresoutside the LongestRange method if needed. In addition, within commentedparts of method LongestRange, you should describe your recursive solutionand how you implement it sequentially. Moreover, you should also describea short running time analysis of your sequential implementation in terms ofn and big-O notation.You are responsible that your source code program Main123456789.javacan be compiled correctly with Java compiler and executed on (any) oneof the computers in the Computer Science Department’s that runs Javainstallation under Linux, where I will test your programs. You may alsoremotely connect to any Linux computer in the Department to compile/testyour program. Programs that will not correctly compile on DepartmentalLinux Java installation will automatically receive mark 0 for the correctnesspart.AssessmentMarking on this assessment will be performed on the following basis:• Accuracy of solution (e.g., does it give correct answers for all of thetest cases, and is it a general solution method for instances of thisproblem?): 60%• Clarity of solution (Is your program easy to follow? Is it commentedto help me see your solution method?): 10%• Correctness of time complexity (in big-O notation of the problem sizen) description of your procedure and description of your solution.(Have you provided an analysis of the (asymptotic) running time ofyour method, and is that analysis correct? Is the description of yoursolution (recursion and sequential implementation) correct and clearlywritten?: 20%• Optimality of solution (Do you have the ”best”, i.e., quickest, solution

November 2, 2022 · 10 min · jiezi

关于算法:CSCI-531-编导指南

CSCI 531 Programming Assignment 2 (100 points) Your task is to implement a system that uses AES to encrypt data and RSA to protect AES keys. You will need to write one program to generate RSA keys, and a second one that uses the RSA keys to perform the encryption and decryption of messages. Any correct implementation is acceptable. Your implementation need not be the best one in terms of run-time.Project DetailsTo complete the project, you will need to write two Python 3.7 programs:1.genkeys.py — generate RSA public and private keys.The program takes a single command line argument: the name of the user for whom the keys will be generated. For test purposes, use the user names alice and bob.The program must be runnable directly from the command shell, e.g., ./genkeys.py aliceThe program must generate an RSA public/private key pair using your own code (you cannot import RSA code from another module such as PyCrypto). It must use random.SystemRandom or os.urandom() as the source of pseudo-random bytes. The keys must be of practical cryptographic size (e.g., 1024 bits).The program must produce two output files, one containing the RSA private key (e.g., alice.prv) and the other one containing the RSA public key (e.g., alice.pub). The format of the key files is up to you.You will need to write code to compute modular inverse and to test whether a number is prime.To achieve the latter, you can implement the Miller-Rabin primality test. ...

November 2, 2022 · 4 min · jiezi

关于算法:MATH5916-存活分析

MATH5916: Survival AnalysisTerm 1, 2022Assignment 2Submission deadline: Friday 22 April, 5:00pmDeliverables: One R Markdown file for the entire assignment with file name of the form“LastName FirstName - z1234567 - Ass#.Rmd”. Your Rmd file should produce a PDF file(use option output: pdf document), make no external references to the file structure onyour computer and you should have no commands to save output externally. A templatecan be found on Moodle and more detailed instructions can be found in Lecture 1.Assignment length: There is a 8 page limit and 12pt font size for your Rmd outputfile. Any pages exceeding this limit or submissions with smaller font sizes will not be marked.If you are over the page limit, be judicious about what R code/output is printed and perhapsmodify figure sizes (they do not need to be large but should be legible).Submission: Upload your R Markdown file to Moodle and include the Plagiarism Statementgiven below (copy-and-paste it).Penalties: Failure to adhere to instructions will result in a minimum 5% mark reduction.Name: Student Number:I declare that this assessment item is my own work, except where acknowledged,and has not been submitted for academic credit elsewhere, and acknowledge thatthe assessor of this item may, for the purpose of assessing this item:? Reproduce this assessment item and provide a copy to another member of theUniversity; and/or,? Communicate a copy of this assessment item to a plagiarism checking service(which may then retain a copy of the assessment item on its database for thepurpose of future plagiarism checking).I certify that I have read and understood the University Rules in respect of StudentAcademic Misconduct.Signed: Date:1 ...

November 2, 2022 · 5 min · jiezi

关于算法:COMPX203计算机系统

The University of WaikatoDepartment of Computer ScienceCOMPX203 Computer SystemsExercise 2 – C and WRAMP ProgrammingDue Date: 13 April 2022ObjectivesThis exercise explores the relationship between high level programming languages, assembly code,and the system stack. You’ll be writing programs using C and WRAMP assembly code, and interactingbetween the two using the system stack.It is highly recommended that you read this entire specification before beginning to write any code.AssessmentThis exercise contributes 10% towards your internal grade, to be assessed in two parts:● The correctness of your source code, to be submitted via Moodle (7%)● Your completion of an online quiz about the exercise, also on Moodle (3%)Both of these parts must be completed on or before the due date.This is an individual exercise; while you may discuss the assignment with others in general terms,you must write your own code, and complete the quiz by yourself.The name of the file must match the following format:ex[exercise number]_q[question number].srecFor example, the third question in this exercise would be called ex2_q3.srecQuestions ...

November 2, 2022 · 10 min · jiezi

关于算法:应用实践Paddle分类模型大集成者PaddleHubFinetuneprompt

相干文章:Paddlenlp之UIE模型实战实体抽取工作【打车数据、快递单】 Paddlenlp之UIE分类模型【以情感偏向剖析新闻分类为例】含智能标注计划) 我的项目连贯:[利用实际:分类模型大集成者[PaddleHub、Finetune、prompt]](https://aistudio.baidu.com/ai...) 1.基于PaddleHub下的分类模型构建PaddleHub--API接口文档阐明:遇到不晓得参数设置具体情况追查接口阐明!!! https://paddlehub.readthedocs... 应用PaddleHub Fine-tune API进行Fine-tune能够分为4个步骤。 抉择模型加载数据集抉择优化策略和运行配置执行fine-tune并评估模型 1.1 二分类模型demo抉择模型 paddlehub反对模型列表 PaddleHub还提供BERT等模型可供选择, 以后反对文本分类工作的模型对应的加载示例如下: 模型名PaddleHub ModuleERNIE, Chinesehub.Module(name='ernie')ERNIE tiny, Chinesehub.Module(name='ernie_tiny')ERNIE 2.0 Base, Englishhub.Module(name='ernie_v2_eng_base')ERNIE 2.0 Large, Englishhub.Module(name='ernie_v2_eng_large')BERT-Base, English Casedhub.Module(name='bert-base-cased')BERT-Base, English Uncasedhub.Module(name='bert-base-uncased')BERT-Large, English Casedhub.Module(name='bert-large-cased')BERT-Large, English Uncasedhub.Module(name='bert-large-uncased')BERT-Base, Multilingual Casedhub.Module(nane='bert-base-multilingual-cased')BERT-Base, Multilingual Uncasedhub.Module(nane='bert-base-multilingual-uncased')BERT-Base, Chinesehub.Module(name='bert-base-chinese')BERT-wwm, Chinesehub.Module(name='chinese-bert-wwm')BERT-wwm-ext, Chinesehub.Module(name='chinese-bert-wwm-ext')RoBERTa-wwm-ext, Chinesehub.Module(name='roberta-wwm-ext')RoBERTa-wwm-ext-large, Chinesehub.Module(name='roberta-wwm-ext-large')RBT3, Chinesehub.Module(name='rbt3')RBTL3, Chinesehub.Module(name='rbtl3')ELECTRA-Small, Englishhub.Module(name='electra-small')ELECTRA-Base, Englishhub.Module(name='electra-base')ELECTRA-Large, Englishhub.Module(name='electra-large')ELECTRA-Base, Chinesehub.Module(name='chinese-electra-base')ELECTRA-Small, Chinesehub.Module(name='chinese-electra-small')通过以上的一行代码,model初始化为一个实用于文本分类工作的模型,为ERNIE的预训练模型后拼接上一个全连贯网络(Full Connected)。 model = hub.Module(name='ernie',task='seq-cls', num_classes=2)hub.Module的参数用法如下: name:模型名称,能够抉择ernie,ernie_tiny,bert-base-cased, bert-base-chinese, roberta-wwm-ext,roberta-wwm-ext-large等。task:fine-tune工作。此处为seq-cls,示意文本分类工作。num_classes:示意以后文本分类工作的类别数,依据具体应用的数据集确定,默认为2。加载数据集: 加载官网提供数据集:选用中文情感分类公开数据集ChnSentiCorp为示例(二分类经典数据集) train_dataset = hub.datasets.ChnSentiCorp(tokenizer=model.get_tokenizer(), max_seq_len=128, mode='train')dev_dataset = hub.datasets.ChnSentiCorp(tokenizer=model.get_tokenizer(), max_seq_len=128, mode='dev')test_dataset = hub.datasets.ChnSentiCorp(tokenizer=model.get_tokenizer(), max_seq_len=128, mode='test')#查看数据集for i in range(10): print(test_dataset.examples[i])参数问题请查看文档:https://paddlehub.readthedocs... ...

November 2, 2022 · 6 min · jiezi

关于算法:小样本学习在文心ERNIE30多分类任务应用提示学习

小样本学习在文心ERNIE3.0多分类工作利用(提醒学习)我的项目链接:https://aistudio.baidu.com/aistudio/projectdetail/4438610?contributionType=1 0.小样本学习简介二分类/多分类工作在商品分类、网页分类、新闻分类、医疗文本分类等事实场景中有着广泛应用。现有的支流解决方案是在大规模预训练语言模型进行微调,因为上游工作和预训练任务训练指标不同,想要获得较好的分类成果往往须要大量标注数据,因而学界和业界开始钻研如何在小样本学习(Few-shot Learning)场景下获得更好的学习效果。 提醒学习(Prompt Learning) 的次要思维是通过工作转换使得上游工作和预训练任务尽可能类似,充分利用预训练语言模型学习到的特色,从而升高样本需求量。除此之外,咱们往往还须要在原有的输出文本上拼接一段“提醒”,来疏导预训练模型输入冀望的后果。 咱们以Ernie为例,回顾一下这类预训练语言模型的训练任务。 与考试中的完形填空类似,给定一句文本,遮蔽掉其中的局部字词,要求语言模型预测出这些遮蔽地位本来的字词。 因而,咱们也将多分类工作转换为与完形填空类似的模式。例如影评情感分类工作,标签分为1-正向,0-负向两类。 在经典的微调形式中,须要学习的参数是以[CLS]向量为输出,以负向/正向为输入的随机初始化的分类器。在提醒学习中,咱们通过结构提醒,将原有的分类工作转化为完形填空。如下图所示,通过提醒我[MASK]喜爱。,原有1-正向,0-负向的标签被转化为了预测空格是很还是不。此时的分类器也不再是随机初始化,而是利用了这两个字的预训练向量来初始化,充分利用了预训练模型学习到的参数。 对于标注样本短缺的场景能够间接应用预训练模型微调实现文本多分类,对于尚无标注或者标注样本较少的工作场景咱们举荐应用小样本学习,以获得比微调办法更好的成果。 下边通过新闻分类的例子展现如何应用小样本学习来进行文本分类。 0.1 环境要求python >= 3.6 paddlepaddle >= 2.3 paddlenlp >= 2.4.0 【预计9月份上线】 0.1.1提前尝鲜获取最新版本!pip install git+ pip 从 git 源码仓库间接 install 。要求是这个github仓库内要有setup.py文件 查看url: 装置git仓库中的包 pip install git+<git仓库地址>pip install git+<git仓库地址>@<分支名称>用到它的场景就是比方你有一个代码曾经上传到github了,要分发给他人用,你就懒得再下载下来再导出成tar.gz或者whl文件,是能够间接让他从github网址装置 pip install git+http://127.0.0.1/xxx/demo.git --userpip install git+https://github.com/shadowsocks/[email protected]等价于: # 两步走的装置(装置完还须要本人删除git文件)git clone http://127.0.0.1/XXX/demo.git#change dircd demo# installpython setup.py install --user# windows环境下加--user 不然容易报错#间接pip git 无奈装置胜利,那就采纳第二种计划# !pip install git+https://github.com/PaddlePaddle/[email protected]先把paddlenlp develop分支下下载到本地,进行压缩上传到aistudio。 $ git clone https://github.com/PaddlePaddle/PaddleNLP.gitCloning into 'PaddleNLP'...remote: Enumerating objects: 27619, done.remote: Counting objects: 100% (125/125), done.remote: Compressing objects: 100% (106/106), done.remote: Total 27619 (delta 46), reused 78 (delta 18), pack-reused 27494Receiving objects: 100% (27619/27619), 73.69 MiB | 3.03 MiB/s, done.Resolving deltas: 100% (18182/18182), done.Updating files: 100% (3115/3115), done.取得的paddlenl文件夹在C:\Users\admin门路下,而后进行压缩上传到aistudiowin10压缩参考上面链接:(或者间接用压缩软件压缩)https://blog.csdn.net/sinat_3... ...

November 1, 2022 · 5 min · jiezi

关于算法:Sanitizers-系列之-address-sanitizer-原理篇

asan 的原理概述如何断定过程是否拜访一片内存区域?一个直观的想法是: 给每个字节做个记号(poison state),将过程不可能拜访的字节标记为 poisoned,而后在每次拜访内存之前先查看它的 poison state,如果是 poisoned,那么就能够判断产生了非法拜访。asan 的外围算法就是基于这个想法,asan 会应用一片专门的内存来保留 application memory 每个字节的 poison state,这片内存的业余名称是 shallow memory,在拜访地址 addr 之前,首先在 shadow memory 中查看 addr 的 poison state,如果 poison state 是 poisoned,那么就能够断定产生了非法拜访,asan 会及时报告谬误,否则程序失常运行。 实际上,asan 的实现远比下面形容的要简单, 概括地说,asan 由两局部组成: 通过上述内容能够看出:asan 的实现既依赖于 compiler 在编译时对源代码做非凡的转换(由 instrumentation module 实现),还依赖一个运行时库,下文将对上述内容进行更加具体的介绍。 Shadow Memoryasan 会将过程的 memory space 分为两大类: Application Memory(简称为 Mem)这部分内存属于利用过程,由利用过程进行应用。 Shadow Memory(简称为 Shadow)这部分内存用于寄存 shadow value,shadow value 其实就是 Mem 各个 byte 的 poison state。”Shadow“的字面意思是“影子”,在 asan 的具体实现上,Mem 和 Shadow 之间存在着一一对应的关系,这就相当于现实生活中的"影子"。依照 Mem 和 Shadow 之间的一一对应的关系,将 Mem 中的一个 byte 标记为“poisoned”是通过将这个 byte 对应的 Shadow 中的 byte 设置为非凡值来实现的。 ...

October 31, 2022 · 5 min · jiezi

关于算法:游戏场景剔除之剔除算法综述

这是一篇对于剔除算法的综述,来总结罕用剔除算法的实现原理和过程。 在游戏运行中,引擎渲染出数以万计的物体,场景复杂度往往是数千万面的级别,同时还须要解决千计盏灯光和数百种材质。因而,如何无效地缩小不必要的绘制就显得分外重要。本文就游戏引擎中用到的各种剔除技术进行概述,会较少波及细节,感兴趣的同学能够去看文末的参考文献,文献中会有相干剔除算法的原理和具体实现。 咱们将分为以下四个方面来介绍: 场景剔除工作原理罕用剔除算法总结参考文献 一、场景剔除工作原理对于场景物体的剔除个别分为可见性剔除和遮挡剔除: 1. 可见性剔除可见性剔除通过判断物体与相机的间隔(间隔剔除)或者是否在相机的视锥体内(视锥体剔除)来对物体进行剔除。 如图所示,不在相机视锥体外部的物体将被剔除不进行渲染。 2. 遮挡剔除遮挡剔除则是在相机可见范畴内通过判断物体是否被其余物体遮挡来对物体进行剔除。遮挡剔除有基于整个物体是否被遮挡的剔除(如Hiz、硬件遮挡查问等),也有基于像素级别的遮挡查问(如Early Z)。 图中蓝色虚线的物体被相机后方的物体遮挡,并将剔除不进行渲染。 二、罕用剔除算法本文将大抵介绍以下剔除算法的原理和实现过程: 间隔剔除视锥体剔除Occluder剔除(软件剔除)视口剔除反面剔除遮挡查问(Occlusion Query)Early Z CullingHiz CullingPVS1. 间隔剔除剔除阶段:应用程序阶段。 通过物体和相机的间隔进行判断物体是否被剔除,原理比较简单,剔除效率也绝对较高。在UE4中能够通过物体属性设置剔除的最大间隔和最小间隔(如下图): 2. 视锥体剔除剔除阶段:应用程序阶段。 即简略判断一个物体是否位于视锥棱台内。裁剪的根据次要是依据摄像机的视线(field of view)以及近裁减面和远裁剪面的间隔,将可视范畴外的物体排除出渲染。 上图中1为近裁剪屏幕,2为裁剪截面体,3为远裁剪立体。 在实践中,因为模型往往是比较复杂的,很难准确计算它和视锥体的交加,因而个别是用轴对齐突围盒(AABB),有向突围盒(OBB)或者突围球(BSphere)代替模型自身进行相交计算。 视锥体剔除是缩小渲染耗费的最无效伎俩之一,能够在不影响渲染成果的状况下大幅缩小渲染波及到的顶点数和面数。 3. Occluder剔除(软件剔除)剔除阶段:应用程序阶段。 这个计划的思路是,首先利用CPU结构一个低分辨率的Z-Buffer,在Z-Buffer上绘制一些场景中较大的遮挡体: 在结构好的Z-Buffer上,绘制小物体的突围盒,而后执行相似于Occlusion Query的操作,查问以后物体是否被遮挡: 因为是纯CPU的,集成起来也比较简单,同时不会有GPU Stall的问题。毛病是须要美术指定一些大的遮挡体,对CPU性能有肯定的耗费。在UE4中通过物体Actor的LOD For Occluder设置遮挡体。 4. 视口剔除剔除阶段:投影变换之后屏幕映射之前。 产生在几何阶段(Geometry Stage)前期,投影变换之后屏幕映射之前,是渲染管线的必要一环。只有当图元齐全或局部存在于标准立方体外部的时候,才将其返送到光栅化阶段。其中,对于齐全位于标准立方体外部的图元,则间接进行下一阶段;齐全处于标准立方内部的图元则齐全被舍弃;局部处于标准立方体外部图元,则会依据视口进行对应的裁剪,在这一过程中可能会产生新的顶点。通过视口剔除能够将视口外的图元舍弃掉,减小光栅化阶段的耗费。 5. 反面剔除剔除阶段:在光栅化阶段进行。 当咱们察看场景中对象时,个别只能以肯定角度来察看,那么对象的某些面咱们是看不到的,例如你察看一个立方体,最多只能同时看到3个面,有时只能看到1个面,而咱们绘制时如果不采取剔除反面的措施,则要绘制6个面,其中包含一些咱们基本看不到的面。对于立方体这个面较少的几何对象,性能开销不显著,然而对于简单的模型,开启反面剔除则能明显改善渲染性能。反面剔除,就是早点抛弃对观察者来说是反面的片元的一种办法。 剔除的基本原理是先断定多边形的朝向,并和以后的察看方向进行比拟。OpenGL中设置反面剔除相干函数:glFrontFace(GL_CW);设置顺时针或者逆时针为侧面glCullFace(GL_BACK);设置剔除侧面或者反面 反面剔除在光栅化阶段进行,执行在Vertex Shader之后,在Fragment Shader片元着色器之前。 6. 遮挡查问(Occlusion Query)剔除阶段:在深度测试时失去待剔除物体,在应用程序阶段执行。 参考步骤和代码:https://www.cnblogs.com/mazhe... 简略来说,Occlusion Query容许你在绘制命令执行之前,向GPU插入一条查问,并且在绘制完结之后的某个时刻,从GPU将查问后果回读到零碎内存里。这条查问命令失去的是某次DrawCall中通过Depth Test的Sample数量,当这个Sample的数量大于0时,就示意以后模型是局部可见的,否则以后模型齐全被遮挡。 OpenGL中实现API接口: //生成查问物体IDglGenQueries(GLsizei n, GLuint *ids);//开始遮挡查问glBeginQuery(GL_SAMPLES_PASSED, 1);//完结遮挡查问glEndQuery(GL_SAMPLES_PASSED);//依据Sample值param是否大于0判断查询号为id的物体是否被遮挡glGetQueryObjectiv(GLenum id, GLenum pname, GLint *param);对于简单的场景,一个不言而喻的优化策略就是用突围盒代替模型自身去做渲染,为了更加准确,咱们也能够用多个紧贴的突围盒或者绝对原模型更简略的Proxy Mesh去做Occlusion Query。基于这些API,咱们就能够失去一个比较简单的遮挡剔除策略: 首先为这些物体生成查问对象ID,并调用glGenQueries;调用glBeginQuery开始遮挡查问;渲染突围体;调用glEndQuery完结遮挡查问;调用glGetQueryObjectiv,依据ID提取遮挡查问的后果,并依据后果绘制相应的物体;glDeleteQueries删除ID,回收资源。Occlusion Query的另一个毛病(也是最致命的毛病)是,它须要将查问后果回读到零碎内存里,这就意味着VRAM->System RAM的操作,走的是比较慢的PCI-E。 ...

October 31, 2022 · 1 min · jiezi

关于算法:推广TrustAI可信分析通过提升数据质量来增强在ERNIE模型下性能

小样本学习在文心ERNIE3.0多分类工作利用(提醒学习)我的项目链接:https://aistudio.baidu.com/aistudio/projectdetail/4438610?contributionType=1 0.小样本学习简介二分类/多分类工作在商品分类、网页分类、新闻分类、医疗文本分类等事实场景中有着广泛应用。现有的支流解决方案是在大规模预训练语言模型进行微调,因为上游工作和预训练任务训练指标不同,想要获得较好的分类成果往往须要大量标注数据,因而学界和业界开始钻研如何在小样本学习(Few-shot Learning)场景下获得更好的学习效果。 提醒学习(Prompt Learning) 的次要思维是通过工作转换使得上游工作和预训练任务尽可能类似,充分利用预训练语言模型学习到的特色,从而升高样本需求量。除此之外,咱们往往还须要在原有的输出文本上拼接一段“提醒”,来疏导预训练模型输入冀望的后果。 咱们以Ernie为例,回顾一下这类预训练语言模型的训练任务。 与考试中的完形填空类似,给定一句文本,遮蔽掉其中的局部字词,要求语言模型预测出这些遮蔽地位本来的字词。 因而,咱们也将多分类工作转换为与完形填空类似的模式。例如影评情感分类工作,标签分为1-正向,0-负向两类。 在经典的微调形式中,须要学习的参数是以[CLS]向量为输出,以负向/正向为输入的随机初始化的分类器。在提醒学习中,咱们通过结构提醒,将原有的分类工作转化为完形填空。如下图所示,通过提醒我[MASK]喜爱。,原有1-正向,0-负向的标签被转化为了预测空格是很还是不。此时的分类器也不再是随机初始化,而是利用了这两个字的预训练向量来初始化,充分利用了预训练模型学习到的参数。 对于标注样本短缺的场景能够间接应用预训练模型微调实现文本多分类,对于尚无标注或者标注样本较少的工作场景咱们举荐应用小样本学习,以获得比微调办法更好的成果。 下边通过新闻分类的例子展现如何应用小样本学习来进行文本分类。 0.1 环境要求python >= 3.6 paddlepaddle >= 2.3 paddlenlp >= 2.4.0 【预计9月份上线】 0.1.1提前尝鲜获取最新版本!pip install git+ pip 从 git 源码仓库间接 install 。要求是这个github仓库内要有setup.py文件 查看url: 装置git仓库中的包 pip install git+<git仓库地址>pip install git+<git仓库地址>@<分支名称>用到它的场景就是比方你有一个代码曾经上传到github了,要分发给他人用,你就懒得再下载下来再导出成tar.gz或者whl文件,是能够间接让他从github网址装置 pip install git+http://127.0.0.1/xxx/demo.git --userpip install git+https://github.com/shadowsocks/[email protected]等价于: # 两步走的装置(装置完还须要本人删除git文件)git clone http://127.0.0.1/XXX/demo.git#change dircd demo# installpython setup.py install --user# windows环境下加--user 不然容易报错#间接pip git 无奈装置胜利,那就采纳第二种计划# !pip install git+https://github.com/PaddlePaddle/[email protected]先把paddlenlp develop分支下下载到本地,进行压缩上传到aistudio。 $ git clone https://github.com/PaddlePaddle/PaddleNLP.gitCloning into 'PaddleNLP'...remote: Enumerating objects: 27619, done.remote: Counting objects: 100% (125/125), done.remote: Compressing objects: 100% (106/106), done.remote: Total 27619 (delta 46), reused 78 (delta 18), pack-reused 27494Receiving objects: 100% (27619/27619), 73.69 MiB | 3.03 MiB/s, done.Resolving deltas: 100% (18182/18182), done.Updating files: 100% (3115/3115), done.取得的paddlenl文件夹在C:\Users\admin门路下,而后进行压缩上传到aistudiowin10压缩参考上面链接:(或者间接用压缩软件压缩)https://blog.csdn.net/sinat_3... ...

October 31, 2022 · 5 min · jiezi

关于算法:INFO2222安全研究

INFO2222 Project1 Security Part DescriptionDesign and implement a secure end to end messaging tool.Basic exemplary flow: In a page, user A logs in, typing username, pwdIf successfully log in, showing friend list, could contain just one; if log in fail, show failure reason.After both A,B log in (in two pages, assuming they are “friends” in the chat), A sends a message(the personalized testing message will be notified before the deadline) to B securely, showing at B’sside.Template. We have provided a website template so that you can run a server and show correspondingsites with the prepared the html pages. While the control functions are located at the correspondingPython files. You can just modify and add function in corresponding Python files. You may want extrapackage to use advanced libraries.Examine criteria:Properly store passwords on the server —– 15 pointsWhen log in, first check server’s certificate (e.g., you can manually create one using a hardcodedCA public key in your code) — 15 pointsSecurely transmitting a pwd to server (leveraging secure protocols or design the secure transmissionproperly) — 10 pointsProperly check whether password is correct (at least use the simple method that defends againstoffline pre-computation attacks) —– 10 pointsSecurely transmitting the message from A to B, even the server who can forward communicationtranscript cannot read the message, or modify the ciphertext (leveraging secure protocols or designthe authenticated secure transmission properly) — 40 pointsClarify of the report. — 10 pointsThere are also 20 points bonus if done well or extra functionalities are added, and for adjustment onsingle-member team.Reporting requirement.explain in one or two sentence how you address each of above itemsshow screenshot as evidence, if you can demonstrate intermediate executions in extra page, wouldbe even better.1clear identify how group members divide the tasks.no explicit word requirementSubmission deadlines. The milestone report about the security part (and corresponding code) willbe due on Saturday mid-night of W8.Remark 1 The template and code were just an example, if you prefer to do it in other framework, orusing other language, it is OK. Just to make sure you can demonstrate that you properly implement thesecurity features listed above.Usability Part DescriptionExpand the basic web based E2EE (secure messaging) to be a website of support system for undergraduateSchool of Computer Science University of Sydney students to share experiences and seek the necessaryhelp (if needed) for their academic studies. It should also have a knowledge repository where students canshare reading or learning materials that they found useful to understand challenging computing concepts.You already have an account and messaging service that allows pair-wise communication amongstudents themselves and to specific academic/administrative staff.Besides the Login, Register, Messaging (view, send), Regular User role, your website should also havefunctionalities like following (to be assessed in last activity)• Data/Info hierarchy – how you organize user generated contents• Admin Role - delete/mute user, delete a course guide• One specific user function – depending on your user investigation.In this part of the project, you are required to design the website with usability and accessibility inmind. A series of recommended activities will be provided in this document as a guide for your team’saction plan and discussion. It is advisable that you pace yourself and utilize the practical session to collectfeedback on your project from your tutors and peers through the mini-presentation session. Starting fromWeek 8, you can use the lab to do mini-presentation to collect feedback from both tutors and peers onpieces of work that have been produced. It is not necessary for presentation slides to be used.Hint: Think about the type of feedback that you would like to get and select the results and workto be presented. you will need to prepare a prototype of the website to conduct a usability test of yourwebsite to the tutor and peers in labs. During this presentation session, you will need to demonstratea typical scenario in which your website will be used by your intended user(s) together with the corerequirements.Submission deadline. The final report about the usability part (and corresponding code) will bedue on Weds mid-night of W11.2.1 Recommended ActivitiesStep1: User Investigation. During this phase, you are to investigate your chosen group to determinewhat they need from your website. To make things easier, your group can concern yourself with a singlevery specific type of user:• Students – this can range from any students starting just starting their program of studies to finalyear students. It can also include students transferring into a computing program from other USydschools.• Alumni – graduates who are willing to give back to their alma mater and to guide their juniors2• SCS/administrative staff – this can include program managers, academic advisors and administrativestaff responsible for the running of program operations that affects students’ academicperformance.Perform a PACT analysis for your chosen group. You will likely still find that your selected group istoo large and complex but your analysis should help you identify what you know about your target groupand what you need to find out during your investigation to narrow your group down to a single persona.Step 1: Expected output: — 20 points.• Outline of the user investigation process (surveys/interviews, how many?) that your group has usedto narrow down your target user.• Research materials used to collect data about your target group• A persona document outlining your target persona• Based on your findings above, gather content (collection of documents) relevant to the interest ofyour target persona. This should be in document form before you convert it to your website andmust keep it updated with any changes. Ensure you cite all sources and quote where you havecopied text verbatim.Step 2: Navigation design. There will hopefully be a lot of information from Step 1 in manypotential categories. As well as this, your website will need to include the following ‘user’ actions statedin the core requirements in addition to actions specified specially for your own target user group. Conducta card sorting session with some of your target user group and use your results to create the navigationmap (site map) of your website.Step 2: expected output. — 20 points.• Outline of card sorting session along with all materials that was used.• Information architecture of your websiteStep 3: Design-Evaluate (Prototype (paper or digital) ). Based on the information architecturethat you have from the previous phase, brainstorm and create sketches of your website. Create aprototype of the best design and perform guerrilla test with target users using this prototype. Each ofyour team member should take part in the guerrilla test, at least one participant is outside of your team.Step3: expected output. — 20 points.• A prioritized list of additional features?• Outline steps taken to determine the ‘best’ design to be prototyped• Paper or digital prototype,• Mini-report that outline of how guerrilla test is conducted, actual raw results, materials used andfindings of the test.Step 4: Design-Evaluate (Hi-Fi Prototype). Focus on converting your (improved) prototype(paper or digital) to the real web server. Do this incrementally and perform evaluations (e.g., think aloudtest) to ensure that you are on the right track.Step 4: expected output: — 20 points.• Incremental development plan (two iterations at least)• Outline of evaluations conducted3• Demonstrations of the functionalities mentioned at the beginning, admin roles, the user specificfunction etc.Remark 2 Your output in Step4 does not need to be perfect, we care more and the markings will focuson your improvements over each iteration.Step5:Final report. — 20 points.• It is a collection of all the previous outputs in a neat format. The template is given.Bonus step.— 20 points. You can re-use and extend many of your existing implementations on thesecurity project to have public and private mode of posts. The default mode of posts could be public.The private mode will be visible to only specific role or user (i.e., you have to use encryption properly).

October 30, 2022 · 6 min · jiezi

关于算法:ECS647U-人工智能算法

ECS647U / ECS773PBayesian Decision and Risk (BDRA)Semester B, 2022 Coursework 2 –Bayes Theorem and Bayesian Learning Deadline: Thursday 14th April 2022 This coursework is based on a fictitious virus called SARS-Cov-4 which causes adisease called Covid-24. Question 1 Despite assumptions to the contrary, it is possible to test positive using a PCRtest, and be diagnosed as having Covid-24, even if someone has not beeninfected with SARS-Cov-4 and has no symptoms of the disease. Thegovernment’s policy recommendation is that people testing positive should selfisolate for 10 days. A number of factors might influence the reliability of thePCR test such as cross reactivity with other viruses, lab mix-ups and faulty/non-sterile testing equipment. ...

October 30, 2022 · 3 min · jiezi

关于算法:人体检测人体追踪的人流统计AI项目在android端部署落地的实战

1 训练营课程 (1)本节课次要学习智慧安防实战训练营的课程: 训练课程次要包含: a. 第⼀节课,即本节课,次要解说AI⾏业智慧城市⾏业的⽬前情况,并从边缘设 备、越界辨认应⽤等为案例,进⾏解说。 b. 第⼆节课,次要从边缘设施的⽅式,Aidlux进⾏解说,理解 在边缘端的各⽅⾯内容。 c. 第三节课,次要从⽬标检测算法的训练,Aidlux上的移植、 测试等⽅⾯进⾏解说。 d. 第四节课,学习了⽬标检测后,会将⽬标检测和⽬标追踪结 合,尝试残缺的⼈体检测追踪,为后⾯的各类业务性能做筹备。 e. 第五节课,会将越界辨认的业务性能也增加进来,当有⼈越 界的时候,会通过喵揭示的⽅式,告诉开发者及时查看⼿机⾥⾯的越界图⽚。 2)学习目标 本次课程是由江大白老师全程教学,第一次接触江大白老师是在知乎上看到他的一篇高赞文章《ref="https://zhuanlan.zhihu.com/p/397993315">深入浅出Yolo系列之Yolox外围根底残缺解说》,关注后发现,大白老师的文章都是对老手十分敌对的,深入浅出,讲的十分粗疏,看了之后获益匪浅。起初长期关注并进了探讨群,有趣味的敌人也能够关注,兴许会有所播种。 两周前,大白老师分享训练营打算,我思考了一下,便抉择加入,因为我从事AI行业以来,始终做的是CPU部署。想通过这个机会,学习一下android端的部署流程。因为通过这一年多的学习,我对本人的定位就是做AI落地方面的工作,至于钻研新的trick,对非科班的我来说是难度较大的。并且该课程与我当初做的一些我的项目也很相似,可能借此机会学习一下大佬的代码也是很不错的。 通过两周的学习,咱们根本曾经把握了从PC端到android端的开发与部署测试流程。所以江大白老师给咱们留了一个大作业。 2 作业题目 (1)题目: 在学习了越界辨认的性能后,采纳人体检测+人体追踪+业务性能的形式实现 人流统计。 (2)实现成果: 上传视频,有Vscode代码页面露出,有AidLux界面露出。 比方Vscode界面+Aidlux端的PC端显示的视频。视频链接: https://b23.tv/hg2bp6m3)代码实现: 相干流程和代码以及原理能够找大白老师分享,代码文件次要包含推理代码yolov5_overstep.py,工具函数utils.py,跟踪算法track文件夹,以及模型文件yolov5n_best-fp16.tflite和测试视频video.mp4.其中推理代码yolov5_overstep.py次要代码如下: 先加载一些必要的包1.用Aidlux的api加载模型:2.初始化一些参数:3.读取视频对视频帧预处理并进行人体检测:4.对检测到的人体框利用track中的跟踪模型算出每个人体框的id5.确定检测线以及每个id在以后帧绝对检测线的地位,并记录在track_id_status字典中:这里字典每个名称对应每个id,内容是以后帧中所有id号绝对检测线的地位,包含历史地位:6.判断id行走方向,统计向上人流数,以及向下人流数:7.在待输入的frame上显示人流统计:8.视频完结后,利用喵揭示公众号下发人流统计信息:能够看到最终喵揭示性能把测试视频中高低两个方向以及总人流数下发到了微信中。 3 学习心得 当然这只是其中一部分代码,整个过程中还有其余代码,都很值得学习,以及调试部署测试过程都还有一些内容,感兴趣的能够问大白老师支付材料。整个学习过程没有什么压力,因为真的是手把手教学,不得不拜服大佬们的思路。 4 AidLux应用心得 最初我想发表一下我对Aidlux的认识,我是在本人手机上高通骁龙778上测试的,我发现Aidlux后盾调试代码超过半小时后手机会很烫,待机没事。然而整个测试的过程中跳帧不多,速度还是能够的,能够和一些CPU差不多了。后续心愿Aidlux官网能出一些前后端的教程,因为一个我的项目并不只是咱们算法工程师实现的,还须要团队的单干。总体而言,我感觉这个终端设备操作简便,便携,成果好,可塑性高,值得摸索一番。期待后续我能有我的项目应用到该产品。

October 29, 2022 · 1 min · jiezi

关于算法:BINF90001-机器学习

BINF90001 – Semester 1, 2022 – Assignment 1Due date: 17:00, Thursday 14 April 2022Instructions This assignment contains 5 questions worth a total of 50 points. It will contribute 20% to yourassessment for this subject. Submit your assignment as a PDF file via the LMS. Please refer to the submission instructionson the LMS for more information. Late assignments will only be accepted under exceptional circumstances. Usually a medicalcertificate will be required. A late penalty may be imposed. Your submission should clearly show your name and student ID number. Provide tables, graphs, R code and concise text explanations to support your answers. Graphsmust be clear and well-labelled, including informative axis labels and titles. All tables, graphsand code must be accompanied by explanation and interpretation. Satisfactory presentationforms part of the marking criteria: points will be deducted for excessive and/or poorly organisedwork. Present all material related to each answer (such as R code and plots) together: do not pro-vide any appendix or supplementary information at the end. Use of R Markdown is highlyrecommended. Do not discuss solutions to these problems on the online discussion forum. However, you canuse the forum to seek clarifications of the questions.DataIn this assignment you will analyse some SNP genotype and phenotype data. The data files areavailable from the Assignments page on the LMS. There are data from three studies:Study 1. 500 individuals each genotyped at 200 SNPs (genotypes1.csv) and their body mass index(BMI) recorded in kg/m2 (phenotype1.csv).Study 2. 1,500 individuals (not including any of the 500 above) each genotyped at the same 200 SNPs(genotypes2.csv) and their overweight status recorded as either true or false (phenotype2.csv).For this study, a person is defined as being overweight if their BMI is greater than 25 kg/m2.Study 3. 100 individuals each genotyped at the same 200 SNPs (genotypes3.csv) and no phenotypesrecorded.Questions ...

October 29, 2022 · 5 min · jiezi

关于算法:CSE-505-两阶段提交

Lab 4 Part 3CSE 505Lab 4 Part 3: Two-phase commit● Keys partitioned over different hosts; one coordinator per transaction● Acquire locks on all data read/written; release after commit● To commit, coordinator first sends prepare messages to all involvedshard-holders; they respond prepare_ok or abort, acquiring locks.○ if prepare_ok, they must be able to commit transaction○ Paxos is used to replicate the prepare log entry (including locks) as well as commit andabort messages● If all prepare_ok, coordinator sends commit to all; they write commitrecord and release locksLab 4 Part 3: HintsAll ShardStoreServer nodes tag their transaction-handling messages with theirconfiguration number.Servers reject any prepare requests coming from different configurations,causing the transaction to abort.Servers delay reconfigurations when there are outstanding locks for keys (i.e.,there are transactions pending in the previous configuration).Distributed Systems in a nutshellGoal of Lab 4 Part 3● Support transactions across multiple keys potentially located acrossdifferent replica groups○ Transactions can be:■ Series of reads■ Series of writes■ Swaps - new one :)● Use Two-Phase Commit to acquire locks during transaction.● Why can’t we just use Paxos? Because each group is responsible for adifferent set of shards and we want to support transactions acrossshards/replica groups.Two-Phase Commit ...

October 29, 2022 · 6 min · jiezi

关于算法:COMS3200网络解析

The University of QueenslandSchool of Information Technology and Electrical EngineeringSemester One, 2022COMS3200 Computer Networks IAssignment 1Due: 3:00pm 27th April, 2022Marks: 100Weight: 25% of your final grade.Revision: 1.0IntroductionThis assignment introduces the Network Edge & Core, the top three Networking layers (from OSImodels) such as Application Layer, Transport Layer, and a small part of Network Layer. Afterfinishing the assignment, you should be able to distinguish between Packet and Circuit Switching,understand End-to-End Delay, be able to interpret and analyse network packets and do networkprogramming.This assignment contains three (3) parts: Part A, Part B and Part C. For Part A and B, you will need tosubmit you answers through the Blackboard Quiz. For Part C, you will submit your code viaCOMS3200 subversion (SVN). All submitted work will be marked automatically. And it's stronglyrecommended that you have read this specification very carefully.Note that this assignment is individual work. Using answers (or code) that you did not calculate(or write) is against course rules and may lead to a misconduct charge.2Part A (34 marks)Answer each of the following questions in the associated quiz on Blackboard, following the specifiedinstructions. All answers will be automatically marked.Figure 1. A simple network configuration map.Figure 1 shows a simple network map that includes two edges: a Local Network (represented as thegrey area) and a Global Network (white area).In the Local Network, there are the three circuit switches (SC1, SC2 and SC3). They are interconnectedby two links (LC1 and LC2). Each of these circuit links has three slots. Each host is directly connectedto one of the switches. In this part, you only consider the communication scenarios between Host Aand Host B. The network reserves one slot on each of the two links. In Figure 1, the dedicated end-toendconnection uses the second slot in both links LC1 and LC2 (see the red coloured line). We assume 3that device C (which is located between is LC3 and L1) is the combination of modem and router in theLocal Network and connected to SC3 through LC3.In the Global Network, packet-switching technique is used in the entire network. We have a scenariowhere a client requests a web page from a remote server on a remote island via a slow satellite linkabove the earth in a geostationary orbit. There is one client C, one server S, and four DNS servers. D1is a Local DNS Server, D2 is a Root DNS Server, D3 is a Top-level Domain DNS Server, and D4 isan Authoritative DNS Server. We don’t need to know where the Link L7 is connected in thisassignment.Scenario 1 – Local Network (6 marks)Host A sends a file of 2,790,000 bits to Host B at the time t0 = 0 mili-second (msec). Link LC1 andlink LC2 use time-division multiplexing, all of them have one frame, and it is one second that is dividedby three slots. The total bit rate is 9 Mbps (from SC1 to SC3). It needs 500 msecs to establish an endto-endcircuit before Host A begins to transmit the file. And the second slot of the circuits in LC1 andLC2 is allocated for the transmission between Host A and Host B. At the time t0 + 500 msecs, the firstslot of the circuits in LC1 and LC2 starts to transmit. At the time t1, Host B has received all bits of thefile from Host A. After 400 msecs from t1, Host B sends a file of 990,000 bits to Host A. Host A hasreceived all bits of the file from Host B at time t2.There are some assumptions for the Local Network:• There are no propagation delays in this networking.• There are no transmission delays between Host A and SC1, as well as Host B and SC3.• The network starts without data transmission.• The slot of the circuits is allocated for the transmission can be used in both directions.• All switches have no processing delays (this is unrealistic though, we assume to simplifycalculations).Answer the questions below in mili-seconds (msecs) rounded to three decimal places.Question 1: What is the value of t1? (3 marks)Question 2: What is the value of t2? (3 marks)Scenario 2 – Global Network (21 marks)A program on one of the hosts in the Local Network starts the process of retrieving a webpage fromthe Server S. The following events happen sequentially: ...

October 29, 2022 · 20 min · jiezi

关于算法:CS6114视频算法

CS6114 AssignmentAssignment 03Video CodingV ideo coding is the process of preparing digital video content for storage or transmission, such as in a data file or bitstream. The libx265 H.265 codec (MPEG-4 High Efficiency Video Coding) was designed to achievefrom 25% to 50% better data compression at the same level of video quality,or substantially improved video quality at the same bit rate than the previouslibx264 H.264 (MPEG-4 Advanced Video Coding) standard for a variety ofdifferent applications. In turn H.264 was designed to achieve good videoquality at substantially lower bit rates than previous MPEG standards. ...

October 29, 2022 · 7 min · jiezi

关于算法:Sanitizers-系列之-address-sanitizer-用法篇

入门例子二分查找算法是十分经典的算法,它看似简略,然而写出一个完全正确的二分查找算法还是比拟考验工程师的算法功力的,上面是在网上流传的一个版本,请读者思考:这个程序正确吗? #include <iostream>#include <vector>size_t binary_search(std::vector<int> &nums, int target){ size_t left = 0, right = nums.size(); while (left < right) { size_t mid = left + (right - left - 1) / 2; if (nums[mid] == target) { return mid; } else if (nums[mid] < target) { left = mid + 1; } else { right = mid; } } return nums[left] == target ? left : -1;}int main(){ std::vector<int> a = {2}; int target = 3; std::cout << binary_search(a, target) << std::endl;}运行上述程序后输入 -1,显然是合乎预期的,那这是否就阐明这个程序是完全正确呢? ...

October 28, 2022 · 5 min · jiezi

关于算法:KeenTune的算法之心KeenOpt-调优算法框架-龙蜥技术

文/KeenTune SIG KeenTune(轻豚)是一款 AI 算法与专家知识库双轮驱动的操作系统全栈式智能优化产品,为支流的操作系统提供轻量化、跨平台的一键式性能调优,让利用在智能定制的运行环境施展最优性能。自 2021年 9 月正式成立 SIG 并发表开源以来,受到了宽广开发者的关注。KeenTune 的整体开源框架聚焦于通用和灵便的设计准则,其中对于调优场景的扩大,通过分布式架构以及标准化的场景配置模式,能够不便的实现对于 Linux 内核参数,利用配置参数,编译器优化参数,benchmark 配置参数等调优对象和配套工具的疾速适配。 明天, KeenTune 再次带来开源重磅个性——新增通用的调优算法框架:keenopt。有了 keenopt 的加持,KeenTune 不再仅仅是反对灵便扩大调优场景的调优工具,还成长为了具备灵便扩大调优算法的调优平台,不仅能够作为性能调优工程师的法宝,也能够成为算法工程师的利器。Keenopt 调优算法框架的开源设计,同样旨在方便快捷的扩大学术界和工业界新提出的调优算法,以及结合实际须要定制化的调优算法。 聪慧的童鞋肯定会天然问出一个问题:为什么不能只调用以后风行的调优算法库,而要打造一个算法框架呢?这就要从咱们调优过程中趟过的一个一个坑说起了... 坑洼调优路一提起调优,首先进入读者脑海的就是近年来愈发风行的针对机器学习模型,尤其是神经网络超参数的调优算法。这些调优算法从贝叶斯优化和遗传算法登程,凝聚了丰富多彩的调优思路,曾经成为晋升机器学习算法研发效率的利器。那么这些大多围绕着机器学习模型超参数优化的算法,是不是能够间接利用于比方系统软件配置和参数调优上来呢?答案是经典的 yes and no。 首先,经典的贝叶斯优化算法(基于高斯代理模型)及其衍生算法(如 TPE),当然是能够间接利用于零碎参数调优的。但概括来说,这类算法整体的调优效率却常常无奈满足无论是机器学习模型超参数调优还是零碎参数调优。相应的,近年来的学术翻新次要围绕着进一步晋升调优的整体效率开展。也就是在这个层面上,机器学习模型超参数的调优和零碎参数调优,走上了不同的路线。 (图1/条条调优路) 对于机器学习模型超参数调优来说,调优的工夫开销次要来自两个方面: (1)调优算法搜寻策略所须要的运算耗时。 (2)机器学习模型训练的耗时。 对于近年来逐步广为人知的基于高保真原理的优化算法,如 Successive Halving[1],HyperBand[2] 等,次要聚焦于缩小第二个方面的工夫开销,毕竟和训练动辄千万上亿级参数的模型,调优算法搜寻策略的开销几乎不值一提。侥幸的事,机器学习模型训练的耗时的确是灵便可调整的。 然而,对于零碎参数调优来说,尽管调优的工夫开销也次要来自两个方面: (1)调优算法搜寻策略所须要的运算耗时。 (2)评估调优举荐参数配置的耗时。 然而其中(2)的耗时因为往往来自调用规范 benchmark 工具取得,是固定不可调整的。具体例子能够构想一下运行 Fio、SPEC CPU 2017 这类 benchmark 工具的过程。因而,针对零碎参数调优的算法畛域,无奈通过优化(2)的开销曲线救国,只能老老实实的晋升调优算法的搜寻策略。到此,咱们来到了第二个坑。 (图2/从满天星到一团火) 参数调优堪称是“维度劫难”的一个重灾区。基于贝叶斯优化框架的调优算法,实质上是在一个乌黑的空间中摸索,而随着维度的减少,这个乌黑的环境的 volume 急剧增大,摸索的工夫老本的减少是不可避免的。对于机器学习模型超参数的调优来说,这个维度往往在十几到二十几这个量级,维度的铁拳依然比拟温顺。而对于零碎参数调优来说,这个维度往往在几十到上百甚至过千的量级。在这个量级维度的铁拳下,经典的贝叶斯调优算法及其衍生算法,往往就会被锤成齑粉。以基于高斯代理模型的贝叶斯优化算法来说,咱们能够比拟毛糙的概括这种算法为“散点”法,这并不是说这类算法就是乱枪打鸟,毕竟有弱小的贝叶斯原理作为引领,搜寻的策略和门路还是有迹可循的。 然而,当维度足够高的时候,曾经有相干钻研证实,贝叶斯优化算法和随机搜索算法基本上是一对卧龙凤雏的存在[3]。因而,近年来 AI 畛域顶会的学术成绩,曾经开始关注高维空间中的贝叶斯优化问题,由这种“散点”法,逐步过渡到“局域”法[4,5]。这里“局域”又是咱们的一个比拟概括的说法,次要原理是在高维空间中,搜寻次要被限度在于较小的部分区域进行,而各个部分区域自身的取舍仍然遵从贝叶斯原理。这类“局域”法无效的限度了搜寻区域的 volume,因而往往有更高效的收敛和更好的调优成果。尤其是更好的收敛成果这种个性,对于零碎参数的调优实际来说,堪称肯定水平上加重了当务之急,因为理论的零碎参数调优实际,往往要思考系统资源开销和整体工夫限度,从而须要在尽可能少的调优轮次中给出最优或略低于最优的调优后果。当咱们欣慰的筹备汲取这些算法进入 KeenTune 去磨刀霍霍的时候,咱们来到了第三个坑。 如前所述,以后支流的调优算法库或工具,往往围绕着机器学习模型超参数调优的场景进行扩大。因而如 Scikit-Optimize (skopt)[6] 和 NNI[7] 这类算法库,更多的聚焦于反对 Successive Halving 和 HyperBand 这些针对模型训练开销优化的算法,而对于解决高维贝叶斯优化问题的算法不够及时。此外,即便想在这些算法库中定制化实现这些算法,也仍然须要具体的研读这些库中算法的实现,照猫画虎的在简单的代码逻辑中后退,这种痛苦只能说懂得都懂。因而,当咱们拔剑四顾的时候,刀鞘却妨碍了咱们披巾斩棘的身影。至此,读者曾经和咱们来到了同样的地步,也看到那临门一脚的必选项 -- 打造更灵便通用的调优算法框架。 ...

October 28, 2022 · 2 min · jiezi

关于算法:openKylin分级冻结机制让系统体验更顺滑

在传统Linux操作系统中,利用过程的生命周期次要由利用自身间接管制。然而,系统资源(包含CPU、I/O、存储等)是无限的,当咱们运行大量的I/O密集型或CPU密集型利用时,常常会呈现零碎卡顿甚至“假死机”的景象,这大大影响了用户的操作体验。为此,咱们在openKylin操作系统中设计了“分级解冻”机制,管控利用生命周期。什么是“分级解冻”机制?“分级解冻”机制是指,在操作系统中,针对处于不同状态的利用进行“分级”解决,以某种非凡形式“解冻”用户未操作利用,从而开释系统资源(如CPU、磁盘I/O、内存等),优先保障用户以后操作利用的资源分配,晋升用户体验。“分级解冻”机制等级划分在openKylin操作系统中,咱们将利用分为以下级别:1.焦点利用示意以后正在操作的利用,个别状况下,不对其做资源限度,充分保证其晦涩度。2.前台利用只存在PC模式下的状态,示意以后运行的未最小化但没有取得焦点的利用。3.后盾利用PC模式下指窗口最小化状态且持续时间≤30min或者前台利用持续时间≥30min的利用;平板模式下指非以后关上且持续时间≤30min的利用过程。4.缓存利用指处于不可见状态且持续时间>30min的利用。5.休眠利用被解冻并且放入swap分区的利用。其中,各级利用的状态时序转换如下图所示基于上述利用分类,openKylin实现了以下个性:1.单实例启动平板模式下利用以单实例的形式启动,并会记录每个利用的启动状态,由零碎接口对立实现,而不须要利用独自适配。2.后盾资源实时调控针对后盾利用,当零碎残余资源达到咱们预约的阈值时,依据零碎策略和用户设置进行相应的资源调控,从而升高零碎的功耗,晋升前台利用的流畅性。3.利用级休眠特定条件下将利用齐全解冻,节俭CPU和内存资源。4.多媒体协定扩大反对针对影音等多媒体利用,实现后盾暂停/播放性能,让用户更灵便地掌控娱乐。openKylin“分级解冻”机制,不仅能进一步晋升零碎性能,给用户提供一个更晦涩的应用环境,也为国产操作系统带来一个新的优化翻新思路。而接下来,openKylin将继续的投入“分级解冻”机制的研发和优化,助力国产操作系统的疾速倒退。openKylin(凋谢麒麟)社区旨在以“共创”为外围,在开源、被迫、平等、合作的根底上,通过开源、凋谢的形式与企业构建合作伙伴生态体系,独特打造桌面操作系统顶级社区,推动Linux开源技术及其软硬件生态凋敝倒退。社区首批理事成员单位包含麒麟软件、普华根底软件、中科方德、麒麟信安、凝思软件、一铭软件、中兴新支点、元心科技、中国电科32所、技德零碎、北京麟卓、先进操作系统翻新核心等13家产业同仁和行业机构。审核:openKylin

October 28, 2022 · 1 min · jiezi

关于算法:快递单中抽取关键信息一基于BiGRUCR预训练的词向量优化

相干文章: 本我的项目连贯:https://aistudio.baidu.com/aistudio/projectdetail/4156802?contributionType=1 快递单中抽取要害信息数据集链接:https://download.csdn.net/dow...次要介绍: PaddleNLP中的网络层BiGRU、CRF、ViterbiDecoder。通过paddlenlp.embedding的性能,热启动加载中文词向量,晋升成果评估指标paddlenlp.metrics.ChunkEvaluator PART A. 背景介绍A.1 快递单信息抽取工作如何从物流信息中抽取想要的要害信息呢?咱们首先要定义好须要抽取哪些字段。 比方当初拿到一个快递单,能够作为咱们的模型输出,例如“张三18625584663广东省深圳市南山区学府路东百度国内大厦”,那么序列标注模型的目标就是辨认出其中的“张三”为人名(用符号 P 示意),“18625584663”为电话名(用符号 T 示意),“广东省深圳市南山区百度国内大厦”别离是 1-4 级的地址(别离用 A1~A4 示意,能够释义为省、市、区、街道)。 这是一个典型的命名实体辨认(Named Entity Recognition,NER)场景,各实体类型及相应符号示意见下表: 抽取实体/字段符号抽取后果姓名P张三电话T18625584663省A1广东省市A2深圳市区A3南山区具体地址A4百度国内大厦A.2 序列标注模型咱们能够用序列标注模型来解决快递单的信息抽取工作,上面具体介绍一下序列标注模型。 在序列标注工作中,个别会定义一个标签汇合,来示意所以可能取到的预测后果。在本案例中,针对须要被抽取的“姓名、电话、省、市、区、具体地址”等实体,标签汇合能够定义为: label = {P-B, P-I, T-B, T-I, A1-B, A1-I, A2-B, A2-I, A3-B, A3-I, A4-B, A4-I, O} 每个标签的定义别离为: 标签定义P-B姓名起始地位P-I姓名两头地位或完结地位T-B电话起始地位T-I电话两头地位或完结地位A1-B省份起始地位A1-I省份两头地位或完结地位A2-B城市起始地位A2-I城市两头地位或完结地位A3-B县区起始地位A3-I县区两头地位或完结地位A4-B具体地址起始地位A4-I具体地址两头地位或完结地位O无关字符留神每个标签的后果只有 B、I、O 三种,这种标签的定义形式叫做 BIO 体系,也有稍麻烦一点的 BIESO 体系,这里不做开展。其中 B 示意一个标签类别的结尾,比方 P-B 指的是姓名的结尾;相应的,I 示意一个标签的连续。 对于句子“张三18625584663广东省深圳市南山区百度国内大厦”,每个汉字及对应标签为: <center><img src="https://ai-studio-static-online.cdn.bcebos.com/1f716a6ad48649cc99c56c27108773bea6b0afa3f36e4efba4851641658b2414" width="500" height="313" ></center><center>图1:数据集标注示例</center> 留神到“张“,”三”在这里示意成了“P-B” 和 “P-I”,“P-B”和“P-I”合并成“P” 这个标签。这样重新组合后能够失去以下信息抽取后果: 张三18625584663广东省深圳市南山区百度国内大厦PTA1A2A3A4PART B. 相干算法简介B.1 门控循环单元GRU(Gate Recurrent Unit)BIGRU是一种经典的循环神经网络(RNN,Recurrent Neural Network),后面一些步骤根本是把该模型当做是黑盒子来用,这里咱们重点解释下其概念和相干原理。一个 RNN 的示意图如下所示, <center><img src="https://ai-studio-static-online.cdn.bcebos.com/a11f62ff794b4e00985f0fc39f2879bd75377481eedd47ebb489c131bc7bc96c" width="500" height="313" ></center><center>图4:RNN示意图 </center> ...

October 28, 2022 · 16 min · jiezi

关于算法:快递单信息抽取二基于ERNIE10至ErnieGram-CRF预训练模型

相干文章: 本我的项目链接:https://aistudio.baidu.com/aistudio/projectdetail/4157455?contributionType=1 1.ERNIE 1.0 实现快递单信息抽取命名实体辨认是NLP中一项十分根底的工作,是信息提取、问答零碎、句法分析、机器翻译等泛滥NLP工作的重要根底工具。命名实体辨认的准确度,决定了上游工作的成果,是NLP中的一个根底问题。在NER工作提供了两种解决方案,一类LSTM/GRU + CRF,通过RNN类的模型来抽取底层文本的信息,而CRF(条件随机场)模型来学习底层Token之间的分割;另外一类是通过预训练模型,例如ERNIE,BERT模型,间接来预测Token的标签信息。 本我的项目将演示如何应用PaddleNLP语义预训练模型ERNIE实现从快递单中抽取姓名、电话、省、市、区、具体地址等内容,造成结构化信息。辅助物流行业从业者进行无效信息的提取,从而升高客户填单的老本。 在2017年之前,工业界和学术界对文本处理依赖于序列模型Recurrent Neural Network (RNN). <p align="center"><img src="http://colah.github.io/posts/2015-09-NN-Types-FP/img/RNN-general.png" width="40%" height="30%"> </p><center>图1:RNN示意图</center> 基于BiGRU+CRF的快递单信息抽取我的项目介绍了如何应用序列模型实现快递单信息抽取工作。 近年来随着深度学习的倒退,模型参数的数量飞速增长。为了训练这些参数,须要更大的数据集来防止过拟合。然而,对于大部分NLP工作来说,构建大规模的标注数据集十分艰难(老本过高),特地是对于句法和语义相干的工作。相比之下,大规模的未标注语料库的构建则绝对容易。为了利用这些数据,咱们能够先从其中学习到一个好的示意,再将这些示意利用到其余工作中。最近的钻研表明,基于大规模未标注语料库的预训练模型(Pretrained Models, PTM) 在NLP工作上获得了很好的体现。 近年来,大量的钻研表明基于大型语料库的预训练模型(Pretrained Models, PTM)能够学习通用的语言示意,有利于上游NLP工作,同时可能防止从零开始训练模型。随着计算能力的一直进步,深度模型的呈现(即 Transformer)和训练技巧的加强使得 PTM 一直倒退,由浅变深。 <p align="center"><img src="https://ai-studio-static-online.cdn.bcebos.com/327f44ff3ed24493adca5ddc4dc24bf61eebe67c84a6492f872406f464fde91e" width="60%" height="50%"> </p><center>图2:预训练模型一览,图片来源于:https://github.com/thunlp/PLM...</center> 本示例展现了以ERNIE(Enhanced Representation through Knowledge Integration)为代表的预训练模型如何Finetune实现序列标注工作。 !pip install --upgrade paddlenlp# 下载并解压数据集from paddle.utils.download import get_path_from_urlURL = "https://paddlenlp.bj.bcebos.com/paddlenlp/datasets/waybill.tar.gz"get_path_from_url(URL, "./")# 查看预测的数据!head -n 5 data/test.txtfrom functools import partialimport paddlefrom paddlenlp.datasets import MapDatasetfrom paddlenlp.data import Stack, Tuple, Padfrom paddlenlp.transformers import ErnieTokenizer, ErnieForTokenClassificationfrom paddlenlp.metrics import ChunkEvaluatorfrom utils import convert_example, evaluate, predict, load_dict1.1加载自定义数据集举荐应用MapDataset()自定义数据集。 ...

October 26, 2022 · 7 min · jiezi

关于算法:基于Ernie30-CAIL2019法研杯要素识别多标签分类任务

本我的项目链接:基于Ernie-3.0 CAIL2019法研杯因素辨认多标签分类工作本我的项目将介绍如何基于PaddleNLP对ERNIE 3.0预训练模型微调实现法律文本多标签分类预测。本我的项目次要包含“什么是多标签文本分类预测”、“ERNIE 3.0模型”、“如何应用ERNIE 3.0中文预训练模型进行法律文本多标签分类预测”等三个局部。 1. 什么是多标签文本分类预测文本多标签分类是自然语言解决(NLP)中常见的文本分类工作,文本多标签分类在各种事实场景中具备宽泛的适用性,例如商品分类、网页标签、新闻标注、蛋白质性能分类、电影分类、语义场景分类等。多标签数据集中样本用来自 n_classes 个可能类别的m个标签类别标记,其中m的取值在0到n_classes之间,这些类别具备不互相排挤的属性。通常,咱们将每个样本的标签用One-hot的模式示意,正类用1示意,负类用0示意。例如,数据集中样本可能标签是A、B和C的多标签分类问题,标签为[1,0,1]代表存在标签 A 和 C 而标签 B 不存在的样本。 近年来,随着司法改革的全面推动,“以公开为准则,不公开为例外”的政策逐渐确立,大量蕴含了案件事实及其实用法律条文信息的裁判文书逐步在互联网上公开,海量的数据使自然语言解决技术的利用成为可能。法律条文的组织呈树形层次结构,事实中的案情盘根错节,同一案件可能实用多项法律条文,波及数罪并罚,须要多标签模型充沛学习标签之间的关联性,对文本进行分类预测。 2. ERNIE 3.0模型ERNIE 3.0首次在百亿级预训练模型中引入大规模常识图谱,提出了海量无监督文本与大规模常识图谱的平行预训练方法(Universal Knowledge-Text Prediction),通过将常识图谱开掘算法失去五千万常识图谱三元组与4TB大规模语料同时输出到预训练模型中进行联结掩码训练,促成了结构化常识和无构造文本之间的信息共享,大幅晋升了模型对于常识的记忆和推理能力。 ERNIE 3.0框架分为两层。第一层是通用语义示意网络,该网络学习数据中的根底和通用的常识。第二层是工作语义示意网络,该网络基于通用语义示意,学习工作相干的常识。在学习过程中,工作语义示意网络只学习对应类别的预训练任务,而通用语义示意网络会学习所有的预训练任务。 <font size=2><center>ERNIE 3.0模型框架</center></font> 3. ERNIE 3.0中文预训练模型进行法律文本多标签分类预测3.1 环境筹备AI Studio平台默认装置了Paddle和PaddleNLP,并定期更新版本。 如需手动更新Paddle,可参考飞桨装置阐明,装置相应环境下最新版飞桨框架。应用如下命令确保装置最新版PaddleNLP: 3.2 加载法律文本多标签数据本数据集(2019年法研杯因素辨认工作)来自于“中国裁判文书网”公开的法律文书,每条训练数据由一份法律文书的案情形容片段形成,其中每个句子都被标记了对应的类别标签,数据集一共蕴含20个标签,标签代表含意如下: DV1 0 婚后有子女DV2 1 限度行为能力子女抚养DV3 2 有夫妻共同财产DV4 3 领取抚养费DV5 4 不动产宰割DV6 5 婚后分居DV7 6 二次起诉离婚DV8 7 按月给付抚养费DV9 8 准予离婚DV10 9 有夫妻独特债权DV11 10 婚前个人财产DV12 11 法定离婚DV13 12 不履行家庭任务DV14 13 存在非婚生子DV15 14 适当帮忙DV16 15 不履行离婚协定DV17 16 损害赔偿DV18 17 感情不和分居满二年DV19 18 子女随非抚养权人生存DV20 19 婚后个人财产数据集示例: ...

October 25, 2022 · 4 min · jiezi

关于算法:JTech-Talk-活动预告|近似最近邻搜索算法-HNSW-的改进与优化

J-Tech Talk 由 Jina AI 社区为大家带来的技术分享 工程师们将深刻细节地解说具体的问题 分享 Jina AI 在开发过程中所积攒的教训 针对海量向量数据的搜寻,无论是工业界还是学术界都做了大量的钻研。因为准确的向量搜寻在海量数据的场景下搜寻工夫过长,所以目前的常见做法,是在向量上建设近似搜寻索引。学术上咱们称之为近似最近邻搜寻 ANN (Approximate Nearest Neighbor Search) 问题,通常都是通过就义搜寻精度来换取工夫和空间的形式,从大量样本中获取最近邻。 依据 Benchmark 上 ANN 算法的基准测试后果,基于图构造的 HNSW 算法在查问速度和精度上优于其余 ANN 算法。然而 HNSW 算法自身的次要问题就是对内存占用较大,限度了其能够索引的数据大小。 目前 Jina AI 的开源向量索引产品 AnnLite 的外围近似搜索算法是基于 HNSW 来实现,并在此基础上提供了更加丰盛的性能(例如反对前置过滤近似查问)。为了使得 AnnLite 可能具备更强的竞争力和理论利用价值,咱们对 HNSW 算法进行了改良和优化。 本期 J-Tech Talk 邀请到了负责本优化我的项目的叶坚白,来分享《近似最近邻搜索算法 HNSW 的改良与优化》。 分享内容 Annlite 的介绍和应用 AnnLite 是一款 Jina AI 开发的多模态向量索引产品,旨在和 DocArray 一起应用。HNSW 算法、 PQ 算法的简介 在 Annlite 中联合 PQ 算法和 HNSW,以升高内存占用和提早为什么要在 Annlite 中引入 HNSW PQ backend在 Jina AI 社区的播种总结 对于讲师叶坚白 Jina AI 开源社区 AnnLite 贡献者 ...

October 25, 2022 · 1 min · jiezi

关于算法:UIESlim满足工业应用场景解决推理部署耗时问题提升效能

我的项目链接:fork一下即可UIE Slim满足工业利用场景,解决推理部署耗时问题,晋升效力!如果有图片缺失查看原我的项目 UIE Slim满足工业利用场景,解决推理部署耗时问题,晋升效力在UIE弱小的抽取能力背地,同样须要较大的算力反对计算。在一些工业利用场景中对性能的要求较高,若不能无效压缩则无奈理论利用。因而,基于数据蒸馏技术构建了UIE Slim数据蒸馏零碎。其原理是通过数据作为桥梁,将UIE模型的常识迁徙到关闭域信息抽取小模型,以达到精度损失较小的状况下却能达到大幅度预测速度晋升的成果。 FasterTokenizer是一款简略易用、功能强大的跨平台高性能文本预处理库,集成业界多个罕用的Tokenizer实现,反对不同NLP场景下的文本预处理性能,如文本分类、浏览了解,序列标注等。联合PaddleNLP Tokenizer模块,为用户在训练、推理阶段提供高效通用的文本预处理能力。use_faster: 应用C++实现的高性能分词算子FasterTokenizer进行文本预处理减速 UIE数据蒸馏三步 Step 1: 应用UIE模型对标注数据进行finetune,失去Teacher Model。Step 2: 用户提供大规模无标注数据,需与标注数据同源。应用Taskflow UIE对无监督数据进行预测。Step 3: 应用标注数据以及步骤2失去的合成数据训练出关闭域Student Model。成果展现: 测试硬件状况: 1点算力卡对应的:V100 32GBGPUTesla V100Video Mem32GBCPU4 CoresRAM32GBDisk100GB 模型模型计算运行工夫precisionrecallF1uie-base68.61049008s0.692770.723270.70769uie-mini28.932519437s0.741380.540880.62545uie-micro26.367019170.747570.484280.58779uie-nano24.89377610.742860.490570.59091蒸馏mini6.839258904s0.77320.750.76142蒸馏micro6.776990s0.782610.720.75蒸馏nano6.6231770s0.79570.740.76684模型计算运行工夫: | 模型 | 模型计算运行工夫 | 提速x倍|| -------- | -------- | -------- | | UIE base | 203.95947s | 1|| UIE base + FasterTokenizer | 177.1798s | 1.15|| UIE蒸馏mini | 21.97979s |9.28 || UIE蒸馏mini + FasterTokenizer | 20.1557s |10.12 | Archive: data.zip inflating: ./data/unlabeled_data.txtinflating: ./data/doccano_ext.json示例数据蕴含以下两局部: ...

October 24, 2022 · 5 min · jiezi

关于算法:算法-详解斐波那契数列问题

本篇是学习了《趣学算法(第2版)》 第一章之后总结的。 上一篇讲到了等比数列求和问题,求$S_n = 1 + 2 + 2^2 + 2^3 + ... + 2^{63}= ?$,该函数属于爆炸增量函数,如果采纳惯例运算,则要思考算法的工夫复杂度。 算法知识点斐波那契数动静布局(拆分子问题;记住过往,缩小反复计算)算法题目假如第1个月有1对初生的兔子,第2个月进入成熟期,第3个月开始生养兔子,而1对成熟的兔子每月会生1对兔子,兔子永不死去..…那么,由1对初生的兔子开始,12个月后会有多少对兔子呢? 做题思路 这个数列有如下非常显著的特点:从第3个月开始,$当月的兔子数=上月兔子数+当月新生兔子数$,而$当月新生兔子数=上上月的兔子数$。因而,后面相邻两项之和便形成后一项,换言之:$$当月的兔子数=上月兔子数+上上月的兔子数$$ 斐波那契数如下: 1 ,1 ,2 ,3 ,5 ,8, 13 ,21 ,34 ...... 递归表达式$$F(n)=\begin{cases}1&, \text{n=1}\1&, \text{n=2}\F(n-1) + F(n-2)&, \text{n>2}\end{cases}$$ 依据递归表达式,初步的算法代码如下: const fbn = (n) => { if (n == 1 || n == 2) { return 1 } else { return fbn(n-2) + fbn(n-1) }}让咱们看一下下面算法的工夫复杂度,也就是计算的总次数$T(n)$ 工夫复杂度工夫复杂度算的是最坏状况下的工夫复杂度n=1时,T(n)=1n=2时,T(n)=1;n=3时,T(n)=3; //调用Fib1(2)和Fib1(1)并执行一次加法运算(Fib1(2)+Fib1(1))当n>2时须要别离调用fbn(n-1)和fbn(n-2),并执行一次加法运算,换言之:$$n\gt2时,T(n)=T(n-1)+T(n-2)+1;$$ 所以,$T(n) >= F(n)$ 问题来了,怎么判断T(n)属于算法工夫复杂度的哪种类型呢?办法一:画出递归树,每个节点示意计算一次 ...

October 24, 2022 · 2 min · jiezi

关于算法:PaddleNLP通用信息抽取技术UIE一产业应用实例信息抽取实体关系抽取中文分词精准实体标情感分析等

相干文章:1.快递单中抽取要害信息【一】----基于BiGRU+CR+预训练的词向量优化2.快递单信息抽取【二】基于ERNIE1.0至ErnieGram + CRF预训练模型3.快递单信息抽取【三】--五条标注数据进步准确率,仅需五条标注样本,疾速实现快递单信息工作1)PaddleNLP通用信息抽取技术UIE【一】产业利用实例:信息抽取{实体关系抽取、中文分词、精准实体标。情感剖析等}、文本纠错、问答零碎、闲聊机器人、定制训练2)PaddleNLP--UIE(二)--小样本疾速晋升性能(含doccona标注)!强烈推荐:数据标注平台doccano----简介、装置、应用、踩坑记录我的项目连贯:https://aistudio.baidu.com/aistudio/projectdetail/4180615?contributionType=1 0. PaddleNLP 一键预测能力 Taskflow API之三大个性性能全面 全场景反对:笼罩NLU和NLG畛域十一大经典工作。文档级输出:反对文档级输出,解决预训练模型对输出文本的长度限度问题,大大节俭用户输出长文本时的代码开发量。定制化训练:反对用户应用本人的数据集进行定制化训练,通过自定义门路一键应用定制化训练好的模型。简捷易用 开箱即用,学习成本低,几行代码便可实现调用。产业级成果 聚合泛滥百度自然语言解决畛域自研算法以及社区优良开源模型,模型成果当先。1. 环境筹备!pip install --upgrade paddlenlp!pip install pypinyin!pip install LAC2. 根底能力这一章节将会学到的Taskflow技能: 利用PaddleNLP Taskflow提取句子中的语言学特色:中文分词、词性辨认,依存关系,命名实体辨认、关系抽取、事件抽取等。2.0 信息抽取PaddleNLP 5.16新发凋谢域信息抽取能力,只有你想不到的schema,没有UIE抽取不到的后果哦! 详情可参考:信息抽取一键预测能力 如需定制化训练,全套代码在此:传送门 实体抽取from pprint import pprintfrom paddlenlp import Taskflowschema = ['工夫', '选手', '赛事名称'] # Define the schema for entity extractionie = Taskflow('information_extraction', schema=schema)pprint(ie("2月8日上午北京冬奥会自由式滑雪男子大跳台决赛中中国选手谷爱凌以188.25分取得金牌!")) # Better print results using pprint[{'工夫': [{'end': 6, 'probability': 0.9857378532473966, 'start': 0, 'text': '2月8日上午'}], '赛事名称': [{'end': 23, 'probability': 0.8503082243989795, 'start': 6, 'text': '北京冬奥会自由式滑雪男子大跳台决赛'}], '选手': [{'end': 31, 'probability': 0.8981535684051067, 'start': 28, 'text': '谷爱凌'}]}]关系抽取# schema = {'歌曲名称': ['歌手', '所属专辑']} # Define the schema for relation extractionie.set_schema(schema) # Reset schemaie('《辞别了》是孙耀威在专辑爱的故事外面的歌曲')[{'歌曲名称': [{'text': '辞别了', 'start': 1, 'end': 4, 'probability': 0.6296147448952354, 'relations': {'歌手': [{'text': '孙耀威', 'start': 6, 'end': 9, 'probability': 0.9988380409852198}], '所属专辑': [{'text': '爱的故事', 'start': 12, 'end': 16, 'probability': 0.9968462078543183}]}}, {'text': '爱的故事', 'start': 12, 'end': 16, 'probability': 0.28168534139751955, 'relations': {'歌手': [{'text': '孙耀威', 'start': 6, 'end': 9, 'probability': 0.9951413914998}]}}]}]事件抽取schema = {'地震触发词': ['地震强度', '工夫', '震中地位', '震源深度']} # Define the schema for event extractionie.set_schema(schema) # Reset schemaie('中国地震台网正式测定:5月16日06时08分在云南临沧市凤庆县(北纬24.34度,东经99.98度)产生3.5级地震,震源深度10千米。')[{'地震触发词': [{'text': '地震', 'start': 56, 'end': 58, 'probability': 0.9977425555988333, 'relations': {'地震强度': [{'text': '3.5级', 'start': 52, 'end': 56, 'probability': 0.998080158269417}], '工夫': [{'text': '5月16日06时08分', 'start': 11, 'end': 22, 'probability': 0.9853299181377793}], '震中地位': [{'text': '云南临沧市凤庆县(北纬24.34度,东经99.98度)', 'start': 23, 'end': 50, 'probability': 0.7874013050677604}], '震源深度': [{'text': '10千米', 'start': 63, 'end': 67, 'probability': 0.9937973233053299}]}}]}]句子级情感分类schema = '情感偏向[正向,负向]' # Define the schema for sentence-level sentiment classificationie.set_schema(schema) # Reset schemaie('这个产品用起来真的很晦涩,我十分喜爱')[{'情感偏向[正向,负向]': [{'text': '正向', 'probability': 0.9990024058203417}]}]评估维度、观点抽取,对象级情感剖析schema = {'评估维度': ['观点词', '情感偏向[正向,负向]']} # Define the schema for opinion extractionie.set_schema(schema) # Reset schemapprint(ie("地址不错,服务个别,设施古老")) # Better print results using pprint[{'评估维度': [{'end': 2, 'probability': 0.9888138676472664, 'relations': {'情感偏向[正向,负向]': [{'probability': 0.998228967796706, 'text': '正向'}], '观点词': [{'end': 4, 'probability': 0.9927846479537372, 'start': 2, 'text': '不错'}]}, 'start': 0, 'text': '地址'}, {'end': 12, 'probability': 0.9588297379365116, 'relations': {'情感偏向[正向,负向]': [{'probability': 0.9949388606013692, 'text': '负向'}], '观点词': [{'end': 14, 'probability': 0.9286749937276362, 'start': 12, 'text': '古老'}]}, 'start': 10, 'text': '设施'}, {'end': 7, 'probability': 0.959285414999755, 'relations': {'情感偏向[正向,负向]': [{'probability': 0.9952498258302498, 'text': '负向'}], '观点词': [{'end': 9, 'probability': 0.9949358587838901, 'start': 7, 'text': '个别'}]}, 'start': 5, 'text': '服务'}]}]跨工作跨畛域抽取schema = ['寺庙', {'丈夫': '妻子'}]ie.set_schema(schema)pprint(ie('李治即位后,让身在感业寺的武则天续起头发,从新纳入后宫。'))[{'丈夫': [{'end': 2, 'probability': 0.989690572797457, 'relations': {'妻子': [{'end': 16, 'probability': 0.9987625986569526, 'start': 13, 'text': '武则天'}]}, 'start': 0, 'text': '李治'}], '寺庙': [{'end': 12, 'probability': 0.9888578809890554, 'start': 9, 'text': '感业寺'}]}]2.1 中文分词分词作为许多NLP工作的第一道工序,如何在不同场景中『用好』、『用对』尤为重要。 ...

October 21, 2022 · 5 min · jiezi

关于算法:智能创意在哈啰的应用实践

什么是创意创意类型及组成 创意的类型很多,包含商品广告创意、视频创意、UGC图文创意、营销流动创意等。右图是哈啰营销流动的banner和弹窗,能够看到banner和弹窗属于不同的创意款式,不同创意款式的元素和元素的属性也各不相同。咱们在对创意进行优化的时候,能够发现款式乘以模板乘以元素数再乘以元素的属性数,这使得创意的组合是变幻无穷的。 如何评估创意品质 从算法的角度,图像品质评估有三种建模条件。一是全参考,咱们同时有原始(无失真、参考)图像和失真图像,外围是比照两幅图像的信息量或特色类似度;二是半参考,只有原始图像的局部信息或从参考图像中提取的局部特色;三是无参考,也叫盲参考,只有失真图像,难度较高。有两种罕用的评估指标,一是线性相关系数,也就是平时咱们用的皮尔逊相关系数,用来评估两组数据之间的差异性。它的公式是两组数据的斜方差除以标准差的商值,其中N示意失真图像数。通过这个公式能够算出失真图像和实在图像的相关性,相关性越高,正值就越大,先决条件是它的数据必须要遵从正态分布。如果不满足这个条件,就能够用上面的Spearman秩相关系数,在意的是在实在值和预测值序列中的排序地位。它跟皮尔逊相关系数实际上是一样的,都是越大越相干。 接下来介绍2016年提出的DeepBIQ模型,将原始图像切分成多个子区域,对多个子区域预测的分数进行均匀来预计图像品质。这个模型之所以具备翻新点,是因为首先它应用了不同的预训练模型,因为咱们平时所拿到的图片数据量较少,就能够进行迁徙学习,用训练好的模型固定它的网络权重,再应用当初较少的数据来进行网络的微调,把他人场景下的网络数据迁徙到咱们的场景当中。其次它应用了大量的图像块而不是整个图像进行的训练,同时应用了不同的特色和后果交融策略,能够看到两头的Fusion of Feature Vectors,通过输出图像的块状特色,通过了CNN的编码之后失去了特色的向量,再通过三种不同的交融策略,包含pooling+svr、comc+svr和svr+pooling,最初选取最好的一种进行模型的评估。 创意品质评估的第二局部是文案的通顺度。对于一个一般的句子序列,它的概率是多个概率的乘积。困惑度是导数的概念,它是句子概率乘积的导数,再开N次方。因而语言模型预测出句子呈现的概率越大,就表明它的困惑度越小,也就是一个比拟好的通顺度比拟高的句子。 智能创意搭建内容智能创意零碎搭建次要分为四个局部,一是内容了解,如实体辨认、分类、标签抽取、embedding和OCR。二是创意生成,包含程序化拼接、素材生成、布局生成和元素渲染。三是品质评估,就是上文提到的文本和图像品质评估。四是创意优选,包含bandit、CTR预估、组合搜寻和多模态特色。 如何进行创意生成什么是生成模型 生成模型是从一个散布为p_data的数据集中取样形成训练集去训练模型,模型会学习和模仿这一散布,咱们就能够从学习到的散布中生成一些样本,样本尽可能让它与实在数据分布统一,如图像、文本等。 为什么要钻研生成模型 一是生成模型代表咱们具备可能示意和操控高维概率分布的能力,二是生成模型能够用有损失的数据进行训练,进行半监督学习,升高了咱们取得数据样本的难度。三是有一些工作须要产生看起来实在的样本,如输出低分辨率的图片,生成模型能够产生靠近于原分辨率的图片;从街道轮廓图生成实在图,从卫星图生成地图。这些图像复原和修复工作须要一些看起来实在的样本,生成模型能够去实现。 生成反抗网络 生成模型是去求解实在的概率分布,如果咱们不在意概率分布自身的样子,只心愿通过模型去生成与实在散布差不多的样本,咱们就能够用生成反抗网络去建模。反抗是指咱们须要构建两个网络,别离是判断网络和生成网络。判断网络的损失是穿插熵损失,生成网络学习的损失函数是判断网络的相同值。这是因为判断网络是为了去辨别出实在样本和生成样本之间的差别,并让他们之间的区分度最大;生成网络用来生成样本,心愿生成样本和实在样本区别越小越好,所以从建模的目标上说,这两个网络的损失函数须要是相同的值,加在一起是一个经典的零和博弈的问题。 这两个网络学习总指标是在判断网络损失函数最小的状况下,生成网络的损失函数也最小。训练过程就是在以下的两个步骤中交替进行,别离去训练这两个网络,对判断网络进行梯度回升,对生成网络进行梯度降落。在理论的训练过程中,并不是1+1交替进行,而是先去训练判断网络,因为只有好的判断网络之后,才可能更好地更新生成网络的参数。 Transformer 生成反抗网络次要使用的畛域是图像生成,图像属于间断零碎,难以对概率分布建模,但文本属于离散系统,用神经网络和softmax就可对概率分布建模,transformer模型次要用于文本的生成。 右图的transformer分为两个局部,别离是编码器局部和解码器局部。这里用一个比拟形象的例子去论述transformer的工作形式。第一步咱们须要输出一条训练数据,以摘要生成为例,咱们输出的训练数据是文章,须要输入的是摘要。在咱们输出文章之后,通过encoder层失去一个编码,再通过decoder失去一个预测后果,预测后果代表词表中的词作为生成词的概率向量。比方词表中有三个词,作为生成词的概率向量别离是0.5、0.5、0.8,那么第三个词作为生成词的概率就比拟高。第二步咱们输出一个句子“张三回家了”中的“张”字,此时咱们心愿模型吐出“三”字的one-hot编码。第三步是通过方才的机制去训练,减小损失,最终失去咱们的生成模型。 如何进行创意优选 创意优选次要解决两个问题,一是创意到人的精准匹配,和个别的商品排序比照,创意多了很多多模态的内容,多模态内容的联结表征是创意优选的一个难点。二是长尾性加多样性,就是用户对于创意的疲劳度绝对较高,它的解法是bandit模型,每种创意保护一个beta(win, lose)散布,win指的是创意被展示且被点击,lose指的是创意被展示但没有被点击,这个散布随着用户反馈的产生实时调整。 哈啰智能创意零碎展现 哈啰在智能创意零碎上做了很多实际,尽管还没有用到多模态的信息,但整个框架依然是CTR+EE框架。同时咱们也进行了一些内容了解的工作,如文案多分类、多标签提取等,对于新的创意和老的创意的解法也不一样。之后咱们会上线图文搭配性能,会思考到素材的美学搭配。同时在创意优选上会进行细粒度的优选,进行元素级的优选模型搭建。此外,会搭建更欠缺的报表和更智能的文案助手。 (本文作者:潘云凤) 本文系哈啰技术团队出品,未经许可,不得进行商业性转载或者应用。非商业目标转载或应用本文内容,敬请注明“内容转载自哈啰技术团队”。

October 20, 2022 · 1 min · jiezi

关于算法:算法图解递归调用栈

这个盒子里有盒子,而盒子里的盒子又有盒子。钥匙就在某个盒子中。为找到钥匙,你将使 用什么算法?先想想这个问题,再接着往下看。 上面是一种办法。 第一种办法应用的是while循环:只有盒子堆不空,就从中 取一个盒子,并在其中认真查找。上面是另一种办法: 第二种办法应用递归——函数调用本人基线条件和递归条件:编写递归函数时,必须通知它何时进行递归。正因为如此,每个递归函数都有两局部:基线 条件(base case)和递归条件(recursive case)。递归条件指的是函数调用本人,而基线条件则 指的是函数不再调用本人,从而防止造成有限循环。栈:计算机在外部应用被称为调用栈的栈。咱们来看看计算机是如何应用调用栈的。 应用栈尽管很不便,然而也要付出代价:存储详尽的信息可能占用大量的内存。每个函数调 用都要占用肯定的内存,如果栈很高,就意味着计算机存储了大量函数调用的信息。在这种状况 下,你有两种抉择。 从新编写代码,转而应用循环。应用尾递归。这是一个高级递归主题,不在本书的探讨范畴内。另外,并非所有的语言都反对尾递归。

October 16, 2022 · 1 min · jiezi

关于算法:谁说算法工程师不会写代码

大家好,我是阿星。我的新书《大规模举荐零碎实战》前段时间上市了,收到很多反馈,看着那些或感激、或认可、或激励的句子,我很有成就感,在这里感激大家的反对! 其实上学的时候就有涉猎一些算法常识,然而我真正意识到应该深刻理解算法,是在 2015 年。因为我发现,算法竟然能够让我研究生阶段学到的矩阵论、最优化实践等看上去毫无用处的常识派上了用场!这在计算机行业的其余方向都是不可设想的。比方很多人自嘲:我开始做商业化的举荐算法是在 2016 年,做短视频举荐。第一个上线的算法是协同过滤,当它“轻而易举”地将用户观看时长晋升了 10%+ 时,我都惊呆了!不禁感叹:“一个小小的算法具备这么大的威力!”看着本人实现的算法可能“管制”几百万人的行为时,那种成就感,我当初仍历历在目。这份成就感,也让我始终放弃着对举荐算法酷爱,去一直钻研它。在这条路上,很幸运地遇到了一些和我一样,对举荐算法感兴趣的人,我也很乐意把我的教训分享给大家。大略 2020 年的时候,我发现很多举荐算法从业者对算法以外的常识理解得非常少,特地是软件工程相干内容,于是常常会被戏谑:算法工程师不会写代码。 而且还有一个很广泛的景象,因为分工的起因,很多从业者的日常工作只波及举荐零碎的一小部分,长此以往就成了“螺丝钉”,这对于集体倒退来说不太敌对。所以我萌发了写一本书的念头,很快就开始盘算“这本书”的定位。 回想起我刚开始接触举荐算法时,到处找博客、看视频、买书。这个畛域和其余技术畛域很像,材料大都停留在实践层面,讲落地的少之又少。 时至今日这种景象也并没有缩小,更别提在以后大数据时代的算法落地,与 10 年前相比,产生了天翻地覆的变动。因而我打算写一本对于举荐零碎实战的书,把重点放在工业界如何将举荐算法落地。过后我认为最重要的就是:肯定要给读者提供具备生产规范的代码,让想要入门的人少走弯路。上面和大家聊聊这本书,其实整本书大体上就是我对举荐零碎的认识。 想要举荐算法价值最大化,个别从数据和模型两个角度来思考,往往前者更加重要。这也是咱们平时在学习和工作中容易漠视的中央,很多从业者会把大量工夫放在折腾模型上,然而,往往数据的优化带来的收益远远高于模型的调优。 但说到底,模型是为了数据服务的,不能轻重倒置。因而数据的结构和优化,在这本书里占据了很大的篇幅。我在书中讲述具体的算法之前,会首先形容算法用来解决什么样的问题,以及如何结构训练数据(比方第7章一整章都在解说特色工程和特征选择,毕竟特色是整个建模过程外围中的外围。) 除此之外,我认为对算法的评估也是一个很重要的方面。评估分为线下评估和线上评估。这在书里都有很具体的阐明和实现,比方线下的召回阶段和排序阶段应用的不同评估形式;线上点击率、转化率、AB 测试,包含业界支流的分层试验计划和指标置信度评估,等等。最初我在这里对立答复一些来自读者的发问。 如何解决零碎冷启动?是否有能够分享的教训?冷启动个别会有用户冷启动、物品冷启动和零碎冷启动,字面意思曾经能够解释这三种冷启动的差异。对于冷启动问题,在本书的第13章也做了较为具体的阐明。 用户冷启动:次要通过热门榜、用户人口属性(地理位置、设施信息等)、内部数据(比方 A 和 B 产品同属一家公司,B 产品是新产品,那么 B 产品可能就会用 A 产品的用户数据)等去做举荐; 物品冷启动:个别通过物品自身的属性去举荐,题目、标签之类的。当然通过多级流量管制也是惯例做法。 零碎冷启动:这是属于最辣手的,能够应用内部数据,如果没有内部数据,个别就等零碎缓缓积攒了,在算法层面,多臂机是很罕用的算法。 如何掂量一个举荐零碎是否优良?能为公司赚钱的举荐零碎就是优良的举荐零碎(哈哈)。站在技术人的角度,一个优良的举荐零碎,必须具备以下几个特点:疾速迭代、疾速反馈:依附分布式训练、可信的 AB 测试平台和零活伸缩性好的模型服务平台。其中前两者在书里的第11章和第15章做了具体的阐明。模型服务平台要可能反对模型疾速上线、扩容、下线,最好是零配置、一键上线、扩容、下线。数据、特色和模型治理:这些须要可能像代码一样,有版本控制、历史追踪等。欠缺的监控零碎:模型指标监控、数据分布监控、线上服务监控等,保障整个举荐零碎的数据品质、模型品质和服务质量。以上其实就是须要一套高效的 MLOps 工具。 大厂对于举荐算法工程师都有什么样的要求?我感觉我无奈间接代表大厂,我来说说我对于举荐工程师的冀望吧。 工程能力:coding 能力&软件工程能力,我始终感觉这是技术能力中最重要的一方面; 算法能力:扎实的实战经验,不是浅尝辄止,而是可能刨根问底,做到实践和业务相结合; 方法论:属于软实力,这个看上去有点虚,然而如果可能总结出本人在工作中的一套方法论,包含剖析问题、解决问题、与人沟通等方面,对于职业生涯更上一层楼大有帮忙。 对举荐算法工程师的将来倒退路线有什么倡议或者教训能够分享吗?增强工程能力,把算法工程师当成是软件工程师,最起码要可能看一些优良框架的源码;不要沦为调包侠/调参侠。留神总结和思考,工作中的很多问题其实都是反复的;多看书,多看论文:集体的能力和精力有限,多看看优良的论文,对眼界宽阔都特地好,在这里举荐谷歌、FaceBook 和阿里的论文。 您在 SHEIN 工作,与之前在字节、苏宁有什么不同吗?SHEIN 作为一家跨境电商,仍然还在砥砺前行、茁壮成长。我退出 SHEIN 也快3年了,成长了很多。 我在 SHEIN 比拟有意思的事是因为咱们在多个国家都有业务,而每个国家的气象、习惯、习俗和信奉什么的都可能不一样,因而在算法建模时都要留神这些方面,这与在做国内业务时还是有很大的区别的。 编辑举荐本书从实战的角度介绍举荐零碎,次要蕴含三局部:召回算法、排序算法和工程实际。书中粗疏分析了如何在工业中对海量数据利用算法,从算法原理,到模型搭建、优化以及最佳实际等。根本涵盖了举荐算法从业人员在理论利用中所要把握的全副外围技能。适宜人群本书适宜心愿入门举荐算法的非行业从业者、心愿在举荐算法畛域进阶的行业从业者,以及心愿全面理解举荐零碎及其运作原理的技术管理者浏览。 特色亮点• 业余背景:一线互联网大厂举荐零碎专家经验总结。• 着眼实战:具体分析大规模举荐零碎从0到1,从1到N。• 开箱即用:附带能够间接用于生产环境的所有支流举荐算法的代码实现。 作者介绍阿星,曾在字节跳动、苏宁易购等企业负责举荐/广告算法的设计、开发和优化工作,在应答海量数据下的算法建模以及点击率/转化率预估等工作中积攒了大量实战经验。 目前就任于跨境电商巨头 SHEIN,负责晋升寰球外围业务场景的流量散发效率。 对于举荐零碎,小伙伴们有什么纳闷吗?大家能够在评论区留言,有可能会被作者大大翻牌哦~(对了,很“大”的问题倡议购书零碎学习哦~)

October 15, 2022 · 1 min · jiezi