关于算法:MindSpore报错RuntimeError-Exception-thrown-from-PyFunc

1 报错形容1.1 零碎环境ardware Environment(Ascend/GPU/CPU): CPUSoftware Environment:– MindSpore version (source or binary): 1.7.0– Python version (e.g., Python 3.7.5): 3.7.6– OS platform and distribution (e.g., Linux Ubuntu 16.04): Windows-10-10.0.19041-SP0– GCC/Compiler version (if compiled from source): 1.2 根本信息1.2.1脚本此案例为创立一个做超分辨率的数据集,应用mindspore.dataset.GeneratorDataset接口实现自定义形式的进行数据集加载。image.png 1.2.2报错报错信息:RuntimeError: Exception thrown from PyFunc. Invalid python function, the ‘source’ of ‘GeneratorDataset’ should return same number of NumPy arrays as specified in column_names, the size of column_names is:1 and number of returned NumPy array is:2image.png ...

June 28, 2022 · 1 min · jiezi

关于算法:PSS你距离NMSfree提点只有两个卷积层-2021论文

 论文提出了简略高效的PSS分支,仅需在原网络的根底上增加两个卷积层就能去掉NMS后处理,还能晋升模型的准确率,而stop-grad的训练方法也挺有意思的,值得一看 起源:晓飞的算法工程笔记 公众号 论文: Object Detection Made Simpler by Eliminating Heuristic NMS 论文地址:https://arxiv.org/abs/2101.11782论文代码:https://github.com/txdet/FCOSPssIntroduction 以后支流的指标检测算法训练时大都一个GT对应多个正样本,使得推理时也会多个输入对应一个指标,不得不对后果进行NMS过滤。而论文的指标是设计一个简略的高性能全卷积网络,在不应用NMS状况下,可能进行齐全的端到端训练。论文提出的办法非常简略,外围在于增加一个正样本抉择分支(positive sample selector, PSS)。 论文的次要奉献如下: 检测流程在去掉NMS后变得更加简略,从FCOS到FCOS$_{PSS}$的批改能植入到其余的FCN解决方案中。试验证实能够通过引入简略的PSS分支来代替NMS,植入FCOS仅需减少大量的计算量。PSS分支非常灵便,实质上相当于可学习的NMS,因为退出PSS分支没有影响到原有构造,可间接去掉PSS分支间接应用NMS。在COCO上,失去与FCOS、ATSS以及最近的NMS-free办法相当或更好的后果。提出的PSS分支可利用于其余anchor-based检测器中,在每个地位一个anchor box的设定下,仅通过PSS分支的动静训练样本抉择也能达到不错的后果。同样的想法也可用于其余指标辨认工作中,如去掉实例宰割中的NMS操作。Our Method FCOS$_{PSS}$的整体构造如图1所示,仅在FCOS的根底上增加了蕴含两个卷积层的SPP分支。 Overall Training Objective 残缺的训练损失函数为: $\mathcal{L}_{fcos}$为原版FCOS的损失项,蕴含分类损失、回归损失和center-ness损失。此外,还有PSS分支损失和ranking损失。在训练时$\lambda_2$设置为0.25,因为ranking损失对准确率只有些许晋升。 PSS损失 PSS分支是NMS-free的要害,如图1所示,该分支的特色图输入为$\mathbb{R}^{H\times W\times 1}$。定义$\sigma(pss)$为特色图上的一个点,仅当该点为正样本时才设为1,所以能够把PSS分支当作二分类退出训练。但为了借用FCOS多分类的劣势,论文将其与分类特色、center-ness特色进行交融: 用下面的分数计算focal loss,与本来的FCOS分类的区别是,这里每个GT有且仅有一个正样本。 Ranking损失 论文通过试验发现,在训练时退出ranking损失能晋升性能,ranking损失的定义为: $\gamma$代表正负样本间的间隔,默认设置为0.5。$n_{+}$和$n_{-}$为正负样本数量,$\hat{P}_{i_{+}}(c_{i_{+}})$为正样本$i_{+}$对应类别$c_{i_{+}}$的分类分数,$\hat{P}_{i_{-}}(c_{i_{-}})$为负样本$i_{-}$对应类别$c_{i_{-}}$的分类分数。在试验中,取top 100负样本分数进行计算。 One-to-many Label Assignment 一个GT抉择多个anchor作为正样本进行训练是以后指标检测宽泛采纳的一种做法,这样的做法可能极大地简化标注要求,同时也可能兼容数据加强。即便标注地位有些许偏差,也不会扭转抉择的正样本。另外,多个正样本可能提供更丰盛的特色,帮忙训练更弱小的分类器,比方尺寸不变性、平移不变性。因而,对于原生的FCOS分支的训练仍然采纳一对多的形式。 One-to-one Label Assignment 一对一的训练形式须要每次为GT抉择最佳正样本,抉择的时候须要思考分类匹配水平和定位匹配水平,这里,先定义一个匹配分数$Q_{i,j}$: $i$为预测框编号,$j$为GT编号,超参数$\alpha$用来调整分类和定位间的比值。$\Omega_j$示意GT $j$的候选正样本,采纳FCOS的规定,在GT的核心区域的点对应的anchor均为候选正样本。最初,对所有的GT及其正样本采纳二分图匹配,通过匈牙利算法抉择最大化$\sum_{j}Q_{i,j}$的匹配计划。 Conflict in the Two Classification Loss Terms 在论文提出的计划中,损失项$\mathcal{L}_{fcos}$采纳一对多的匹配计划,而损失项$\mathcal{L}_{pss}$采纳一对一的匹配计划,这意味着有局部anchor可能会被同时划分为正样本和负样本,导致模型难以收敛。为此,论文提出了stop-grad的概念,即阻止PSS分支的梯度回传到FCOS中。 Stop Gradient stop-gradient操作在训练的时候将其中一部分网络设置为常数,定义$\theta=\{\theta_{fcos},\theta_{pss}\}$为网络须要优化的参数,训练的指标是求解: ...

June 27, 2022 · 1 min · jiezi

关于算法:什么是LIDAR激光雷达如何标注激光点云数据

主动驾驶汽车重大依赖输出的训练数据来做出驾驶决策,从逻辑上来说,数据越具体,车辆做出决策就越好,最重要的是更平安。尽管古代相机能够捕捉到十分具体的真实世界特色,但输入后果依然是2D的,成果并不够现实,因为它限度了咱们能够提供给主动驾驶汽车神经网络的信息,这意味着汽车必须学会对3D世界做出猜想。与此同时,相机捕获信息的能力无限,比方在下雨的时候,相机捕捉到的图像简直无奈分别,而激光雷达依然能够捕获信息。因而,2D相机无奈在所有环境下工作,因为主动驾驶汽车是神经网络一个高危利用场景,咱们必须确保构建的网络尽可能完满,这所有要从数据说起。现实状况下,咱们心愿咱们的网络将3D数据作为输出,因为它须要对3D世界进行预测,这就是激光雷达的用武之地。 本文旨在对LiDAR技术和应用它的网络进行全面的介绍,包含以下内容: LiDAR 是什么以及它是如何工作的 神经网络如何解决 LiDAR 数据以及它们面临的挑战 LiDAR 数据与 2D 图像有何不同以及标注过程如何变动 LIDAR到底是什么?LiDAR代表光检测和测距。简而言之,它是一种遥感技术,应用激光脉冲模式的光来测量传感器和指标物体之间的间隔和尺寸。在主动驾驶场景下,激光雷达用于检测物体绝对于车辆的地位,例如其余汽车、行人和建筑物。人工神经网络的日益遍及使激光雷达比以前更有用。 激光雷达技术自 1960 年代以来始终被人们应用,过后它被装置在飞机上以扫描它们飞过的地形。随着 GPS 的呈现,LiDAR 在 1980 年代变得越来越风行,过后它开始被用于构建真实世界地位的 3D 模型。 LIDAR是如何工作的?大多数 LiDAR 零碎由四个局部组成: 1) 激光:向物体发送光脉冲(通常是紫外线或近红外线)。 2) 扫描仪:调节激光扫描指标物体的速度和激光达到的最大间隔。 3) 传感器:测量来自激光的光从指标物体反弹并返回零碎所需的工夫(从而测量间隔)。 4) GPS:跟踪激光雷达零碎的地位,以确保间隔测量的准确性。 古代 LiDAR 零碎通常每秒能够发送高达 500k 的脉冲。来自这些脉冲的测量值被聚合成一个点云,它实质上是一组坐标,代表零碎曾经感应到的物体。点云用于创立 LiDAR 四周空间的 3D 模型。 点云(Velodyne LiDAR)有两种个别类型的 LiDAR 零碎:机载和高空。因为咱们探讨的利用场景是主动驾驶汽车,咱们将次要关注高空激光雷达。高空激光雷达附着在固定在高空上的物体上,并在所有可见方向上进行扫描。它们能够是动态的(例如,连贯到不动的三脚架或建筑物上)或挪动的(例如,连贯到汽车或火车上)。 应用激光雷达数据进行深度学习鉴于 LiDAR 系统生成的输入类型,将它们与神经网络相结合非常正当,并且的确在点云上运行的神经网络已被证实是无效的。激光雷达点云在主动驾驶汽车上的利用能够分为两类: 1)以指标检测和场景了解为目标的实时环境感知和解决。 2)生成用于指标定位和参考的高清地图和城市模型。 听起来可能很简单,但实际上它只是意味着 LiDAR 数据用于语义宰割、指标检测/定位和对象分类,惟一的区别是当初咱们在 3D 中进行,这使得咱们的模型有更多的细微差别。 对于在激光雷达数据上运行的神经网络来说的一个挑战是,依据扫描时间、天气条件、传感器类型、间隔、背景和大量其余因素存在大量变动。因为激光雷达的工作形式,物体的密度和强度变化很大。再加上传感器常常有噪声,尤其是 LiDAR 数据通常不残缺(因为某些资料的低外表反射率和城市背景芜杂等因素),解决 LiDAR 数据的神经网络须要可能解决很多变动。 3D 数据的另一个问题是,与 2D 图像不同,LiDAR 传感器的点没有直观的程序,这在咱们的模型中引入了对排列和方向不变性的需要,并非所有架构都满足。 为解决 LiDAR 数据而提出的四个架构系列如下: ...

June 27, 2022 · 1 min · jiezi

关于算法:哈啰推荐引擎搭建实战

导读:逛逛是哈啰APP推出的内容社区,旨在为用户提供优质的生存攻略。本次分享以逛逛为例,介绍一下逛逛业务的举荐降级之路。 什么是举荐引擎 举荐引擎实质上是一种信息过滤零碎,特点是用户无明确用意。它跟搜寻不一样,用户搜寻的时候明确晓得本人想看什么,比如说会输出一个关键词,或者是有一些特定的条件,而举荐是心愿挖掘出用户感兴趣的货色,而后推给用户。所以,举荐的定义是对于用户,在特定场景下针对海量物品构建函数,预测用户对所有物品的感兴趣水平并排序生成举荐列表。 如何构建举荐引擎 举荐要解决的问题是在一个场景下给用户举荐他感兴趣的物品。对于逛逛业务来说,在我负责前原先应用的举荐服务是基于dataman的业务流程开发,非常复杂,须要将逛逛业务的帖子数据、用户行为数据或用户自身的数据导入到hive里,通过各个hive工作的依赖去计算出举荐的表。如图,最上面的表用来建举荐的,比方须要给用户推过去7天内看过的一些帖子,或用户看过的关注过的人发过的帖子。通过这种形式生成若干个工作,每个工作会生成一个hive表,最终业务会把这些hive表导入到业务的MySQL或者pg里。这其实是一种基于规定的举荐引擎。为了引入算法能力,咱们构建了一个新的基于算法的举荐引擎,其中最外围的局部在于举荐服务。举荐服务用来接管用户申请并生成举荐后果,外面须要用到一些数据源,咱们目前应用的是es和redis。其次,引入算法须要有排序模型,实质上是部署在决策流平台上的。如上图,黑线的实线能够认为是申请的流转过程,虚线能够认为是数据的流转过程。数据能够是物品数据、用户数据或行为数据,这三个数据存储在业务的数据库外面。因为咱们最终推的是物品,所以须要把物品数据导入到数据源外面。为什么应用es和redis两个数据源,这里是有衡量思考的。es能够反对比较复杂的搜寻条件和排序需要,redis比较简单,但es的毛病在于性能绝对较差。咱们会依据不同的召回需要选用不同的数据源存储,物品数据咱们目前存储在es。除了物品数据,咱们还须要思考用户数据和行为数据,把这些数据拿到后须要做离线定时计算,生成物品的品质分或标签。此外还须要做离线定时训练,训练出排序模型,因为每隔一段时间用户的行为模式会发生变化,所说这个模型自身也须要变动。 数据源筹备好后,咱们整个举荐服务分为四步。第一步是召回,也就是从这两个数据源中捞取数据,这部分前面会具体介绍。第二步和第三步叫粗排和精排,粗排的性能比拟好但成果会比拟差,精排的性能较差但成果较好。接着咱们拿到比拟好的后果列表进行重排,再返回给业务后端,这里没有把业务后端画进去。业务后端把这个后果透传给前端,这样就失去了用户的举荐列表。接下来,咱们比照一下两种举荐办法。第一,原来基于规定的举荐会造成千人一面,即每个人看到的举荐页面第一页都是一样的。对于基于算法的举荐,因为引入了一些用户的特色,因而能够达到千人千面的成果。 从时效性上,基于规定的举荐因为所有的调度工作都放在dataman上,它可能是定时的解决,所以时效性较差。基于算法的举荐是基于flink工作的实时性开发,所以时效性较高,用户的行为数据能够马上影响到下一页的举荐后果。 第三,基于规定的举荐无奈体现数据的价值,因为它是依据产品的需要,产品会拍脑袋认为合乎某种模式的帖子成果比拟好,并作为需要提出,写一个固定的Hive SQL语句。基于算法的举荐次要通过模型做数据的排序,所以它会通过模型来反映用户的行为数据,能更好体现行为数据的价值。接着咱们讲一下召回,就是从海量数据中获取用户感兴趣的帖子。上图是咱们召回的分层构造,原始数据在最上面,包含pg、hive和kafka。hive是归档数据,各种依赖全,不便计算;pg是实时业务数据,及时反映业务变动;kafka次要是用户行为数据,及时反映用户行为。接着,通过搜寻平台和dataman两个产品将这些数据导入到在线存储的es和redis中,再通过这两个数据存储去反对在线服务进行多路召回。在线服务层和在线存储层间用中间件做,如rpc服务去调用。召回后咱们须要通过两轮排序进行优中选优,也就是粗排和精排。在之前的架构图中提到粗排和精排都走的模型,但理论算法同学只训练一个模型,所以咱们目前粗排是基于规定的。最重要的区别在于粗排要参加排序的数量多,成果较差。精排要参加排序的数量较少,但成果更好。之所以两轮排序,是在性能和成果间获得均衡。当然如果有需要,也能够引入更多轮排序,但这样可能 rpc调用的耗时占比会更高,可能得失相当。在粗排和精排后,最初一步是重排。重排的目标是为了更粗疏地调节举荐列表,比方对逛逛来讲,如果有个大V发帖子品质分都很高,某个用户十分关注他,这样用户举荐列表外面可能一页都是同一个人发的帖子,会造成用户审美疲劳。所以,须要有一些业务规定去进行打散,目前咱们的算法有滑动窗口法和权重调配法。 第二个目标是为了造就用户的心智。举个例子,在逛逛业务外面咱们有一个需要,对于某些人群须要给他举荐某一类帖子,但帖子品质不肯定十分高,排序模型不能准确达到把这些帖子排在后面的目标。所以须要在精排后退出重排,而后把特定的帖子置顶。当然置顶也不是间接全排后面,而是通过跳一个插一个的形式把这些帖子放后面,通过这种形式来造就用户的心智。 还有另一种做法是流量池的设定,比方经营感觉某些帖子品质比拟高,但他并不知道用户喜不喜欢,或者一些新品也能够放到流量池外面,给它相应的曝光,这样能让用户看到这些帖子并由用户来决定品质高不高。用户如何决定能够通过离线工作来计算,比方看过来一个小时内帖子的CTR怎么样来判断品质高不高,这种形式的实现也是在重排中从流量池捞一些帖子进行置顶,再去回收成果。 这里能够把它形象成一个算法问题,叫做多臂老虎机问题,解决这个问题的算法是bandit算法。多臂老虎机有多个不同的臂,摇动不同的臂会吐出不同数量的金币,要解决的问题就是通过什么样的策略摇臂,能吐出最大数量的金币。有很多算法能够去解决这个问题,bandit是其中一种算法,映射到举荐服务来讲,就是新品池里每个帖子是一个臂,帖子CTR的值是它吐的金币数,因为咱们曝光量无限,应该怎么去把更优良的帖子获取更大的曝光率,一种比较简单的解决算法叫 bandit算法。举荐的步骤讲完了,这里还波及到一个问题是曝光过滤。曝光过滤的目标是避免给用户反复举荐物品,左边是它的实现计划。手机代表用户的APP,他的行为数据由前端采集到kafka外面,再通过flink工作实时读取kafka中的数据,写入到redis外面,redis外面就存储了用户看过的帖子。当一个用户从手机上发送申请,录入到咱们的举荐服务上获取曝光数据。咱们从多路召回拿到数据之后,须要通过曝光过滤,从redis中获取用户看过的帖子并删除,而后返回给用户。 这里有一个细节,是怎么样定义给用户曝光的帖子。如果咱们把通过flink工作写进去的数据作为用户曝光帖子的话会有个问题,比方用户一屏刷了10个,等他刚看完第10个再往下刷的时候,第二屏申请就曾经发动了,这时候flink的数据还没来得及写入redis,所以会呈现反复。思考到这个问题,咱们能够有另一种解决方案,就是举荐服务在咱们本人这边,咱们的举荐服务推出来10个,就认为这10个全曝光了,间接把它作为曝光过滤的列表。但这里也有一个问题,很可能用户申请了10个,但一屏可能只看了两三个,这时候就有七八个被节约了。所以咱们的曝光过滤有两个设计指标,一是高时效性,即不能给用户举荐反复的货色;二是避免浪费,比方接口曝光有10个,用户只看2个的话就节约了8个。咱们的实现计划就是在redis中存两个key,一个key写它的实在曝光列表,另一个key写它的接口曝光列表,接口曝光列表是会滚动过期的。咱们进行曝光过滤的时候,须要把这两个列表都拿到取个并集作为曝光列表,过滤召回的物品。因为接口曝光数据会定时过期,所以被接口曝光多曝光的一些物品,会在前面适当释放出来,最终还是用实在曝光数据来作它的曝光过滤后果。接下来是冷启动问题,咱们思考的不是十分多,但它是举荐中大家都面临的一个问题。冷启动分为用户冷启动和物品冷启动,用户冷启动咱们没有思考很多,因为个别用哈啰逛逛业务的用户可能只是没用过这个业务,但其余业务如单车或助力车都曾经用过了,所以用户的信息咱们曾经存在了。如果对一些不存在信息,比如说i2i召回,即零碎过滤召回,它的含意是依据用户过往点赞过或评论过的帖子,去找类似的帖子推出来,这种状况可能拜访为空,但实质上一些热门或者LBS的路它能拜访后果,所以说用户冷启动并不是比拟大的问题。 比拟大的问题在于物品冷启动,因为咱们大量的召回阶段都依赖于算法离线算的数据,比方帖子的品质分、帖子跟帖子的类似度。咱们具体的解决算法分成两类,一类是在召回阶段新增新品召回的办法,让新品可能取得肯定的曝光量。还有一类是刚提到流量池的办法,能够把一些新品放到流量池里,通过bandit算法把它展现获取肯定的曝光量。思考到排序模型中须要用到特色,因而咱们须要对冷启动用户或冷启动物品增加特色默认值。在举荐做完之后,会波及到很多性能优化。咱们举荐服务的步骤十分多,因而整个举荐申请如果耗时比拟长的话,咱们并不能晓得每一步耗时多久,也不能通过单个case去看,比方只看某一个申请每一步耗时多久,这种状况可能失去的数据只是特例,并没有通用性。所以最终咱们的做法是埋了一些点,在举荐申请执行过程中,每一步耗时多久都打印了进去,而后通过采集性能进行采集,在grafana上依据筛选数据源配置大盘。上图就是大盘产生后果,大家能够看到咱们举荐的均匀耗时大略400毫秒不到,图中每条小线代表各个步骤的耗时,每次申请都是各个步骤耗时之和,取各个不重叠的步骤耗时之和来决定整个耗时,这样咱们能够通过曲线的趋势来看到哪一块是耗时的性能热点,咱们才须要去解决。 通过这样的图表,咱们次要剖析出两点。一是召回耗时比拟久,因为波及到很多路召回。二是排序模型耗时比拟久,排序模型耗时会由算法同学去优化。接下来重点介绍一下召回阶段如何做性能优化。右边这张图是咱们举荐申请召回一开始实现的版本,在性能优化时就发现了问题。第一步须要进行多路召回,比方LBS召回、标签召回、关注者召回,因为召回简单所以走的都是es,前面两个召回走的都是redis。咱们的做法是每个召回都去线程池中拿一个线程往es或redis中去查问,并返回出后果,这样它的最长耗时就是由所有申请中最长的那个耗时决定的,实际上是木桶原理,即一只水桶能装多少水取决于它最短的那块木板。但这个服务上线之后,在QPS比拟低的状况下,申请耗时还能够承受;QPS一旦高起来,耗时就会变得十分长。通过剖析,咱们发现在拜访 es的时候,es申请后果外面会带一个叫took的字段,形容了es在搜索引擎外面运行了多久。而后咱们发现去拜访es的时候,从一个线程发动申请到拿到后果,耗时比took耗时多了几十倍。起因就在于一个举荐申请进来之后,它会裂变成十几个申请,这样就算咱们线程值设置的再大,一个申请就要占用十几个线程,很可能QPS就上不去。 思考到这点,咱们就变成了右图的执行逻辑。每个举荐申请进来之后,同样进行多路召回,但最终从线程池收回的只是两个申请,一个申请查es,另一个申请查redis。这样一个举荐申请其实只分成了两个申请,占了两个线程。es是通过multisearch机制去拜访的,比如说右边三路,LBS召回、标签召回、关注者召回,我都把它拼起来变成一个申请,这样只须要申请一次。redis是通过pipeline机制去拜访,这样在QPS晋升之后,还是能达到跟右边一样,甚至比右边更好的耗时后果。在性能优化之后,稳定性建设也是十分重要的一点。为了在线服务阶段不报错,咱们应用了多重兜底的机制。首先在召回阶段引入兜底召回,保障就算其余几路召回为空,也能有举荐后果。第二是在排序阶段也退出兜底操作,保障就算依赖的排序服务出问题,也能反馈出一个比拟正当的举荐后果。另外比如说刚刚提到的i2i召回,可能须要获取用户已经操作过的帖子,也就是说有一个内部依赖的服务去获取。所以咱们对所有内部服务的谬误都提供默认值作为兜底。除了上述三个在举荐服务里实现,还要思考到十分极其的状况,即举荐服务自身故障,所以咱们在业务后端对举荐服务也做了兜底,保障用户能看到货色。 兜底会有个问题在于SOA不报错,这样咱们可能就感知不到,因而必须在兜底做报警,报警咱们目前是通过Argus来实现。这里我从Argus上截了一些图,右边是每路召回数据总数,如果某一路跌到变动比拟大的阈值,咱们就会认为这一路出问题了,须要人工排查告警。左边是依赖的内部服务SOA谬误的告警。上图展现的是举荐成果,右边是一个旧版举荐服务的 pv-ctr和uv-ctr的指标,左边是新版举荐服务的指标。能够看到晋升十分大,当然绝对值还是比拟小的。 举荐引擎的后续布局最初介绍一下咱们举荐服务后续的布局。将来咱们心愿在召回这一层再引入向量召回,这也是算法强烈推荐以及感觉成果比拟好的召回。因而咱们后续的布局次要是在召回多样化,召回多样化有不同层面的含意,在线存储层咱们会引入一种新的存储介质,用来反对向量搜寻的性能,在线服务层咱们会减少更多的召回门路。咱们还打算把举荐服务变成平台化的服务。除了目前曾经接的本地生存和逛逛业务之外,咱们能够接更多业务的举荐。右边的图是现有服务的简化架构,数据存储次要是用es和redis。举荐服务各自去撑持各自的业务后端。这种状况下,如果再加一个业务,可能须要再加一个举荐服务,但其实大量代码都是反复的。这样老本会十分高,保护起来也不容易,所以后续咱们会把举荐服务平台化。 (本文作者:盛晓昌) 本文系哈啰技术团队出品,未经许可,不得进行商业性转载或者应用。非商业目标转载或应用本文内容,敬请注明“内容转载自哈啰技术团队”。

June 27, 2022 · 1 min · jiezi

关于算法:力扣之有效的回文

题目形容给定一个字符串,验证它是否是回文串,只思考字母和数字字符,能够疏忽字母的大小写。 阐明: 本题中,咱们将空字符串定义为无效的回文串。 示例 1: 输出: "A man, a plan, a canal: Panama"输入: true解释:"amanaplanacanalpanama" 是回文串示例 2: 输出: "race a car"输入: false解释:"raceacar" 不是回文串力扣原题目地址:https://leetcode.cn/problems/...解决方案计划一 判断第i项和第j项是否相等(i+j==s.length-1)下方代码中,我就不辨别i和j了,间接是i和(filterS.length - 1) - i var isPalindrome = function (s) { let flag = true // 先加工数据,替换去掉空格特殊符号,以及转成小写英文对立比照 let filterS = s.replace(/[^A-Za-z0-9]/g, '').toLocaleLowerCase() for (let i = 0; i < filterS.length; i++) { // 如果有其中一项不合乎规定,就间接完结循环,返回后果即可 if (filterS[i] != filterS[filterS.length - 1 - i]) { flag = false return flag } } // 最初再返回一下,因为有可能就是回文数,要返回true return flag};留神,代码中的循环,其实不必循环所有项,只须要循环一半就行了,所以上述代码也能够换一下写法:for (let i = 0; i < Math.trunc(filterS.length / 2); i++) {......} ...

June 26, 2022 · 1 min · jiezi

关于算法:力扣之斐波那契数列

题目形容写一个函数,输出 n ,求斐波那契(Fibonacci)数列的第 n 项(即 F(N))。斐波那契数列的定义如下: F(0) = 0,   F(1) = 1F(N) = F(N - 1) + F(N - 2), 其中 N > 1.斐波那契数列由 0 和 1 开始,之后的斐波那契数就是由之前的两数相加而得出。如:fib(2) == 1、fib(5) == 5 力扣原题目地址:https://leetcode.cn/problems/...解决方案计划一 间接递归递归本人调用本人,一直执行,直到遇到某一条件进行递归 寻找法则 第0项 == 0第1项 == 1第2项 == 第1项 + 第0项第3项 == 第2项 + 第1项第4项 == 第3项 + 第2项......第i项 == 第i-1项 + 第i-2项 // 从第2项开始,即 i >= 2应用递归示意法则 function fib(i) { if (i == 0) { return 0 } if (i == 1) { return 1 } if (i >= 2) { /** * 这句话能够了解为:fib(i)函数执行的后果值等于return fib(i - 1) + fib(i - 2) * 即:fib(i) == fib(i - 1) + fib(i - 2) * 合乎上方法则:第i项 == 第i-1项 + 第i-2项 // 从第2项开始,即 i >= 2 */ return fib(i - 1) + fib(i - 2) }}console.time()console.log('斐波那契第10项', fib(10)); // 55console.timeEnd() // default: 0.279052734375 ms咱们应用timeEnd()打印出fib(10)第十项大抵递归执行工夫,发现是279毫秒。这里是有点慢了,起因举例: ...

June 26, 2022 · 2 min · jiezi

关于算法:数组一口气冲完快慢指针

前言 上篇文章讲了差分数组,这篇文章开始讲双指针技巧的快慢指针技巧。另外,数组有下图这些知识点与技巧。 思路 通过两个指针来操作数组,通常利用在:1.对数组有更改且不能建设新数组的状况下。2.一次遍历实现需求。 另外,双指针类型有快慢指针,左右指针,滑动窗户,一般类型。快慢指针模板 int 慢指针 = 0;for (int 快指针 = 0; fast < nums.length; 快指针++) { if (快指针满足某个条件) { 慢指针赋值操作 慢指针右挪动操作 }}删除有序数组中的反复项leetcode第26题解题思路 套用模板,“快指针满足某个条件中的条件”:指快慢指针所指的元素不同。 最初返回值时,须要将慢指针+1。复杂度剖析 工夫复杂度:O(n),n是数组的长度。 空间复杂度:O(1)。代码 class Solution { public int removeDuplicates(int[] nums) { int slow = 0; for (int fast = 0; fast < nums.length; fast++) { //快慢指针所指元素不同 if (nums[fast] != nums[slow]) { nums[++slow] = nums[fast]; } } return slow + 1; }}移除元素leetcode第27题解题思路 套用模板,“快指针满足某个条件中的条件”:指快指针所指的元素与给定值不同。复杂度剖析 工夫复杂度:O(n),n是数组的长度。 空间复杂度:O(1)。代码 ...

June 25, 2022 · 1 min · jiezi

关于算法:COSC-1114-RMIT-Classification

Page 1 of 6RMIT Classification: TrustedCOSC 1114 Operating Systems PrinciplesSemester 2, 2021Programming Assignment 2AssessmentTypeIndividual assignment.Marks are awarded for meeting requirements as closely as possible.Clarifications/updates may be made via announcements/relevant discussion forums.SubmissionPolicySubmit online to Canvas → Assignments → PrgAsg2 .2 submissions are required . The first in week 13, and the final submission in start of week 14.Late final submissions are penalized at the rate of 10% per day, pro-rata to 1%. In other words,the formula is floor(hoursLate*10/24) as percentage of the mark received. So 12 hours late for asubmission given the mark 20/30 will be penalized as per newMark = origMark (1 – (floor(hoursLate10/24) / 100)) = 20 * (1 – 0.05) = 19to 19/30.NB. In any dispute over late submissions, GitHub commit dates (which can be falsified) will NOTbe considered acceptable as evidence.SubmissionDue DateStart of week 14.Marks 30 (30% of semester) ...

June 24, 2022 · 14 min · jiezi

关于算法:实时渲染实时离线云渲染混合渲染的区别

渲染,就是将3D模型转换成2D图像,并最终出现在屏幕上的过程。尽管这里只有一句话,然而这一句话外面蕴含了太多的数学、物理和计算机方面的常识,它形容了咱们用计算机来虚拟化真实世界的根本逻辑。渲染过程是须要计算机进行运算且耗费工夫的。 不同的渲染分类,会用到不同的渲染引擎。比方实时渲染咱们个别会用到Unity和Unreal,离线渲染咱们会用到V-ray和Keyshot。然而这些技术和引擎产品都是相通的,所以Unreal的实时渲染能力也能够部署在云端,成为云渲染的体现。尽管,因为应用场景的不同,引擎自身的渲染算法都有本人的特点和劣势。然而,随着硬件计算能力的倒退,它们的界线也缓缓变得含糊。 常见的渲染类型有以下几种:实时渲染、离线渲染、云渲染、混合渲染。 它们两头有重叠穿插,也有技术区别。咱们防止太多的专业性形容,尝试用浅显易懂的形式来进行解释。 实时渲染 实时渲染(Real-time Rendering)从字面的意思非常容易了解,就是咱们要实时的看到渲染之后的3D物体或者场景的成果。实时,用数字怎么了解?至多24FPS:只有达到或者超过1秒钟播放24张连贯图像的速度,人眼观看时就不会造成卡顿的感觉。 个别的实时渲染场景都是带有强交互属性的,比方最常见的3D游戏《王者》《吃鸡》,或者是一些带有交互的3D利用,比方智慧城市、智慧园区的可视化我的项目。实时渲染的场景中,这些利用都会独立运行在咱们的电脑、手机上,通过本地的硬件能力实现实时渲染的过程。因而,玩大型游戏的话,硬件性能肯定要好。 离线渲染 离线渲染(Offline Rendering)这个从字面意思了解,如同就是“断网”之后在做渲染,然而这种了解是不对的。 离线渲染是跟实时渲染绝对应的,简略说就是咱们不须要实时地看到渲染成果的场景。 这种场景最常见的就是咱们的家装效果图。做过装修的小伙伴应该都晓得,如果让设计公司出效果图个别都是要免费的(有些为了吸引客户当然也会收费),他们其实就是在做离线渲染的工作。 那为什么咱们不能实时地去渲染一张效果图,反而要用离线渲染的机制呢?这就要看最初的渲染成果到底要多高了。 实时渲染,尽管渲染速度快,能够实时生成渲染内容,然而渲染的成果和真实度相对来说是不可能特地高的。对于离线渲染的场景,根本都是对渲染要求十分高的,甚至是齐全实在的。 比方方才提到的家装效果图,你可能不须要立即看到渲染图,然而如果看到的时候,发现成果不好,就可能要换其余设计公司了。 另外一个最常见的就是好莱坞影视大片、3D动画等影视场景。他们都须要达到一个十分真切的渲染成果甚至是齐全实在的场景复现,然而对实时性要求不高。 所以,个别的好莱坞大片,尤其是特效十分好的那种,拍摄实现后的制作周期都十分长。比方咱们耳熟能详的《阿凡达》,过后动用了40000颗CPU,104TB内存,10G网络带宽,整整离线渲染了1个多月。 说到这大家应该会有一个疑难了,怎么能够用到40000颗CPU来进行渲染呢?什么电脑能有这么多CPU呢?其实这就是离线渲染在概念上,容易让人误会的中央:离线渲染大多数状况反而恰好是在线的。 通常状况,如果咱们在做家装效果图,是能够用本人的一台一般电脑去进行渲染制作的,然而本人的电脑硬件配置必定不会特地好。 因而,实现整套渲染计算的过程到最终出图是须要很长时间的,当然电脑硬件越好,工夫越短。 如果是业余的设计团队,尽管是须要使用离线渲染达到很高的渲染成果,同时必定也是心愿出图的工夫越短越好。 因而就呈现了一种新的离线渲染状态:渲染农场。说到渲染农场置信很多人都不生疏,它就是在云端买了很多渲染服务器,这些服务器能够搭建成千上万颗CPU或者GPU的集群,来专门服务那些须要疾速实现离线渲染的用户。 这就是为什么《阿凡达》的渲染会用到那么多CPU的起因,当然当初根本都是采纳GPU来进行渲染工作了。渲染农场其实就是搭建了渲染服务器集群,那当然就是在线的了。所以说,只有提到渲染农场,它是离线渲染场景中的一种渲染模式,然而实际上它恰好是在线的。 云渲染 云渲染(Cloud Rendering),这个从字面意义了解就是在云端实现渲染的意思。然而为什么下面讲到渲染农场的时候,并没有特意强调它就是云渲染呢? 其实如果依照渲染产生的节点来说,渲染农场这种离线渲染就是属于云渲染领域的。然而,咱们通常对于云渲染的了解,个别都是在云端实现实时渲染的场景。下面咱们提到的实时渲染大部分时候都是在咱们本人本地的电脑或者手机上实现的,因而对于终端硬件的要求是比拟高的,不然“卡顿”必定是无奈防止的。 云渲染的呈现就是为了解决这个问题:让硬件性能不太好的终端也能够实时的渲染成果不错的3D内容。 云渲染的基本原理是,把所有的3D渲染工作都交给云端。渲染实现后,编码成为视频实时地传送给咱们的客户端,客户端就变成了一个视频播放器,对视频流进行解码和播放,这个过程中能够监听一些鼠标和键盘操作,来实现交互性能。 这样大量的三维数据和美术资源不必装置到咱们的手机或者电脑的客户端,而是全副在云端实现渲染,客户端只有具备看视频的性能,就能够体验具备比拟好渲染成果的3D利用。对于公众来说,手机设施不必特地高配,就能够体验成果很好的游戏,而且手机个别也不会发烫了。目前云渲染的场景次要也是体现在游戏场景中,即云游戏。当然还包含一些对渲染品质要求比拟高的3D可视化或者数字孪生我的项目。 说到这里,大家对于实时渲染,离线渲染和云渲染这三种不同的渲染模式,应该有根本的了解了。其实说到渲染自身,就是一个数学算法在计算机上的运算过程。它们都有各自的优劣和应用场景: 01、实时渲染 谋求渲染速度,要求比拟强的交互体验。所以即使在客户端硬件性能较高的状况下,也要做大量的数学算法优化,在不是特地升高渲染成果的同时,缩小渲染工夫,达到很好的实时性交互。 02、离线渲染 谋求渲染品质,不要求实时性和交互性。谋求的是极致的渲染成果,达到以假乱真的体验。因而就用最极致最优良最贴近实在物理原理的渲染算法,来进行真实度极高的渲染过程。通过渲染农场的云端计算能力,尽量地缩小渲染工夫。 03、云渲染 谋求绝对较高的渲染品质同时,也要达到实时性要求。所以云端算力的部署和调度的能力要求会更高,让客户端配置不高的用户通过云渲染也能领会到不错的3D利用。

June 24, 2022 · 1 min · jiezi

关于算法:refdiff插件的计算提交版本差异算法

本文作者:Nddtfjiang个人主页:https://github.com/mappjzc 什么是 计算提交版本差别(CalculateCommitsDiff)?咱们经常须要计算两个提交版本之间的差别。具体的说,就是须要晓得两个不同的分支/标签之间相差了哪些提交版本。 对于个别用户来说,通过计算提交版本差别,用户能迅速的判断两个不同的分支/标签之间在性能、BUG 修复等等方面的区别。以帮忙用户抉择不同的分支/标签来应用。 而如果只是应用 diff 命令来查看这两个不同的分支/标签的话,大量庞杂冗余的代码批改信息就会毫无组织的混淆在其中,要从中提取出具体的性能变更之类的信息,等同于海底捞针。 对于一款致力于晋升研发效力的产品来说,通过计算提交版本差别,就能查看一组组不同的分支/标签的变迁情况,这一数据的获取,有助于咱们做进一步的效力剖析。 例如,当一个我的项目的管理者,想要看看为什么最近的几个版本发版越来越慢了的时候。就能够对最近的几组分支/标签来计算计算提交版本差别。此时有些分支/标签组之间有着大量的提交版本,而有些分支/标签组之间有着较少的提交版本。我的项目管理者能够更进一步的计算这些提交版本各自的代码当量,把这些数据以图表的模式展现进去,最终失去一组很直观的分支/标签的图像。此时他或者就能发现,原来是因为最近的几次发版波及到的变更越来越简单了。通过这样的直观的信息,开发者和管理者们都能做出相应的调整,以便晋升研发效力。 已有的解决方案当咱们在 GitLab 上关上一个代码仓库的时候,咱们能够通过在 url 开端追加 compare 的形式来进入到仓库的比对页面。 在该页面,咱们能够通过设置源分支/标签 和指标分支/标签让 GitLab 向咱们展现 指标分支落后于源分支哪些版本,以及落后了多少个版本。 设置结束后,GitLab 会展现如下: 在这里,咱们能看到咱们抉择的指标分支/标签比源分支/标签少了如图所示的提交版本(Commits) 然而遗憾的是,像 GitLab 这类解决方案,都没有做批量化,自动化的解决。也更没有对后续的计算出来的后果进行相应的数据汇总解决。用户面对海量的分支提交的时候,既不可能手动的一个一个去比拟,也不可能手动的去把数据后果本人复制粘贴后再剖析。 因而 DevLake 就必须要解决这个问题。 所谓的计算提交版本差别具体是在计算什么?以 GitLab 的计算过程为例来说的话,所谓的计算提交版本差别也就是当一个提交版本在源分支/标签中存在,然而在指标分支/标签中不存在的时候,这个提交版本就会被 GitLab 给逮进去。 那么,或者有人会问,如果一个提交版本在源分支/标签中不存在,相同的,在指标分支/标签中存在,那是不是也会被抓起来呢? 答案是,不会。 也就是说,当咱们计算提交版本的差别的时候,咱们只关怀指标分支/标签短少了什么,而并不关怀指标分支/标签多进去了什么货色。 这就如同以前有一位算法比赛的学生,在 NOI 较量完结后被相干学校面试的时候,一个劲的自我介绍本人负责过什么广播站青协学生会,什么会长副会长之类的经验。后果很快就惹得面试官老师们忍气吞声的告诫道: 咱们只想晓得你信息学方面的自我介绍,其余的我都不感兴趣!!!在计算提交版本差别时,GitLab 是这样。 GitHub 也是这样。事实上,在应用 git 命令 git log branch1...branch2 的时候,git 也是这样的。 它们都只关怀指标分支/标签绝对于源分支/标签短少的局部。 计算提交版本差别实际上就是: 计算待计算的指标分支/标签绝对于源分支/标签短少了哪些提交版本。对提交版本进行数学建模想要做计算,那么首先,咱们须要把一个形象的事实问题,转换成一个数学问题。 这里咱们就须要进行数学建模了。 咱们须要把像指标分支/标签、源分支/标签、提交版本 这样一系列的概念变成数学模型中的对象。 如此咱们能力为其设计算法。 想当然的,咱们就想到了应用图的形式来进行数学建模。 咱们将每一个提交版本都看作是图上的一个节点,把提交版本合并之前的一组提交版本与以后提交版本之间的父子关系,看作成是一条有向边。 因为指标分支和源分支事实上也各自与一个特定的提交版本相绑定,因而也能将它们看作是图上的特地节点。 将指标分支/标签所对应的节点,命名为旧节点将源分支/标签所对应的节点,命名为新节点当然,这里咱们还有一个须要特地关注的节点,就是初始的提交版本所代表的节点 将初始提交版本所对应的节点,命名为根节点上述的形容或者显得有点儿形象。 ...

June 23, 2022 · 3 min · jiezi

关于算法:融云让银行轻松上云

金融科技政策解读2021 年 12 月 31 日,中国人民银行印发《金融科技倒退布局( 2022-2025 年)》(以下简称《布局》),提出新期间金融科技倒退领导意见,明确金融科技的倒退愿景是:力争到 2025 年,整体程度与外围竞争力实现跨越式晋升。 并提出八个方面的重点工作,其中包含:强化金融科技治理,全面塑造数字化能力;建设绿色高可用数据中心;深入数字技术金融利用;放慢监管科技的全方位利用,强化数字化监管能力建设;扎实做好金融科技人才培养,继续推动规范规定体系建设等。 这是央行编制的第二轮金融科技倒退布局。2019 年 8 月,央行颁布首轮金融科技倒退布局——《金融科技( FinTech )倒退布局( 2019—2021 年)》,确定了六方面重点工作:一是增强金融科技战略部署;二是强化金融科技正当利用;三是赋能金融服务提质增效;四是加强金融风险技防能力;五是强化金融科技监管;六是夯实金融科技根底撑持。 首轮布局的次要倒退指标是“立柱架梁”,到 2021 年建立健全我国科技倒退的 “四梁八柱”,进一步加强金融业科技利用能力,实现金融与科技深度交融、协调倒退。 相比之下,本轮《布局》着重在解决金融科技倒退不均衡不充沛等问题,推动金融科技健全治理体系,欠缺数字基础设施,促成金融与科技更深度交融、更继续倒退,更好地满足数字经济时代提出的新要求、新工作,推动我国金融科技从“立柱架梁”全面迈入“积厚成势”新阶段。 能够看出,本轮《布局》重点已从“施展金融科技赋能作用”向“金融数字化转型”迈进。实际上,我国金融科技在数字化建设路线上,从未进行过摸索,从部分数字化到全流程数字化,一直发明新历史。但与此同时也面临诸多挑战,数字化浪潮下智能技术利用问题日益凸显,金融科技倒退也给金融消费者爱护带来新挑战。 为此,银保监会已出台多项动作,就销售流程中的音视频双录、销售行为可回溯等多个作业场景提出了具体的监管要求。 银行业现状剖析新冠肺炎疫情暴发以来,无接触服务成了不少金融科技企事业单位的“必修课”,对银行来说,线上服务与经营日渐被器重,尤其是近程银行不断深入倒退。次要体现在数据驱动的智能化、平台撑持的场景化,对批发银行数字化转型作用也日益浮现。事实上,近程银行的倒退已演绎出新业态,开启了“非接触金融服务新时代”,外延服务价值一直晋升,内涵服务边界继续扩充。 但作为银行数字化建设外围的“数据”,却大多处于沉睡状态,多维度数据无奈聚合,结构化指标难以实现,数据孤岛问题频现。这种状况下,中台的架构设计显得尤为重要及紧迫。 而面对前端业务部门数字化新需要,很多银行受制于传统技术能力,难以疾速响应、继续迭代,经常呈现数字化建设与需要脱节的状况。 另外,传统以客户经理为核心,局限于线下网点拓客的形式逐步显现出效用有余、客户覆盖面无限的弊病。 以后银行业痛点融云在金融行业已深耕多年,凭借多年服务银行业的教训,咱们认为目前局部银行大多面临以下几大难题: 获客方面:私域流量无限、获客难、促活难以及客户转化率低。中台方面:通信平台根底建设有余、近程银行业务零碎缺失;传统业务零碎繁多,未造成统一标准;企业架构布局凌乱,数据孤岛问题重大。技术方面:前端业务场景类别繁多,但研发针对业务需要响应速度慢。业务办理方面:线上办理模式缺失,线下办理便捷度有余,客户体验不佳。合规方面:危险提醒与记录留痕成重要需要,银行现有业务零碎无奈满足新形势下的合规需要。 融云金融行业解决方案基于上述金融政策、银行业现状及其需要与趋势,融云从“助力行业倒退,深度赋能行业客户”的倒退理念登程,特地推出更适宜金融行业数字化建设的解决方案,可满足银行变革业务办理模式、拓展客户覆盖面、晋升用户体验和合乎监管合规等多种需要。 融云作为当先的寰球互联网通信云服务商,基于 IM 即时通讯能力、 RTC 实时音视频能力和视频双录-Demo 能力,为银行业数字化降级全面赋能,笼罩视频面签、在线理财、金融贷款、保险双录等多个场景。图:线上营业厅场景化利用零碎 线上营业厅场景化利用零碎整体架构分为 3 层,包含:银行面向客户的 C 端入口、银行外部的经营平台以及银行面向外部员工的 B 端利用。 “线上营业厅”看上去像是一个商店,撑持数字化经营主力军是源源不断的新流量。所以在流量入口,融云不仅为客户现有生态系统提供能力撑持,还为其在企微、电商以及智慧城市等第三方场景平台做撑持,助力银行获取更多流量,帮忙银行将现有业务能力晋升至更高层次。 海量流量引入后,在“线上营业厅”办理各种业务。为此,融云为线上营业厅平台提供了核心技术能力:基于 RTC 音视频能力和 IM 即时通讯能力封装的场景化利用组件打造的音视频通信中台,提供业务办理所需组件并撑持组件扩大能力,次要包含交融双录、智能调度、流程策略引擎、平安加密、会话监控质检等能力。 另外,还反对第三方 AI 能力兼容,帮忙客户建设连贯通信通道和互动能力。在上述能力根底上,联合流程引擎为前端业务响应提供疾速且敌对的撑持,满足前端业务动静需要。 虚构背景为每个坐席设置不同背景,为客户在物理装修上节约大笔费用;尤其是对于多法人多机构的企业,可带来极大便捷。交融双录基于纯音频和音视频的双录组件,联合水印、白板、屏幕共享、文件共享等多种交互组件于一体的根底能力,实用于多种业务场景。智能调度依据用户级别、业务需要等路由规定引擎进行坐席调配。业务需要蕴含坐席闲暇时长、坐席等级、坐席技能、呼入场景、坐席所属网点、插队等。流程策略引擎流程引擎将多种技术能力通过利落拽的形式进行设置,可能疾速响应业务变更,帮忙业务疾速上线,极大晋升员工上岗速度,加重员工培训累赘。平安加密针对金融行业数据安全高保障需要,对数据传输、存储进行端到端加密,反对国密算法。会话监控质检对每一次双录进行文件品质检测,实时预警,全面晋升数据品质。 截至目前,线上营业厅根本可撑持高柜、低柜和挪动多种交易场景。不过,任何新型交易场景的实现都须要全新技术的撑持。融云基于弱小的底层技术能力,确保全业务流程运行晦涩稳固。 近程银行业务流程图身份认证↓呼叫排队↓信息采集↓业务办理↓电子签章↓服务评估 除此,融云提供公有云、公有云、混合云等部署计划,反对集群、高可用、两地三核心部署。公有云部署可实现整体线上营业厅平台齐全在内网部署;混合云部署可实现音视频云端部署,其余能力本地化部署。 在安全性方面,融云反对适应内外网分层网络架构治理,反对金融行业对数据和信息流向可管控、可审计的需要,内外网不同服务各司其职,可将对接服务和媒体网关搁置在数据缓冲区域,抵挡内部威逼间接入侵内网外围,避免外部信息透露,隔离爱护外围数据,满足金融严格网络安全要求。 另外,融云产品已全面适配国产化 CPU 、操作系统、数据库及中间件等,并组建了专门的适配团队,包含服务端研发、PC 端研发和 DevOps 的部署施行等人员,致力于改善国内安全通信国产化过程、规范和利用建设。 金融行业解决方案价值通过融云金融行业解决方案的部署,将帮忙银行实现以下四个方面的成果: 实现高效获客。帮忙银行晋升客户流量宽度,晋升客户转化率。晋升客户体验。晋升银行业务办理的实时性与业务办理品质,满足客户足不出户办理业务的需要,极大晋升客户体验,进步银行品牌度与客户粘性。满足监管合规与平安需要。金融双录性能,保障数据安全可靠,满足金融监管与合规需要,同时也保障了金融业务的可回溯性。满足银行低成本、高效率要求。依靠于融云高质量的代码和运算逻辑,可保障所提供服务均具备高性能、硬件资源占有率低等个性,充沛满足客户对低成本、高效率的要求。 结语将来,融云将踊跃推动国内金融数字化基建欠缺,深度参加金融畛域数字化,继续为金融行业数字化转型提供技术撑持。 ...

June 23, 2022 · 1 min · jiezi

关于算法:NFNetNFResNet的延伸不用BN的4096超大batch-size训练-21年论文

论文认为Batch Normalization并不是网络的必要结构,反而会带来不少问题,于是开始钻研Normalizer-Free网络,心愿既有相当的性能也能反对大规模训练。论文提出ACG梯度裁剪办法来辅助训练,能无效避免梯度爆炸,另外还基于NF-ResNet的思维将SE-ResNet革新成NFNet系列,能够应用4096的超大batch size进行训练,性能超过了Efficient系列 起源:晓飞的算法工程笔记 公众号 论文: High-Performance Large-Scale Image Recognition Without Normalization 论文地址:https://arxiv.org/abs/2102.06171论文代码:https://github.com/deepmind/deepmind-research/tree/master/nfnetsIntroduction 目前,计算机视觉的大部分模型都得益于深度残差网络和batch normalization,这两大翻新可能帮忙训练更深的网络,在训练集和测试集上达到很高的准确率。特地是batch normalization,不仅可能平滑损失曲线,应用更大的学习率和batch size进行训练,还有正则化的作用。然而,batch normalization并不是完满,batch normalization在实践中有三个毛病: 计算耗费大,内存耗费多。在训练和推理上的用法不统一,并且带来额定的超参数。突破了训练集的minibatch的独立性。 其中,第三个问题最为重大,这会引发一系列的负面问题。首先,batch normalization使得模型难以在不同的设施上复现精度,而且分布式训练常常出问题。其次,batch normalization不能用于要求每轮训练样本独立的工作中,如GAN和NLP工作。最初,batch normalization对batch size非常敏感,在batch size较低时体现较差,限度了无限设施上的模型大小。 因而,只管batch normalization有很弱小的作用,局部研究者仍在寻找一种简略的代替计划,不仅须要精度相当,还要能用在宽泛的工作中。目前,大多数的代替计划都着力于克制残差分支的权值大小,比方在残差分支的开端引入一个初始为零的可学习的标量。但这些办法不是精度不够,就是无奈用于大规模训练,精度始终不如EfficientNets。 至此,论文次要基于之前代替batch normalization的工作,尝试解决其中的外围问题,论文的次要奉献如下: 提出Adaptive Gradient Clipping(AGC),以维度为单位,基于权值范数和梯度范数的比例进行梯度裁剪。将AGC用于训练Normalizer-Free网络,应用更大batch size和更强数据加强进行训练。设计Normalizer-Free ResNets系列,命名为NFNets,在ImageNet上达到SOTA,其中NFNet-F1与EfficientNet-B7精度相当,训练速度快8.7倍,最大的NFNet可达到86.5%top-1准确率。试验证实,在3亿标签的公有数据集上预训练后,再在ImageNet上进行finetune,准确率能比batch normalization网络要高,最好的模型达到89.2%top-1准确率。Understanding Batch Normalization 论文探讨了batch normalization的几个长处,这里简略说一下: downscale the residual branch:batch normalization限度了残差分支的权值大小,使得信号偏差skip path间接传输,有助于训练超深的网络。eliminate mean-shift:激活函数是非对称且均值非零的,使得训练初期激活后的特征值会变大且均为负数,batch normalization恰好能够打消这一问题。regularizing effect:因为batch normalization训练时用的是minibatch统计信息,相当于为以后batch引入了噪声,起到正则化的作用,能够避免过拟合,进步准确率。allows efficient large-batch training:batch normalization可能平滑loss曲线,能够应用更大的学习率和bach size进行训练。Towards Removing Batch Normalization 这篇论文的钻研基于作者之前的Normalizer-Free ResNets(NF-ResNets)进行拓展,NF-ResNets在去掉normalization层后仍然能够有相当不错的训练和测试准确率。NF-ResNets的外围是采纳$h_{i+1}=h_i+\alpha f_i(h_i/\beta_i)$模式的residual block,$h_i$为第$i$个残差块的输出,$f_i$为第$i$个residual block的残差分支。$f_i$要进行非凡初始化,使其有放弃方差不变的性能,即$Var(f_i(z))=Var(z)$。$\alpha=0.2$用于管制方差变动幅度,$\beta_i=\sqrt{Var(h_i)}$为$h_i$的标准差。通过NF-ResNet的residual block解决后,输入的方差变为$Var(h_{i+1})=Var(h_i)+\alpha^2$。 此外,NF-ResNet的另一个外围是Scaled Weight Standardization,用于解决激活层带来的mean-shift景象,对卷积层进行如下权值从新初始化: ...

June 23, 2022 · 1 min · jiezi

关于算法:技术实践-场景导向的音视频通话体验优化-原创

(点击报名) 在古代生存中,音视频通话是咱们最常应用的沟通形式之一。比方,社交中的一对一音视频,医疗中的近程问诊征询,房产交易中的线上看房,以及近程工作场景下随时随地可能产生的一对一和群组音视频沟通。*本文转自公众号【融云寰球互联网通信云】,回复 抽奖 获福利。 而咱们在应用中也多少感触过产品逻辑的“卡壳”,比方音视频无奈自在切换、1V1 不能降级群聊、退出群视频无奈随时退出等等。6 月 16 日,融云 RTC · 进阶实战高手课聚焦音视频通话,从音视频通话实现、多场景体验痛点和融云 New CallLib 的最佳实际等方面,拆解音视频通话在多种应用场景下面临的体验挑战,分享优化计划。后盾回复【通话】获取残缺课件 音视频通话实现咱们通常说的音视频通话,指相似微信等必须含有呼叫流程的利用场景。有一个主叫和一个或多个被叫,主叫发动通话,被叫能够抉择接听或者挂断。音视频通话的应用场景十分多,特地是当咱们正在经验一场大型数字化转型时。 比方,近程问诊,医生能够通过音视频通话对患者进行沟通从而不便诊断;VR 看房,房产中介通过音视频通话和租客进行沟通,联合 VR 实现近程看房;线上相亲,红娘能够通过群聊让相亲对象交换,这是一个群组的音视频通话应用场景。 (音视频通话应用场景) 音视频通话呈现在咱们线上生存的方方面面,也是各类利用的必要能力。那么,如何实现一个音视频通话呢? 从须要把握的基本知识方面来看,大体分三个局部,音视频、网络传输和服务器。这是一个非常复杂的零碎,这里只做大略形容。(RTC 基本知识) 音视频音视频的基础知识:音视频的采集,不同的平台采集办法有所不同。开发者须要把握元数据的基本知识,也就是咱们通过采集间接失去的数据格式。 音视频数据的解决:要把握音频降噪、音频的回音打消、图像的裁剪等。 音视频的编解码:至多要把握一种音频编码和一种视频编码。 编码格局有对应的解码器,比拟通用的编码格局还能够应用硬件解码,可依据解决方案的不同抉择软解还是硬解。软解的兼容性高,但会损耗 CPU 性能,硬解性能好,但可能面对一些兼容性问题。 音视频的播放和渲染也是必须把握的,通常播放和渲染指的是对元数据的播放和渲染,音频其实就是 PCM 的播放,视频如果是客户端会用到 OpenGL,浏览器须要用到 WebGL 等。 网络传输客户端能够抉择 TCP 或 UDP,通常音视频应用 UDP 传输,这是因为音视频数据要求的是实时性,而不是完整性,音视频的数据即便不残缺也能够失常播放。 TCP 和 QUIC 都是可靠性传输协定,相似业务信令数据等要求完整性的更多应用 TCP 或者 QUIC。 QUIC 协定是建设在 UDP 协定上的一种保障完整性的协定。UDP 自身是不牢靠协定,如果要保障完整性就须要本人做丢包重传策略,而 QUIC 是具备丢包重传策略的一套数据协定,能够达到与 TCP 同样的成果。 服务器通常分为信令服务器和音视频服务器。顾名思义,信令服务器负责传输业务相干数据,音视频服务器负责传输音视频数据。不同的技术计划对应实现服务器的技术也会有所不同。利用以上基本知识,咱们能够实现音视频通话场景的外围逻辑了。在思考和呼叫场景强相干的业务解决之前,要先解决以下两个问题。 首先是业务数据的即时传输。要发动一个通话,要有主叫端、被叫端两个客户端。被叫端如何收到主叫端发送的发动信令?能够应用 Push+长链接的模式,或者第三方提供的 IM SDK 来实现。 接下来是更要害的音视频根底能力,以及音视频数据的实时传输能力。 开发者如若自研,能够抉择 WebRTC,这是 Google 提供的一套具备音视频根底能力及传输能力的残缺开源计划;或者能够从头自研一套残缺的 RTC 零碎。当然,不论是抉择哪种自研计划,都有非常复杂的底层常识须要学习,须要有相当的研发能力和人员配备。 ...

June 21, 2022 · 1 min · jiezi

关于算法:浅谈融云即时通讯服务日志优化

《神探狄仁杰》剧迷们对狄仁杰的断案能力极为叹服,狄小孩儿总是能将十分诡异的案件查得上不着天;下不着地,连武则天都赞他“神乎其技”。实际上,狄仁杰之所以被称为“神探”,很大一部分起因,是他善于通过极为细小的线索推导、还原,进而破案。关注【融云 RongCloud】,理解协同办公平台更多干货。 对应到软件开发上,用来记录零碎或程序运行状态的日志,已成为程序运行问题的重要“线索”,它能够记录程序运行过程,疾速定位问题,便于程序的监控和优化。 日志应用Java 畛域有多种日志框架,Log4j2 是其中一种。Log4j2 凭借可配置化的集成形式、简略的 API、弱小的性能及性能劣势,成为 Java 畛域应用最宽泛的日志解决方案。 融云即时通讯服务的日志框架抉择的就是 Log4j2。 日志级别Log4j2 定义了 8 个日志级别,别离是:OFF、FATAL、ERROR、WARN、INFO、DEBUG、TRACE、 ALL。其中罕用的日志级别是4个,优先级从低到高为 DEBUG、INFO、WARN、ERROR。 DEBUG指定细粒度信息事件是最有用的利用程序调试,次要用于开发过程中打印一些运行信息。 INFO指定可能突出在粗粒度级别的利用程序运行状况的信息,能够帮忙程序员无效理解程序的流转,可用于生产环境中输入程序运行的一些重要信息。 WARN指定具备潜在危害的状况,有些信息是错误信息,但也须要给程序员的一些提醒。 ERROR谬误事件,可能依然容许应用程序持续运行,打印谬误和异样信息。 日志性能日志打印对服务器性能产生损耗,会增大服务的提早,升高服务吞吐量。尤其在高并发大业务量状况下,日志打印得越多,服务的性能损耗越大。 即时通讯服务在进行压力测试过程中,开启 INFO 级别日志与开启 ERROR 级别日志做比拟,随着业务量级的增大,服务的性能损耗也一直增大。 而在理论运行中,因私有化部署的束缚和对问题排查便利性的思考,即时通讯服务往往是开启 INFO 级别日志,这就对在 INFO 级别下即时通讯服务的性能提出了更严厉的考验和更高的要求。 为此,融云即时通讯服务除了做好日志级别分类和日志内容精简外,还进行了相干优化。 日志优化敞开 Location 信息如果 Log4j 配置了%C or $class, %F or %file, %l or %location, %L or %line, %M or %method 等配置项,Log4j 将会获取堆栈的快照,遍历堆栈轨迹来获取 Location 信息,从而影响性能。 对于同步日志记录器来说,速度要慢 1.3 - 5 倍;对于异步日志记录器而言,获取堆栈快照的性能影响甚至更大,因为有地位的日志记录比没有地位的日志记录慢 30-100 倍。因而,异步日志记录器和异步附加器在默认状况下不蕴含地位信息。 所以,融云即时通讯服务去掉了 %C or $class, %F or %file, %l or %location, %L or %line, %M or %method 等配置,通过在日志中增加类名以及埋点标识的形式用于疾速定位问题代码。 ...

June 20, 2022 · 1 min · jiezi

关于算法:ME-273-Finite-Element

ME 273 Finite Element Methods in Engineering Department of Mechanical EngineeringME 273-Finite Element Methods in Engineering, Fall 2021Course and Contact InformationClass Days/Time: No days/time; i.e. asynchronous with few optional in-person sessionsOptional Discussion Sessions: Tu & Th 16:30-17:30 via Zoom: https://sjsu.zoom.us/my/armaniClassroom: Engineering 213/215 for in-person sessionsPrerequisites: BSME or Instructor ConsentInstructor: Dr. Amir ArmaniOffice Location: Engineering 310ETelephone: 408-924-8354Course FormatThis is a hybrid class, with mostly asynchronous online sessions and a few optional in-person sessions. It requires use ofthe Canvas learning management system, accessed via https://sjsu.instructure.com. Course materials, including syllabus,lecture videos, slides, assignments, and projects will be gradually uploaded on Canvas. Successful completion of courserequirements necessitates accessing the course website frequently, typically at least twice a week on a regular basis.Technical support for Canvas is available at http://www.sjsu.edu/at/ec/can... Important communications regarding thisclass may be sent via Canvas or to email addresses listed in MySJSU, and thus each student is expected to maintain up-to-date contact information in both systems.Course Description http://info.sjsu.edu/web-dbge...Introduction into various finite element methods for developing stiffness equation. Truss, beam, 2-D, 3-D andaxisymmetric elements. Applications and case studies.Course Learning OutcomesUpon successful completion of this course, students will be able to: ...

June 20, 2022 · 8 min · jiezi

关于算法:运筹优化工具ortools解读与实践概览

背景在咱们的工作和生存中,有十分多带有束缚的问题须要解决。例如, 在估算无限的状况下,如何买到区位、学区、楼龄、户型都比较满意的房子?散布在北京各个地区的几个哥们要聚餐,抉择哪个餐厅能力让大家通行间隔比拟靠近,餐厅口味也不错?公司有一个由10辆车组成的车队,从仓库登程为100家企业配送物资,每家企业都有不同的收货工夫窗口,物资体积、分量也各不相同,同时,车辆有其最大载容、载重及最大行驶间隔。如何做车辆与企业匹配和门路布局,可能满足要求的同时最小化老本?解决这类问题有比拟罕用的套路,即便不理解运筹优化底层原理,也可能疾速解决问题: 定义问题建模问题利用成熟的求解器求解问题在求解器中,能够分为商业求解器和开源求解器。财大气粗的传统行业以购买商业求解器为主,通常解决的问题规模大、计算性能好;互联网公司以开源求解器为主,稍逊色,益处是收费,个别场景下也够用了。当然,如果问题比拟非凡(e.g.时效要求较高),须要自行编码实现求解过程。 咱们接下来要介绍的ortools是google开源的一种运筹优化工具。之所以称为“工具”,是因为ortools不仅自研了cpsat求解器,也提供了对开源求解器(e.g.SCIP)、商业求解器(Gurobi、CPLEX)的反对。 须要补充一点,不同的求解器/工具有其善于之处。就算是开源工具,不同工具也各自优劣。例如,ortools提供了线性规划、整数布局、束缚布局以及后续VRP问题、网络流问题等场景化利用,但ortools API非常匮乏,相干材料较少;jsprit则聚焦在VRP问题,我的项目整体具备比拟好的设计理念,非常适合公司层面的我的项目开发,毛病也比拟显著,它只反对VRP问题。 本系列次要以ortools官网指南为底本,从理论利用的角度登程,解读ortools工具,并提供应用案例及代码解读。 外围模块外围模块大体能够分为两局部,后面3个模块是根底性能: 线性规划(Linear Optimization)整数布局(Integer Optimization)束缚布局(Constraint Optimization)前面5个模块并重场景利用: 调配(Assignment)门路布局(Routing)装箱(Bin Packing)网络流(Network Flows)调度(Scheduling)根底性能线性规划线性规划问题指,指标函数和约束条件都为线性的优化问题。例如, $$\begin{equation}\begin{array}{r}\operatorname{maximize} x_{1}+2 x_{2} \\\text { subject to } x_{1}+x_{2} \leq 3 \\x_{2} \leq 2 \\x_{1} \geq 0 \\x_{2} \geq 0\end{array}\end{equation}$$ 几何含意:在可行域内(4条实线突围的蓝色区域)挪动指标函数(虚线),使得指标函数最大化。 整数布局整数布局个别指束缚变量含有整数的优化问题。例如,常见的背包问题 设有一个背包,其最大承重为 b ,思考 n 件物品,其中第 j 件分量为 \( a_j \) ,其价值为 \(c_j\)。问如何选取物品装入背包中,使得背包内物品的总价值最大? 设决策变量 \(x_j\)取值0或1,示意是否抉择该物品。则背包问题能够示意为下列整数布局: $$\begin{array}{c}\max _{x} \sum_{j=1}^{n} c_{j} x_{j} \\\text { s.t. } \quad \sum_{j=1}^{n} a_{j} x_{j} \leq b \\x \in\{0,1\}^{n}\end{array}$$ ...

June 19, 2022 · 1 min · jiezi

关于算法:comp10002-基础算法

School of Computing and Information Systemscomp10002 Foundations of AlgorithmsSemester 2, 2021Assignment 2Learning OutcomesIn this project, you will demonstrate your understanding of dynamic memory and linked data structures (Chapter10) and extend your program design, testing, and debugging skills. You will also learn about Artificial Intelligenceand tree search algorithms, and implement a simple algorithm for playing checkers.CheckersCheckers, or draughts, is a strategy board game played by two players. There are many variants of checkers.For a guide to checker’s families and rules, see https://www.fmjd.org/download...and_rules.pdf. Your task is to implement a program that reads, prints, and plays our variant of the game.(d) Legal capturesFigure 1: Example board configurations, moves, and captures.Setup. An 8x8 chessboard with 12 black and 12 white pieces initially positioned as shown in Figure 1a.Gameplay. Each player plays all pieces of the same color. Black open the game by making a move, then whitemake a move, and then players alternate their turns. In a single turn, the player either makes a move or capture.For example, the arrow in Figure 1a denotes an opening move of the black piece from cell G6 to cell F5.Moves. A piece may move to an empty cell diagonally forward (toward the opponent; north for black and southfor white) one square. The arrows in Figure 1b show all the legal moves of black and white pieces.Towers. When a piece reaches the furthest row (the top row for black and the bottom row for white), it becomesa tower (a pile of pieces). The only move of the white piece at cell D7 in Figure 1b promotes it to the tower. Atower may move to an empty cell diagonally, both forward and backward, one square. The arrows in Figure 1cshow all the legal moves of black and white towers.Captures. To capture a piece or a tower of the opponent, a piece or a tower of the player jumps over it and landsin a straight diagonal line on the other side. This landing cell must be empty. When a piece or tower is captured,it is removed from the board. Only one piece or tower may be captured in a single jump, and, in our variant ofthe game, only one jump is allowed in a single turn. Hence, if another capture is available after the first jump, itcannot be taken in this turn. Also, in our variant of the game, if a player can make a move or a capture, they maydecide which of the two to complete. A piece always jumps forward (toward the opponent), while a tower canjump forward and backward. The arrows in Figure 1d show all the legal captures for both players.Game end. A player wins the game if it is the opponent’s turn and they cannot take action, move or capture,either because no their pieces and towers are left on the board or because no legal move or capture is possible.Input DataYour program should read input from stdin and write output to stdout. The input should list actions, one perline, starting from the initial setup and a black move. The input of moves and captures can be followed by asingle command character, either ‘A’ or ‘P’. Action should be specified as a pair of the source cell and the targetcell, separated by the minus character ‘-’. For example, “G6-F5” specifies the move from cell G6 to cell F5.1The following file test1.txt uses eleven lines to specify ten actions, followed by the ‘A’ command.Stage 0 – Reading, Analyzing, and Printing Input Data (8/20 marks)The first version of your program should read input and print the initial setup and all legal actions. The first 42lines that your program should generate for the test1.txt input file are listed below in the two left columns.1 BOARD SIZE: 8x82 #BLACK PIECES: 123 #WHITE PIECES: 124 A B C D E F G HLines 1–21 report the board configuration and specify the initial setup from Figure 1a. We use ‘b’ and ‘w’characters to denote black and white pieces, respectively. Then, lines 22–42 print the first move specified in thefirst line of the input. The output of each action starts with the delimiter line of 37 ‘=’ characters; see line 22.The next two lines print information about the action taken and the cost of the board; see lines 23 and 24. Thecost of a board is computed as b + 3B − w − 3W, where b, w, B, and W are, respectively, the number of blackpieces, white pieces, black towers, and white towers on the board; that is, a tower costs three pieces. Then, yourprogram should print the board configuration that results from the action. The complete output your programshould generate in Stage 0 for the test1.txt input file is provided in the test1-out.txt output file.If an illegal action is encountered in the input, your program should select and print one of the following sixerror messages. Your program should terminate immediately after printing the error message.1 ERROR: Source cell is outside of the board.2 ERROR: Target cell is outside of the board.3 ERROR: Source cell is empty.4 ERROR: Target cell is not empty.5 ERROR: Source cell holds opponent’s piece/tower.6 ERROR: Illegal action.The conditions for the errors are self-explanatory and should be evaluated in the order the messages are listed.Only the first encountered error should be reported. For example, if line 2 of the test1.txt file is updated tostate “G2-A8”, line 43 of the corresponding output should report: “ERROR: Target cell is not empty.”Stage 1 – Compute and Print Next Action (16/20 marks)If the ‘A’ command follows the input actions (see line 11 in the test1.txt file), your program should computeand print the information about the next Action of the player with the turn. All of the Stage 0 output should beretained. To compute the next action, your program should implement the minimax decision rule for the treedepth of three. Figure 2 exemplifies the rule for the board configuration in Figure 3a and the turn of black.First, the tree of all reachable board configurations starting from the current configuration (level 0) and of therequested depth is constructed; if the same board is reachable multiple times in the same tree, the correspondingtree node must be replicated. For example, black can make two moves in Figure 3a: the tower at A6 can moveto B5 (Figure 3b) and the piece at C8 can move to D7 (Figure 3c); see level 1 in Figure 2. The tree in Figure 2explicitly shows nodes that refer to 15 out of all 30 board configurations in the minimax tree of depth three forthe black turn and the board from Figure 3a. The labels of the nodes refer to the corresponding boards shownin Figure 3. For instance, nodes with labels (f)–(h) at level 2 of the tree refer to the boards in Figures 3f to 3h,respectively, which are all the boards white can reach by making moves and captures in the board in Figure 3c.Figure 2: A minimax tree.Second, the cost of all leaf boards iscomputed; see the nodes highlighted witha gray background (level 3). For example,six board configurations at level 3 of thetree can be reached from the board in Figure3d. The boards in Figures 3i and 3jhave the cost of 3, while the four boardsreachable via all moves of the tower at cellB5 in board (d), not shown in the figure,have the cost of 2. Intuitively, a positivecost suggests that black win, a negativecost tells that white win, and the magnitude of the cost indicates the advantage of one player over the other.Third, for each possible action of the player, we check all possible actions of the opponent, and choose thenext action of the player to be the first action on the path from the root of the tree toward a leaf node for which theplayer maximizes their gain while the opponent (considered rational) aims to minimize the player’s gain; see thered path in Figure 2. Black take actions in the boards at level 2 of the tree. At this level, black aim to maximizethe gain by choosing an action toward a board of the highest cost. This is cost 3 for board (d) toward boards(i) and (j), 1 for (e) toward (k), 0 for (f) toward (m), 1 for (g) toward (n), and 1 for (h) toward (o); the arrowsfrom level 3 to level 2 encode the cost selections and node labels at level 2 encode propagated costs. White takeactions in the boards at level 1 of the tree. White aim to maximize their gain, which translates into minimizationof the gain by black. Thus, at every board at level 1, white choose an action toward a board at level 2 with thelowest cost propagated from level 3. This is cost 1 for board (b) toward (e), and 0 for (c) toward (f); again, seethe arrows from level 2 to level 1 and the costs as node labels at level 1. Finally, to maximize their gain, blackpick the next action in the game to be the one that leads to the board with the highest propagated cost at level 1.This is move “A6-B5” toward board (b) on the path to (k); assuming white are rational and play “B7-A8” next.To compute the next action for white, the order of max- and min-levels must be flipped. If several childrenof the root have the same propagated maximum/minimum cost, the action to the left-most such child must bechosen. To construct the children, both for black and white turns, the board is traversed in row-major orderFigure 3: Board configurations for possible evolutions of an example checkers endspiel.3and for each encountered piece or tower all possible actions are explored, starting from the north-east directionand proceeding clockwise. Children should be added from left to right in the order they are constructed. Eachcomputed action should be printed with the “*” marker. Lines 1–21 in the right column of the listing in theStage 0 description show the output for the example computed action. Black and white towers are denoted by ‘B’and ‘W’ characters, respectively. Boards in which black or white cannot take an action cost INT MIN and INT MAX,respectively, defined in the <limits.h> library. If the next action does not exist and, thus, cannot be computed,the player loses, and the corresponding message is printed on a new line (“BLACK WIN!” or “WHITE WIN!”).Stage 2 – Machines Game (20/20 marks)If the ‘P’ command follows the input actions, your program should Play ten next actions or all actions until theend of the game, whatever comes first. The game should continue from the board that results after processingthe Stage 0 input. If the game ends within the next ten turns (including the last turn when no action is possible),the winner should be reported. The computation of actions and winner reporting should follow the Stage 1 rules.Important...The outputs generated by your program should be exactly the same as the sample outputs for the correspondinginputs. Use malloc and dynamic data structures of your choice to implement the minimax rule for computingthe next action. Before your program terminates, all the malloc’ed memory must be free’d.Boring But Important...This project is worth 20% of your final mark, and is due at 6:00pm on Friday 15 October.Submissions that are made after the deadline will incur penalty marks at the rate of two marks per dayor part day late. Students seeking extensions for medical or other “outside my control” reasons should emailammoffat@unimelb.edu.au as soon as possible after those circumstances arise. If you attend a GP or otherhealth care service as a result of illness, be sure to obtain a letter from them that describes your illness and theirrecommendation for treatment. Suitable documentation should be attached to all extension requests.You need to submit your program for assessment via the LMS Assignment 2 page. Submission is notpossible through grok. There is a pre-submission test link also provided on the LMS page, so you can try yourprogram out in the test environment. It does not submit your program for marking either. Note that thispre-test service will likely overload and fail on the assignment due date, and if that does happen, it will not be abasis for extension requests. Plan to start early and to finish early!!Multiple submissions may be made; only the last submission that you make before the deadline will bemarked. If you make any late submission at all, your on-time submissions will be ignored, and if you have notbeen granted an extension, the late penalty will be applied. A rubric explaining the marking expectations islinked from the LMS, and you should study it carefully. Marks will be available on the LMS approximately twoweeks after submissions close, and feedback will be mailed to your student email account.Academic Honesty: You may discuss your work during your workshop, and with others in the class, but whatgets typed into your program must be individual work, not copied from anyone else. So, do not give hard copyor soft copy of your work to anyone else; do not have any “accidents” that allow others to access your work;and do not ask others to give you their programs “just so that I can take a look and get some ideas, I won’tcopy, honest”. The best way to help your friends in this regard is to say a very firm “no” if they ask to seeyour program, pointing out that your “no”, and their acceptance of that decision, are the only way to preserveyour friendship. See https://academicintegrity.uni... for more information. Note also thatsolicitation of solutions via posts to online forums, whether or not there is payment involved, is also AcademicMisconduct. In the past students have had their enrolment terminated for such behavior.The FAQ page contains a link to a program skeleton that includes an Authorship Declaration that you must“sign” and include at the top of your submitted program. Marks will be deducted (see the rubric linked fromthe FAQ page) if you do not include the declaration, or do not sign it, or do not comply with its expectations. Asophisticated program that undertakes deep structural analysis of C code identifying regions of similarity willbe run over all submissions. Students whose programs are identified as containing significant overlaps willhave substantial mark penalties applied, or be referred to the Student Center for possible disciplinary action.Nor should you post your code to any public location (github, codeshare.io, etc) while the assignment isactive or prior to the release of the assignment marks. ...

June 19, 2022 · 12 min · jiezi

关于算法:CMPUT-366-智能系统

Computing Science DepartmentCMPUT 366 - Fall 2021Problem SetUnit 2 - LearnersIntelligent Systems (CMPUT 366) Consider the trees below representing zero-sum two-player games. Write the values of x that allowMinimax search with Alpha Beta pruning to prune the dashed nodes. You should write the word‘None’ if no value of x allows the nodes to be pruned. You should assume that the search algorithmvisits the children from left to right.maxminmax8 5 9 5 x 10 20maxminmax5 71xmaxminmaxx 5 5 71The tree below represents a zero-sum two-player game where the green nodes (root of the tree) aremax’s nodes and yellow nodes are min’s nodes. Assuming a left-to-right ordering of visit, prune thebranches that Alpha Beta pruning would prune. This example created by Ariel Felner.Consider the following training set of a regression problem, where given a value of x one wants topredict the value of y with the hypothesis hw(x) = wx + b.1x y123a) Given that w = b = 0 and = 0.1, what are the values of w and b after the first iteration ofgradient descent?b) For = 0.1 the algorithms takes approximately 300 iterations to converge to values of w and bfor which further gradient updates will not decrease the Mean Squared Error of the model. Whathappens if we reduce the value of to 0.01. Do you think it will converge with more or feweriterations than when = 0.1? What is the difference between the solution encountered with = 0.1 and with = 0.01?c) Linear regression learns a linear function of the input values x. Explain two ways we could learna non-linear function of the input values.Consider the classification problem given by the training data below. In this problem we are trying toclassify images of dogs while considering only three binary features: ears, fur, and hat. The column ygives the labels: 0 for an image without a dob and 1 for an image with a dog. For example, the firstimage contains no ears, fur, nor hat and it is labelled as ‘not dog,’ while the last image in the data setcontains ears, fur, and hat and it is labelled as ‘dog’. Considering the training set below, answer thefollowing questions.ears fur hat y0 0 00 0 01 0 01 1 00 1 11 1 1a) Is this problem linearly separable? Justify your answer.b) What if we modify the training so that [1, 1, 0] has the label of 1 instead of 0 and [1, 1, 1] has thelabel of 0 instead of 1, is the problem linearly separable?c) How many hidden layers does a neural network need for solving the problem given by the dataset above where the instance [1, 1, 0] has the label of 1 instead of 0 and [1, 1, 1] has the label of 0instead of 1.Consider the XOR problem shown in the table below. One of your classmates is trying to train aneural network to learn the mapping of x0 and x1 values to the labels in the training data.Your classmate told you that their model is unable to learn the correct mapping from the input valuesto the output values. Suspecting they were using a model with no hidden layers, you asked them to2x0 x1 ¬(x0 ⊕ x1)0 11 00 01 1draw the model they have implemented. Your classmate then draws the following model on the back ofa napkin and they mention that they initialize all weights of the model with the value of zero. Suddenlyyou understand why their model is unable to learn the XOR function. Explain to your classmate whythe weights can’t be initialized with the same value.+1x0x1+1a0a1hwJorge, the capybara, needs your help to compute the Q(s, a) values for the problem below. Jorge startsin position (1, 1) (see the figure below). The states with a dashed squared and with the letter G haveonly the action “Out” available. All other states have the actions up (U), down (D), left (L), and right(R) available. Once Jorge applies the “Out” action it goes to a terminal state in the Markov decisionprocess.The table shows the experiences Jorge has collected by following an -greedy policy. Assuming thatQ(s, a) = 0 for all s and a, = 1 and = 0.5, what are the values of Q(s, a) after processing theexperience shown in the table below with Q-Learning.Sarsa is an on-policy algorithm that employs an -greedy policy to gather experience by interacting withthe environment. Sarsa then learns an optimal -greedy policy by interacting with the environment.If the value of decreases over time and eventually converges to = 0, then Sarsa is able to learn3Episode 1 Episode 2 Episode 3 Episode 4(1, 1), D, (1, 2), 0 (1, 1), D, (1, 2), 0 (1, 1), D, (1, 2), 0 (1, 1), D, (1, 2), 0(1, 2), R, (2, 2), 0 (1, 2), R, (2, 2), 0 (1, 2), R, (2, 2), 0 (1, 2), R, (2, 2), 0(2, 2), U, (2, 1), 0 (2, 2), R, (3, 2), 0 (2, 2), U, (2, 1), 0 (2, 2), R, (3, 2), 0(2, 1), Out, Terminal, -10 (3, 2), R, (4, 2), 0 (2, 1), Out, Terminal, -10 (3, 2), R, (4, 2), 0(4, 2), U, (4, 1), 0 (4, 2), U, (4, 1), 0(4, 1), Out, Terminal, +50 (4, 1), Out, Terminal, +50an optimal policy for the problem. Q-Learning also uses an -greedy policy to gather experience byinteracting with the environment. However, instead of learning an -greedy policy, Q-Learning learnsa greedy policy directly. What are the negative effects if Q-Learning also employed a greedy policy todrive its behavior while interacting with the environment?

June 16, 2022 · 5 min · jiezi

关于算法:ECON4330-Macroeconomics

ECON-4330 Advanced Macroeconomics I Professor Nurlan TurdalievHomework Assignment 3 Fall 2021Due: Friday, November 12, 2021, 6pmProblem 1Consider the economy with monetary expansion studied in class. Assume that u(c1, c2) = ln(c1) + c2, N = 200, y = 3.a. Suppose there is no seigniorage. For = 1.2, find the real value of the transfer a in thestationary case.b. Consider the case of seigniorage. Find function g() discussed in class.c. Plot the function g() obtained in part b.Problem 2Consider the following economy: Individuals are endowed with y units of the consumption goodwhen young and nothing when old. The fiat money stock is constant. The population grows atrate n. In each period, the government taxes each young person goods. The total proceeds ofthe tax are then distributed equally among the old who are alive in that period.a. Write down the first- and second-period budget constraints facing a typical individual at timet. (Hint: Be careful; remember that more young people than old people are alive at time t .)Combine the constraints into a lifetime budget constraint.b. Find the rate of return on fiat money in a stationary monetary equilibrium.c. Does the monetary equilibrium maximize the utility of future generations?d. Does this government policy have any effect on an individual’s welfare?e. Does your answer to part d change if the tax is larger than the real balances people wouldchoose to hold in the absence of the tax?f. Suppose that tax collection and redistribution are (very) costly, so that for every unit of taxcollected from the young, only 0.5 unit is available to distribute to the old. How does youranswer to part d change?Problem 3Consider an overlapping generations model with the following characteristics. Each generation iscomposed of 1,000 individuals. The fiat money supply changes according to Mt = 2Mt?1. Theinitial old own a total of 10,000 units of fiat money (M0 = $10, 000). Each period, the newly printedmoney is given to the old of that period as a lump-sum transfer (subsidy). Each person is endowedwith 20 units of the consumption good when born and nothing when old. Preferences are such thatindividuals wish to save 10 units when young at the equilibrium rate of return on fiat money.a. What is the gross real rate of return on fiat money in this economy?b. How many goods does an individual receive as a subsidy?c. What is the price of the consumption good in period 1, p1, in dollars?ECON-4330 Advanced Macroeconomics I Professor Nurlan TurdalievHomework Assignment 4 Fall 2021Due: Friday, December 3, 2021, 6pmProblem 1Consider the economy with capital studied in class. Assume the endowment vector (y, 0). Supposethe production function is f(k) =√k and u(c1, c2) = ln c1 + ln c2.a. Suppose there is no money. Find the equilibrium consumption allocation (c?1, c?2).b. Now suppose there is money in this economy. Find the equilibrium consumption allocation(c?1, c?2).c. Let u?(y) = u(c?1, c?2) and u?(y) = u(c?1, c?2). Calculate the values of u?(y) and u?(y) for thevalues y = 1, 5, 10. What is larger, u?(y) or u?(y)?d. Plot u?(y) and u?(y) for values of y ∈ [0, 10] on the same graph using different colours orthickness. You can use Maple, Excel, or any other software.Problem 2Consider the economy with capital and private debt but without money studied in class. Assumethe endowment vectors are (y, 0) for lenders and (0, y) for borrowers. Suppose the productionfunction is f(k) =√k and u(c1, c2) = ln c1 + ln c2.a. Find the equilibrium gross interest rate r?. (Remember that r > 0. Note that you may obtainmore than one value of r?. Hint: use the fact that one of the roots of the equation you willbe solving is r = 1.)b. Find the value(s) of k?.c. Find the values of consumption in both periods for borrowers and lenders? ...

June 15, 2022 · 3 min · jiezi

关于算法:COMP61021-学习

COMP61021: Representation Learning Ke ChenClustering Analysis*Ke ChenTo carry out this assessed coursework, you will need the Python notebook, clustering.ipynb,which contains code to get you started with each of the assignments, along with several data filesrequired by dierent assignments (see the related assignments for details of those data sets) in thiscoursework. All above are available in a zipped file on BlackBoard alongside this document.Clustering analysis in its own right is a classical topic in unsupervised learning to learn a high-levelsummary of data, which provides a representation of data from a global perspective. In this course-work, you are asked to implement state-of-the-art clustering algorithms in Python and apply yourimplementations along with the provided Python implementation of clustering algorithms to sev-eral meaningful synthetic datasets for clustering analysis.1 K-means Clustering AnalysisK-means is one of the most commonly used clustering analysis algorithm. In this work, you areasked to apply the providedK-means functions to synthetic datasets to understand its behaviourand how to use a cluster validity index to decide the proper number of clusters underlying a dataset.Assignment 1 [3 marks] Apply the built-inK-means function, sklearn.cluster.KMeans, in thescikit-learn library with Euclidean distance to the 2-D dataset of 3 clusters,kmeans_data_1.npy,with three dierent initial conditions given in the notebook, clustering.ipynb. In your answernotebook, (a) implement the function, partition, that produces a partition for a given dataset sothat the data points in this dataset are grouped into clusters based on their closest centriods. Allthe points in each cluster are assigned the same label specified by their corresponding centroid; (b)apply the built-inK-means function to the dataset mentioned above for clustering analysis with 3given dierent initialisation settings, respectively; and (c) based on the clustering analysis resultsachieved in (b), use your partition function implemented in (a) to create 6 scatter plots corre-sponding to 3 initial partitions and 3 final partitions in order to visualise 6 partitions. You are askedto display 6 plots in a 2×3grid; the first row shows 3 initial partitions and the second row shows 3 fi-nal partitions aligned with their corresponding initial partitions shown in the first row. In each scat-ter plot, you must mark the cluster centroids with the red-coloured "+", all the data points in a clus-ter must be marked with the same colour (but dierent from red to allow for seeing their centroidclearly) and dierent clusters must be indicated by dierent colours. (Hint: to carry out the displayformat described above, you may use the built-in function, matplotlib.pyplot.subplot.)Assignment 2 [3 marks] K-means algorithm cannot be used until the hyperparameter K (thenumber of clusters) is set up. In a real application, however, the number of clusters is oen un-*Assessed Coursework: the deadline and requirements can be found at the end of this document.Page 1COMP61021: Representation Learning Ke Chenknown. In this circumstance, the scatter-based F-ratio index1 may be applied to decide the num-ber of clusters. In your answer notebook, (a) implement the scatter-based F-ratio index in Pythonwhere Euclidean distance is used; (b) forK = 2, 3, · · · , 10, run the theK-means built-in function,sklearn.cluster.KMeans, in the scikit-learn library with Euclidean distance on the dataset,kmeans_data_2.npy (for each K, you must run K-means with 3 dierent random initialisationconditions set by yourself), then plot F-ratio index (y-axis) versus K (x-axis) (in this plot, for eachK, use only the least F-ratio index value measured on 3 partitions resulting from dierent initial-isation conditions), and report the optimal number of clusters in this data set; and (c) display thefinal partition corresponding to the optimal number of clusters you find out in (b) with the the samedisplay format described in Assignment 1.2 Spectral Clustering AnalysisAs a state-of-the-art clustering analysis method, spectral clustering can deal with data of nonlinearand non-convex manifold with the connectivity criteria. In this work, you are asked to implement aspectral clustering algorithm in Python and apply your own implementation to synthetic datasetsin order to understand how spectral clustering works on data sets in dierent nature.Assignment 3 [4marks] In your answer notebook, implement the asymmetric normalised spec-tral clustering2 algorithm where the fully connected graph is used to generate the Laplacian ma-trix used in spectral clustering. You are asked to use two functions: gaussian_similarity forgenerating the fully connected graph and asymmetric_SC for the asymmetric normalised spec-tral clustering in your implementation. (Hint: To implement the asymmetric_SC function, you canuse the built-in function, np.linalg.eig, in the numpy library for eigen analysis and two built-in functions in the scikit-learn library, sklearn.cluster.KMeans for K-means clustering andpairwise_distances for measuring the distances between data points.)Assignment4 [3marks]Apply your implementedgaussian_similarity function inAssignment3 to the dataset, SC_data_1.npy, to generate a Laplacian matrix. In your answer notebook, (a) de-scribe how you find out an appropriate hyperparameter value in the Gaussian kernel and explicitlyreport this value; (b) conduct eigen analysis on the Laplacian matrix, list all the elements of theeigenvector corresponding to the second smallest eigenvalue or the 1st smallest non-zero eigen-value in a 4 × 10 table carried out by a proper 2-D array; and (c) with the result achieved in (b),provide the computational evidence to decide how many clusters in this dataset and display theresultant partition in a 2-D plot where dierent clusters must be marked in dierent colours.Assignment 5 [2 marks] Apply your implemented gaussian_similarity and asymmetric_SCfunctions in Assignment 3 to the dataset, SC_data_1.npy, with the number of clusters you findout inAssignment 4, and two other datasets of two clusters, SC_data_2.npy andSC_data_3.npy,respectively. In your answer notebook, (a) display the 3 resultant partitions of the datasets in 2-Dplots where clusters must be marked in dierent colours, and (b) check whether this clusteringalgorithm works for all 3 datasets. If not, identify the dataset(s) it fails and explain why.1For the definition of the F-ratio index, see “K-means Clustering” lecture note.2For the algorithmic description of this algorithm, see “Spectral Clustering” lecture note.Page 2COMP61021: Representation Learning Ke Chen3 Hierarchical Clustering AnalysisAs one of the most important clustering analysis techniques, hierarchical clustering enables oneto achieve all possible clusters at dierent levels for a data set. In this work, you are asked to applythe commonly-used agglomerative algorithm with dierent cluster-distance metrics to a syntheticdataset in order to understand how this algorithm works.Assignment 6 [4 marks] You are asked to use Euclidean distance to produce the initial distancematrix and further apply the built-in function, scipy.cluster.hierarchy with three dierentcluster-distance metrics3, single-linkage, complete-linkage and group-average, in thescipy libraryto the dataset, HC_data.npy, respectively. In your answer notebook, (a) plot three dendrogramtrees achieved by the use of three cluster-distance metrics in the agglomerative algorithm; (b)implement the function, get_longest_lifetime, used to find out the longest K-cluster lifetimefrom a dendrogram; and (c) use your get_longest_lifetime function implemented in (b) to re-port the longest K-cluster lifetimes along with their corresponding K (number of clusters) foundin terms of the longest K-cluster lifetime criterion for 3 dendrograms achieved from (a) and fur-ther display 3 partitions corresponding to the longest K-cluster lifetimes. For visualisation, youmust arrange 3 plots, each with the explicit cluster-distance metric title, in one row in the order ofsingle-linkage, complete-linkage and group-average from le to right.4 Ensemble Clustering AnalysisAs one of the state-of-the-art clustering analysis techniques, ensemble clustering algorithms al-low for combining dierent types of clustering algorithms and working on various feature sets of adata set to reach a synergy for clustering analysis. In this work, you are asked to implement theevidence-accumulated clustering algorithm and apply your implementation to two benchmarkdata sets to understand how this algorithm works in practice.Assignment7 [2marks] In your answer notebook, implement a function, ensemble_clustering,for the evidence-accumulated clustering algorithm4 based on K-means and the agglomerativealgorithms in Python where K-means algorithm with Euclidean distance is used to generate ini-tial partitions. (Hint: To implement the ensemble_clustering function, you can use the built-infunctions, sklearn.cluster.KMeans, in the scikit-learn library for K-means clustering, thescipy.cluster.hierarchy.linkage and scipy.spatial.distance.squareform in the scipylibrary for hierarchical clustering.)Assignment8 [4marks]Apply yourensemble_clustering function implemented inAssignment7 to two datasets, SC_data_2.npy and SC_data_3.npy, respectively. In your experiment, you areasked to figure out how to decide how many initial partitions need to be generated by K-meansalgorithm with Euclidean distance and what an appropriate cluster-distance metric is to make theclustering ensemble algorithm work properly on a given dataset. In your answer notebook, (a) foreach of two datasets, describe how you generate initial partitions and what the cluster-distancemetric that lead to satisfactory results with justification (you need to state the number of initial3For the definition of cluster-distance metrics, see “Hierarchical Clustering” lecture note.4For the algorithmic description of this algorithm, see “Clustering Ensemble” lecture note.Page 3COMP61021: Representation Learning Ke Chenpartitions and the chosen cluster-distance metric explicitly), and (b) plot two dendrogram treesproduced by the cluster ensemble algorithm on two datasets and further display the optimal con-sensus partitions of two dataset with the longestK-cluster lifetimes achieved, respectively, in theformat of 2-D scatter plot where clusters in a partition must be marked in dierent colours.Requirement: Before starting working on this assessed coursework, you need to ...

June 15, 2022 · 8 min · jiezi

关于算法:直播场景音频降噪传统算法-VS-AI-算法对比和实践

摄影中最重要的是光,找光、等光、拍光,而在室外录音录像中,则是要等声音。确切点说,是等乐音过来,尤其是刹时噪声,飞机呼啸而过、学校的下课铃、汽车的鸣笛等等。关注【融云寰球互联网通信云】理解更多这些,就须要通过 AI 算法进行智能降噪解决。AI 降噪能够通过模型训练的形式,辨认出须要过滤掉的刹时噪声。 6 月 9 日的融云 RTC · 进阶实战高手课中,融云音频算法工程师从降噪技术、AI 降噪技术、融云 AI 降噪摸索实际等方面对 AI 降噪相干技术进行了全面分享。 本文将对课件内容进行梳理展现,欢送珍藏转发~ 微信后盾回复【AI降噪】获取残缺课件 降噪技术乐音其实是一个绝对概念,不同场景对有用声音与乐音的定义并不统一。 比方在一个有背景音乐的环境中通话,背景音乐就是乐音,须要用降噪技术去除掉。而在直播中,主播唱歌的背景音乐就成了一个有用信号,不仅不能去掉,还须要保障无失真地保留。 因而,咱们须要依据不同场景有针对性地设计降噪计划。 降噪技术倒退多年,每个阶段都会有一些典型的算法和重要的技术冲破。比方晚期的线性滤波法、谱减法,起初的统计模型算法、子空间算法。 近些年,基于深度学习的降噪算法失去疾速倒退,也就是本文所分享的 AI 降噪算法。次要是基于幅度谱的深度学习算法,还有复数谱的深度学习算法,以及起初的基于时域信号的深度学习算法。(不同阶段的次要降噪技术) 传统算法,是由研究者总结乐音法则来建模,继而施行背景乐音解决,次要包含线性滤波法、谱减法、统计模型算法以及子空间算法。 线性滤波法,就是用高通滤波器等对已知频带的信号进行滤除。比方有个 50 赫兹的烦扰,咱们用高通滤波器,截止频率在 50 赫兹以上,就能够把 50 赫兹的干扰信号滤除掉。 谱减法,记录非语音段的一个乐音能量,而后用含噪语音谱减去乐音谱,就失去污浊语音。 统计模型算法,基于统计的办法计算出各频点的语音和乐音重量。 子空间算法,将含噪语音映射到信号子空间和乐音子空间,通过打消乐音子空间成分,保留有用的信号子空间成分,来预计真正有用的语音信号。(降噪算法原理框图) 上图(左)展现了传统降噪办法的典型原理。 信号 y(t) 通过短时傅里叶变换后失去含噪语音幅度谱与相位谱,传统办法通常重点关注语音信号的幅度谱,将幅度谱信息经 Noise Estimator(乐音预计模块)对乐音进行预计,而后通过 Gain Estimator 进行最终 Gain 值计算,将含噪语音的幅度谱与 Gain 值相乘失去最终的加强语音幅度谱,再将其与含噪语音的相位谱联合,进行 iSTFT,从而失去加强语音。 因为乐音预计模块通常是通过平滑递归来计算乐音的估计值,非安稳乐音就很难被精确预计。因而,咱们须要引入 AI 降噪进一步晋升降噪性能。 上图(右)是基于 AI 降噪的原理图,将含噪语音通过特征提取输出到训练好的神经网络,失去去噪后的加强语音。 其本质是利用神经网络模型学习语音与乐音各自的个性与区别,从而去除乐音保留语音。 AI 降噪AI 降噪次要钻研三个方面。 首先是模型 Model,从最晚期的 DNN 网络倒退到起初的 RNN 网络,再到起初的 CNN 网络、GAN 网络及近期的 Transformer 等,AI 降噪模型的倒退是随深度学习模型的倒退而倒退的。 ...

June 14, 2022 · 2 min · jiezi

关于算法:DynamicHead基于像素级路由机制的动态FPN-NIPS-2020

论文提出了细粒度动静detection head,可能基于路由机制动静地交融不同FPN层的像素级部分特色进行更好的特色表白。从设计的路由空间来看是一个非常耗时的操作,然而作者设计的高效路由器理论计算非常高效。试验后果来看,细粒度动静detection head能够即插即提点 起源:晓飞的算法工程笔记 公众号论文: Fine-Grained Dynamic Head for Object Detection 论文地址:https://arxiv.org/abs/2012.03519论文代码:https://github.com/StevenGrove/DynamicHeadIntroduction 在指标检测算法的钻研中,特色金字塔FPN是非常重要的构造,可能很好地表白指标的多尺度特色。近期也有很多FPN构造的改良钻研,比方手工设计的PANet、FPG以及主动搜寻的NAS-FPN、Auto-FPN。但上述的改良钻研有两点问题: 在训练时将训练指标粗略地调配给某个FPN层,并且认为指标区域是不可分割,层间交融也是整层进行。这种策略可能会疏忽了指标扩散在FPN不同层的细粒度部分特色,这些部分特色可能很好地进步指标的语义信息。detection head的预测后果基于单层FPN特色,分辨率固定, 可能会疏忽了重要的小区域特色。 为了解决上述的问题,论文提出了细粒度动静detection head,可能基于路由机制动静地交融不同FPN层的像素级部分特色进行更好的特色表白。该办法参考了粗粒度的动静网络办法,集中在像素级别进行路由抉择。 Fine-Grained Dynamic Routing Space FPN-based指标检测网络通过骨干网络获取不同分辨率特色,而后通过top-bottom pathway以及横向连贯进行多尺度特色交融,最初应用简略的共享detection head对不同分辨率的特色进行后果预测。 细粒度动静detection head的外围在于细粒度动静路由空间(fine-grained dynamicrouting space)的设计,如上图所示。对于第$n$层特色,动静路由空间的深度为$D$,与FPN的3层特色相干,别离为$n$层、$n-1$层以及$n+1$层。动静路由空间的根底为细粒度动静路由器(fine-grained dynamic router),依据状态抉择各像素的后续门路,每个像素有3个不同的门路可供选择。 Fine-Grained Dynamic Routing Process 给定路由空间以及几个独立的节点,应用论文提出的细粒度动静路由器(fine-grained dynamic routers)实现多尺度特色的交融,次要进行element-wise的相加以及像素级路由门路的抉择。 Fine-Grained Dynamic Router 给定路由空间节点$l$,该节点的特色标记为$x^l=\{x_i^l \}^N_{i=1}$,$N=H\times W$为像素地位,共有$C$维,路由节点的候选门路$F={f_k^l(\cdot) | k\in {1, \cdots, K} }$依据相邻FPN层的尺寸定义,$K$为候选门路数。每个门路都有一个空间管制门(spatial gate),空间管制门的输入为门控因子(gating factor): $\theta_k^l$为帮助网络的参数,对应第$k$个管制门,参数是地位共享的。而$m_i^{k,l}\in [0, 1]$是间断的,容许单个像素的多个后续门路被激活。在实现时,只取激活门控因子为负数的门路,所以单节点的多路径路由输入为: Gate Activation Function 门控激活函数的输入范畴为$[0,1]$,当输入为0时禁止该门路。另外,门控激活函数必须是可微的,不便反向流传的学习。在思考了其它钻研的实现计划之后,论文提出了restricted tanh函数的变种: $\tau$为超参数,用于管制$0^+$的梯度值。公式3不仅可导,还解决了restricted tanh在零处梯度不间断的问题。 ...

June 14, 2022 · 1 min · jiezi

关于算法:第八届中国国际互联网大学生创新创业大赛介绍

简介:阿里云与你一起数字翻新、永无止境!历经十余年艰苦创业历程,阿里云实现了中国云计算从 0 到 1 的要害核心技术冲破,自主研发了服务寰球、超大规模的通用云操作系统——飞天,成为我国根底软件畛域的一项重大科技成果,也是以企业为主体实现自主翻新的成功实践。 受第八届中国国内“互联网+”大学生翻新守业大赛产业命题赛道之邀,阿里云围绕“以云为外围的新型计算零碎”,推出弹性计算、操作系统、云数据库、云原生、智能搜索引擎、物联网、低代码开发共7大技术方向、32道赛题,诚邀各大高校翻新守业团队一道关注云计算核心技术,数字翻新、永无止境。 大赛地址:https://developer.aliyun.com/learning/topic/internetplus大赛报名及提交作品工夫:2022.6.1-2022.7.31为了帮忙参赛者获得更好问题,开发者学堂提供4个模块助力参赛者获得更好问题 1、赛题解析,蕴含赛题解析视频,帮忙参赛者更好理解命题方向,波及的技术能力 2、赛前训练营,阿里命题组委会技术专家开营授课,提供赛前培训,为参赛者助力 3、学习材料,体系化学习路线,电子书,课程等赛题相干材料供参赛者参考 4、飞天减速打算,所有抉择阿里云产业赛道命题的比赛团队,欢送返回阿里云“飞天减速打算”专区,每位团队成员能够收费支付一台专属的ECS云服务器,应用时长最长为2.5个月。链接:https://developer.aliyun.com/plan/student 云原生赛道 基于云原生开源消息中间件 RocketMQ 的轻量级流计算翻新利用命题解析:https://developer.aliyun.com/learning/course/1017/detail/15082 基于开源KubeVela 构建面向混合云的微服务治理标准命题解析:https://developer.aliyun.com/learning/course/1024/detail/15096 基于开源我的项目 Serverless Devs 的创意利用命题解析:https://developer.aliyun.com/learning/course/1020/detail/15090 基于开源我的项目 Apache Dubbo 的大规模集群实际调优命题解析:https://developer.aliyun.com/learning/course/1027/detail/15102 基于开源 KubeVela 构建云原生利用平台命题解析:https://developer.aliyun.com/learning/course/1025/detail/15098 云原生环境下基于 Serverless 架构的翻新利用命题解析:https://developer.aliyun.com/learning/course/1021/detail/15091 基于开源 Open-Cluster-Management的中枢集群容灾能力建设数据库赛道 搭建开源云原生分布式数据库 PolarDB-X 混沌测试零碎搭建云原生分布式数据库 PolarDB-X 问题诊断与定位系统基于开源云原生关系型数据库 PolarDB for MySQL 实现并行创立索引基于云原生数据库 PolarDB for PostgreSQL 分布式开源我的项目实现序列号生成基于云原生数据库 PolarDB for PostgreSQL 分布式开源我的项目实现性能调优联合云原生数据仓库 AnalyticDB 个性实现结构化和非结构化数据的联结剖析基于云原生多模数据库 Lindorm 构建物联网利用内存数据库容量极致优化全命题解析:https://developer.aliyun.com/learning/course/1023/detail/15094 智能引擎搜寻赛道 基于"问天引擎"的智能搜寻举荐算法开发命题解析:https://developer.aliyun.com/learning/course/1014/detail/15075 物联网赛道 基于HaaS Python物联网智能设施疾速开发框架的性能优化基于AliOS Things零碎和RISC-V芯片打造国产全自研物联网零碎解决方案操作系统方向命题解析:https://developer.aliyun.com/learning/course/1015/detail/15078 基于HaaS物联网设施云端一体开发框架实现无障碍关心零碎基于HaaS物联网设施云端一体开发框架实现智能化场景利用物联网全栈开发方向命题解析:https://developer.aliyun.com/learning/course/1016/detail/15080 操作系统赛道 基于龙蜥操作系统开源技术 Plugsched 优化 Linux 内核调度器命题解析:https://developer.aliyun.com/learning/course/1019/detail/15088 龙蜥开源操作系统 Anolis OS 调度器并发度优化命题解析:https://developer.aliyun.com/learning/course/1022/detail/15092 ...

June 14, 2022 · 1 min · jiezi

关于算法:直播倒计时1天天翼云HPC解决方案助力企业腾飞

数字时代下企业如何畅享高性能计算?高性能计算的背地是哪些技术在做撑持?6月15日 14:00-14:50“天翼云HPC解决方案 减速企业数字化转型”直播将准时开启倒计时1天!敬请期待!

June 14, 2022 · 1 min · jiezi

关于算法:数组三道题学会差分数组

前言 上篇文章讲了前缀和前缀和数组,这篇文章开始讲查分数组。另外,数组有下图这些知识点与技巧。 思路 场景:频繁对原始数组的某个区间的元素进⾏增减。原数组nums与差分数组diff如下图所示。 区间加法leetcode第370题 解题思路 间接在差分数组上做操作:diff[startIndex] = diff[startIndex] + inc, diff[endIndex + 1] = diff[endIndex + 1] - inc。 这就代表了原数组nums的startIndex到endIndex地位的元素都加上inc。 但当endIndex就是指向nums的最初一个元素时,就无需做diff[endIndex + 1] = diff[endIndex + 1] - inc操作了。 复杂度剖析 工夫复杂度:O(n + m),n是差分数组的长度,m是操作的次数。对于每一次操作都要解决一次差分数组,并最初对差分数组求前缀和。 空间复杂度:O(1),留神返回值不计入空间复杂度。 代码 class Solution { int[] getModifiedArray(int length, int[][] updates) { int[] diff = new int[length]; for (int[] u : updates) { diff[u[0]] += u[2]; if (u[1] < length - 1) { diff[u[1] + 1] -= u[2]; } } for (int i = 1; i < length; i++) { diff[i] = diff[i - 1] + diff[i]; } return diff; }}航班预订统计leetcode第1109题 ...

June 13, 2022 · 1 min · jiezi

关于算法:如视技术副总裁杨永林当传统产业遇到数字空间

简介: 打造极致的看房体验,重塑用户找房习惯私享会现场.jpg 图:2022阿里云视觉计算私享会现场 5月11日,在“2022阿里云视觉计算私享会”上,如视技术副总裁杨永林为大家带来了题为《当传统产业遇到“数字空间”》的主题分享。以下内容依据他的演讲整顿而成。 随着互联网的倒退,咱们一直地将事实世界进行信息化、数字化,再做线上化,让信息在线上进行流转和解决。在信息的处理过程中,空间信息的数字化绝对艰难,而它又是很多行业十分重要的伎俩,可能晋升服务体验。 在过往很长的一段时间内,咱们对空间的形容都是通过扁平、繁多的数据,比方房产行业个别应用“几厅几卫”、“几房朝南”、“南北通透”等标签性的数据形容空间。 而这些数据是被人为形象过的,并不是精确的数据。其次,这些数据带有很典型的行业特色,并不是主观的数据。在不同的行业里,这些数据往往体现出不同的标签性质,因而数据之间很难产生关联性,最终会变成畛域里的孤岛。 所以过往的数据并不能提供很好的沉迷式体验。即使附加图片或视频甚至全景图片,无非也只是二维信息在某地位上的展示,并没有实在反映出主观的物理世界。 image001.png 因而,如视率先提出了数字空间的概念,将其分为几个档次来了解。 首先,尽可能多地将物理世界的信息、物理特色通过技术手段数字化,而后采集到零碎里,使其转化为数字形容的模式。再通过一些 AI 伎俩和策略,从中剖析辨认出一些信息,比方空间的布局、户型图、立体构造等,通过这些曾经解读进去的信息,一方面能够产生利用,使人在空间外面进行交换互动,也能够产生一些工夫维度上的后果。比方在房间外面搁置一台空调,那么空间里的空气会是什么样?模仿一天内太阳的变动,空间里的光照会是什么样?以上过程可能产生一些交互数据。 数字空间相当于对物理空间的复刻,须要尽可能多地将物理世界的信息挪到数字世界里。当然,它不止对物理事件进行复刻,更要将真实世界产生的行为和互动信息都在数字空间内进行重塑,包含人与人之间的交互行为。 将所有交互信息放在一起,就是数字空间的概念。 image003.png 在实际过程中,将事实世界尽可能还原到数字世界里,首先在技术层面上须要有三维重建、采集的根底能力,将事实世界在数字世界进行复刻。 在此基础之上,还须要做一些场景化的利用,将采集后的信息以场景化的形式展现进去。比方在贝壳找房,能够在线上看到房子,同时能够对空间进行治理,也能够将这些数据积淀下来,作为数据存档。这是对数据档次绝对较低的高级利用。 此外,数据之间有关联信息,能够通过一些技术手段对这些关联信息进行开掘,不同的畛域可能挖掘出不同的常识图谱,也能够对行业进行深层次的转化。比方在房产行业,传统的形式是手动测量每一处数据,再由人工进行平面图绘制。而当初,通过数据的采集,拿着设施去房间里扫一圈,即可通过 AI 伎俩主动生成户型图,大大简化了流程。 场景里利用不够丰盛的时候,会催生出一些新的性能,对数据生产的能力也会有更高的要求。比方在采集方面,可能对采集设施要求越来越轻量,越来越便捷,或是对数据的精度要求更高,须要应用更好的传感器。 image005.jpg 上图展现了如视次要的硬件采集产品。 最左侧是如视的外围产品伽罗华,它是咱们自研的扫描器,能够做定点扫描,将其搁置于三脚架上主动旋转,100 平米的房子大略采集 20 个扫描点即可将房间进行数字化重塑。测量面积极限误差管制在0.4%。 激光设施失去的数据除了黑白信息以外,还有间隔信息,每个点位内都存在 RGB 信息和深度信息的对照。采集到 100 万套房屋信息后,咱们失去了大略 2000 万个点位,再基于 RGB 和深度的对照信息,咱们开始尝试通过黑白信息揣测深度信息。 目前,通过全景相机实现对深度的揣测曾经可能达到1.35%左右误差的精度。因而,在对精度要求不高的状况下,不须要业余设施去采集空间信息,应用全景图揣测深度即可。 2020 年咱们做了全景相机采集计划。因为全景相机的画质个别,而手机的像素和画质足够好,因而咱们自研了手机采集计划,将手机搁置在REALSEE G1云台上,云台的非凡转轴设计即可实现手机采集出无拼缝全景画面。通过全景图对深度的揣测能够失去画质较好、模型成果过关的模型数据。 综上,咱们提供了两条数字空间采集的解决方案:首先是精度和还原度较高的激光VR扫描仪伽罗华;其次是通过REALSEE G1云台加手机、全景相机与手机连贯的轻量化解决方案。 image007.jpg 采集到空间数据后,即可将其投入利用。比方贝壳体系下,提供了 VR 看房的性能,能够在房间内游走,查看空间场景。同时还能提供空间的解读数据,比方南北通透、动静分区、户型的分数等,通过数据给予用户更直观的感触。 此外,还能对数据进行深层次的加工。比方对空间的编辑,输出标签;比方某处有一台某品牌的电器;也能够进行空间测量,在场景外面添置家具等;还能够进行重塑,将家具全副革除,从新安排。 AI 营销助手比拟实用于家电、家具厂商,可能以 AI形式将家具、家电间接部署到客户家里,为客户提供最直观的感触,实现场景化营销,可能无效晋升获客和转化率。 依靠数字空间的复刻,咱们能够将物理世界空间内的交互平移到线上。挪动比特的老本远低于原子,只有做到低成本地将物理空间进行数字化,同时将尽可能多的运算和交互在数字空间内实现,再反馈给物理世界,就可能在事实世界中失去很好的提效,也会带来商业模式上的提高。 image009.jpg 2017 年,如视成立了实验室,次年成立事业部,次要做批量生产 VR 的硬件采集设施,并进行规模化落地。2019 年公布了在空间内的智能AI解说,以及一些下层利用。2020年,疫情后复产停工,VR 带看性能助力房产交易行业复苏。当初, VR 看房曾经成为房产中介行业的外围性能。 image011.jpg 通过几年的倒退,如视曾经为 27 个国家和地区的 160 多个客户提供了数字空间相干技术的反对与服务。除了房产交易行业,在家居家装、文博会展、酒店餐饮行业也做了十分深刻利用。 那么,数字空间到底对传统行业带来了什么样的扭转? image013.jpg ...

June 13, 2022 · 1 min · jiezi

关于算法:合成数据相对于真实数据的优势

注:该文章转载自neptune.ai,为了让读者更顺畅地浏览,咱们对文章进行了局部批改,如增加了一些插图或改变了一些用词。 人工智能在 2020 年风行一时,但许多AI算法团队都遇到了一个瓶颈:AI训练数据。 对于大多数人工智能,机器学习我的项目来说,领有一个宏大并且通过加工的数据集是必不可少的,但获取这些数据通常是微小的挑战。 不仅必须从事实世界中收集数据,还必须要通过人工的荡涤和标注。对于大学的AI研究室、小型钻研团队和晚期守业公司来说,训练数据的有余是一个重大阻碍。 这就是合成训练数据派上用场的中央,合成数据就是模仿真实世界的假数据。 对于某些 ML 应用程序,创立合成数据比采集和标注实在数据容易得多。 这次要有三个起因: 可按需生成尽可能多的数据。可生成事实世界中难以采集到的数据(如车祸,极其顽劣天气、波及个人隐私的人脸数据等)合成数据是自带标注信息的,并且100%精确。 让咱们来更具体地解释下什么是合成数据: 什么是合成数据?机器学习的最根底条件之一是大量的AI训练数据。您须要的数据量能够从一万个到数十亿条数据不等,高质量的数据越多,您的AI模型就越准确。 对于主动驾驶汽车这样简单的AI我的项目,进行大规模的数据采集和数据标注是一项微小的挑战。侥幸的是,当初能够通过合成数据解决这个问题。 采集和标注的速度难以晋升是实在数据的一大弱点。 在大多数状况下,每多采集和标注一条数据,破费的工夫是成倍的,但合成数据并非如此。 使合成数据一大益处是能够批量生成。一万条训练数据?没问题。一百万条训练数据?没问题。十亿?也能够,您须要只是弱小的GPU。 相比之下,标注十亿条实在的训练数据则难以实现。 合成数据同步为什么应用合成数据(合成数据VS实在数据)收集实在数据可能很危险。比如说,主动驾驶AI不能齐全依赖实在数据。从事这项技术的公司,例如 Alphabet 的 Waymo,必须进行模仿。 想一想,要训练 AI 防止车祸,您须要无关车祸的训练数据。但采集到实在车祸的大型数据集切实是太低廉和太冒险了——所以你要模仿车祸。 实在数据可能十分常见和危险数据一样,合成数据也能够模仿真实世界的常见状况。 例如,您想让您的AI模型适应雾霾或者暴雪天气,合成数据能够生成足够数量的常见事件来训练 AI 模型。 往往人工智能的最大价值就是能主动地解决常见事件,但正是因为常见,在事实世界采集是难以实现的。 回到汽车的例子,车祸并不常常产生,咱们很难有机会采集这些数据。应用合成数据能够有限次地模仿车祸。 合成数据齐全由用户设计合成数据模仿中的所有都由用户设计和操控,这是一把双刃剑。 弊病是在某些状况下,合成数据会短少真实世界中的行为或者特色,对于这种状况,必须通过迁徙学习来补充一部分实在数据。 益处是事件频率、样本分布等等都取决于用户。 合成数据领有100%的标注准确度合成数据的另一个长处是完满的标注,完全避免了人工标注产生的谬误。 能够为模仿场景中的每个对象主动生成各种标注(突围框、语义宰割、关键点等),这绝对于人工标注来说能节俭大量的老本。 您不须要为标注付费,因为是主动生成的,合成数据的次要老本是后期的建模费用,然而在建模实现之后,您能够生成有限多的标注数据。 合成数据能够是多光谱的目前,许多主动驾驶公司曾经意识到标注不可见数据具备微小的挑战性。这就是为什么他们始终是合成数据的最大支持者。 Alphabet 的 Waymo 和通用汽车的 Cruise 等公司应用合成 LiDAR 数据。因为这些数据是合成的,因而根本事实是已知的,并且数据会被主动标记。 同样,合成数据也实用于人类无奈齐全解读图像的红外或雷达计算机视觉利用。 同步合成数据合成数据的应用领域有哪些?合成数据有很多用处。目前,合成数据次要有两大畛域:计算机视觉和表格数据。 计算机视觉是指应用AI算法检测图像中的对象和模式。摄像头利用于越来越多的行业,从汽车到无人机,再到医学,等等。 合成数据与更先进的人工智能相结合,意味着计算机视觉技术才刚刚起步。 合成数据的另一个用处是在表格数据中。表格合成数据引起了钻研人员的宽泛关注。麻省理工学院的钻研人员最近公布了 Synthetic Data Vault,这是一个用于合成电子表格数据的开源工具。 衰弱和隐衷数据对于合成办法来说尤其成熟。这些数据受到隐衷法律的高度限制。合成数据能够帮忙钻研人员在不进犯人们隐衷的状况下取得他们须要的训练数据。 随着新工具和教程的公布,合成数据将可能在人工智能的倒退中施展越来越大的作用。 论断大量数据、危险的实在数据收集和完满的标注是应用合成数据的三大起因。 如果你想查看一个实在的产品,Simerse公布了一个收费的空幻引擎插件,能够更轻松地生成合成数据。 还有很多其余工具能够生成合成数据。无论您抉择哪种形式,合成数据都是获取训练数据的好办法,并且很可能成为下一代 AI 的一大推动力。

June 13, 2022 · 1 min · jiezi

关于算法:算法与数据结构体系课已完结

download:算法与数据结构体系课【已完结】Django API 开发:一个 Todo 利用的后端引言本文中,咱们将学习利用 Django 构建一个 Todo(待办事项)利用的 API 后端,而后将其与 React 前端连接。 咱们已经制作了第一个 API,并回顾了 HTTP 和 REST 的工作原理,然而您仍然可能还没有“残缺”了解它们如何拆散在一起。咱们将创建一个 todo 结构,其中蕴含咱们的后端 Django Python 代码和咱们的前端 React JavaScript 代码。最终的布局将如下所示。todo| ├──frontend| ├──React... | ├──backend| ├──Django...复制代码初始化创建后端利用任何 Django API 的第一步始终是安装 Django,而后在其之上增加 Django REST Framework。 首先在桌面上的代码目录中创建一个专用的 todo 目录。打开一个新的命令行控制台,而后输出以下命令:$ cd ~/Desktop$ cd code$ mkdir todo && cd todo复制代码注意: 确保已从上一章中停用了虚拟环境。 您可能通过键入退出来执行此操作。 命令行后面是否没有括号? 好。 那么您就不在现有的虚拟环境中。在此 todo 文件夹中将是咱们的后端和前端目录。 让咱们创建一个后端文件夹,安装 Django,而后激活一个新的虚拟环境。$ mkdir backend && cd backend $ pipenv install django==2.2.6 $ pipenv shell复制代码您应该在命令行上看到括号,以确认虚拟环境(后端)已激活。现在已经安装了 Django,咱们应该首先创建一个传统的 Django 我的项目 todo_project,在其中增加第一个应用程序 todo,而后迁徙初始数据库。(backend) $ django-admin startproject todo_project . (backend) $ python manage.py startapp todos (backend) $ python manage.py migrate复制代码在 Django 中,咱们始终需要将新利用增加到 INSTALLED_APPS 设置中,所以现在就这样做。 在文本编辑器中打开 todo_project/settings.py。 在文件底部,增加 todos.apps.TodosConfig。 ...

June 12, 2022 · 4 min · jiezi

关于算法:ECS759P-方法

ECS759P: ARTIFICIAL INTELLIGENCECoursework 2: Logic and reasoning, neural networks and classificationDUE DATE: PLEASE REFER TO THE EXACT DATE FROM QMPLUSInstructions: The coursework is composed of two questions. The first is a writing exerciseabout logic and reasoning. Only the second exercise (on classification) involves programming,You are expected to submit one zip file ONLY through the QM+ submission link, containung: A single PDF file that must be at most 5 pages long. Any file submitted under the wrongformat (e.g. doc, docx, odt, etc.) or exceeding the length limit will be penalised. ThePDF can include scans of handwritten material as long as it is legible but a typewrittenversion is encouraged (even better if you use LATEX).A single folder containing all your (well documented and sufficiently commented) codes.The code should be written using Python. Your code should run (no bugs!). There mustbe an easy to follow readme.txt file inside the folder.It is allowed to use codes from online resources. However, this has to be clearly cited withreference in your report. Collaboration is NOT permitted when attempting the answers. Highlevel discussion when not attempting the questions may be fine, but discouraged. A bettermeans is using our discussion forum on QM+. Please be aware that systems can be busy andslow to respond shortly before deadlines. So you should aim to submit at least one hour beforethe announced deadline.Question Points ScoreCrystal clear! (Logic problem) 50Lost in the closet (Classification) 50Total: 100Question 1: Crystal clear! (Logic problem) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Although you are looking for it everywhere, you cannot find your true love. A bit desperate,you decide to see Madame Irma the most famous (and serious) fortune teller of thecity. On the entrance you see a sign stating: Everything that I say must be proved to bebelieved. More perplexed than ever, you still go inside. After glaring at you for some time,she looks into her crystal ball, which has a strange glow, and says in a mysterious voice:• You have a dog.• The person you are looking for buys carrots by the bushel.• Anyone who owns a rabbit hates anything that chases any rabbit.• Every dog chases some rabbit.• Anyone who buys carrots by the bushel owns either a rabbit or a grocery store.• Someone who hates something owned by another person will not date that person.The sentences you just heard reminds you of a person: Robin. But before you leave, shechallenges you with a conclusion:• If the person you are looking for does not own a grocery, she will not date you.Remembering the sentence at the entrance, you realise that what she has told you is trueonly if you can prove her challenge conclusion. Since you don’t want any awkward situation,you decide to provide a proof for her conclusion before going to see Robin.(a) (10 points) Express Madame Irma’s six statements into First Order Logic (FOL).Note: You are allowed to change the person you are looking for to Robin.(b) (10 points) Translate the obtained expressions to Conjunctive Normal Forms (CNFs)(c) (10 points) Transform Madame Irma’s conclusion into FOL, negate it and convert itto a CNF.(d) (20 points) Based on all the previously created CNF (you should have at least 7 dependingon how you split them), prove that Madame Irma is right and that you shouldgo to see Robin to declare to her your (logic) love.Page 2Question 2: Lost in the closet (Classification) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .You are an artist who secluded yourself for years to come up with the perfect design fora new brand of clothes. However, your time off civilisation was not so beneficial sinceyou cannot distinguish a T-shirt from a dress or a sneaker from a sandal any more! Inorder to redress (!) that issue, you choose to train a Convolutional Neural Network (usingPyTorch) that will help you identify each cloth to match the perfect design you created.In order to train it, you decide to rely on the dataset fashion MNIST.You can access the data using the following lines:import torchvisionimport torchvision . transforms as transformsimport torchtrain_set = torchvision .datasets. FashionMNIST (root = ".", train = True ,download = True , transform = transforms .ToTensor ())test_set = torchvision .datasets. FashionMNIST (root = ".", train = False ,download = True , transform = transforms .ToTensor ())training_loader = torch.utils.data. DataLoader (train_set , batch_size = 32,shuffle = False)test_loader = torch.utils.data. DataLoader (test_set , batch_size = 32,shuffle = False)torch. manual_seed (0) ...

June 11, 2022 · 5 min · jiezi

关于算法:拉勾算法突击特训营3期百度云

download:拉勾-算法突击特训营3期【百度云】Django API 开发:一个 Todo 利用的后端引言本文中,咱们将学习利用 Django 构建一个 Todo(待办事项)利用的 API 后端,而后将其与 React 前端连接。 咱们已经制作了第一个 API,并回顾了 HTTP 和 REST 的工作原理,然而您仍然可能还没有“残缺”了解它们如何拆散在一起。咱们将创建一个 todo 结构,其中蕴含咱们的后端 Django Python 代码和咱们的前端 React JavaScript 代码。最终的布局将如下所示。todo| ├──frontend| ├──React... | ├──backend| ├──Django...复制代码初始化创建后端利用任何 Django API 的第一步始终是安装 Django,而后在其之上增加 Django REST Framework。 首先在桌面上的代码目录中创建一个专用的 todo 目录。打开一个新的命令行控制台,而后输出以下命令:$ cd ~/Desktop$ cd code$ mkdir todo && cd todo复制代码注意: 确保已从上一章中停用了虚拟环境。 您可能通过键入退出来执行此操作。 命令行后面是否没有括号? 好。 那么您就不在现有的虚拟环境中。在此 todo 文件夹中将是咱们的后端和前端目录。 让咱们创建一个后端文件夹,安装 Django,而后激活一个新的虚拟环境。$ mkdir backend && cd backend $ pipenv install django==2.2.6 $ pipenv shell复制代码您应该在命令行上看到括号,以确认虚拟环境(后端)已激活。现在已经安装了 Django,咱们应该首先创建一个传统的 Django 我的项目 todo_project,在其中增加第一个应用程序 todo,而后迁徙初始数据库。(backend) $ django-admin startproject todo_project . (backend) $ python manage.py startapp todos (backend) $ python manage.py migrate复制代码在 Django 中,咱们始终需要将新利用增加到 INSTALLED_APPS 设置中,所以现在就这样做。 在文本编辑器中打开 todo_project/settings.py。 在文件底部,增加 todos.apps.TodosConfig。 ...

June 11, 2022 · 4 min · jiezi

关于算法:算法与数据结构体系课完结无密

download:算法与数据结构体系课|完结无密leetcode 2295. Replace Elements in an Array描述You are given a 0-indexed array nums that consists of n distinct positive integers. Apply m operations to this array, where in the ith operation you replace the number operationsi with operationsi.It is guaranteed that in the ith operation:operationsi exists in nums.operationsi does not exist in nums.Return the array obtained after applying all the operations.Example 1:Input: nums = [1,2,4,6], operations = [[1,3],[4,7],[6,1]]Output: [3,2,7,1]Explanation: We perform the following operations on nums: ...

June 11, 2022 · 2 min · jiezi

关于算法:拉勾算法突击特训营3期完整无密

download:拉勾-算法突击特训营3期【残缺无密】leetcode 2295. Replace Elements in an Array描述You are given a 0-indexed array nums that consists of n distinct positive integers. Apply m operations to this array, where in the ith operation you replace the number operationsi with operationsi.It is guaranteed that in the ith operation:operationsi exists in nums.operationsi does not exist in nums.Return the array obtained after applying all the operations.Example 1:Input: nums = [1,2,4,6], operations = [[1,3],[4,7],[6,1]]Output: [3,2,7,1]Explanation: We perform the following operations on nums: ...

June 11, 2022 · 2 min · jiezi

关于算法:词对齐任务相关文献2022年-个人整理综述

是什么在machine translation中的词对齐问题。算是机器翻译的子衍生问题吧,感觉利用面不是很广。一篇文文献里的自述:Word Alignment is the task of finding the correspondence between source and target words in a pair of sentences that are translations of each other.个别这种对应关系会被示意成这样子的相关矩阵,谁分数高就示意谁与谁对齐,我就把他叫做词相关矩阵了(不晓得其他人是不是这么叫的): 掂量最常见的是AER(https://zhuanlan.zhihu.com/p/...),当然还有recall precision(见https://arxiv.org/pdf/2103.17...)。 如何实现此指标因为是机器翻译外面的问题,其实现依存于机器翻译模型,英文MT(machine translation)。MT分为两大支流实现形式:NMT(nueral MT)和SMT(statistical MT)。 SMT算是比拟早支流的了,经典的统计办法模型,IBM模型1 2 3代等等。NMT是因为深度学习崛起大部分人在深挖其与本工作的联合形式,大部分应用LSTM、RNN、CNN等支流组件去实现。互信息直算实现此指标,换句话说是如何求出第一局部那个词与词的矩阵。 NMT附丽下的word alignment说道机翻显然就想到transformer,其encoder-decoder构造其实即使是在应用了lstm等模型上也是这样的,附丽在NMT的word alignment工作就能够间接应用seq2seq的输入对输出的词attention(动图https://www.bilibili.com/vide...,36:00)来表征word alignment。 词互信息(PMI)直算这个是很intuitive的办法,我不应用任何模型,间接用概率统计的办法,算出两词间的互信息值,很多文章里叫PMI(pointwise mutual information),间接用这个值作为根据,填出词相关矩阵。互信息是什么?这个场景下的互信息怎么算?见https://blog.csdn.net/index20...。 附丽NMT的词对齐这种模式的word alignment的最终解决形式是求得word的相关矩阵,用分数示意各个词的相关度,文章中名词叫做soft align。经典seq2seq+att的模型和transformer based模型会在decoder阶段失去以后输入词与原sentence的词的attention,利用此能够组成相关矩阵。对于老式的seq2seq+att来说, 对于transformer来说, 值得注意的一点是,只管bert是在transformer的根底上倒退来的,只取了transformer的encoder,在文字了解、浏览等工作有宽泛应用和很好成绩,然而在机器翻译这一工作上bert encoder的体现 很个别 ,甚至不如lstm等老牌rnn,连带的word alignment也不算好(ACL 2019)。 MarianNMT自身是一个汇合了很多seq2seq和transformer的机器翻译的工具箱,word alignment能够依附于机器翻译,应用src的word embedding与target embedding计算词汇的相关矩阵。 从可解释性角度进行word align (ACL 2019)前言文章借鉴了LRP删除法判断重要性的办法(ACL 2016)。LRP最先在cv畛域提出。具体来说,对于cv来说,删掉某一部分使得模型错判,则阐明此局部对于后果是重要的。在nlp中,上文提出间接把word embedding全0示意来“删除”这个word。LRP能给出每个word对后果的相干值。·文章首先摸索了应用bert的att的办法也不咋地,应用transformer做word alignment工作的话有些甚至不如用互信息(PMI)直算: 文章一共比拟了 互信息直算(PMI)用transformer attention他的两种model agnostic的办法,一个叫PD,一个叫EAM PD(prediction difference)办法其办法如下,对于一个填词问题来说,把原sentence的某一个word $x$替换成全0embedding,把替换前后的模型输入词$y$的差值作为x与y的“相关度”。 ...

June 10, 2022 · 1 min · jiezi

关于算法:音频-3A-处理实践让你的应用更动听

五月底,咱们在周末刷屏中轮流感触了一次罗大佑和孙燕姿的“联结”演唱会,个体追忆青春,一整个 DNA 动了。关注【融云寰球互联网通信云】理解更多 疫情影响下,在人头涌动的体育馆相会变得遥遥无期,用线上的形式和大家见面,促成了多场引起大家强烈共鸣的线上演唱会。事实上,咱们在把很多线下的场景搬到线上,演唱会只是其中之一。语聊房、KTV、教学……在 RTC 实时音视频技术的反对下,线上玩法更加丰盛,也给技术实现带来新的挑战。 尤其是在有音乐参加的场景玩法中,对音质出现的高要求就须要引入 3A 算法,并依据不同场景做针对性方案设计。 3A 算法3A 音频解决技术,是声学回声打消(AEC)、背景噪声克制(ANS)、自动增益管制(AGC)三种音频算法的合称。 在音频数据的处理过程中,在音频数据采集实现之后须要进行预处理,3A 是预处理的要害。(音频解决流程图) AEC 回声打消算法原理及详解回声打消(AEC)是指在二线传输的两个方向上同工夫、同频谱地占用线路,在线路两个方向传输的信号齐全混在一起,本端发信号的回波就成为了本端信号的干扰信号,利用自适滤波器可对消回波以达到较好的接管信号品质,即为回声打消。 回声打消的原理就是利用接管到的音频与本地采集的音频做比照,增加反向的人造回声,将远端的声音打消。 在容易产生回声的通信场合,自适应回声打消算法是一项不可短少的技术,其次要应用领域有视频会议零碎、免提电话、可视电话终端、挪动通信或声控零碎及会议麦克风等。 尤其在视频会议零碎和免提语音通话中,回声的存在重大影响会议品质,特地是在企业近程会议中,因为传输延时加大,回声的影响更加顽劣显著。 ANS 背景噪声克制办法和作用背景噪声克制(ANS)指的是将声音中的背景噪声辨认并进行打消的解决。 背景噪声分均衡噪声和刹时噪声,安稳噪声频谱稳固,刹时噪声频谱能量方差小,利用噪声的特点,对音频数据增加反向波形解决即可打消。 目前,对于安稳的噪声曾经有很多种简略办法可能胜利克制,然而生存中常见的一些瞬态噪声却仍然不足好方法。 瞬态噪声的独特特点就是突发性极强,在时域上呈振荡瘦弱的模式,持续时间在十几毫秒至上百毫秒不等;在频域上散布很宽,瞬态噪声的频谱基本上是和失常语音的频谱混叠在一起,很难进行克制。 AGC 自动增益算法实现与影响自动增益管制(AGC)次要用于调整音量幅值,进步语音通信零碎在带噪声环境中的性能。 人们失常交谈的音量在 40-60dB 之间,低于 25dB 的声音听起来很吃力,而超过 100dB 的声音会让人感到不适,AGC 的作用就是将音量调整到人承受的范畴。 音频响度及麦克风拾音管制是保障音视频沟通品质的重要技术手段,一般来说,音频规范、传输条件、人为失误等因素都可能导致音频信号之间呈现声音渐变或者响度不统一的状况,这时候就须要对音频信号放大或放大以失去天然清晰的语音通信。 3A 解决在不同场景的利用每个场景对于音质的要求和解决形式都是不一样的。为了提供更优质的服务,融云在不同场景下施行针对性的 3A 策略适配,力争给客户带来最好的音质体验。 音视频通话 人声为先 动静调整通话场景以清晰人声为优先要求,无论用户身处嘈杂的户外还是在公开车库的弱网状况,对于清晰稳固的人声接管,都是通话场景的最外围诉求。 在通话场景中,融云如何针对性设置 3A 解决呢? 首先是 ANS 克制背景噪声,将用户所在环境中的背景噪声最大水平地克制掉。 均衡噪声是背景噪声的次要因素,该局部克制起来并不艰难。难点在刹时噪声,刹时噪声个别是忽然呈现在通话过程中的,比方飞机呼啸而过,学校的下课铃,汽车的鸣笛等等,这就须要通过 AI 算法智能降噪。 AI 降噪能够通过模型训练的形式,辨认出须要过滤掉的刹时噪声,随着语料库的逐步扩充,AI 降噪的成果也会越来越好。 其次是 AEC 回声打消,回声打消是否开启也取决于用户是否应用了外接设备。比方,用户若应用耳机来进行通话,是不会产生回声的,天然也就不须要开启回声打消。 若间接应用手机麦克风和扬声器进行通话,就须要开启回声打消性能了。回声打消性能会对本地的人声产生肯定的抑制作用,所以对于不同的音量范畴和声音清晰度要求,回声打消的强度也会不同。 例如,在通话过程中,应用扬声器外放,并且把音量开启到最大,回声克制就能够开到最大,尽可能地将回声全副打消掉。相应地,本地人声也会受到最大水平的克制,须要在保障对方能够听分明的前提下进行克制水平的调整。 最初是 AGC 自动增益,它和回声打消克制人声有肯定先后逻辑,人声克制后,通过自动增益来放大声音,让声音达到对端听分明的水平。有一些手机的扬声器自身音量增益很小,也能够针对不同的机型做声音的增益,让本端的播放音量更清晰。 语聊房音乐与人声 奥妙均衡语聊房场景中,人声仍然很重要。然而语聊房的一个重要特点是,须要在房间内播放音乐来衬托氛围,达到业务场景中的娱乐作用。 主播唱歌展现才艺,也是晋升用户活跃度和营收的重要抓手。 那如何保障主播唱的歌传到观众端仍然柔美难听呢?这就与 3A 有很大关系。 ...

June 9, 2022 · 1 min · jiezi

关于算法:深度解析智能运维下告警关联频繁项集挖掘算法原理

在智能运维畛域,告警关联中的频繁项集开掘(也被称之为关联规定开掘)算法,在告警关联剖析、根因定位以及告警降噪中常常应用。本篇内容咱们将为大家介绍一种典型的频繁项集开掘算法:FP-Growth 算法。 一、告警关联简介随着大型公司零碎架构复杂性、异构性的疾速倒退,故障定位的效率和异样行为监测的准确度间接决定了公司内业务零碎的稳固水平,并间接影响了公司的理论经济效益。 因而,越来越多的公司开发出足够弱小的监控核心,可能无效治理、监控和追踪零碎中潜在的故障和曾经产生的故障,并将其作为警报发送给运维人员。然而如何高效的解决大量警报,也由此成为了运维人员面临的新挑战。 实践上讲,如果可能实时并百分百精确地实现对每个警报的根因定位,那么便可能无效解决这一问题。然而依据学术界目前的研究进展,在将来几年内都很难实现这一指标,次要起因不仅在于钻研自身的难度,也与警报的发送机制无关,很多状况下,根因警报反而在衍生警报之后收回,这使得实时根因剖析不可能失去最正确的后果。因而,不论是学术界还是工程界最终都更偏向于从 工夫 、文本、空间等维度开掘警报之间的关联关系,并依据这种关联关系实现警报的分组,依照所含信息量及重大水平等信息划分警报的优先级,以减速故障定位的过程。 为此,咱们提出了一种告警降噪的架构,并在其中具体的定义了告警关联这一问题,定义如下:依据关联场景,将肯定 工夫 窗口内的多个警报依照工夫、空间和语意相关性,关联为形容以后场景中特定问题的汇合,每个汇合称为一个事件。 基于这一定义,咱们研发出了多种算法剖析警报之间的关联个性,其中 FP-Growth 算法便是一种典型的剖析工夫相关性的办法。 二、频繁项集开掘简介频繁项集开掘罕用于购物记录剖析中,通过剖析用户常常一起购买的商品实现商品举荐性能。在这一场景中,频繁项集开掘是查找常常一起购买的商品组合的技术术语,而在告警关联场景中,咱们能够认为频繁项集开掘是指查找常常一起呈现的警报组合,其中每一个警报以及上文中的每一件商品都能够被称之为一个“项”,比方警报 ID“A”、“B”或者商品“啤酒”、“鸡蛋”都能够被看作一个独自的项。多个项组合在一起能够被成为一个项集,比方警报 ID 组成的项集["A"、"B"],商品项集["啤酒"、"鸡蛋"]。 这类问题的原始数据是多个项集组合成的数据库,频繁项集开掘的指标是应用疾速无效的算法辨认其中频繁一起呈现的项与项的组合,最容易想到的解决方案是遍历所有项,并列举出所有可能存在的项集,这显然须要耗费大量的工夫,因而咱们须要更好的解决方案。 三、Apriori 算法原理FP-Growth 算法是该畛域中最先进的算法之一,但为了更好的了解 FP-Growth 算法,咱们将首先介绍该畛域中最根本的算法,即 Apriori 算法,并借此引出频繁项集开掘这一畛域的局部基本概念。 在 1994 年提出的文章《Fast Algorithms for Mining Association Rules》中,作者提出了 Apriori 算法用于解决这类问题,这一算法次要蕴含 7 个步骤: 计算项的反对度频繁项集开掘算法基于反对度的概念,反对度能够被了解为在全副的项中,待计算项呈现的概率, 具体的计算方法是统计待计算项呈现在了几个项集中,以及原始项集的总个数,求取比值作为以后待计算项的反对度。 假如啤酒、纸尿裤都被 4 集体购买,鸡蛋只有 2 集体购买,则依据步骤 1,咱们可能计算出三件商品的反对度。 确定反对度阈值确定每个项的反对度后,须要一个规范用于过滤掉不常见的项,这个规范称之为反对度阈值。 比方对于步骤 1 中的数据,假如咱们并不心愿关注购买人次有余 3 人次的商品,则可将反对度阈值设定为 0.3。 筛选频繁项确定反对度阈值后,反对度低于这一规范的项将作为不常见的项被过滤掉,也就不会参加到后续的剖析步骤中。 在上文的案例中,鸡蛋便是被过滤掉的不频繁项。 计算频繁项集的反对度接下来的剖析与上文雷同,但剖析的单元从独自的项变成了项与项的组合也就是项集。比方上文提到的啤酒和鸡蛋组合后可看作一个项集。能够设想,通过对频繁项的筛选,须要生成的项集组合的数目比不通过频繁项筛选时要少得多。针对这些新的项集组合,咱们仍然能够统计他们的呈现频次,计算所有组合呈现频次之和,并确定他们的反对度。 对新的项集反复上述步骤通过步骤 1-4,咱们曾经实现了频繁项的过滤与组合,以及反对度的统计,反复上述步骤,咱们便能够取得蕴含更多项的频繁项集。 生成关联规定并计算置信度当初咱们曾经取得了频繁项集,在特定的场景下,仅仅是频繁项集并不可能满足使用者的需要,还须要将他们转化为关联规定,并针对这些关联规定的可信水平进行评估。 关联规定的格局为:项 X = > 项 Y,这意味着咱们取得了一条规定,规定的含意为在项 X 存在的状况下,有很大概率项 Y 也会存在。而置信度则是对这一规定的可信水平的考量,置信度 100%意味着项 X 存在的状况下,项 Y 永远存在,而 50%则意味着项 X 存在时只有 50%的概率同时呈现项 Y。这一指标可通过计算项 X 和项 Y 的呈现次数与项 X 独自呈现次数的比值取得。 ...

June 9, 2022 · 1 min · jiezi

关于算法:系列教程-用Jina搭建PDF搜索引擎Part-3

前两篇文章解说了PDF搜寻的操作方法,本期推送将解说构建PDF搜索引擎的教训和教训。 之前咱们以一个案例为代表讲述的PDF搜索引擎的构建,并不能包揽全副PDF搜寻的品种和状况。 咱们的初始版本如下: https://github.com/alexcg1/ex... 它旨在:01 具备通用性,并能很好地解决任何类型的PDF数据(强调工作良好 - 仅仅返回后果并不意味着它是好的 - 它须要返回高质量的后果)。 02 跨模态搜寻,因而你能够应用图像/文本作为输出/输入。 初始版本后果后果是次优的。我将一些从维基百科下载的 PDF 文件作为示例数据集,从那儿咱们能够找到任何事物的维基百科搜寻页面。 但数据迷信的根本规定是:绝大部分的工作都在于依据用例做数据预处理。因为每个潜在的应用案例都有截然不同的数据,因而破费数小时将维基百科 PDF 整顿好没有多大意义。 例如,在搜寻“兔子耳朵”时: 咱们能够失去简短的无序列表的文本片段,这些文本片段只有URL链接或者是只有几个单词长的字符串。 只管对于兔子耳朵的句子被索引了,然而其中大多数只是对于兔子的,没有提到耳朵。 与一些不太相干的匹配后果相比,最相干的匹配得分较低(在余弦中,分数越低意味着相关性越高)。 只管键入了所述图像的形容且被索引,然而都无奈返回图像。 后果失败起因01 编码器或模型自身不够好(反驳:CLIP 尽管不适宜文本,然而至多是可用的。) 02 兴许数据集自身太小了(反驳:尽管它只是几个PDF,但被分解成几千块,其中许多是残缺的句子或图像。) 03 索引(*尾注,文本片段,对书页的援用)不是“实在内容”,编码器无奈解读其中的大部分内容。(解释:可能是次要问题) 如何调整PDF搜寻以适应别人建设的PDF?到目前为止,在PDF搜寻中大多数人都心愿只关注文本,这并非好事。 以前咱们试图搜寻文本和图像,须要一个编码器能够将两者都嵌入到一个公共向量空间中。即 CLIPEncoder(如下所示): https://hub.jina.ai/executor/... CLIP 十分善于图像搜寻,然而文本搜寻体验较为个别! 咱们能够用什么来代替CLIP? 如果咱们只解决文本,咱们能够应用其余编码器,例如: 01 SpacyTextEncoder:反对多种语言,速度快,适宜通用文本。 参考链接: https://hub.jina.ai/executor/... 02 TransformerTorchEncoder:反对多种语言和非凡例子(例如医学文本搜寻)。 参考链接: https://hub.jina.ai/executor/... 咱们将建造什么样的搜索引擎?挪动部件更少就可能更分明地看到工作细节,咱们能够采纳这种策略构建搜索引擎。 因而,咱们咱们将为简略文本PDF构建一个搜索引擎,文本不须要太多预处理: 1、删除页码。 2、删除尾注、脚注。 3、解决大量援用和意外标点符号(如 )。Fly-fishing for Dummies, 1988 Penguin Press, A.Albrechtson et al, pp.3–8. http://penguin.com/flyfishing 4、在分页符之间合并文本块。 简而言之,剥离所有可能使编码器无奈运作的事物。启动运行后,咱们就能够开始思考: 1、更简单的 PDF(逐步减少)。 2、多语言搜寻(曾经存在用于此的模型)。 3、搜寻文本和图像。 欢送提出对 PDF 搜寻的想法!如果您有任何想法,通过https://slack.jina.ai/退出咱们的Slack,并在#projects-pdf 频道和咱们进一步探讨。 ...

June 8, 2022 · 1 min · jiezi

关于算法:Apsara-Stack-同行者专刊-怀同行之心筑信任之基践数智之行

简介: 政企云平台处在怎么的历史阶段?数智翻新的同行者们面临着怎么的挑战与时机?在时代巨幕下,政企期待云厂商表演怎么的角色?阿里云智能研究员、混合云平台总经理刘国华认为,云厂商不仅须要有定力与实力,也须要领会云平台的分量与温度。 编辑 切换为居中增加图片正文,不超过 140 字(可选) 行路过半,道阻且长 十几年前,许多人还不晓得"云"为何物;而当初,咱们的日常生活与云计算技术的倒退轨迹越发重合。从“双十一”全民购物狂欢日的海量交易反对,到春运铁路网络购票的海量承载,再到一个个政务云让越来越多的业务实现掌上办理,一路走来,行业逐步加深了对云的了解和承受,同时也对云的部署状态和产品个性有了更多的要求与期待: 从阿里云成立的2009年到2013年是中国云计算的孵化期,这个期间局部企业开始理解与尝试云计算,公共云技术在市场锻炼中一直成熟,但专有云尚处在孵化中,未能有大规模利用;2014年到2017年是探索期,一些有互联网型翻新业务的政企开始进行上云试点,来反对电商、互联网金融、社交媒体等海量在线业务或大数据型业务需要。彼时行业对于专有云的定义和技术路线没有对立明确,大家摸着石头过河,凌乱和变动是常态。阿里云专有云在这一时期诞生,而且一开始就明确了技术路线——不要独立于阿里云公共云从新构建专有云,而要做与公共云同根同源的原生混合云;2018年到2020年是成长期,政企的互联网+业务大规模上云。随着云计算的逐步清朗,全栈云逐步成为行业共识,也验证了在探索期阿里云专有云技术路线的前瞻性和正确性。这个期间,阿里云专有云的成长也十分迅速,短短几年服务了近千位中大型政企客户,与客户同行的过程中,咱们也一直修炼内功。从2021年到将来的2025年,行业将会进入精进期。在数字化改革和国家对自主翻新技术可控的提倡下,政企纷纷建云,传统业务也在往云上迁徙。与之对应,各个云厂商的产品技术也逐步走向成熟,技术竞争的门槛一直贬低,须要云平台有更加综合的能力。阿里云也更加动摇地面向未来进行布局——将专有云产品事业部策略降级为混合云产品事业部。 编辑 切换为居中增加图片正文,不超过 140 字(可选) 聚焦当下,尽管云平台在实践中一直精进,然而在反对与服务政企方面,整个行业还面临着一系列挑战: 云平台须要更强的企业级个性来满足政企需要:毋庸置疑,云是从互联网诞生的,在反对互联网业务的过程中熟能生巧,然而政企业务需要的特殊性和复杂性对撑持的技术平台提出了更高的要求,这就意味着原生混合云平台的企业级个性仍需晋升;云厂商对于政企数智化转型的经验不足:和传统IT仅在底层提供反对不同,云平台纵向逾越了建云、管云、用云等多层面,即便和政企有宽泛单干、对政企组织架构与工作流程有所理解,还是远远不够。对于云厂商而言,更须要理解的是适宜政企的IT运维和业务经营模式,打造适宜政企的交付和服务模式,从单纯的供应商降级为深度的服务商,能力让云平台领有政企可信可用的能力。 当初,政企对于混合云云平台曾经有了初步的理解和体验。然而,在云平台的概念术语、架构理念、设计准则、技术原理、运维办法、最佳实际以及配套的治理形式、人才素质、组织流程、制度标准等方面,咱们还将继续和政企之间,更深刻地做好常识传递交换、需要了解共识以及实际共建共创。让政企对混合云架构有全面的“白盒化”安全感、可控感、自主感,晋升政企全面上云的信念,管制全面上云的危险,保障业务平安稳固运行。 另外,随着混合云云平台技术架构将本来绝对独立的计算、网络、存储、平安等竖井式,变成了软件定义化、分层服务化、软硬一体化的全新云平台架构,与之绝对应,IT人才也要从传统繁多某垂直畛域的专业性人才,演进到“有利用、数据、技术全局视线和能力”的全栈型企业架构人才,“有软件能力又有技术特长”的软件定义化人才,“懂市场业务又懂技术产品”的服务经营型人才。这些复合型人才的倒退需要,也须要政企在上云过程中,通过互联网翻新、全面上云、团体整合、上下游整合、行业整合,倒退云的规模经济、平台经济和数智经济,进而带动人才队伍的转型和倒退。 在精进期,能够预想到的是,政企对于云平台的企业级需要会催化云产品的成熟,这十分考验云厂商的定力与实力。因为没有弱小的实力,则无奈满足一直新增的需要;另一边,如果没有足够的定力,则会陷入需要驱动的有限循环。若此时技术路线再重复摇晃,就会导致产品兼容性差,无奈爱护客户既有的IT投资,让云平台的使用者有苦难言。 不忘初心 方得始终 在精进期,云厂商不仅须要有定力与实力,也须要时常记得云平台的分量与温度。我曾实地参观访问过东北某农信云平台,在当地的营业厅里办理低保业务的农民老人默默排着队,这个云平台传递着国家对他们的搀扶与承诺;某省的政务云平台如果呈现问题,那天的民政局门口将无奈看到新人的笑脸,因为他们不能在本人选出的“良辰吉日”领到结婚证,这个云平台反对着社会对一个个大家庭最后的承诺;某电网云平台承载着万家灯火的平静祥和,守护着咱们每一个早晨在灯下辅导孩子作业,陪前辈看看电视剧的奢侈幸福。这样的例子还有很多,每一个场景的背地,都株连着一个行业的寄托: 政府:我国政府的云化比例曾经很高,公共服务实现一网通办,便民利民;接下来,政务云平台须要对资源进行粗放治理,反对业务翻新,并摸索对外行业云的经营售卖;金融:大部分金融机构曾经将泛互联网类新型业务建在云上,同时在被称为“银行IT皇冠上的明珠”的外围零碎畛域上积极开展上云试点。金融客户对于安全性和可靠性的要求十分高,须要前沿的技术撑持,并须要实现自主可控与自运维,以满足本身对于技术的可控性;企业:央国企大型团体往往领有宏大的分支机构,心愿通过“物理扩散,逻辑对立”的架构来匹配总部对于省市公司既要对立治理,又要最大化激发企业自主生机的组织运作模式;同时,大型企业目前须要成熟的行业解决方案,逐渐从公共服务上云,过渡到经营管理系统上云,再将生产治理外围利用迁徙上云,一直加深云化。 编辑 切换为居中增加图片正文,不超过 140 字(可选) 在时代背景下,做好政企在数智翻新路上的同行者,是云厂商的历史使命。一路走来,反对云厂商和政企同行的根底,是信赖: 这份信赖来自对技术领导力的认可,云厂商要深耕不辍,放弃技术和路线的先进性和前瞻性,成为行业的指南针和水位线;这份信赖也来自对产品的应用体验,云厂商的产品是否能满足企业级需要,继续投入进行稳固的产品升级,保障产品能力迭代的连续性;这份信赖还来自于深度服务的良性循环,无论政企还是云厂商,在数智翻新的路上,大家也是IT的同行,将来的单干关系将不是简略的上下游,更像是能力互补的拼图式单干,彼此促成,实现螺旋式回升。 编辑 切换为居中增加图片正文,不超过 140 字(可选) 加强信赖 同行致远 当用“同行者”的特色来掂量阿里云混合云时,通过四个阶段的倒退,咱们也积淀了一些教训: 首先,基于对云计算的深刻理解以及时代课题的规律性把握,咱们在技术方向的抉择上十分动摇,七年来始终如一保持和公共云同宗同源的飞天架构,让阿里云混合云的产品和架构能够一以贯之,得以连续。当初越来越多的云厂商认可了这样的技术路线,阿里云也曾经凭借先发劣势积攒了技术的代际劣势;保持走自研可控的路线,灵便随着中国政企客户的理论需要演进云产品能力。阿里云混合云每一次产品的跨越式迭代,其本源都是中国政企客户具体的课题和需要。咱们的产品,不是在文稿中写进去的,而是在满足客户业务场景的过程中被打磨进去的;积攒大规模的业务实战经验,让政企客户在精进期不用放心成为“小白鼠”。阿里云混合云曾经服务了1000多个客户。孤举者难起,众行者易趋,丰盛的客户实际让同行者的队伍更加宏大。 编辑 切换为居中增加图片正文,不超过 140 字(可选) 客户的外围业务上云,意味着咱们要有更多的敬畏之心,放弃同行(Xing)的心态,保持IT同行(Hang)的姿势,凭借专业性取得政企客户的信赖,用技术推动业务的倒退,同时在客户业务的倒退过程中持续降级技术,相互成就。 行胜于言,2021年咱们公布的Apsara Stack 2.0,既是与政企同行的工具,也凝聚了同行的信心: 与Apsara Stack 2.0绝对应的是企业外围利用全面上云的大势所趋,云曾经成为了企业数字化翻新的基石与枢纽,阿里云混合云核心技术的降级次要有三个方面:第一,阿里云公共云最新最先进的云计算技术,在阿里云专有云中亦得以实现,让专有云具备了“一云多芯、一云多Region”以及“全场景灾备”的能力。这其中的局部能力所体现的企业级个性,甚至比公共云更胜一筹,以更好地满足政企客户的外围诉求。能够说,阿里云专有云在有些方面能够做到“青出于蓝而胜于蓝”。之后,专有云不仅因与公共云同宗同源而自信,公共云也会为专有云的企业级个性而感到自豪。第二,再度降级“管云”的能力,从原来可治理、可运维的云,逐渐降级为可经营的云。从运维到经营的能力拓展,意味着阿里云混合云对云基础设施的“治理”降级到对云基础设施的“治理”,通过治理解决整个团体的IT、整个技术架构演进以及老本管制、对外经营等方面的问题。第三,降级了部署架构。除了当初反对的核心云以外,咱们的产品版本能力曾经能够反对边缘计算,真正实现云边一体的混合云架构体系。这个从核心云到边缘的残缺模式,得益于阿里云混合云业界当先的残缺技术架构体系。 编辑 切换为居中增加图片正文,不超过 140 字(可选) 编辑 切换为居中增加图片正文,不超过 140 字(可选) 编辑 切换为居中增加图片正文,不超过 140 字(可选) 随着Apsara Stack 2.0的公布,咱们也明确了阿里云混合云的品牌愿景——政企数智翻新的同行者。心愿能以这样的身份,不仅帮忙政企建好云,更能管好云、用好云:第一,真金不怕火炼。咱们通过“同行者我的项目”,去推动整个云计算的技术白盒化,咱们有底气把云计算“解剖”进去,与咱们的客户讲清楚云计算的原理是什么,咱们的设计理念是什么,设计的劣势和局限别离是什么。通过这种形式,帮忙客户更好地了解云计算的外部原理,从而更好地把云放入整体技术布局中。第二,授人以鱼不如授人以渔。咱们把阿里巴巴过来近20年在运维畛域的教训形象总结进去,基于阿里巴巴的最佳实际,构建了“利用+云平台”的一体化运维形式,帮忙客户端到端实现整体的业务平安生产建设和运维能力建设。此外,基于业务场景,咱们提供方法论和残缺的利用运维平台,便于与客户的业务更好地联动,让云利用平台成为客户整体经营平台一部分,最终实现运维平台的利用评级以及全链路协同的平安生产体系。第三,机会总是留给有筹备的人。面向未来的云原生时代,咱们的云效领有构建研发麻利和组织麻利的“双敏”能力。它来自于阿里巴巴过来近20年的研发体系构建教训,阿里巴巴外部同样也在应用。当初,咱们把它命名为“云效”,输出到客户端,来帮忙客户减速整个利用的云原生革新,把业务从传统的研发模式牵引到云原生的形式,构建“组织麻利和研发麻利”的“双敏能力”,最终实现十倍研发效力晋升,让客户取得用好云的最佳实际。 编辑 切换为居中增加图片正文,不超过 140 字(可选) ...

June 8, 2022 · 1 min · jiezi

关于算法:大容量高性能国家级实验室分布式并行文件存储实践

近年来,北京、上海和粤港澳大湾区科创核心、综合性国家迷信核心建设热火朝天,国内曾经呈现一批科技翻新当先,无力撑持国家技术倒退的新型科研机构。在人工智能、信息网络、生物技术等战略性产业中,新型科研机构须要借助具备创新性、引领性的基础设施,一直摸索未知领域,为颠覆技术创新而致力。 作为国家级的网络通信畛域新型科研机构(以下简称:实验室),实验室聚焦宽带通信和新型网络等重要策略工作,以网络通信、网络空间和网络智能为次要钻研方向,发展畛域内战略性、前瞻性、基础性重大迷信问题和要害核心技术钻研。 在倒退过程中,该实验室抉择引入前沿的分布式并行文件存储技术,搭建起超大容量的存储集群,撑持其在智能交通、计算机视觉、自然语言、主动驾驶、智慧医疗等方面的试验钻研训练数据。 打造双轮驱动模式,建设高性能存储支柱该实验室保持以重大工作攻关和重大科技基础设施与平台建设为牵引,以科技翻新和体制机制翻新为主线,深刻摸索在社会主义市场经济条件下,要害核心技术攻关新型举国体制,建成了若干重大科技基础设施与平台,公布了多语言机器翻译平台,以及中文预训练语言模型等一系列重大利用。 为了进一步打造“重点项目+根底钻研”的双轮驱动特色科研模式,该实验室需建设一个能全方位撑持钻研训练的存储平台,满足实验室在技术钻研过程中的数据训练需要。在建造新型数据中心的过程中,性能、可扩大能力、安全性等是重点思考的因素: 在性能方面,在每次 AI 训练过程中,须要拜访数 TB 左右的数据,这部分数据须要被几百个计算节点同时拜访,导致其对存储吞吐量和数据加速度的要求极高。因而新建设的 IT 基础设施必须满足性能高、存储空间大的特点;在可扩大能力方面,在以后的效力计算体系中,该实验室须要搭建 64PB 的高速并行可扩大存储,次要面向于国家重大策略我的项目中的智能训练,其中蕴含着不少图片、视频、语音等非结构化数据。然而传统存储体系,无论是 DAS(直连存储设备),还是 NAS 矩阵,不仅很难撑持海量的数据存储需要,更是难以跟上数据激增的步调,存储平台的可扩展性也非常重要;在安全性方面,工信部在一直建立健全行业数据安全保障体系,实验室在建设存储平台过程中也要时刻关注数据安全性问题,在摸索新技术钻研利用过程中,也要实现平安防护技术的智能化和自主可控。一站式分布式并行文件存储,满足数据平台全方位需要焱融科技在服务过的大量客户实际案例中,遇到过不少相似的状况,不仅领有丰盛的计划教训,而且外围产品 YRCloudFile 也在类似案例中稳固运行多年。通过屡次测试和考查,该实验室最终抉择与焱融科技达成此次单干,独特建设高性能的国家级数据平台。 在这样的背景下,该实验室抉择部署超过 1800 块磁盘存储集群,为我的项目提供了靠近 30PB 的高速并行文件存储空间,同时配合 200Gb 的超高宽带网络和磁盘的混合搭配,完满实现存储集群从 0-1 的搭建,不仅满足了超大容量的需要,而且也能实现在数据量突发增长时,疾速扩容,不影响训练状况。 通过焱融科技提供的存储计划,该实验室搭建起大规模高速并行可扩大存储的数据平台,满足了根底钻研须要的同时,有了更多的播种: 算力跃迁:相较于常见的分布式存储和传统存储,其在面向人工智能的小文件场景和高性能计算并发时,存储性能和并发性能都有肯定水平的限度,难以达到最优成果。焱融科技自主研发的数据传输协定基于 RDMA 技术的 InfiniBand 网络,实现了超过 400GB/s 的数据吞吐带宽,且超高带宽的实现也为平台性能再次加码,造成点对点的传输方式,让数据传输效率晋升近 60%,减速计算周期。数据保密性极强:数据寄存采纳了焱融科技并发分布式文件存储,让数据以切片的模式存在不同的存储节点上,同时实现多节点备份。让居心叵测的人即便从存储节点上拿走了磁盘,也无奈读取到残缺的数据。大大晋升了数据的安全性,让数据能够失去永恒的存储,从基本解决了数据安全问题。老本和性能极致均衡:在 AI 训练过程中,YRCloudFile 文件存储系统的智能分层性能能够依据用户须要,自定义冷热数据策略,冷数据主动流动至低成本的对象存储并实现压缩,向上依然为业务提供规范的文件拜访接口,并放弃目录构造不变,数据在冷热数据层之间流动对业务齐全通明,能无效地对老本和性能做好均衡。易用性极高:YRCloudFile 所具备的全对称、可扩大的元数据集群架构,反对实验室在面对数十亿文件时,对元数据的操作性能以及读写性能继续保持稳定。同时,YRCloudFile 曾经完满兼容适配以后国内外多个 Kubernetes 发行版,包含但不限于 Rancher、灵雀云、浪潮云、博云、谐云等。YRCloudFile 铸基国家级实验室基础设施建设实验室采纳焱融科技 YRCloudFile 提供的解决方案,打造了一套高性能、高可用、高扩展性的 IT 存储基础设施,无效实现数字孪生建模、仿真、交互、在线服务等技术冲破,并撑持示范利用、智能人机交互关键技术的冲破,为实验室技术疾速落地提供了要害撑持。 数据平台作为数据的核心、计算的核心、网络的核心,撑持着信息技术的减速翻新。同时,数据平台作为互联网和各行业数字化的技术实体,利用于生产生存的多个环节,撑持技术创新疾速倒退。焱融科技作为一家高性能文件存储和容器存储的领导者,长期致力于为各大企业日益增长的海量数据提供优质的存储、治理和应用服务。将来,焱融科技将继续为更多创新型科研机构提供强力存储撑持。

June 6, 2022 · 1 min · jiezi

关于算法:打造哈啰自动化增⻓算法闭环下

导读:上篇咱们介绍了哈啰C端算法场景和挑战及哈啰被动增长算法。本篇次要介绍哈啰被动增长算法和哈啰增长引擎的实际。 哈啰被动增⻓算法端内流量散发 被动增长更多是一种流量算法。咱们端内的流量散发参考了广告平台,实际上它没有真正的竞价结算,然而咱们把流量在各个业务线的散发之间,其实是有竞价机制的存在。这里的竞价是通过一个归因工具来做真正的价格辨认,难点次要是归因工具外面的口径,须要所有业务线都认可,这须要自上而下的推动才可能实现。 另外是短期的流量效率和长期的穿插引流,咱们心愿一个用户尽可能在平台同时应用多个业务。这两个指标其实有肯定矛盾,实际上咱们能够把长期穿插引流看成LTV的价值,只有把这个价值定义分明,其实和咱们短期的GMV的指标也是可比的,能够放在同一条公式上进行竞价排名。具体的模型用的是一些经典模型,选型的思路就不细说。次要是咱们的特色还不够多,特色组合在咱们这特地重要,所以咱们用 Autolnt会绝对多一点。在某些弹窗畛域,它的用户行为事件会特地强,所以咱们须要更好的序列embedding,基本上会用最原始的DIN。 虚构商城排序 比拟特地的是咱们这外面很多排序,它并不是实物卡券这些货色。虚构商品和实物商品有很大的不同,第一个特点是它的item会特地的少,可能最多就几十个。另一个特点就是用户在不同的优惠券之间的抉择,并不是基于像电商畛域的趣味购买做抉择的,而是基于比价之类的纯感性纯利益方面的抉择。所以说它的item之间是互斥的,咱们用户量又很大,特色维度又少,这就导致咱们这个场景其实不太适宜用PointWise的办法。咱们一开始尝试了PairWise之后,发现效果显著高于 PointWise,前面就改成ListWise框架,而ListWise损失函数类型用的是Softmax穿插熵。咱们有一个Generator的模块来结构这个list,另外是给这个list的序列进行打分,这个咱们叫 Evaluator。目前应用的模型是DCN的第二版本和Bi-LSTM。Bi-LSTM对咱们的item序列特色进行抽取,前面具体的打分评估是通过DCN实现。 搜寻举荐 在搜推畛域,因为咱们本地生存很多,比如说逛逛、门票、租车、游览、酒店等等。因而传统的搜推的一些办法,包含召回的embedding和排序的CTR预估都有做。须要重点提的是咱们在本地生存上尝试了一个二维的多指标学习,因为本地生存在主页上有一些举荐位,详情页也有一些举荐位。咱们想这些不同举荐位,它的CTR和CVR预估都能用一个模型,所以参考了二维多指标学习。 另外是多域或多业务的一个模型,咱们在逛逛中尝试了这个。CTR的晋升比拟大,让首页和详情页可能共用一个模型,每个场景都有本人的独立子网络,同时又有一个公共子网络,这样就可能博采众长。 哈啰增⻓引擎算法组件化 哈啰最后做算法的思路,是想尽可能高效的进行整个算法体系建设,因为咱们的人力很无限。所以咱们不同的域有本人特色的算法,最终不同域特色算法,咱们都会把它落地成一个组件,其余域的开发同学也就不会反复开发。 一个算法组件基本上分为两局部。一个是离线局部,离线局部就是一个规范的表,一个规范的工作格局,输入一个规范的后果类型,这是一个离线的组件。另一个是在线组件,会对咱们不同的在线推理算法进行一些规范在线推理的代码。通过这种组件化,咱们把一个新场景的接入工夫从均匀一个月升高到了一周到两周。 搜推⼀体化引擎 咱们的搜寻举荐用的是一套引擎,并不是两套,因为像垂类的业务其实是没有必要这么做的,咱们当初其实实质上是在倒退为一个中厂的平台。而大厂有不同的团队,共用一个引擎历史包袱很重。但搜推引擎也有一些不同,它并不是齐全一样,咱们也会针对搜寻和举荐的不同,对搜寻的QueryParser这块进行独自的用意辨认组件的建设。所以咱们最终的搜推是一个引擎,一体化之后能让咱们的开发成本升高一半。 在搜推引擎建设之后,一个新业务想要疾速对接进来,基本上是通过服务编排的形式。通过简略的配置和服务编排,再抉择一些规范的算法组件,就能把一个新的场景疾速的配置起来,只须要业务方对咱们的数据格式以及API进行简略对接。 营销引擎 接下来是营销引擎,咱们刚刚提到了营销根本会有4w2h,这些工具是在一个链路上的,怎么把它串联起来,让每个工具都用到全局的数据,以便指标也可能拉齐。所以咱们要建一个数据和指标的总线,这样就须要一套引擎才可能实现。 如果不建设这个引擎会产生什么状况,大家可能看到当初有很多APP满屏都是营销弹窗,这对用户体验和成果有很大的损失。咱们这边通过引擎能够让不同的投放工具或者不同的投放流动之间进行一个拉通,从而让他们的投放更有节奏,不会对用户进行适度的打搅。 L3⾃动化⽤户经营策略零碎 对两轮这块,咱们更进一步试点了自动化经营。咱们把最后提到的很多策略,进行了一个标准化的形象之后,积淀了很多策略。往年很多策略能够主动的触发,有日常的有周期的。比如说梅雨季节,咱们就须要很多促销,因为大家不太违心出行或者骑车。这时候很多的促销策略会主动触发,目前大部分策略曾经达到了自动化经营的程度。 从新思考C端算法 最初咱们来说说做了这一年半之后,咱们本人的一些认知的变动。咱们最后的算法同学基本上都是在排序召回的漏斗中找一些点的优化点,这样做的话就会越做越死。一个场景刚上的时候成果很好,可能做个一两年也就优化不动了,对于算法自身也就是提效的作用,只是精益求精。对某个业务来讲,有算法和没算法并没有一个量变,所以咱们更多是工具人的角色。 而在深刻业务之后,咱们更多从一个新的视角,或者说从经营视角上对待整个C端算法,最终是为了晋升整个公司的数字化经营的效率,而整个经营效率它是能够拆解的。咱们C端其实就是做增长,刚刚提到的被动增长和被动增长,其实最终都是要落在流量上,只是对待的视角和维度不同而已。在这种新的对待C端算法的形式之后,就更容易在整个经营链路中找到一些结构性的机会,而不是最后点的机会。 最近因为疫情互联网的大环境整体并不好,算法工程师的将来会是什么样?在我看来在这种局势下,技术作为次要的驱动力是更加凸显的,而不是说减弱,因为简略的产品经营的形式进行的增长缓缓没有太多了,技术上的发力点空间还很大。所以咱们认为在C端算法畛域,技术的作用和位置会进一步的晋升。 咱们来做一个总结,在传统的技术视角下肯定会越来越内卷。咱们的算法同学在当初或者在将来几年肯定是多面手的角色,最好成为一个业务专家,这样的话你在面中找结构性机会才会更容易。 其次,尽管Match- Rank曾经玩不出太大花色,但不同的公司还是能够做微翻新的。比如说咱们场景中的表和别的场景就不一样,咱们是大窄表。咱们的用户量很大,然而特色并不是高维稠密,所以咱们会选一些非高维稠密的模型。另外咱们推的很多虚构商品有锚定效应,ListWise在传统的电商举荐等场景不会作为一个主模型,最多在重排等外面做纠偏。另外像PU-Learning等技术,辨认真正的负样本,当然还有其余的一些偏差,这种偏差在某些场景特地大,而不是咱们设想中的那么少。 另外,因果推断作为咱们这里确定性的趋势,咱们肯定会继续的发力,把各个领域CTR预估的办法都缓缓转为因果推断的办法,同时因果推断也是一种去偏的形式。咱们目前也在建设一个因果推断的平台,不仅在营销畛域应用,也会在硬件的故障诊断以及经营的归因剖析等畛域尝试应用。 效率方面,因为人力的问题,咱们会一直的往通用模型、主动训练的方向倒退。目前咱们精准定向这一块的圈人曾经实现了自动化训练。 最初我想说,咱们的算法同学还是要用外卷来破除内卷。而破除的办法就是从新对待咱们本人的角色,以及从新的视角从新定义咱们的业务。 (本文作者:贾立) 本文系哈啰技术团队出品,未经许可,不得进行商业性转载或者应用。非商业目标转载或应用本文内容,敬请注明“内容转载自哈啰技术团队”。

June 6, 2022 · 1 min · jiezi

关于算法:COM4509-MLAI使用

COM4509/6509 MLAI - Assignment Part 2 BriefDeadline: Friday, December 3, 2021 at 15:00 hrsPlease READ the whole assignment first, before starting to work on it. Check out the FAQ with important clarifications (last update: 9:48am 29 Nov 2021)Scope: Sessions 6 to 8; Number of marks available for Part 2: 25How and what to submit A Jupyter Notebook with the code in all the cells executed, outputs displayed, and code documented. We expect to see all the answers in the notebook. Yes, you need to create one.Name your Notebook as COM4509-6509_Assignment_Part2_Username_XXXXXX.ipynb where XXXXXX is your username such as abc18de.Upload a .zip file to Blackboard before the deadline that contains two Jupyter Notebooks, one for Part 1 and one for Part 2 (COM4509-6509_Assignment_Part1_Username_XXXXXX.ipynb and COM4509-6509_Assignment_Part2_Username_XXXXXX.ipynb)NO DATA UPLOAD: Please do not upload the data files used in this Notebook. We have a copy of the data already. Instead, please use a relative file path in your code (data files under folder ‘data’), as in the lab notebook so that we can run your code smoothly when needed. So ‘./data/’, instead of ‘/User/username/myfiles/mlai/assignment1/’Assessment Criteria1)Being able to build complete, reproducible machine learning pipelines from loading data to evaluating prediction performance.2)Being able to design different machine learning models to compare/optimise prediction performance.3)Being able to perform exploratory data analysis to gain insights. Late submissionsWe follow Department's guidelines about late submissions, i.e., a deduction of 5% of the mark each working day the work is late after the deadline. NO late submission will be marked one week after the deadline because we will release a solution by then. Please read this link if you are taking COM4509 or read this link if you are taking COM6509.Use of unfair means"Any form of unfair means is treated as a serious academic offence and action may be taken under the Discipline Regulations." (from the students Handbook). Please carefully read this link on what constitutes Unfair Means if not sure, for COM4509. If you are taking COM6509, please read this link if you are not sure what is Unfair means. If you still have questions, please ask your Personal tutor or the Lecturers. ...

June 4, 2022 · 8 min · jiezi

关于算法:COMP3023-算法学习

COMP3023 Design and Analysis of AlgorithmsFall 2021Programming AssignmentSubmission by Nov 28 2021Instructions:Write a program that can return any three of the following four artifacts from a given weighted,undirected graph: (Note each numbered item is considered as one artifact.) A Depth-First Search (DFS) Tree (Lecture06)All its Articulation Points (AP) and Biconnected Components (BC) (Lecture06)A Minimum Spanning Tree (MST), using Kruskal’s Algorithm (Lecture08)The Shortest Path Tree (SPT), using Dijkstra’s Algorithm (Lecture09)The input to your program is a data file named graph.txt, which specifies 1) the number of vertices(int), 2) the number of edges (int), 3) each edge’s two vertices and its weight (int). A sample input fileis shown in Figure 1, along with the actual graph that it represents:680, 1, 30, 2, 30, 3, 41, 3, 32, 3, 23, 4, 43, 5, 24, 5, 4Figure 1 A sample input file with the graph it representsYour program shall read the file name from keyboard, read the graph information from the file, runthe above-mentioned four algorithms, and display the results on the console. Your program shallrepeatedly ask for an input data file until the user press "CTRL+Z". A sample of console output is given on thenext page, in Figure 2.Submission:Please write your program in C or C++.Put all your code in one single file and name it PA_#######.cpp, where ####### is yourstudent ID.Build an executable file and name it PA_#######.exe.Pack the .cpp and .exe files into a zip file and name it PA_#######.zip.Please make sure your program can be executed. An unexecutable program willautomatically yield a grade of zero.43 44 3 42 252 ...

June 4, 2022 · 2 min · jiezi

关于算法:6-Z-字形变换

public class ZConvert { public String convert(String s, int numRows) { int n = s.length(), r = numRows; if (r == 1 || r >= n) { return s; } StringBuffer[] mat = new StringBuffer[r]; for (int i = 0; i < r; ++i) { mat[i] = new StringBuffer(); } //一个周期元素个数 = numRows + (numRows - 2); int t = 2 * (numRows - 1); //指标字符串共须要 (n/t) + 1 个周期 int tCount = (n/t) + 1; //以后遍历的下标 int index = 0; for (int i = 0; i < tCount; i++) { //以后周期下标 <= 字符串长度 if (index+t <= n) { //截取以后周期的字符 processT(s.substring(index, index+t), numRows, t, mat); } else { processT(s.substring(index, n), numRows, t, mat); } index += t; } StringBuffer ans = new StringBuffer(); for (StringBuffer row : mat) { ans.append(row); } return ans.toString();}public void processT(String sSub, int numRows, int t, StringBuffer[] mat) { int count = t; //子串的长度 小于 周期 if (sSub.length() < t) { //从新赋值子串遍历个数 count = sSub.length(); } for(int i = 0; i < count; i++){ char ele = sSub.charAt(i); //遍历次数 小于 t-(numRows-2) if (i < t-(numRows-2)) { //间接追加以后字符 mat[i].append(ele); } if (i >= t-(numRows-2)) { //遍历次数 大于等于 t-(numRows-2) int matIndex = numRows-(i+1)%numRows-1; // mat的下标 = numRows-(i+1)%numRows-1 mat[matIndex].append(ele); } }}public static void main(String[] args) { String s = "PAYPALISHIRING"; String target = "PAHNAPLSIIGYIR"; String result = new ZConvert().convert(s, 3); Assert.check(target.equals(result), "失败"); System.out.println("胜利!");}} ...

June 2, 2022 · 2 min · jiezi

关于算法:递归迭代和动态规划以九宫格键盘为例

本文记述笔者的算法学习心得,因为笔者不相熟算法,如有谬误请不吝指正。 九宫格键盘问题给定一个从数字到字母的映射表:1 => [a, b, c], 2 => [d, e, f], 3=> [g, h, i], ......,实现一个函数List<String> calculate(String input),若用户输出任意的数字串,要根据映射表转换每一个数字,返回所有可能的转换后果。例如,若输出“12”会失去ad, ae, af, bd, be, bf, cd, ce, cf这9个后果;若输出“123”会失去27个后果。 以上是此题的根底版,还有一个难度加强版:映射表的键还能够是数字组合,如12 => [x], 23 => [y]。若输出“12”会有10个后果,还会有x这1个后果(总共10个后果);若输出“123”,岂但有之前的27个后果,还会有xg, xh, xi, ay, by, cy这6个后果(总共33个后果)。 根底版的解法能够用递归法也能够用迭代法,两种办法是等价的。以下是算法思维和实现代码。 递归法递归法的思维是继续把问题降解为子问题,直到子问题足够小。例如,calculate("123")等价于calculate("1") * calculate("23"),而calculate("23")等价于calculate("2") * calculate("3")。这里引入了一种非凡的汇合乘法,能把如[a, b, c]和[d, e, f]这样的两个汇合相乘失去9个后果(即输出“12”对应的后果),这种乘法能够用一个函数来实现。如此就清晰地表述了递归法的算法框架。 实现代码为 static List<String> calculate(String input) { if (input.isEmpty()) { return Collections.emptyList(); } String key = String.valueOf(input.charAt(0)); List<String> values = mappings.get(key); String substring = input.substring(1); if (substring.isEmpty()) { return values; } else { return product(values, calculate(substring)); }}// 乘法static List<String> product(List<String> lefts, List<String> rights) { List<String> results = new ArrayList<>(); for (String left : lefts) { for (String right : rights) { results.add(left + right); } } return results;}迭代法迭代法的思维是顺次解决输出的每一位,用已得后果集示意以后状态,记住和更新以后状态。例如,calculate(“123”)的处理过程是,第一步解决”1”,失去初始状态[a, b, c],第二步解决”2”,让以后状态[a, b, c]乘以“2”对应的[d, e, f],失去新状态[ad, ae, af, bd, be, bf, cd, ce, cf],第三步解决”3”,让以后状态乘以”3”对应的[g, h, i],失去新状态,此时输出值已全副解决实现。 ...

June 1, 2022 · 3 min · jiezi

关于算法:CS-440-人工智能

CS 440: INTRODUCTION TO ARTIFICIAL INTELLIGENCE FALL 2021Assignment 3Adversarial Search - Bayesian NetworksDeadline: December 7th, 11:55pm.Perfect score: 30.Assignment Instructions:Teams: Assignments should be completed by teams of up to three students. You can work on this assignment individuallyif you prefer. No additional credit will be given for students that complete an assignment individually. Make sure to writethe name and RUID of every member of your group on your submitted report.Submission Rules: Submit your reports electronically as a PDF document through Canvas (canvas.rutgers.edu).Each team of students should submit only a single copy of their solutions and indicate all team members on theirsubmission. Failure to follow these rules will result in lower grade for this assignment.Late Submissions: No late submission is allowed. 0 points for late assignments.Extra Credit for LATEX: You will receive 10% extra credit points if you submit your answers as a typeset PDF (usingLATEX, in which case you should also submit electronically your source code). There will be a 5% bonus for electronicallyprepared answers (e.g., on MS Word, etc.) that are not typeset. If you want to submit a handwritten report, scan it andsubmit a PDF via Canvas. We will not accept hardcopies. If you choose to submit handwritten answers and we are not ableto read them, you will not be awarded any points for the part of the solution that is unreadable.Precision: Try to be precise. Have in mind that you are trying to convince a very skeptical reader (and computer scientistsare the worst kind...) that your answers are correct.Collusion, Plagiarism, etc.: Each team must prepare its solutions independently from other teams, i.e., without usingcommon notes, code or worksheets with other students or trying to solve problems in collaboration with other teams. Youmust indicate any external sources you have used in the preparation of your solution. Do not plagiarize online sources andin general make sure you do not violate any of the academic standards of the department or the university. Failure to followthese rules may result in failure in the course.Problem 1 (10 points) : Consider the two-player game described in Figure 1. ...

June 1, 2022 · 7 min · jiezi

关于算法:生成一定范围内的随机整数

Math.random()是令零碎随机选取大于等于0.0且小于1.0的伪随机double值Math.random()*99是生成一个大于等于0且小于99的随机数Math.floor(x)返回小于参数x的最大整数,即对浮点数向下取整,因而能够用Math.floor(Math.random()*99)取得随机整数想要生成大于等于5且小于12的随机数,应用5+Math.random()*(12-5);封装成js办法如下 function getRandomValue(minValue, maxValue) { return Math.floor(Math.random() * (maxValue - minValue) + minValue);}

June 1, 2022 · 1 min · jiezi

关于算法:两数之和

输出:一个整数数组,一个指标整数计算:在数组中找出和为目标值的两个整数,留神不能为同一元素输入:两个数对应下标组成的数组,找不到则返回空数组 eg:输出[2,3,5,7,11,15],1010 = 3 + 7 => [1, 3] 法1:for + indexOf function sumOfTwoNum(arr, target) { for (let i = 0; i < arr.length; i++) { let value = target - arr[i] if (arr.indexOf(value) !== -1 && arr.indexOf(value) !== i) { return [i, arr.indexOf(value)] } } return []}let arr = [2,3,5,7,11,15]let target1 = 10let target2 = 19console.log(sumOfTwoNum(arr, target1))console.log(sumOfTwoNum(arr, target2))法2:应用字典map function sumOfTwoNum(arr, target) { let map = new Map(); for (let i = 0; i < arr.length; i++) { // num 为 target 减去 以后循环的数值 num = target - arr[i]; // 在map中查找是否有键名为num的元素 if (map.has(num)) { // 如果有,返回num的下标,以及以后循环的下标 return [map.get(num), i]; } // 如果没有,存进map // 键名为数值,值为下标,因为最终须要返回的是下标 map.set(arr[i], i); } return []}let arr = [2,3,5,7,11,15]let target = 10console.log(sumOfTwoNum(arr, target))

June 1, 2022 · 1 min · jiezi

关于算法:对数组按指定特征进行分组

输出:数组,函数/属性输入:对象,其中key:数组所有元素通过解决后的值,value:雷同key的数组元素汇合 eg:输出[6.1,4.2,6.3],Math.floor输入{4: [4.2], 6: [6.1,6.3]} 输出:['one','two','three'],'length'输入:{3:['one','two'], 5:['three']} 法1:map+reducereduce()办法对数组中的每个元素执行用户定义的reduce函数 arr.reduce(function(prev,cur,index,arr){...}, init);prev 必须。上一次调用回调时的返回值,或者初始值init;cur必须。示意以后正在解决的数组元素;index可选。示意以后正在解决的数组元素的索引,若提供init值,则起始索引为0,否则起始索引为1;简略来说就是,不设置init,则从第二个元素开始循环,设置了就从第一个开始循环,pre就是initarr可选。示意原数组;init可选。示意初始值。 法2:应用字典map function groupBy(arr, fn) { let map = new Map() arr.forEach(item => { let key = null if (typeof fn === 'function') { key = fn(item) } else { key = item[fn] } let value = item if (map.has(key)) { map.set(key, [...map.get(key), value]) } else { map.set(key, [value]) } }) let result = {} for (let [key, value] of map) { result[key] = value } return result}let arr1 = ['one', 'two', 'three']console.log(groupBy(arr1, 'length'))let arr2 = [6.1, 4.2, 6.3]console.log(groupBy(arr2, Math.floor))

June 1, 2022 · 1 min · jiezi

关于算法:优酷老片修复算法超高清重温童年回忆

《大闹天宫》、《黑猫警长》、《舒克和贝塔》……这些儿时的“小伙伴”陪伴咱们一起度过难忘的童年时光。随着技术的提高,高清视频、高分辨率显示设施、更高的传输带宽等新技术的呈现,为咱们带来了前所未有的视觉体验,也让咱们对影片品质有着越来越高的谋求。而这些经典动画因为噪声、含糊、划痕等画质问题,在现在的显示设施上则“惨不忍睹”,如图1所示。图1 顺次为:噪声 划痕 含糊 压缩 针对年代久远的经典老片,能够通过传统的人工修复晋升视频品质,但在实操中耗时费劲,业余修复人员一天的修复量也只能以“帧”计,即使能够对胶片上的某些脏点或者划痕进行有针对性的去除,但对于视频分辨率低、帧率低、压缩噪声等问题仍然很难解决。近年来,随着人工智能、尤其是深度学习技术的蓬勃发展,其在视频解决畛域失去了宽泛的利用。相比于传统办法,深度学习类算法基于大量的数据训练,高维的特色空间推理,在许多视频解决、分类、辨认问题上都获得了很好的成果,那么把基于深度学习的办法利用在老动画片的修复上,后果会如何呢?即使借助深度网络这样的强力武器,老动画片的修复还是面临诸多挑战。首先就是动画片的品种繁多,不同国家,不同年代,不同类型的动画片,都须要解决;其次,老动画的故障多种多样,含糊、噪声、伤害等问题都须要修复;最初,这些故障都不是独立呈现的,他们的不同组合、不同强度,让输出数据域散布十分发散,对修复网络是极大的挑战。优酷数字多媒体实验室依靠站内海量的高清视频资源,联合深度学习畛域最新研究成果,克服了上述的多种艰难,针对老旧动画片开发出一套集智能超分、去噪、去块、去模糊、生成细节等修复性能为一体的修复模型,不仅仅具备很好的问题修复能力,而且可能优化线条、生成细节,让老动画观感面目一新。比方针对经典的去噪问题,动画片中的噪声多种多样,不光是简略的高斯白噪声,粗颗粒噪声、小构造噪声、压缩噪声,甚至斑点噪声都很常见,要解决好去噪问题,首先就要对动画片中的噪声特点和散布有全面的意识和总结,并且在咱们的数据结构和增广中去精密模仿,这样,咱们的网络去噪就具备了必要的鲁棒性;其次,工夫噪声是升高观看体验的要害,也是码率杀手,咱们的去噪网络必须具备去除工夫噪声的能力,所以咱们也是采纳了经典的多帧模型,并且把主体网络离开设计成光流模块加修复模块,前者用最新的光流网络,对齐帧间特色,后者通过3D卷积等形式,进行特色交融、像素重建;最初,为了在无效去除噪声的同时保留细节,咱们引入了更能反映高层语义的感知loss,训练专门的鉴别器甄别细节和噪声。借助这些伎俩,咱们的修复模型在噪声解决上有了不错的能力。其余的去模糊、超分等能力,也是基于相似的思考和设计,这里就不赘述了。值得一提的是,当一个综合性能的网络,要解决的问题越来越多样化时, 网络的单项能力是越来越弱的,也就是“能力全”和“成果精”不能得兼。咱们基于老本和复杂度的思考,给主修复网络减少了内部参数调节层,一方面升高了修复网络的数据域范畴,晋升域范畴内的修复成果;另一方面,借助可调参数,也让修复网络能灵便适配多种修复场景,兼顾了“全”和“精”,不过,就须要借助人工或者一些前置算法,对具体的各个片子进行参数配置了。 整体修复流程如图2所示。算法形成大体蕴含数据采集、数据扩增、模型训练和部署推理四个局部。上面,从数据、网络结构、训练形式等方面对咱们的模型进行具体的介绍。 图2 整体流程图 模型的泛化性能间接影响算法的理论利用成果。为了利用一个模型修复多种视频缺点,训练数据的结构非常重要。这里,工程师们在训练数据的结构上投入了大量精力。在如何无效扩增数据规模、开发更加实在的数据扩增形式、数据荡涤等多个方面进行了深入研究。目前,算法团队开发的自适应高阶降质算法能够无效地适应各种低质量动画视频的降质类型,具备鲁棒性强、修复成果好的特点。例如,在老动画片中,咱们常常能够遇到画面含糊、蕴含较多噪声、因为压缩等导致的块状残留等。利用咱们提出的算法能够无效修复这一缺点,从而失去清晰、锐利、紧致的线条,极大地改善了用户的观看体验。 如图3所示,通过算法的智能修复,无论月亮、还是修建、亦或是树木都失去了更为清晰的出现。 图3 去模糊:原图 模型修复后 如图4所示,通过模型修复后,画面中的噪声失去了无效的去除,内容不仅更为清晰,而且线条更为锐利、紧致。 图4去噪:原图 模型修复后 如图5所示,因为原图中存在较多块状噪声,非常影响用户观感。通过咱们的算法智能修复后,在图像中曾经较好地打消了块状噪声。 图5去块:原图 模型修复后 在泛滥深度学习算法中,研究者们针对不同工作提出了大量网络结构:如分类工作中的残差网络、宰割工作中的U型网络、跟踪工作中的孪生网络等。尽管这些网络在各自畛域获得了惊人的成就,但对修复工作却并不实用。为了尽可能晋升推理速度、保留原始视频的信息、稳固精确地去除噪声、以及生成真切正当的高频细节,咱们针对修复工作开发出轻量、高效、稳固的深度网络模型。通过对不同层级特色进行跨层连贯实现高效的特色复用;通过多分支构造提取不同尺度的特色,从而对图像内容进行多尺度剖析;利用时空注意力机制更好地聚焦图像的低质量区域;此外,借助高分辨率特色图和图像的构造特点更好地保留无效信息、生成真切的细节。 最初,算法团队针对动画修复的工作特点,开发出一套基于生成反抗模型的训练框架。借助判断器网络的反传梯度以及多个额定设计的损失函数,生成网络不仅能够去除大部分噪声和含糊,而且能够使得画面更为活泼,即为网络赋予了“无中生有”的修复能力。在这一能力的加持下,修复后的动画视频在优酷取得了“新生”。如图5所示,修复后的云层细节更为清晰、富裕层次感。 图5 高频细节生成:原图 模型修复后 动画片不仅仅是咱们儿时的美妙回顾,也是贵重的文化资产,优酷的小伙伴们会在老动漫修复路线上持续摸索后退,一直把更多更好的修复成果出现给大家,为艺术增辉添彩,让经典永不褪色。 明天,让咱们一起在优酷重温经典动画,欢度六一儿童节!

June 1, 2022 · 1 min · jiezi

关于算法:融云互动游戏-SDK-丰富娱乐玩法破冰陌生人社交

(点击报名) 这届年轻人,社恐又社牛。关注【融云寰球互联网通信云】理解更多 人均社恐曾经人尽皆知的 Z 世代,又整出新花样。开始在网上发视频花式征友、真挚征友、正经征友,介绍本人的内容包含但不限于年龄、星座、MBTI、身高、体重、游戏级别、电脑配置。当然,他们在对本人的性情形容中,仍然少不了“社恐”二字。 其实,社恐只是他们在现实生活中的社交形式,一旦来到线上社交场,立马进入“蹦迪”状态。他们不仅爱社交,还非常青眼陌生人社交。 艾媒征询数据显示,近年来,我国陌生人社交用户规模一直增长,2020 年已靠近 6.5 亿人。而 Mob 研究院的考察显示,在 1995-2010 年出世群体的线上社交趣味偏向中,偏好寻求喜好雷同陌生人的超过 40%。不过,市场虽广袤,赛道已拥挤。各种利用层出不穷,也正中“花心”年轻人的下怀。哪个好玩就玩哪个咯~这就给利用设计和开发提出了更高要求。 用户如何破冰和留存?经营如何继续?商业内容如何设计?用户生命周期价值如何晋升?关关惆怅,关关得过。或者,你能够从融云近期推出的互动游戏 SDK 上,找到答案。 融云互动游戏 SDK,蕴含你画我猜、狼人杀、碰碰我最强、五子棋、台球等数十款游戏,集成方便快捷,实用多种场景。碰碰我最强 友尽闯关 狼人杀 台球 五子棋 石头剪子布 对互联网原住民的 Z 世代来说,植根于赛博空间以个人兴趣和价值观念为根底的小众文化社群是他们的社交圈层根底,而在模式上,他们更青眼轻松、趣味的社交。 “社交+游戏”就是最能击中他们的产品状态。依据 data.ai 的调研,“游戏”这一关键词在社交类利用的简介中呈现频次最多,有近半数社交类 App 在商店简介中提及游戏相干词语。其余常见表白还有“敌人”、“互动”、“一起”等。 这在肯定水平上阐明:对于关系型利用来说,是否能通过更多玩法设计晋升互动的轻松度和频率,是用户的要害期待。交融游戏性或是社交类 App 的趋势。 融云互动游戏服务,助力社交、泛娱乐利用抓住这一趋势。语聊房、视频直播、1V1 聊天、IM 聊天、游戏平台,疾速交融游戏性,只需一个 SDK。 语聊房 辞别尬聊 轻松破冰语聊房作为语音社交的典型场景,也是社交产品解围陌生人社交赛道的无力武器。 而陌生人社交中破冰难题最容易让用户心生退意、鸣金收兵。语聊房+游戏,减少破冰流动的多样性,进一步开释用户的交友需要。 匹配游戏↑ 切换游戏↑ 接入融云互动游戏 SDK,将传统语聊房打造成多人游戏互动场景。玩家能够边玩游戏边语聊,观众也能够通过聊天频道与游戏中的玩家互动,疾速晋升房间的内容玩法及互动性,减少语聊房场景下的用户沉闷、粘性、在线时长。 多种多人语音 PVP 互动型游戏超强互动性,让用户疾速在游戏中建设关系高达 48khz 的高质量语音反对 iOS、安卓设施灵便的麦位与游戏位权限治理性能 视频直播留存用户 晋升价值直播平台卷势已久,无论是基于颜值还是内容,在实现最后的用户吸引后,如何尽可能地延长用户生命周期,以及在无限的工夫内让用户发明价值,都是外围问题。 一般直播无奈像大网红一样用几十人的团队打造丰盛的内容环节,游戏插件就是晋升用户 LTV(生命周期总价值)的适配计划。 手机竖屏直播(App 端)抉择游戏↑ 游戏完结↑ 接入融云互动游戏 SDK,通过不同的游戏类型与玩法(单人面目表情玩法、多人互动型玩法等),在不影响用户音视频性能的前提下,减少与观众的互动,丰盛直播内容,晋升直播间沉闷、在线、营收数据。 单人面目表情游戏,减少直播内容的丰富性多人 PVP 对战游戏,晋升互动性和营收原生利用与互动小游戏完满联合反对多设施,多平台游戏毫秒级提早 电脑横屏直播(Web 端) ...

May 31, 2022 · 1 min · jiezi

关于算法:数组一文搞定前缀和数组

前言 就从数组开始,当前会始终更新算法。数组有下图这些知识点与技巧。本文次要解说其中的前缀和知识点。 思路 适宜的场景:原始数组不会被批改,且频繁查问某个区间的累加和。 创立一个prefixSum数组,长度比原数组nums长度多1。prefixSum[i]存储nums[0]到nums[i]的和。 尤其要留神prefixSum与nums的坐标换算,如下图所示。 区域和检索 - 数组不可变(一维前缀和)leetcode第303题 解题思路 惯例思路是通过遍历i到j。但这样工夫复杂度就是O(n)。 采纳前缀和。sumRange = prefixSum[right + 1] - prefixSum[left]。留神原数组与前缀和数组的下标换算,例如nums[i]的前缀和是preSum[i + 1]。如下图所示。 复杂度剖析 工夫复杂度:初始化O(n),每次检索O(1),n是数组长度。 空间复杂度:O(n)。代码 class NumArray { private int[] prefixSum; public NumArray(int[] nums) { prefixSum = new int[nums.length + 1]; for (int i = 0; i < nums.length; i++) { prefixSum[i + 1] = prefixSum[i] + nums[i]; } } public int sumRange(int left, int right) { return prefixSum[right + 1] - prefixSum[left]; }} ...

May 31, 2022 · 2 min · jiezi

关于算法:融云-x-幸识-专属-00-后的真我社交自留地内含抽奖

(点击报名) 互动有奖互动奖品:可口可乐星河散步网红无糖汽水 * 12 罐关注+转发,参加抽奖: ① 关注【融云寰球互联网通信云】公众号,回复 抽奖 获取抽奖小程序② 转发头条文章到朋友圈且不设置分组 ※ 侥幸同学将由抽奖助手随机抽出,记得实现以上两个动作,以便兑奖时验证嗷~※ 本流动最终解释权归融云所有。 咫尺共此 shi。 这是 00 后社交软件幸识在利用商店的副标题,奇妙地用拼音 shi,双关了咫尺共此“时”的陪伴,以及软件上戳中大量用户萌点的拉shit小组件。作为一款专属于 00 后的社交 App,幸识里 00 后黑话和爆梗气氛浓重,从找人聊天、约游戏、约学习等场景切入,设计了一系列将扩列同好游戏化的社交玩法,致力于与 00 后用户一起,发明一个轻松乏味的线上世界。 在社交赛道,每一代年轻人都会书写新故事,发明新冷落。新的人口就是新的商业,而超过 3 亿的 Z 世代群体就是这个故事的根本盘。咱们为什么总是在期待新的一代年轻人,新的商业故事?因为他们敢于尝试和敢于创新。 幸识从 2020 年上线以来,在产品上也体现出了不断创新、尝试的勇气和信心。基于对用户了解的一直累积和认知降级,幸识的几次大版本迭代都在突破本人,寻找撑持“专属 00 后的开放式社交平台”这一产品定位的新支点。而在融云 IM 即时通讯稳固牢靠、超强拓展的能力反对下,幸识完满交融 00 后梗文化和社交需要的产品实际又下了一城。最近的版本迭代,幸识上线了两个直击用户爽点的新性能——霸屏喊话、承包幸识。 前者,用户能够将本人的文字或者音频,挂在全平台用户的首页,也就是“霸屏”;后者,用户承包圈定用户的幸识开屏,在用户进入 App 的第一工夫展现本人的高清大图。这两个性能,因为提供超额互动和社交资产而让用户十分上头。而它们也非常符合幸识 App 的整体格调——“有梗”。 模因,00后社交的非凡成分从玩法到 icon、UI 乃至客服的名字“实习生小王”,幸识都饱含梗元素,营造出满满梗气氛。 梗,也就是 meme、模因,被认为是与基因同行的一种文化传递单位,在人们的复制模拟中实现流传,甚至成为特定群体共有的文化印记。 模因是一个参与者共创的后果,比方咱们都相熟的表情包青蛙佩佩。人们给佩佩穿上各种衣服,变成各种职业,搭配各种表情,表白各种情绪。反复的主体+随机变量,实现了一个梗图的风行。比方:经典 meme,表情包青蛙佩佩 对 Z 世代来说,模因是他们交换的新型语法。 而这,也是幸识的独特气氛,App 中充斥了梗元素,年老用户“懂自懂”。进入幸识,凭借文案、UI,一个“合格的 00 后”立即就能晓得不同模块怎么玩儿。足够简略和普世,让幸识迅速在 00 后中关上了场面。幸识上线后的第二年,便位列小米风云榜第 3 名、App Store 社交榜第 7 名。 依据幸识提供数据,目前 App 领有注册用户近 300 万。在种草平台的 #00 后社交平台# 自发安利中,幸识也是前三名的常客。能够说,幸识曾经是 00 后的扩列乐园。(幸识迅速在 00 后中关上了场面) ...

May 31, 2022 · 1 min · jiezi

关于算法:打造哈啰自动化增⻓算法闭环上

导读:本次分享的主题是哈啰打造自动化增长算法闭环的实际,上篇将次要介绍哈啰C端算法场景和挑战及哈啰被动增长算法。 哈啰C端算法场景和挑战 首先看一下哈啰的C端算法大略有哪些场景。哈啰C端算法最终的目标是要服务于咱们出行业务的增长,同时也要搀扶咱们生存服务相干的业务。目前在端内流量类型有很多,包含咱们惯例的banner、弹窗,还有一些组件。端外咱们会对打车逆风车鼎力投放广告,次要是在公共的广告平台,包含在一些运营商的零碎上投广告。还有一些收费流量,次要是指在微信和抖音这样的公域和私域流量。另外,有一块特色就是咱们线下的门店以及两轮车,咱们能够把它看成一些智能的硬件,或者说一些智慧的门店,通过咱们的AloT平台接入到公司零碎中,也是一个重要的流量起源。 这些不同的流量类型和咱们当初的各种业务穿插起来,就会发现哈啰的C端场景太多了,而对哈啰这样一个中等规模的公司来讲,就呈现了场景泛滥和开发的人力非常无限的矛盾。同时咱们本人团队也会有一些技术谋求,如果只反对业务,不仅对咱们没有成长,而且成果也未必会达到最好。所以业务撑持和技术深耕间也是一个矛盾。 既然搜广推有这么多服务场景和矛盾,咱们在最后半年的实际过程中,一直造成如何解决这个矛盾的方法论,根本的思维就是不要反复造轮子。咱们在进步算法开发效率的同时,各个域将行业最新经典的技术和自主翻新相结合。 最后咱们撑持业务还是用一些最简略的定制的模型,包含Tree模型和 CTR预估中的一些经典的模型,业务也只是从体量最大的出行业务开始,其中对两轮这部分它的支出经营咱们进行一个业务策略的高度形象。 在2021年,咱们开始依照一个新的方法论打造整个算法体系。首先咱们要有对立的C端算法体系。C端算法体系无论是搜广推,还是咱们说的营销以及其余的流量散发等,它的根底技术是高度同质的,是有可能做对立的。 另外咱们在计算的过程中,想把哈啰增长引擎给打造进去。咱们底层的机器学习平台是咱们自主研发的贾维斯AI平台,所有算法同学都在下面工作。下层的话,咱们在算法铺量的过程中打造了搜推引擎和营销引擎,对少部分的场景,也就是对两轮支出经营开始做自动化经营的实际。自动化经营,就是要对策略要做一个高度形象。而策略也是分不同层级的,咱们会参考OKR拆解的办法,把策略从一个指标级的策略,拆解到KR级的策略,再拆解到Task级的策略。因为用户经营的工作是绝对标准化的,所以这个流程是齐全能够自动化的拆解下来。 对于打造对立的C端算法体系,让各个域不要反复造轮子,让咱们来看一张图。最右边一块是哈啰所有的流量,最左边一块是哈啰所有投放的内容,包含一些营销内容,以及咱们传统的社区,还有一些咱们的电商商品和本地生存的一些服务商品的内容。 这些商品从流量侧看,咱们要晋升流量效率,这个就是eCPM。从业务侧的视角看,咱们要晋升它的用户增量以及支出,也就是GMV,而用户增长次要看ROI。这几个域都会用同一套的技术体系,也就是业界罕用的多路召回和Rank算法。咱们这外面的各个模块和业界会稍有不同,有些畛域比如说Rank中咱们会重点建设因果推断及L2R的技术。在多路召回中,咱们会建设Graph Embedding,以及一些知识库搜寻这样的召回体系。 咱们会把基于流量的算法叫被动增长算法,因为不须要咱们额定造一些资源位,打搅用户做一些推送。而咱们将用户增长和支出增长定义为被动的增长算法。 哈啰被动增⻓算法4w2h 被动增长算法是咱们对一个用户心愿进行一些营销动作,也就是广义的营销算法。整个营销它是一个链路,用的是一套4w2h的体系。第一,你要抉择什么样的人来做投放,就是精准定向。第二,你投放的内容是什么,就是咱们的素材,包含文案、图片、卖点等等。第三,你要抉择什么机会,抉择什么素材来投放,这在咱们这块叫做智能触达,包含push也是放在这一块。第四,投放给一个用户的营销,基本上会通过流动的模式,或者说工作的模式等等,工作是能够自动化的生成。当然最重要的一块是咱们的补贴,因为大部分的营销它要是有肯定的实实在在的开销,能力把用户给最终吸引过去,所以要有补贴,补贴在出行和本地生存畛域是一个很外围的事件。 精准定向 精准定向,在哈啰这边它有两种模式。一种是从一个大的池子中挑选出少部分的精准用户,咱们这叫行业包。还有一种是LookAlike,给一个种子人群,依据类似度扩充它的规模,在咱们这边的支流办法是行业包。因为和广告畛域不同,咱们的用户池子其实是已知的,次要是哈啰注册的5亿用户,而后在池子中捞一部分人对各个不同的业务进行一些拉新促活。 最简略的形式其实是有监督,但有监督会有很多的问题。比如说第一个问题,高潜的用户会很快耗尽。像很多新业务,如果是用有监督的形式,如果这个池子比拟小,可能一两个月池子就被耗尽了,接下来就没有高潜用户能够营销。另外,咱们有很多动作是拉新,新用户显著特色是比拟稠密的,可能样本也比拟少。然而最大的问题是在精准定向这个畛域,它是没有真正的负样本的,比方一个用户的营销不起作用,不肯定是他对这个业务不感兴趣,有可能他是对营销不感兴趣。因为人的心理特地简单,大部分人看到一个营销动作,本能其实不会有太大的反馈。 咱们的负样本并不是一个真正负样本,应该叫未知样本。所以这里的解决办法就要用到半监督的形式。即从未知的样本中,辨认出真正的负样本,咱们会应用PU- Learning技术,最终的成果是在等同ROI的根底上,把咱们拉新的潜客规模扩充2-10倍。同时像特色少的问题,基本上会用穿插业务的特色,比方打车和酒店就是一个高度相干的业务,他们之间特色就有很多能够复用。另外两轮是咱们用户基数最大的一个业务,很多业务线在拉新建设的时候,都会复用两轮的特色。 接下来咱们来看PU- Learning是怎么做的。一开始咱们用的是最传统的TSA算法,也就是特务样本技术。咱们首先会在正样本中挑选出一些,伪装它是一个负样本,混在未知样本的池子里,相当于人为进步一个正负样本辨别的难度,而后在未知样本和正样本当选进去一些特务样本,伪装它是一个负样本,和正样本在一块训练一个分类模型,而这个分类模型咱们是心愿尽量把负样本中的未知特务样本,也就是那局部正样本和真正的负样本给辨别开来。 一旦分类器建设之后,咱们就用第一步的分类器来给所有样本打一个分,把其中分低的作为真正的负样本。而后再建第二个样本池子,在这样重复的迭代过程中,直到咱们把特务样本齐全辨认进去,做到一个收敛状况。通过这种办法,咱们就能把未知样本中真正的负样本给辨认进去。 前面咱们又做了一些改良,因为传统TSA算法会有几个问题。第一个问题是你正负样本划分的阈值,它其实是一刀切的,并不是一个正当的值。所以咱们用EM算法把散布给聚类起来,学到了它真正的正负样本的阈值。这其实也是对正样本进行了数据加强,因为正样本在咱们这边非常少。而另一个改良点,咱们一开始用的 PU- Learning基准模型其实是GBM, GBM套着GBM,工夫长了肯定会实现信息茧房效应。所以咱们在第一步和第二步的模型前面进行了一个辨别,第二步模型改成DeepFM,通过GBM和DeepFM的穿插迭代的学习,缩小信息茧房的问题。 刚刚讲的是第一种形式——行业包,即在一个大的池子中捞出一部分精准人群。另一种形式是LookAlike,这是更传统的一种形式。咱们用的技术是Graph Embedding,通过用户之间的行为或者某种关联给用户作为点,用户有行为关联的建设一个边,最初把用户的Embedding给学习进去,从而通过这种向量,用类似度的计算能把用户的人群扩充。 Graph Embedding当初曾经绝对成熟,然而在哈啰的次要挑战是这个图怎么构建。因为它和传统电商不同,最重要的是辨认出强的行为,怎么把用户之间的边给连接起来。 第一种咱们会用时空,实在用户在出行中的时空空间上的关联给它建设图,比如说同一个地块,同一个时间段,两个不同的用户产生了同类行为,如给单车开关锁,这样它就能连一个边,但这种行为还不够强。咱们参考了电商畛域的行为构建形式,咱们在想是不是咱们整个APP所有的事件,所有的物料的行为都能够用来建图,于是咱们在首页进行了摸索。 这里有一个图,比如说下面的icon,两头的banner,还有上面的种种其余的营销物料,其实在不同资源地位以及每一个物料,它都有一个物料ID,同时它也是某个业务推出来的物料,这三者的联合就能惟一确定一个item是什么货色。用户在咱们整个首页点的所有item的一个序列,通过这种序列也能够来结构用户之间的边。 咱们的技术模型选用的是EGES,因为哈啰还是一种偏工具的APP,而且行为的确没有像电商的购买行为这么强,所以SideInfo对咱们来讲就会更加重要。 同时哈啰的用户量还是很大的,当然咱们选的是近几天沉闷的用户作为咱们的向量池子来扩大,非沉闷用户的话也就给刨掉了。如果是全量的话,几亿的用户算下来计算的性能耗不起。过后的向量引擎选的是Milvus,一开始咱们也试验过其余向量引擎,但比照下来Milvus的性能是最好的。咱们在几千万用户以及几十维向量这样的规模下,能够做到小时级别的全量用户的向量化。Milvus线上的查问也能达到近实时查问的水平,最终的试验成果通过向量的类似度进行量级的放大。咱们能够扩充人群的规模10-1000倍不等,同时保障ROI相比人工策略始终是晋升的。当然放大规模越大,晋升幅度也会越小。 咱们在构图的过程中用的是用户的工夫序列,但目前还没有把一些非信息流的页面的事件,或者说各个业务私域的一些事件序列给拉排进来。这须要更对立的数据埋点体系的建设,也会是往年的一个重点。 智能补贴 有了定向的人群之后,咱们就须要晓得怎么做补贴。补贴能够认为是这几个畛域中对咱们最外围的一个域。补贴这个域,基本上因果推断曾经逐步成为技术支流。一开始咱们用的是CTR 预估的办法,来看一个用户喜不喜欢点券之类的货色。但实际上用户并不是只有点和不喜爱点这两类,而是有四类,包含营销敏感、天然转化、金石为开和副作用类。因为局部用户其实你不营销,他本人喜爱这个业务可能也会来,营销并没有带来增量的作用。还有局部用户对营销比拟恶感,营销之后他反而不来了,影响他的留存和沉闷等等。 举个具体的例子,假如咱们有两类用户各1万集体,卖一个商品是10元,券是8折券,当初想给这两拨人来决定到底给谁发8折的券。比如说本来状况下B类用户发券了之后的购买率是1.5%,不发券是1.4%,但实际上发券这个动作带来的增量的购买率只有0.1%,A类用户反而带来的增量购买率更大,是0.5%。所以并不是说 B类用户的购买率高,更应该给他发券,而是A类用户发券带来的增量效应更大,才更应该给他发券。 那B类用户到底应不应该发券呢?其实还能够看收益的增量。如果把咱们发过券之后,打折带来的损失以及咱们购买率晋升带来的增益,合起来算的话,B类用户甚至还是亏的。不发券能挣1400块钱,然而发券之后因为打了折,反而只能挣1200块钱。所以对B类用户就不应该发券,只用对A类用户进行发券。 所以对因果效应的建模是咱们的一个重点,咱们用的是Uplift model。第一版咱们建了两种Uplift model,它实用的场景不同。第一种是基于Tree构建的,原始的Uplift Tree相当于是做一个增量转化率的预估。增量转化为什么选Tree,第一它是对Uplift进行间接建模的,而不是说建两个不同的模型,它的建模精度会比拟好。另外Tree的可解释性是绝对强的,咱们晓得Tree基本上是通过决裂准则来模仿指标最大化的一个过程。咱们能够比照一下一般的决裂准则和Uplift Tree的决裂准则有什么区别,一般决裂准则就是信息增益最大化,Uplift Tree最原始的形式是通过散布散度最大,来让咱们的干涉组和被干涉组,所谓干涉组也就是发券组,这两个组的散布差别最大,从而达到Uplift最大的成果。上面是一个示意图,通过Uplift Tree的决裂,咱们最终能够把人群真正辨别成4类不同类型的人群,最初只对营销敏感的这部分人群进行真正的营销,而其余三类并不需要营销。 当然这个原始的Uplift Tree,它是针对转化率做增量的,而咱们事实的业务中大部分场景指标是收益,而不是转化率。所以咱们进行一个改良,把决裂准则改良成一种新的形式来做收益的最大化。 假如决裂前数据集是,咱们就能够计算决裂前的收益是多少,也就是发券组和不发券组人均效益进行一个差,而后乘以一个平方,它其实是对欧氏间隔散布散度最大化的一个扩大的改良。而后是依据某个特色对以后节点进行决裂,失去一个决裂后的因果效应,决裂前和决裂后的因果效应的差,其实就代替了咱们之前的信息增益的最大化。通过决裂前和决裂后因果效应差值的最大化,来作为咱们的一个决裂准则,就这样一直抉择新的特色,这是第一层的决裂。第二层就选另一个特色接着决裂,一直抉择这种迭代递归的过程,最终整个构建进去。这就是一个TreeLift的过程。 TreeLift的难点是怎么结构样本,因为事实中不存在平行时空,咱们不可能对一个人同时发券又不发券。那怎么样让模型学习发券相比不发券的增量收益呢?咱们想到是用群体来代替个体,如果是两个同质的群体,其实能够学习发券群体和不发券群体之间的增量收益。这就通过结构随机试验的形式,也是当初Uplift畛域的一个支流办法。最终的成果,咱们在自有的数据集和业界的公开数据集及传统的经典办法做了一个比照,发现它的Uplift曲线是最大的,相比咱们本人的响应模型,在场景下的收益大略有4.7%的晋升。 另一个是咱们的DeepLift的模型,DeepLift模型是咱们在DragonNet的根底上进行改良的。DragonNet有几个长处,它不须要用随机试验,随机试验的结构老本是很高的,你的模型前面基本上没有方法做主动的更新。咱们用DragonNet通过向量化模仿了一个随机试验,同样它又结构了一个偏向分的子网络,可能做一个样本筛选,能够把因果无关的一些特色变量筛掉,而大量的特色其实和因果并没有关系。咱们在DragonNet根底上做了一些改良,第一是减少了模型的复杂度,第二是扭转它的loss,更加的贴近业务。因为原始的DragonNet其实和原始的Uplift Tree一样,并没有以收益为指标,而是以转化率为指标。因而咱们各种loss减少了新的G的网络,以及扭转了它根底的loss的形式。咱们DeepLift模型的网络结构能够看左边,DeepLift咱们更多应用在一些须要自动更新的场景。 智能文案 晓得了什么人,也晓得补贴多少钱,这个素材自身对用户的冲击力是更间接的。咱们通过智能文案对整体的点击率,不同款式的点击率,包含banner、push、弹窗等等,造成了30%-100%不等。营销畛域的文案广泛都是比拟短、比拟正式的那种文字,和电商title、视频的题目不太一样。另外绝对于内容畛域,咱们的语料并没有那么短缺,所以一开始它的文案生成用的是模板的形式,在模版中加上一些动静词包。但在往年曾经革新成了模板加上语句通顺度的辨认这样的形式,大量裁减咱们的文案候选集,减少多样性,缩小用户的疲劳。 另外在有监督模型根底上,咱们减少了EE的模块,因为文案的多样性,还有新文案,新素材的疾速试验是特地重要的。具体EE的算法,咱们用的是最奢侈的Epsilon-Greedy算法。 智能广告外投 ...

May 31, 2022 · 1 min · jiezi

关于算法:实现深层对象属性访问

输出对象以及属性名,取得属性值 eg:输出:data, 'a/b/c' const data = { a: { b: { c:1, d:2 } }}输入:1 办法1:while遍历 function findObjectValue(object, attribute) { let arr = attribute.split('/') let i = 0 while (arr[i]) { object = object[arr[i]] i++ } return object}const data = { a: { b: { c:1, d:2 } }}console.log(findObjectValue(data, 'a/b/c'))办法2:eval拼贴字符串拼出来就是这样的,temp['a']['b']['c'] const findObjectValue = (data, attr) => { let temp = data; return eval(`temp['${attr.split('/').join(`']['`)}']`);}const data = { a: { b: { c:1, d:2 } }}console.log(findObjectValue(data, 'a/b/c'))

May 31, 2022 · 1 min · jiezi

关于算法:二分查找

function binarySearch(arr, value) { let minIndex = 0 let maxIndex = arr.length - 1 let middleValue while (minIndex <= maxIndex) { let middleIndex = Math.floor((minIndex + maxIndex) / 2) middleValue = arr[middleIndex] if (value < middleValue) { maxIndex = middleIndex - 1 } else if (value > middleValue) { minIndex = middleIndex + 1 } else { return middleIndex } } return -1}

May 30, 2022 · 1 min · jiezi

关于算法:搜索插入的位置

给定一个排序数组和一个目标值 在数组中找到目标值,并返回其索引如果目标值不存在于数组中,返回它将会按程序插入的地位eg:输出[1,3,5,6],5输入:2 输出[1,3,5,6],2输入:1 输出[1,3,5,6],7输入:4

May 30, 2022 · 1 min · jiezi

关于算法:自动驾驶离真正量产还差什么

2022年上半年,主动驾驶商业化在政策端与市场端均迎来新的倒退阶段。 政策方面,4月份北京正式对外发放无人化载人示范利用通知书,并容许Robotaxi主驾去掉安全员; 5月份,云南省工业和信息化厅公布了《对于“十四五”推动云南省车路协同主动驾驶试点示范建设的领导意见》,明确到2025年,逐渐实现高级别主动驾驶商业利用,L4级别智能车辆在特定畛域开始试运行,力争建设成为国家级车路协同主动驾驶产业会聚区。 而在厂商方面,IDC最新公布的《中国主动驾驶汽车市场数据追踪报告》中显示,2022年一季度,中国主动驾驶汽车市场,L2级主动驾驶乘用车渗透率达23.2%,较2021年一季度的7.5%大幅晋升,主动驾驶商业化利用正迎来新的倒退黄金期。 然而,政策与厂商端的炽热,却无奈在短时间内扭转生产端对主动驾驶的认知,公众对主动驾驶技术的场景适应性仍存疑难。主动驾驶落地场景更多集中于关闭路段,间隔真正的凋谢路段大规模商业化利用仍有一段距离。 那么主动驾驶,离真正量产到底还缺了点什么? 硬件老本逐年降落长期以来,主动驾驶技术无论是在硬件端,如激光雷达、多目摄像头,还是在软件算法端,后期的投入与洽购老本均非常昂扬。 以主动驾驶感知零碎为例,目前支流的感知技术门路有两种,一种是以机器视觉为外围,毫米波雷达+摄像头解决方案,典型代表企业特斯拉、Mobileye、百度Apollo等;另一种则是以高精地图+激光雷达为外围的传感器路线,代表企业为Waymo、华为等。 为了谋求更高的感知度,进步行车安全性,各大主动驾驶企业在感知零碎硬件抉择上均投入了较高的老本。 以特斯拉应用的前置摄像头为例,3个摄像头每个像素约为120万。行将量产的Cybertruck,像素将晋升至为540万,老本不菲。而激光雷达老本则更为昂扬,以激光雷达行业内知名企业Velodyne 公司为例,旗下的HDL-64E售价在靠近10万美金左右。 但随着生产工艺的提高,激光雷达的老本已显著降落。华为已将自研的激光雷达老本管制在200美元之内,并打算在将来两年将老本进一步升高至100美元,这为激光雷达的大规模遍及打下了松软的根底。 数据成为算法迭代外围既然硬件端规模化量产不存在问题,那么问题则大概率呈现在软件算法端。 目前,主动驾驶外围算法以深度学习形式为主,是基于已知变量和因变量推导函数关系的算法模型。 不同于矿山、港口、机场等关闭场景,凋谢路段场景更为简单且多变,须要主动驾驶算法有很深的场景积攒度与迭代能力。但算法的迭代无奈独立实现,须要人工智能的另外两驾马车,即算力与数据的拉动下能力实现。 深度学习技术实质上须要海量的数据进行“投喂”能力推动算法的迭代与更新。以特斯拉FSD计划为例,这套计划通过视觉感知网络生成三维向量空间,融入老本函数、人工干预数据或其余仿真模仿数据,取得最优的规控计划,实现汽车主动驾驶。 这套计划无论在感知层面还是规控层面,外围算法都是由数据进行驱动,数据的规模与品质间接决定了算法的最终性能。 正如泰合资本曾指出的一样,数据已是行业技术的外围竞争点,对技术迭代起到决定性作用,唯有进步数据迭代速度、升高迭代老本,能力继续取得胜利,实在数据规模未然成为智能驾驶行业的“命根子”。 数据规模化量产主动驾驶算法离不开海量数据的“投喂”,这事关各大厂商主动驾驶算法的优化成绩以及事实落地效率,因而构建一套高效获取、标注及仿真训练数据的闭环至关重要。 然而,与指数型增长的数据服务需要相比,则是行业长久以来受限的数据生产力,尤其体现在数据产能与数据产出品质两方面。 产能方面,目前国内数据标注第一梯队服务商年营业额广泛以千万级为主,业务规模、执行效率与项目经理能力高度绑定,产能瓶颈问题凸显,无奈无效填补并抢占极速扩张的需要市场。数据标注产业在国内倒退多年,却从未诞生独角兽企业,供需之间的鸿沟已愈发难以填平。 而在数据产出品质方面,随着主动驾驶行业迈向商业化经营阶段,以点云数据为代表的数据处理需要占比逐步扩充,传统依附简略工具且依赖人力的业务执行形式,也早已无奈满足垂直市场的需要。 主动驾驶实现规模化量产,数据服务畛域是否率先实现冲破将成为要害。 而作为行业当先的数据服务厂商,曼孚科技深知主动驾驶数据服务行业痛点,凭借从策略到技术落地的一站式数据解决方案以及PLG商业模式(Product-Led Growth,产品驱动增长),构建起高效的数据闭环,直击数据产能与数据产出品质两大外围要害。 以曼孚科技SEED数据服务平台为例,作为曼孚科技第三代数据智能平台产品,SEED平台除领有目前市面上支流第二代平台的“多场景标注能力+无限项目管理能力”以外,还创新性的大量引入生命周期治理、AI加强等模块,造成了笼罩“数据全生命周期治理能力+供应链治理+我的项目协同+AI人机协同+自定义权限+全场景标注”的多维平面数据处理能力。 在这些功能模块的加持下,平台数据标注效率均匀晋升10倍以上;AI辅助筛查下,数据精准度可达99.99%级别,直击AI企业数据需要痛点,从源头端解决AI利用场景继续拓展对于高质量多源异构数据的海量需要。 凭借PLG模式带来的旺盛创新力与产能复刻能力,曼孚科技在实现主动驾驶数据标注量产的同时,也构建起了一套可继续迭代的数据闭环,为主动驾驶行业在数据方面的短板提供了新的行之有效的解决方案。 曼孚科技期待用高质量数据助推AI利用继续拓展与落地,早日实现主动驾驶规模化商业量产。

May 27, 2022 · 1 min · jiezi

关于算法:Day-72100-数据结构链表12链表小结

(一)需要快半个月了,始终在学习链表的相干算法常识和做题。今儿来小结下~ (二)单链表和双链表小结1、共同点它们都无奈在常量工夫内随机拜访数据。它们都可能在 O(1) 工夫外在给定结点之后或列表结尾增加一个新结点。它们都可能在 O(1) 工夫内删除第一个结点。2、不同点在单链表中,它无奈获取给定结点的前一个结点,因而在删除给定结点之前咱们必须破费 O(N) 工夫来找出前一结点。在双链表中,这会更容易,因为咱们能够应用“prev”援用字段获取前一个结点。因而咱们能够在 O(1) 工夫内删除给定结点。(三)单链表和双链表的比照 如果你须要常常增加或删除结点,链表可能是一个不错的抉择。如果你须要常常按索引拜访元素,数组可能是比链表更好的抉择。参考链接作者:力扣 (LeetCode)链接:https://leetcode.cn/leetbook/... 写在最初的话学习路上,经常会懈怠《有想学技术须要监督的同学嘛~》https://mp.weixin.qq.com/s/Fy...

May 25, 2022 · 1 min · jiezi

关于算法:社交泛娱乐应用海外淘金文化关怎么过

(点击报名) 出海风光万般好,谨防被困“文化”礁。关注【融云寰球互联网通信云】理解更多近期,位列东南亚最大在线购物网站之一的出海电商引起了轩然大波。该平台在广告中启用了一位风评简单的跨性别网红和一名坐轮椅的女士作为广告配角,被认为映射长年坐轮椅的泰国王室成员和歧视残疾人。 只管平台曾经下架广告并郑重赔罪,但感到被挫伤的人们却并不买账。广告风波不仅轰动了泰国总理,导致平台遭军队抵制,被政府部门起诉,甚至引来了中国驻泰国大使馆官网回应。 正如泰国政府发言人针对此事件强调的,“内容创作者,应该小心他们在网上公布的内容。”本应在审核中过滤出的危险内容因文化差异而不查,未曾想引起如此巨浪。 而出海企业都会面临这样的“水土不服”,内容审核成为不容忽视的环节。 作为寰球 30 万+ App 的通信云搭档,融云不仅以遍布寰球 233 个国家和地区的通信网(SD-CAN)和自研的最优链路调度算法为根底,为用户提供平安、牢靠的通信云服务,还联结业余合作伙伴打造出海内容审核解决方案,为寰球社交、泛娱乐利用提供多语言智能内容风控服务。 海内掘金第一关克服文化上的“水土不服”对于出海企业而言,对当地文化的敏感和常识储备,是管制危险的必要条件。在涵盖多个宗教文化的东南亚地区,更须要审慎,尤其是在社交畛域。随着行业迅速倒退,社交产品呈现出数量大、品种多、状态丰盛、内容多元等特点,流量和利益激增的同时,也随同着一系列监管危险,内容平安的预防、管制和清理,各个环节都须要严格把关。 社交产品对内容审核能力有着更高要求和更大挑战,次要体现在: 1. 各国监管要求不同的复杂性对于海内市场来说,法律、宗教、文化、语言等简单因素影响下,出海 App 的合规性既要满足当地法律,还要合乎当地的人文习性,这给内容审核带来了新的挑战。 拿欧美市场来说,互联网内容采纳严格的分级制度,对 3 岁、13 岁、17 岁等不同年龄段的未成年人有严格的爱护策略,并且对种族舆论是明令禁止的;在中东地区,十字架、猪等波及宗教的元素极为敏感;在日本和泰国,要防止发表对天皇制和皇室不满的舆论,韩国对朝鲜政府的涉政舆论在当地也是被严格审查的。 2. 爱护品牌形象的必要性在线上社交成为支流的明天,如何给用户营造一个洁净、衰弱的社交环境,是影响到品牌形象的头等大事,进而影响到 App 的胜利。 经考察显示,用户在衰弱的环境中参加互动后,留存率会减少 3 倍,会话时长减少 60%,而在受到网络骚扰后,15% 的用户会转向其余社交平台。 国别、场景错落各异海内内容危险品种多样,细节繁冗文化的差别体现在方方面面,比方,东南亚国家的笑点与国内有很大不同,在气氛上,他们的直播会显得更加“嘈杂”。而在内容审核方面,除了不同地区带来的差别,即使是同一地区,不同的利用场景也面临极大的审核差别。 比方,在社交场景中,Kill、Shoot 等字眼是不被容许的,要被辨认及躲避;而它们呈现在游戏类场景中,则很正当。再比方,在游戏昵称中,企业个别会对 Admin、Operator 等词汇的应用设定特地规定,因为放心用户借此伪装成软件经营方,带来欺诈等危险;而它们呈现在聊天中则不用特地留神。 这就要求内容审核服务业余而全面,对于海内社交属性的 App 来说,内容的危险品种次要包含涉黄、涉政、涉毒、涉暴、种族、歧视、宗教、未成年人、唾骂、拉人广告等,以上都是各国网络监管部门重点关注的对象。 聚焦海内社交业余、全面的风控策略融云在 IM 即时通讯和 RTC 实时音视频的双核心能力之上,减少 X 元素 —— 通信周边能力的总和,全效赋能开发者。而“审核”就是融云重点布局的 X 能力之一。 在这方面,融云和业内当先的业余搭档单干,帮忙社交场景下的开发者,精准辨认即时通讯、实时音视频业务中的文本、图片、音频、视频的黄、暴、恐等违规内容,满足全场景需要;通过数字化的形式,提供审核、打标、自定义配置等服务来满足企业需要,打造业务、内容、用户三重平安保障。(内容审核检测类别,点击查看大图) 反对中文(简体)、中文(繁体)、英文、日语、韩语、泰语、越南语、马来语、印尼语、印地语(拉丁印地语)、 菲律宾语、阿拉伯语、土耳其语、俄语、德语、法语、意大利语、西班牙语、葡萄牙语、瑞典语、波兰语、希腊语、挪威语、荷兰语 24 种规范语言的文本及音频审核。反对中东埃及、沙姆、北非、海湾、苏丹 5 种外乡方言以及印度地区孟加拉语、乌尔都语、马拉地语、阿萨姆语的文本检测。1. 文本审核全球化部署文本审核,审核后果在 100ms 以内响应,可依据海内不同国家的审核规范制订策略,反对标准语、方言、俚语、缩略语、社交费解语等表述,可联合上下文语义辨认防止误检,且紧跟各国最新政策、时政新闻,不断更新算法模型。(文本审核示例) 2. 图片审核应用先进的指标检测及内容辨认算法,实时检测图片中的违规内容,反对卡通场景和真人场景辨认,反对“画中画”、头像小图、含糊图片等简单场景,对光线遮挡、角度偏移等有较强检测能力。(图片审核示例) 3. 音频审核专一于社交等场景,可精准辨认并审核 23 种语言,利用 ASR+文本模型以及声纹模型综合判断涉黄、唾骂、暴恐、涉政、拉人广告、怨恨舆论、未成年人等内容,无效抵挡音频内容违规危险,准确率达到 95% 以上。(音频审核实用场景) ...

May 25, 2022 · 1 min · jiezi

关于算法:4寻找两个正序数组的中位数

/** * 4.寻找两个正序数组的中位数 * 给定两个大小别离为 m 和 n 的正序(从小到大)数组nums1 和nums2。请你找出并返回这两个正序数组的 中位数 。 * * 算法的工夫复杂度应该为 O(log (m+n)) * */public class Median { public static double findMedianElement(int[] numArray1, int[] numArray2) { int length1 = numArray1.length, length2 = numArray2.length; int totalLength = length1 + length2; //奇数 if (totalLength % 2 == 1) { int midIndex = totalLength / 2; double median = getElement(numArray1, numArray2, midIndex + 1); return median; } else { //偶数 int midIndex1 = totalLength / 2 - 1, midIndex2 = totalLength / 2; int k1 = getElement(numArray1, numArray2, midIndex1 + 1); int k2 = getElement(numArray1, numArray2, midIndex2 + 1); double median = ( k1 + k2 ) / 2.0; return median; } } public static int getElement(int[] numArray1, int[] numArray2, int k) { int length1 = numArray1.length, length2 = numArray2.length; int index1 = 0, index2 = 0; //长期存储K int kTemp = k; //记录遍历次数 int count = 0; while (true) { //非凡状况,取第一个元素 if (k == 1) { if (length1 == 0){ return numArray2[index2]; } if (length2 == 0){ return numArray1[index1]; } return Math.min(numArray1[index1], numArray2[index2]); } //元素初始值 int pivot1 = -99999, pivot2 = -99999; //数组1,下标没有越界,且数组个数大于0 if (index1 <= length1 -1 && length1 > 0){ pivot1 = numArray1[index1]; } //数组2,下标没有越界,且数组个数大于0 if (index2 <= length2 -1 && length2 > 0){ pivot2 = numArray2[index2]; } //曾经遍历了 k-1次 等同于 曾经找到了指标元素 if(count == (kTemp-1)){ if (index1 > length1 - 1) { return pivot2; } if (index2 > length2 - 1) { return pivot1; } return Math.min(pivot1,pivot2); } //谁的元素小,谁挪动指针 if ((pivot1 != -99999 && pivot2 != -99999 && pivot1 <= pivot2) || pivot2 == -99999 ) { //右移 nums1 指针 index1 += 1; //记录遍历次数 count += 1; } else { //右移 nums2 指针 index2 += 1; //记录遍历次数 count += 1; } } }

May 18, 2022 · 2 min · jiezi

关于算法:额头上的贴纸问题

问题形容有A、B、C、D、E这5集体,每个人额头上都帖了一张黑或白的纸。5人对坐,每 集体都能够看到其他人额头上纸的色彩。5人互相察看后: A说:“我看见有3人额头上贴的是白纸,1人额头上贴的是黑纸。”B说:“我看见其余4人额头上贴的都是黑纸。”C说:“我看见1人额头上贴的是白纸,其余3人额头上贴的是黑纸 。”D说:“我看见4人额头上贴的都是白纸。”E什么也没说。当初己知额头上贴黑纸的人说的都是谎言,额头贴白纸的人说的都是瞎话。问这5人 谁的额头上贴的是白纸,谁的额头上贴的是黑纸? 思路:因为题目开端介绍贴黑纸的就是贴谎言,贴白纸的就是瞎话。因而,咱们将5集体的话翻译过去,那就是: A:“3人瞎话,1人谎言。”B:“4人谎言”C:“1人瞎话,3人谎言。”D:“4人瞎话”E不发言。用表达式进一步示意(0为扯谎,1为诚恳),则有:如果a的话为真,则:a&&b+c+d+e==3否则:!a&&b+c+d+e!=3 其余亦然(思考文本无限,不再过多表述)。 因而,本题我采纳穷举法的思路实现。 #include<stdio.h>int main(){ int a, b, c, d, e; /*0示意彩色,1示意红色*/ for(a=0; a<=1; a++) /*穷举五个人额头帖纸色彩的全副可能*/ for(b=0; b<=1; b++) for(c=0; c<=1; c++) for(d=0; d<=1; d++) for(e=0; e<=1; e++)//*条件输出 if( (a&&b+c+d+e==3 || !a&&b+c+d+e!=3) && (b&&a+c+d+e==0 || !b&&a+c+d+e!=0) && (c&&a+b+d+e==1 || !c&&a+b+d+e!=1) && (d&&a+b+c+e==4 || !d&&a+b+c+e!=4) )//*三目运算符使用 { printf("A额头上的贴纸是%s色的.\n",a?"白":"黑"); printf("B额头上的贴纸是%s色的.\n",b?"白":"黑"); printf("C额头上的贴纸是%s色的.\n",c?"白":"黑"); printf("D额头上的贴纸是%s色的.\n",d?"白":"黑"); printf("E额头上的贴纸是%s色的.\n",e?"白":"黑"); } return 0;}即本题后果为:A额头上的贴纸是彩色的.B额头上的贴纸是彩色的.C额头上的贴纸是红色的.D额头上的贴纸是彩色的.E额头上的贴纸是红色的.

May 17, 2022 · 1 min · jiezi

关于算法:COMP2300加密算法

COMP2300/COMP6300 Applied CryptographyAssignment 2Total marks: 30Weighting: 15%Deadline: Tuesday (Week 13), 1 June 2021 (11:59 pm).Note: Submit the assignment via Turnitin (Include Student Name and ID in assignment).ObjectivesThis assignment has been designed to test your knowledge of public-key cryptography and application ofcryptography in cryptocurrencies.Notes• Assumptions (if any) must be stated clearly in your answers.• There may not be one right answer for some of the questions. So, your explanations need to presentyour case clearly. The explanations you provide do not have to be long; conciseness is preferred tomeandering.• The hints to solutions of almost all questions in this assignment are in the lecture slides, and thetextbooks [Sma16] and [NBF+16].1Submission• On line submission via Turnitin.Assignments will be marked and returned online. There are no hardcopy submissions for written assignments.Ensure you submit the correct file. The submission process shows you a complete preview of your entireassignment after you have uploaded it but before you have submitted it. Carefully check through everysingle page to ensure everything is there and the correct version has been uploaded.Multiple submissions may be possible via Turnitin prior to the final due date and time of an assessment taskand originality reports may be made available to students to view and check their levels of similarity prior tomaking a final submission. Students are encouraged to use these reports to ensure that they do not breachthe Academic Honesty Policy through high levels of similarity (plagiarism).Teaching staff will use the report to judge whether plagiarism has occurred and whether penalties shouldapply for breaches of the Academic Honesty Policy. Any similar text identified by Turnitin will be consideredcarefully to see if it is indeed a breach of the Academic Honesty Policy.2Question 1 (6 marks)Recall the (randomised) Elgamal cryptosystem. Let p be a prime. Let G be the group Z∗p = {1, 2, . . . , p − 1}under multiplication modulo p. Let g ∈ G be a generator of the group. Let (x, h) denote Bob’s (private key,public key) pair, where x is a random element of Zp−1 = {0, 1, . . . , p − 1}, and h ≡ gx(mod p).(a) Suppose Alice sends a message m ∈ G with ciphertext c = (c1, c2) to Bob, encrypted using a randomk ∈ Zp−1. Suppose Eve, the eavesdropper, comes to know both the message m, and its ciphertext c. Explainwhat can Eve do if Alice were to encrypt m0 ∈ G using the same k, resulting in ciphertext c0 = (c01, c02). (2marks)An encryption system is considered malleable if given a ciphertext of some unknown plaintext, it is possibleto obtain a valid ciphertext of a related plaintext without even knowing the contents of the plaintext. This isproblematic depending on the application. For instance, in bidding for a contract, a company might outbidits competitor by simply multiplying it’s rival company’s encrypted bid by 0.9, without even knowing thebid [DDN03]. The following questions relates to the malleability of the Elgamal cryptosystem taught in thelecture.(b) Suppose we are given the ciphertext c = (c1, c2) of some unknown message m, where c1 ≡ gk(mod p)for some unknown random integer k ∈ Zp−1 and c2 ≡ m · hk(mod p), where h is the public key of someunknown private key x, in the Elgamal cryptosystem. Let m0 be a message that you know. Can you obtaina valid ciphertext of the message m · m0 without knowing m? (2 marks)(c) Let p = 227. Given the following ciphertext of some message m1 encrypted using randomized Elgamal,what is the ciphertext of m1 · m2, where m2 ≡ 11 (mod p)? Show the steps in PARI/GP. (1 mark)(c1, c2) = (48, 3)(d) Continuing from part(c), suppose the private key is x = 73. What is the message m1? (1 mark)Question 2 (6 marks)Let X be a random variable taking on n values with probabilities p1, p2, . . . , pn. Recall from Lecture 9 thatthe min-entropy of X, denoted E∞(X), is given byE∞(X) = mini1pi.If X is uniformly distributed then p1 = p2 = · · · = pn =1n.(a) Show that if X is not uniformly distributed then necessarily one of the pi’s is > 1/n. (2 marks)(b) Show that if X is not uniformly distributed then E∞(X) < n. (2 marks)(c) Argue that min-entropy is the highest if X is uniformly distributed. What is the minimum entropy inthis case? (2 marks)Question 3 (2 marks)Let H be a hash function that has the properties of hiding and collision-resistance. Recall that collisionresistance property means that it is infeasible to find two inputs x, y with x 6= y such that H(x) = H(y).3Consider the commitment scheme from Lecture 9. To commit to a message m, Alice samples a randomnonce r, and computesC = H(r||m),and publishes C as her commitment. A commitment scheme is binding if it is infeasible to find two pairs(m, r) and (m0, r0) with m 6= m0such thatH(r||m) = H(r0||m0).Show that if you can find a collision in H, this does not necessarily break the binding property of thecommitment scheme. (2 marks)Question 4 (3 marks)In lecture 10, we saw that the initial value for block reward for bitcoins was 50 Bitcoins, which halves every210,000 blocks. Recall that the sum of an infinite geometric series isS = a + ar + ar2 + ar3 + · · · =a1 − r,where a is the starting coefficient, and r is the common ratio between adjacent terms. Since new Bitcoinscan only be created if a new block is created, using the above formula, calculate the final number of Bitcoinsthat will ever be created. Your answer should explain your choice of a and r. (3 marks)Question 5 (3 marks)Recall from Lecture 10 that a 51% attacker is an attacker who holds at least 51% of the total hash power.Let represent the proportion of hash power held by this attacker. Then, ≥ 0.51. Suppose this attackerwants to suppress Carol’s transactions by not including any of her transactions. To do so, whenever theattacker (or the attacker’s nodes) solves the hash puzzle, it proposes a block without Carol’s transactions.Show that the attacker will be successful in the sense that the longest valid consensus chain will eventuallybe the one proposed by the attacker. Why this will not be the case if < 0.5?(3 marks)Question 6 (10 marks)Recall hash puzzles from Lecture 10. In this question, we will see how they work in practice. This questionrequires programming in a language that has an implementation of SHA-256 hash function. You could useJava to program, although, you are free to use any other language with a library containing SHA-256, e.g.,Python’s hashlib. Create a string s containing all the digits in your student ID. For example, if my studentID is MQ12345678, then s = 12345678. Set the target t to:t =225620Let H be the SHA-256 hash function. Let r be a counter starting from 0.(a) Implement a program that tries successive values of r, i.e., r = 0, 1, 2, 3, . . ., computes H(s||r), comparesit with t and halts whenever H(s||r) < t, with the output r. You need to provide the program and theoutput r. (5 marks)4(b) Modify the program from part (a) by adding i to s, where i = 0 to 999 inclusive, and for each i computingthe hash until the value falls before the target. What is the average number of attempts (over 1,000) beforeyou found the target? You need to provide your program. (3 marks)(c) If you drew random values between 0 and 2255 inclusive, how many attempts on average it would takebefore you find a value below the target? What does it tell you about SHA-256? (2 marks)References[DDN03] Danny Dolev, Cynthia Dwork, and Moni Naor. Nonmalleable cryptography. SIAM review,45(4):727–784, 2003.[NBF+16] Arvind Narayanan, Joseph Bonneau, Edward Felten, Andrew Miller, and Steven Goldfeder. Bitcoinand cryptocurrency technologies: a comprehensive introduction. Princeton University Press,2016.[Sma16] Nigel P Smart. Cryptography made simple, volume 481. Springer, 2016. ...

May 15, 2022 · 7 min · jiezi

关于算法:206反转链表-算法leetcode附思维导图-全部解法300题

零 题目:算法(leetcode,附思维导图 + 全副解法)300题之(206)反转链表一 题目形容 二 解法总览(思维导图) 三 全副解法1 计划11)代码: // 计划1 “本人。化归法”。// 技巧:“化归法,将不相熟 转换成 相熟的。个别咱们将链表转换成数组模式去存储,题目就会变得很好做(注:但面试官可能会不太称心!!)”。// 思路:// 1)边界:若 为空链表,间接返回 null 。// 2)状态初始化:resList = [], resHead = head 。// 3)外围1:遍历链表,将链表上的值存入 数组 resList 中。// 4)外围2:逆序遍历 resList ,顺次将至更新值 head.val 中。// 5)返回后果:resHead 。var reverseList = function(head) { // 1)边界:若 为空链表,间接返回 null 。 if (!head) { return null; } // 2)状态初始化:resList = [], resHead = head 。 let resList = [], resHead = head; // 3)外围1:遍历链表,将链表上的值存入 数组 resList 中。 while(head){ resList.push(head.val); head = head.next; } // 4)外围2:逆序遍历 resList ,顺次将至更新值 head.val 中。 const l = resList.length; head = resHead; index = l - 1; while (index >= 0) { head.val = resList[index]; index--; head = head.next; } // 5)返回后果:resHead 。 return resHead;};2 计划21)代码: ...

May 14, 2022 · 2 min · jiezi

关于算法:159271-计算思考

159.271 Computational ThinkingAssignment 2This assignment will be a piece of cake. That is, you need to smarten up the computer player fora game we shall call “Piece of Cake”.Piece of CakeThe game works as follows: We have a cake that is cut into pieces which can differ in thickness.Players take turns in choosing a piece of cake. But they need to be polite: After the first piece ofcake has been removed, only one of the two pieces adjacent to the gap can be taken. Once the cakeis gone, the player who ate the most wins.A simple implementation for a 2-player version of the game (computer vs human, human goesfirst) is provided on the course website (if you see gaps in the cake border, that’s a bug in the graphicslibrary). The cake has 32 pieces (an even number ensures some measure of fairness), with thicknessranging from 5 to 9.TasksCurrently, the computer player is using a simple greedy heuristic, choosing the bigger of the two piecesavailable (this is done in cake picker.py - your implementation should modify this class). A betterstrategy is to maximize the total amount of cake you can get regardless of how your opponent plays.That is, you assume that your opponent always picks the piece which minimizes the overall total youcan get (and maximizes theirs).(a) Give an example to show that the simple greedy heuristic used by the template is not optimal,i.e., that it does not maximize the total amount of cake the computer will get when taking theminimum among all possible choices for the human player. [2 points]Note: The number of pieces left is always odd when the computer choses. A minimal odd-sizedexample showing the non-optimality of a greedy strategy has 5 pieces.(b) Implement an algorithm which maximizes the computer player’s guaranteed overall total in eachstep (as described above). This algorithm should run in polynomial time. [6 points]Hint: Use dynamic programming techniques.(c) Analyze the time complexity of your algorithm, as a function of the number of pieces. [1 point](d) Describe briefly how to modify your algorithm if the computer player were to start. [1 point] ...

May 13, 2022 · 2 min · jiezi

关于算法:穷举思路解决撒谎问题

先来一个简略的算法题: 问题形容诚恳族和说谎族是来自两个岛屿的不同民族,已知诚恳族的人永远说真话,而说谎族的人永远说实话。 一天,谜语博士遇到3集体,晓得他们可能是来自诚恳族或说谎族的。为了考察这3集体到底来自哪个族,博士别离问了他们问题,上面是他们的对话: 博士问:“你们是什么族的? “ 第1集体答复说:“咱们之中有2个来自诚恳族。” 第2集体说:“不要胡说,咱们3集体中只有一个是来自诚恳族的。”第3集体接着第2集体的话说:“对,的确只有一个是诚恳族的。” 这个题中,说谎族所说的话必定是实话,因而如果将每个人的话用代码示意,为了不便计算机意识,咱们将诚恳的状况列为1,扯谎状况为0,那就是 如果第一个人说法正确,那么后果为:A&&A+B+C==2如果第一个人说法扯谎,后果为:!A&&A+B+C!=2 其他人亦然用穷举办法实现,残缺代码为: #include<stdio.h> int main() { int A, B, C; { for(A=0; A<=1; A++) for(B=0; B<=1; B++) for(C=0; C<=1; C++) if( (A && A+B+C==2 || !A && A+B+C!=2) && (B && A+B+C==1 || !B && A+B+C!=1) && (C && A+B+C==1 || !C && A+B+C!=1) ) { printf("第一个人来自%s\n",A?"诚恳族":"说谎族"); printf("第二个人来自%s\n",B?"诚恳族":"说谎族"); printf("第三个人来自%s\n",C?"诚恳族":"说谎族"); } } return 0; }当然,本题也能够用递推法实现,对于本题而言,应用穷举只不过是为了让代码整体更加简略,构造更加清晰。 刚刚是一个简略的例子,如果咱们的题目简单一些 问题形容两面族是岛屿上的一个新民族,他们的特点是谈话时一句真话一句实话,虚实交替。即如果第一句说的是真话,则第二句必为实话;如果第一句说的是实话,则第二句必然是真话。但第一句话到底是真是假却不得而知。 当初谜语博士碰到了3集体,这3集体别离来自3个不同的民族,诚恳族、说谎族和两面族。谜语博士和这3集体别离进行了对话。 首先,谜语博士问右边的人:“两头的人是哪个族的?”,右边的人答复说:“是诚恳族的”。 谜语博士又问两头的人:“你是哪个族的?”,两头的人答复说:“两面族的”。 最初,谜语博士问左边的人:“两头的人到底是哪个族的?”,左边的人答复说:“是说谎族的”。 ...

May 13, 2022 · 1 min · jiezi

关于算法:算法与数据结构体系课完结无密

download:算法与数据结构体系课|完结无密RabbitMq消息丢失原因及其解决打算 一、RabbitMQ消息丢失原因 1.1、消费者丢失消息消费者将数据发送到rabbitmq的时候,可能因为网络问题导致数据就在半路给搞丢了。 1.使用事务(性能差) RabbitMQ 客户端中与事务机制相干的方法有三个: channel.txSelect 、channel.txCommit 和 channel.txRollback。channel.txSelect 用于将以后的信道设置成事务模式,channel.txCommit 用于提交事务,channel.txRollback 用于事务回滚。在通过 channel.txSelect 方法开启事务之后,咱们便可能公布消息给 RabbitMQ 了,如果事务提交胜利,则消息肯定到达了 RabbitMQ 中,如果在事务提交执行之前因为 RabbitMQ异样崩溃或者其余原因抛出异样,这个时候咱们便可能将其捕捉,进而通过执行channel.txRollback 方法来实现事务回滚。注意这里的 RabbitMQ 中的事务机制与大多数数据库中的事务概念并不相同,需要注意分别。 事务确实能够解决消息发送方和 RabbitMQ 之间消息确认的问题,只有消息胜利被RabbitMQ 接收,事务才能提交胜利,否则便可在捕捉异样之后进行事务回滚,与此同时可能进行消息重发。然而使用事务机制会“吸干”RabbitMQ 的性能。 2.发送回执确认(推荐) 消费者将信道设置成 confirm(确认)模式,一旦信道进入 confirm 模式,所有在该信道下面公布的消息都会被指派一个唯一的 ID(从 1 开始),一旦消息被投递到所有匹配的队列之后,RabbitMQ 就会发送一个确认(Basic.Ack)给消费者(蕴含消息的唯一 ID),这就使得消费者通晓消息已经正确到达了目的地了。如果消息和队列是可持久化的,那么确认消息会在消息写入磁盘之后收回。RabbitMQ 回传给消费者的确认消息中的 deliveryTag 蕴含了确认消息的序号,此外 RabbitMQ 也可能设置 channel.basicAck 方法中的 multiple 参数,示意到这个序号之前的所有消息都已经失去了处理,注意辨别这里的确认和生产时候的确认之间的异同。 注意要点: 事务机制和 publisher confirm 机制两者是互斥的,不能共存。 事务机制和 publisher confirm 机制确保的是消息能够正确地发送至 RabbitMQ,这里的“发送至 RabbitMQ”的含意是指消息被正确地发往至 RabbitMQ 的交换器,假如此交换器没有匹配的队列,那么消息也会丢失。 1.2、RabbitMQ弄丢了数据-开启RabbitMQ的数据持久化 为了防止rabbitmq自己弄丢了数据,这个你必须开启rabbitmq的持久化,就是消息写入之后会持久化到磁盘,哪怕是rabbitmq自己挂了,复原之后会主动读取之前存储的数据,一般数据不会丢。除非极其罕见的是,rabbitmq还没持久化,自己就挂了,可能导致大量数据会丢失的,然而这个概率较小。 设置持久化有两个步骤,第一个是创建queue的时候将其设置为持久化的,这样就可能保障rabbitmq持久化queue的元数据,然而不会持久化queue里的数据;第二个是发送消息的时候将消息的deliveryMode设置为2,就是将消息设置为持久化的,此时rabbitmq就会将消息持久化到磁盘下来。必须要同时设置这两个持久化才行,rabbitmq哪怕是挂了,再次重启,也会从磁盘上重启复原queue,复原这个queue里的数据。 而且持久化可能跟消费者那边的confirm机制配合起来,只有消息被持久化到磁盘之后,才会告诉消费者ack了,所以哪怕是在持久化到磁盘之前,rabbitmq挂了,数据丢了,消费者收不到ack,你也是可能自己重发的。 ...

May 12, 2022 · 1 min · jiezi

关于算法:CISC372-并行计算

CISC372-ParallelProject 6Overview:In the last project, you implemented an image filter program using pThreads. A special case of the filterprogram is called a box blur. Basically, this type of filter involves setting all of the values in the matrix to1, then dividing the result by the number of values in the matrix. = [1 1 11 1 11 1 1] ℎ ℎ , ℎ , 9The issue we had in the last program, is that when an image is high resolution, a 3x3 filter does very littleto change the appearance of the image. We would like a bigger filter (i.e. the radius here is 1, we mightwant a radius of 20 or 40), but this would make the problem somewhat intractable.A fast way to do this is to simply keep a running sum for each row of the last 2*radius+1 elements, thentake the resultant image, and do the same for each column. If we divide each of these by the width ofthe kernel (2*radius+1), Then we end up computing exactly what the filter computes (average around aradius), with exactly one pass through the columns and one pass through the rows. Now that each rowand each column is independent, we have a hope of parallelizing this algorithm.Project Details:For this project, you may either work alone, or in pairs. You will have until the final Friday (5/14) tocomplete this assignment. If you work in pairs, make sure that the header of all files that you generatecontains the names of both people who worked on the project so that you both get credit. Both peopleshould hand in the final project via Canvas. You may run this code anywhere you like (on PSC, oncisc372 using srun, or on your own machine configured for CUDA). You should hand in your final .cu fileand any other files you produce.Part 1: Fast BlurYou can retrieve my fast blur code from github, along with a sample image (Gauss,jpg) from github at:gsilber/CISC372_HW6 (github.com)Use the included makefile to build the program. You can run it as is by executing ./fastblur gauss.jpg 40where 40 is the desired radius (this is a big image). You can play with different values of radius to seehow it behaves. The radius is dependent on the image resolution. On different resolutions, the radius isa different percentage of the entire image, and thus will have a different blurring effect.Part 2: Simple CUDAIn this part of the project, you should modify the fastblur.c file to create cudablur.cu (cuda code musthave a .cu extension to work). You will need to change the makefile to use nvcc instead of gcc tocompile for cuda.Rewrite the program, so that each column runs in its own thread. I suggest a thread block size of 256.This means turning the computeColumn function into a kernel, and figuring out the col parameter fromthe threadIdx, blockIdx, and blockdim variables.Then you must sync up the threads with a call to cudaDeviceSync and repeat the process for each row.Finally convert back to uint8_t array, and save the image.I suggest for this part you use cudaMallocManaged and cudaFree for all the arrays to simplify the code.If you have a block size of 256, then you would have a block count of (width+255)/256 columns. Makesure to check in your kernel function for unused threads where the computed column>pWidth. Do thesame for the rows (height+255)/256. And check the computed row against height. If the height or widthis not divisible by the blocksize, then we will have some extra threads that need to just returnimmediately.Part 3: More advanced CUDAPart 2 is kind of slow. This is because of the managed memory. To speed it up, we want to allocate thememory we need on the device where possible and move that memory with cudaMalloc andcudaMemcpy up to the device for calculation. Then when complete, copy that memory back to the hostin order to save it to the output file. Play with the values for blocksize to try to maximize performance.See how fast you can get the computation to run.What to hand in:Hand in your cudaBlur.cu file from part2, and from part3 along with makefiles for each and any otherfiles you added which are required to build your program. Make sure your program compiles and runs,and put the system where you ran it in the comments to avoid any confusion.GradingThis is a hard project. My intent is that most people will be able to do part 2, so part 2 is worth 75% ofthe grade on this project. Part 3 is worth the remaining 25%. ...

May 12, 2022 · 4 min · jiezi

关于算法:戴尔赋能科创小企业共塑科创大时代

这是硬科技的时代,也是高翻新的时代。时代舞台的配角,将在近50万家科创小企业之中诞生。《科创人》创刊近3年,专访上百位科创首领,均匀对话时长2小时,转换成文本是45k~80k文字量——然而,单篇成稿最多也不过6k文字。那些被隐去、删减甚至默认窃密的,大都是痛楚。诉苦结束,往往跟一句“聊归聊,这段就别写了”——科创之苦、初创之艰巨堪称一步一槛,可企业服务畛域又鲜有服务初创企业者。最须要帮忙的群体,成了最无助的群体。现在,戴尔秉承“在中国,为中国”的企业理念,以硬核计算力成就硬科技,致力于帮忙中国科创小企业博得将来。 亿万级算力,撑持数智原生企业成熟倒退的数据智能技术,无疑是科创时代的外围支柱之一。成立于2020年的北京方云科技有限公司,将人工智能算法与IT研发过程中人造产生的过程数据相结合,生成合乎对齐用户策略方向的研发绩效模型,攻克研发管理体系中最难解决的研发绩效难题。方云智能创始人于振坤曾表白过这样的苦恼:“独家算法须要大量数据能力无效地实现训练,在算力设施上投入资金较大”。像方云智能这样,以数智技术联合价值场景,曾经成为科创小企业的支流模式。对于初创企业而言,最头疼的莫过于如何打造兼具性价比与算力弱小稳固的数智底层零碎,让企业可能集中全力打磨产品、晋升服务、跑通市场。对于科创小企业来说,“少花钱、少操心、多办事”并非遥不可及:戴尔PowerEdge服务器系列,具备高存储量、高I/O性能、高响应速度、高可扩大且低运维老本的智能化基础架构。利用Hadoop存储解决方案可为客户节俭35%的洽购老本,并且在AI集群中应用Nvidia v100s GPU代替老品v100,以3.6%的价差可换来15%的性能晋升,帮忙科创小企业匹配高性能硬件,削冗无用配置。借助戴尔IT服务,科创小企业的开创团队能够专一于技术创新和场景价值开掘,在戴尔算力弱小、运维老本较低的服务器上运行新模型、新算法、新思路,最大限度地进步生产力、放慢流程,生产出更为先进的行业解决方案,疾速跑通MVP。 独立平安芯片,爱护数智外围资产数据威逼无处不在,既来自内部,也来自外部:一方面,网络攻击呈现出显著的To B趋势,数据安全威逼情报企业、北京微步在线科技有限公司创始人CEO薛锋向《科创人》介绍说,网络攻击近年来呈现出显著的模式翻新,由以往To C偷盗,转向To B窃取企业外围数据进行贩售或勒索;另一方面,设施受损导致数据损毁不足为奇,程序员删库泄愤更是上过N次热搜。对科创小企业来说,数据、算法、模型等外围研发成绩不仅须要爱护,还要保证数据流通性、防止“信息孤岛”,最大化施展数据算法的作用和价值。深刻理解科创小企业平安痛点的戴尔,在行业中率先提出“数据为先”的策略,帮忙客户应答数据保护、数据管理等畛域的复杂性、关键性难题。例如,通过戴尔网络复原解决方案,可能为科创小企业提供“隔离、辨认、加锁”三大数据保护能力。戴尔还可能提供从边缘到外围到云的数据保护计划,在间断可用、复制、快照、备份、归档、LTR以及隔离复原等畛域都能提供残缺的计划和服务。对于资金并不拮据的科创小企业而言,戴尔被动翻新技术,帮忙客户升高首次购买老本。以戴尔PowerStore为例,它能够实现至多4:1的数据缩减率,帮忙科创小企业大大减少磁盘配置的同时,使数据失去更好的流通与爱护。搭配戴尔PowerEdge高性能服务器应用,软硬件双重加密爱护,一直将强化的服务器设计晋升到新的高度,以爱护、检测网络攻击以及从网络攻击中恢复过来,从内外部为科创小企业的数据库保驾护航。韧性柔性兼具高负载运行不宕机、减少配置不换机成都数之联科技股份有限公司联结创始人CTO方育柯在承受《科创人》采访时,曾回忆起守业之初对产品线大刀阔斧地迭代调整,最终100多个布局的产品模块削减至3个,其中To C的拍图购性能大跨度转化为To B的工业缺点检测能力,撑持起了数之联的长期业务增长;上海派拉软件股份有限公司CEO谭翔也有着相似经验,守业初期团队自信满满,产品路线笼罩云计算、系统监控、性能治理、平安、容灾……3年多苦楚迭代,最终确定深耕身份平安这一条垂直赛道。《科创人》专访过的科创先行者们普遍认为,企业整体的应变能力与可扩大是生死难题。科创小企业既须要面对市场疾速响应,实现韧性和麻利供应链治理,也须要保障在研发过程中IT设施长期高负载运行不卡顿,遇到故障具备肯定的自我修复、自动更新能力。戴尔稳固的硬件、优良的软件架构、严格的测试,可能保障IT设施的平安且稳固连续性运行。以智能制作行业为例,初创企业往往不能在“进步生产效率”的同时兼顾“产线平安稳固运行”,创始人时常面临苦楚取舍。戴尔提供的无人危险零碎、生产现场工程测试零碎、esp治理、设施集成、仿真测试等一系列数字化降级设施,可能助力智能制作类科创小企业在晋升效率的同时保障业务的稳固连续性,高负载运行同时不宕机。戴尔的一站式装置服务,又能节俭数字化过程中员工调配设施的大量工夫。此外,因小企业业务转型变动快,需随市场迅速倒退或调整IT研发专精赛道,这就须要配置的设施需可能满足多场景业务和多研发需要,具备强扩大的性能。戴尔服务器具备多扩大插槽,可装备高达10个GPU插槽,让小企业能够一步到位购买长期可用设施,随时更改设施配置不换机,满足小企业业务的不同阶段刚需。 定制化解决方案,全生命周期服务科创小企业往往擅长于技术能力,匮乏于行业洞察,不怕攻坚却苦恼于鸡毛蒜皮。然而,初创企业广泛“钱少事多”,导致To B服务商往往不愿为它们投入外围资源、重度服务。为撑持科创小企业衰弱倒退,戴尔会为其提供AI、智能制作、新批发、基因测序、大数据、软件开发等翻新主干道行业的成套定制化解决方案。尤其在疫情期间,近程办公成为常态化,科创小企业的员工须要疾速诊断设施问题并解决。戴尔领有超过1200人的业余参谋团队,7*24小时在线疾速响应服务,专人客户对接,让科创小企业享受灯塔客户级的服务体验的同时大幅晋升工作效率。科创二字背负着世界的将来,眼下,近50万家科创小企业正在简单的外部环境影响下艰巨前行。漫天飞舞的黑天鹅一直加剧着他们的生存压力,但《科创人》看到的是,不管兜里叮当作响、还是疫情打断业务倒退,都没有磨灭他们眼中的光辉。他们置信翻新是时代的正解,事实也的确如此。正因如此,这个时代分外须要服务创新者的全力践行者。秉承“在中国,为中国”策略的戴尔,动摇服务于肩负中国科创使命的科创小企业。无论是提供经济型算力、保障IT设施的长期稳固运行不宕机,还是在外围数据信息与知识产权爱护与全生命周期服务商,戴尔可能提供高性价比的解决方案服务。更为难得的是, 在长期服务中国科创小企业客户的过程中,戴尔积攒了泛滥个性化解决方案,可能针对科创企业不同倒退阶段对IT设施进行灵便拓展,让科创小企业提前感触大客户服务。疫情之下、改革以后,戴尔将助力更多科创小企业晋升数字化成熟度与研发创新能力,推动中国科技翻新事业,谋求企业与社会的长期稳固倒退之道。

May 12, 2022 · 1 min · jiezi

关于算法:编程之美21-求无符号整数N的二进制表示中1的个数

题目:求无符号整数N的二进制示意中1的个数 #include <iostream>// way1办法相似将10进制数转换为二进制数的过程,// 如果一个整数对2取模,如果后果为1,代表其最低位为1;// 而后咱们将该整数向右挪动一位(即除2)// 反复此过程,就能够拿到所有1的个数int way1( unsigned int num ){ int count = 0; while ( num ) { if ( num % 2 == 1 ) { count++; } num = num / 2; } return count;}// way2办法:相当于把取模运算变为了按位与,将除2变为了右移操作,从而晋升了效率int way2( unsigned int num ){ int count = 0; while ( num ) { count += num & 0x01; num = num >> 1; } return count;}// way3办法原理如下利用N和(N-1)的二进制表达式的关系,即N&(N-1)就会打消N的二进制中最左边的1。// 具体阐明如下:// 已知N,求N-1,咱们回顾一下,求N-1的二进制的减法过程// 在N的二进制示意中,从最左边向左找第一个1,而后借位,被借的那个数位1变为0,而后往右返回一个2(二进制,借1当2),左边数位留下一个1,再借给右边的数位一个1,// 反复此过程,直至最左边的数位。// 举个例子,比方N=1100(十进制的12),N-1 = 1100 - 1 = 1011 ( 十进制的11)// 请留神这个过程会产生一个景象,即N-1的二进制表达式和N的二进制表达式,从N的最右边的一个1( 即1[1]00, 被[]括起来的那个1 )开始,数位是齐全相同的,// 而这个被括起来的1的右边,N和N-1是统一的。// 因而,咱们能够利用这个法则,用N&(N-1)(&为按位与)来打消N的最低的一位1,( 1100 & 1011 = 1000 ), 而后将后果赋值给N,// 如此重复,能够做几次N&(N-1),其二进制中就有几个1int way3( unsigned int num ){ int count = 0; while ( num ) { num = num & (num - 1); count++; } return count;}int main( int argc, char** argv ){ // 求无符号整数num的二进制示意中1的个数 // 为了不便验证后果,咱们间接将整数以二进制模式定义 unsigned int num = 0b101110001; std::cout << "num is " << num << std::endl; std::cout << "way1 result : " << way1(num) << std::endl; std::cout << "way2 result : " << way2(num) << std::endl; std::cout << "way3 result : " << way3(num) << std::endl; return 0;}

May 12, 2022 · 1 min · jiezi

关于算法:编程之美22-不要被阶乘吓倒

题目: 给定一个整数N,nameN的阶乘N!结尾有多少个0呢?求N!的二进制示意中最低位1的地位#include <iostream>// 遍历1~N,找到每一个5的倍数蕴含5这个因数的个数// 比方 N=34,咱们会找到// 1. 数字5蕴含1个因数5(5=1*5),// 2. 数字10蕴含1个因数5(10=2*5)// 3. 数字15蕴含1个因数5(15=3*5),// 4. 数字20蕴含1个因数5(20=4*5),// 5. 数字25蕴含2个因数5(25=5*5),// 5. 数字30蕴含1个因数5(30=2*3*5),// 一共找到1+1+1+1+2+1=7个5int count0_way1( int N ){ int count = 0; for ( int i = 1; i <= N; i++ ) { int j = i; while ( j % 5 == 0 ) { count++; j /= 5; } } return count;}// 咱们也能够间接在1~N中找到蕴含因数5的数的个数,// 比方 N=34的数字中,// 1. 蕴含1个因数5的数字有5,10,15,20,25,30,共6个(即34/5的后果)// 2. 蕴含2个因数5的数字(即25)有25, 共1个,即34/25的后果,// 3. 蕴含3个因数5的数字(即125)有0个,即34/125的后果,// 4. .....// 一共找到34/5 + 34/25 = 6+1=7 个int count0_way2( int N ){ int count = 0; while ( N ) { count += N / 5; N = N / 5; } return count;}// 求N!后果中最低地位1的地位,等同于求N!的2的质因数的个数// 咱们能够察看到,// 1. 任何奇数的二进制示意中,最初一位都是1// 2. 任意多个奇数相乘的后果仍然是奇数,也就是说,奇数相乘,其后果的最初一位1总是在最低位上// 3. 任意一个数,都能够合成为质因数相乘,在所有的质数中,只有2是偶数,其余的都是奇数// 4. 一个数乘以2,相当于其二进制示意左移一位, 即最低位的1的地位向左挪动一位// 5. 因而,咱们把算式 N! = N*(N-1)*(N-2)*(N-3)....*1 合成质因式,其所有的因子中,只会存在2和奇数(因为质数中只有2是偶数)// 依据2,奇数的乘积还是奇数,只有因数2才会扭转最低位1的地位,每乘一次2(也即呈现一个因子2)就会使得1的地位左移一次// 失去咱们的论断:求N!后果中最低地位1的地位,等同于求N!的2的质因数的个数,// 求N!中质因数2的个数的办法能够参考Question1的办法2,int OnePosition_way1(int N ){ int count = 0; while ( N ) { count += N / 2; N = N >> 1; } return count + 1;}int main( int argc, char** argv ){ // Question1: 求N!的后果中,结尾0的个数。 // 求一个乘法算式后果的结尾0的个数,等同于求乘法算式中因子10的个数,而10=2*5,且在自然数的因子中,因子2的个数大于因子5的个数, // 因而,求这个算式后果的结尾0的个数,等同于求这个算式中因子5的个数 int N = 34; std::cout << " count 0 in " << N << std::endl; std::cout << " way1: " << count0_way1( N ) << std::endl; std::cout << " way2: " << count0_way2( N ) << std::endl; std::cout << " DONE " << std::endl; // Question2: 求N!后果的二进制示意中,最低位1的地位,比方 N=3, N!=3*2*1=6=0b(110), 其结尾最低位1的地位是2. std::cout << " the positon of lowest 1 : in " << N << std::endl; std::cout << " way1: " << OnePosition_way1( N ) << std::endl; //std::cout << " way2: " << 1position_way2( N ) << std::endl; std::cout << " DONE " << std::endl; return 0;}

May 12, 2022 · 2 min · jiezi

关于算法:ECS-32B介绍数据结构

ECS 32B – Introduction to Data StructuresHomework 04Due: Friday, May 14, 2020, 5:00pm PSTImportant:• You may upload as many times as you want before the deadline. Each time the autograder will letyou know how many of the test cases you have passed/failed. To prevent people from manipulatingthe autogader, the content of some test cases are hidden.• Please do not copy others’ answers. Autograder can detect similar code.Problem 1 (5 points)For Problem 2 in Homework 03, the recursive version of transform can be written as:1 def transformRecursive ( lst ) :2 if not lst :3 return []4 return [ lst . val ] + transformRecursive ( lst . next )Let head be the head of the linked list 10 → 6 → 3 → 13 → 2. Visualize the call transformRecursive(head)using• the activation stack model; and• the substitution model.(Please follow the definiton of transformRecursive above instead of your own version in homework 03.)Problem 2 (5 points)For Problem 3 in Homework 03, the recursive version of concatenate can be written as:1 def concatenateRecursive ( lst1 , lst2 ) :2 return concatenateRecursive_helper ( lst1 , lst2 , lst1 )34 def concatenateRecursive_helper ( lst1 , lst2 , cur ) :5 if not lst1 :6 return lst27 if not cur . next :8 cur . next = lst29 return lst110 return concatenateRecursive_helper ( lst1 , lst2 , cur . next )1Let head1 be the head of the linked list 8 → 20 → 4 → 5 → 10, and head2 the head of the linked list7 → 2 → 3. Visualize the call concatenateRecursive(head1, head2) using• the activation stack model; and• the substitution model.(Please follow the definiton of concatenateRecursive above instead of your own version in homework 03.)Problem 3 (28 points) ...

May 11, 2022 · 5 min · jiezi

关于算法:GPU分类和应用现状分析

GPU最后用在PC和挪动端上运行绘图运算工作的微处理器,与CPU集成以集成显卡(核显)的状态施展性能。NVIDIA于2007年率先推出独立GPU(独显),使其作为“协处理器”在PC和服务器端负责减速计算,承接CPU计算密集局部的工作负载,同时由CPU持续运行其余程序代码。 作为独显的GPU由GPU外围芯片、显存和接口电路形成。 独GPU与CPU之间通过PCIe总线连贯,因此PCIe总线规范间接影响到通信带宽;而针对GPU之间的互连,Nvidia推出NVLink技术代替传统PCIe总线的形式,依据Nvidia官网数据,GPU性能晋升5倍。 目前因为AI性能开掘仍有空间,曾经部署的服务器中GPU算力尚有冗余,预计PCIe由3.0降级至4.0和5.0短期内对GPU影响不大。但支流参与者仍在依照工艺门路继续推动产品升级。 依据AIBResearch数据,Nvidia占据独显市场近80%的份额,目前NVIDIA Ampere A100产品7nm曾经投入生产。 NVIDIA、AMD和Intel在GPU市场三分天下。依据Jon Peddie Research数据,Intel、AMD和Nvidia别离占据63%、19%和18%的市场份额。Intel和ADM在PC端GPU市场占据强势位置,次要起因是PC端集成GPU(核显),而Intel和AMD在PC端x86 CPU市场别离占据84%和16%的份额。 在独立GPU(独显)市场,Nvida是行业的奠基者和龙头,占据近70%份额。AIB 数据显示,2019年Q4,Nvidia和AMD在独立GPU市场份额别离为81%和19%。针对HPC和AI场景,Nvidia推出的产品次要是Tesla系列,包含V100、P100、K40/K80、M40/M60等多个型号,K系列更适宜高精度计算,M系列更适宜深度学习。 2019年3月,Nvidia发表以49亿美元收买Mellanox,预计2020年4月底该项交易最终实现,成为Nvidia历史上最大的一笔收买。Mellanox是服务器和存储端到端连贯解决方案的供应商,产品波及HPC、云计算、数据中心、企业计算及存储市场,包含Smart NIC,网络交换机芯片和高速数据互联等。 AI芯片在智能摄像头、无人驾驶等畛域利用宽泛。数据、算力和算法是AI三大因素,CPU配合减速芯片模式成为典型的AI部署计划,CPU提供算力,减速芯片晋升算力并助推算法的产生。常见的AI减速芯片包含GPU、FPGA(Field Programmable Gate Array)和ASIC(Application Specific Integrated Circuit)三种类型。 CPU适宜逻辑管制和串行计算等通用计算,计算能力没有GPU强,次要由专为程序串行解决而优化的几个外围组成; GPU用于大量反复计算,由数以千计的更小、更高效的外围组成大规模并行计算架构,装备GPU的服务器可取代数百台通用CPU服务器来解决HPC和AI业务(依据Nvida)。 FPGA是一种半定制芯片,灵活性强集成度高,但运算量小,量产老本高,实用于算法更新频繁或市场规模小的专用畛域; ASIC专用性强,市场需求量大的专用畛域,但开发周期较长且难度极高。谷歌自主设计了一款基于ASIC的TPU(Tensor Processing Unit)专门用于机器学习工作负载。 训练和推断是云端AI两大运行过程,训练产生算法,推断实现算法利用。训练阶段须要大量数据运算,GPU预计占64%左右市场份额,FPGA和ASIC别离为22%和14%。 推理阶段无需大量数据运算,GPU将占据42%左右市场,FPGA和ASIC别离为34%和24%。AI芯片经营场景包含云端(服务器)、边缘端和终端三类,不同利用场景对AI芯片的需要不同。就云端芯片而言,2023年市场需求将达200亿美元(依据Nvidia)。

May 11, 2022 · 1 min · jiezi

关于算法:SIT742-数据分析

SIT742 (Modern Data Science)Full Marks: 40Assessment Task 022021 Trimester 1, Due: 8:00pm AEST, 22/05/2021Students with difficulty in meeting the deadline because of illness, etc. must apply for anassignment extension in CloudDeakin no later than 12:00pm on 21/05/2021 (Friday).• This is a group work for group with up to 3 members. If you choose to work on itindividually, please seek approval from unit chair via email.• There are folders for this task on CloudDeakin, please enrol into the group (2 or 3members) before 15/05/2021 (12:00am):2021 Assessment Task 2 (1-member Group) for students with approval ofworking alone; Approval required;2021 Assessment Task 2 (2-member Group) for groups of 2 members; Selfenrollmentrequired;2021 Assessment Task 2 (3-member Group) for groups of 3 members; Selfenrollmentrequired.• Please form the group first, and then self-enrol into the appropriate group before15/05/2021 (12:00am).InstructionsSix files are provided for this assessment task:HTWebLog_p1.zip The compressed zip file is for Part I of this assessment task, and it is a sample of HotelTULIP Web log dataset, which contains the web access log information from 11/2006 to 02/2007. 1.Citation2003-2021.csv This CSV file is for Part II of this assessment task, and the file structure is provided.Search-results.csv This CSV file is for Part II of this assessment task, and the file structure is provided.SIT742Task2.ipynb This is the notebook file for the Python code in ipynb, and the latest notebook is alsoreleased in SIT742Task2.ipynb.Web log This code snippet contains all the coding requirements and also hints for Part I of thisassessment task.Predictive Aanalysis This code snippet contains all the coding requirements and also hints is forPart II of this assessment task.You will need to complete the code in the notebook and make it run-able. The results of running thenotebook will help you to develop your report, as well as generate the required files: Citation2003-2021.csv and Search-results.csv.SIT742Task2-Report-Template.docx This is the Word template for your report SIT742Task2-Report.pdf.What to Submit?You are required to submit the following completed files to the corresponding Assignment (Dropbox) inCloudDeakin:SIT742Task2.ipynb The completed notebook with all the run-able code on all requirements.SIT742Task2-Report.pdf Your report for the both Part I and Part II of this assessment task.1This file is exclusively for SIT742 educational purpose only. You are not allowed to further distribute it.Page 1 of 6SIT742 (Modern Data Science)Full Marks: 40Assessment Task 022021 Trimester 1, Due: 8:00pm AEST, 22/05/2021Citation2003-2021.csv The completed citation information as CSV file, sorted by year.Search-results.csv The completed parameter grid search result as CSV file.Part IData Analytic — Web Log Data (20 marks)Here is the hypothetical background:Hotel TULIP (a hypothetical organisation) is a five star hotel that locates in Australia. It is avery special hotel with an equally special purpose: Not only does it embody all the creative energyand spirit of TULIP-Lab, it’s a “learning environment” on which the tourism and hospitalitystudents are trained for future hoteliers.In the past two decades, the Web server of Hotel TULIP has logged all the web traffic to thehotel website, and stored large amount of data related to the use of various web pages. The hotel’sCIO, Dr Bear Guts (not Bill Gates!), believes that those log files are great resources to help theirInformation Technology Division improve their potential customers’ online experience, and helptheir Market Promotion Division to identify potential customers and their behaviour patterns.Hence, Hotel TULIP would like you Group-SIT742 (a hypothetical data analytics group with upto 3 data analysers) to analyse web log files and discover user accessing patterns of different webpages.The Web server is using Microsoft Internet Information Service (IIS), and the Web log formatcan be found at: https://msdn.microsoft.com/en...(v=vs.90).aspxTask DescriptionThis task requires you to develop a data analysis report for the provided Hotel TULIP Web logs.Without exploration or further analysis, ‘raw’ Web log data hardly reveals any insightful information.In this part, you are required to complete the Python code snippets to generate suitable numeric and visualdescription in the Hotel TULIP Web log dataset based on the detailed requirements in SIT742Task2.ipynb,and develop the report SIT742Task2-Report.pdf to summarise the data analytic results. The detailedrequirements can also be found in the notebook SIT742Task2.ipynb, here we summarise them as follows:1 Data ETL (4 marks)1.1 Load Data (2 marks)Load data from files. In order to reduce the processing time, we will remove missing values, and select 30%of total data for the following tasks.Code • Remove missing values. For the columns, if the column is with 15% NAs, you need to removethat column. Then, for the rows, if there are any NAs in that row, you need to remove that row(requests)• Randomly select 30% of the total data into a new dataframe weblog_df.Report • Please show the number of requests in weblog_df.1.2 Feature Selection (2 marks)Code Select ’cs_method’, ’cs_ip’, ’cs_uri_stem’, ’cs(Referer)’ as features and ’sc_status’ as the classlabel into a new dataframe ml_df for following Machine Learning Tasks.Page 2 of 6SIT742 (Modern Data Science)Full Marks: 40Assessment Task 022021 Trimester 1, Due: 8:00pm AEST, 22/05/2021Report • Data Description of ml_df.• Show the top 5 rows of ml_df.2 Unsupervised learning (4 marks)You are required to complete this part using sklearn.Code • Perform unsupervised learning on ml_df with K Means.Report • Visualization of ‘KMeans’ performance using the elbow plot , with a varying K from 2 to 10.• What is the best K for this dataset?3 Supervised learning (8 marks)You are required to complete this part using PySpark packages.3.1 Data PreparationPrepare the data for supervised learning by completing the code.3.2 Logistic Regression (4 marks)Code • Perform supervised learning on ml_df with Logistic Regression.• Evaluate the classification performance using confusion matrix including TP, TN, FP, FN;• Evaluate the classification performance using Precision, Recall and F1 score.Report • Show the classification result using confusion matrix.• Evaluate the classification performance using confusion matrix including TP, TN, FP, FN,• Evaluate the classification performance using Precision, Recall and F1 score.3.3 K-fold Cross-Validation (4 marks)You are required to use K-fold cross validation to find the best hyper-parameter set where K = 2.Code • Implement K-fold cross validation for three (any three) classification models.Report • Your code design and running results.• Your findings on the classification model or its hyper-parameters based on cross-validation results(Best results).4 Association Rule Mining (4 marks)You are required to complete this part using suitable package for association rule mining.Code • Analyze the dataset using association rule mining;• Choose suitable threshold for confidence, support and/or other parameters.Report • Your code design and running results.• Your findings on the association rule mining results.Page 3 of 6SIT742 (Modern Data Science)Full Marks: 40Assessment Task 022021 Trimester 1, Due: 8:00pm AEST, 22/05/2021Part IIData Analytic — Prediction (8 marks)Google Scholar is a web service that indexes the metadata of research articles on many scientists. Majorityof computer scientists use Google scholar to track their publications and research development. Therefore,the web crawling on Google Scholar can provide the citation information on all professors with a publicGoogle Scholar profile. After the crawling, the prediction could be conducted to predict the future citationnumbers such as citation all.Task DescriptionIn 2021, to better introduce and understand the research works on the professors, the university wants toperform the citation prediction for individual professors. You are required to implement a web crawler tocrawl the citation information for A/Professor Gang Li from 2003 to 2021 (inclusive), and also conductseveral prediction as required. You will need to make sure that the web crawling code and prediction codemeets the requirements. You are free to use any Python package for Web crawling and prediction by finishingthe following tasks. ...

May 11, 2022 · 10 min · jiezi

关于算法:RTC-系统音视频传输弱网对抗技术

Hi~这里是25万+社交,泛娱乐,出海开发者青眼的寰球互联网通信云·融云若你对国产化,协同办公解决方案感兴趣,欢送关注本号的【兄弟号】关注【融云 RongCloud】,理解协同办公平台更多干货。 明天,你刘畊宏女孩了吗?关注【融云寰球互联网通信云】理解更多继续大热的“李佳琦女生”和近期大势的“刘畊宏女孩”都在证实着,直播行业仍然热度不减。通过多年倒退,直播曾经衍生出了越来越丰盛的玩法,比方连麦 PK、一起看等。而这些场景,都十分依赖 RTC 实时音视频技术的衰亡。 疫情重复,很多人又进入了居家时刻。把生存和工作转向线上成为大家反抗“停摆”焦虑的解决方案。除了直播、语聊房等娱乐社交场景,还有线上课堂、视频会议,乃至线上问诊征询。在咱们把娱乐、社交和生存的方方面面搬到线上的过程中,RTC 实时音视频技术迅速倒退,一直打卡新利用,浸透新场景。 一体两面,当先进技术为线上场景带来微小增长的同时,也面临用户越来越高的体验要求,更低延时、更高画质、更加顺畅。这三个用户体验的影响因素,对应着的也是 RTC 的三大外围指标,即实时性、清晰度、晦涩度。三者之间,往往鱼与熊掌不可兼得。实时性要求较高的场景可能会就义清晰度来保障低延时;而清晰度要求高的场景则可能用肯定的延时换取高质量的音视频数据。 然而,小孩子才做抉择。为了做到“既要又要”,咱们通常须要通过网络传输优化来谋求更低的延时、更高的清晰度和流畅性。其中的大 BOSS 就是弱网,这是造成拥塞、丢包、延时抖动等影响用户体验问题的次要因素。 弱网反抗技术就是针对上述问题以及其余网络伤害问题的技术解决方案统称。本文分享 RTC 零碎音视频传输弱网反抗技术概览。 对于 TCP/IP 传输层协定的抉择首先,简要介绍一下传输层协定。 传输层协定在 TCP/IP 分层协定中位于应用层之下,个别由操作系统外部提供实现,包含 TCP 和 UDP 两种协定。TCP 是面向连贯的牢靠传输协定,为数据传输的完整性和有序性提供了保障;UDP 是无连贯的不牢靠传输协定,数据传输的可靠性齐全交由应用层解决。 实时音视频利用场景下,UDP 作为优先选择曾经是业界宽泛共识。起因次要包含以下几点: TCP 协定并非为音视频实时利用场景设计,其外部的拥塞管制和差错控制等机制为了可靠性和高吞吐量而导致延时的减少,在弱网环境下延时的好转更为显著。ITU StandardG.114 对延时的定义是,端到端延时大于 400ms 时,用户的交互体验将受到显著的影响。 TCP 的拥塞管制机制和差错控制机制位于操作系统外部实现,应用层无奈优化,无奈应答不同场景需要进行调整,重大不足灵活性。UDP 协定自身开销比 TCP 小,传输控制策略齐全交由应用层来实现,具备足够的灵活性。 因而,本文后续探讨的弱网问题及相应的弱网反抗技术基于 UDP 协定以及运行在 UDP 之上的被音视频畛域广泛应用的 RTP/RTCP 协定来探讨。 弱网次要问题及其反抗技术音视频传输弱网问题简略来说就是指影响音视频通信用户体验的网络环境问题,次要指网络拥塞、网络丢包、抖动等问题。 这些问题是造成音视频卡顿、实时性不佳的次要起因。因为网络环境具备较强复杂性、异构性,上述的弱网问题在不同环境下的重大水平也有很大差别。如何保障用户在简单网络环境下进行顺畅的沟通,始终是 RTC 畛域关注的重点问题。 拥塞问题当网络中传输的数据流量超过网络瓶颈容量,就会产生拥塞问题。拥塞的间接影响是突发丢包或者突发抖动,如果不及时预测拥塞的产生,及时升高发送数据量,接收端将会呈现卡顿、延时大、画质差等等问题。 反抗拥塞问题的次要计划是,通过设计拥塞控制算法对网络拥塞进行及时的探测,并从拥塞状态尽可能快地复原,尽量升高对用户体验的影响。 拥塞控制算法的需要思考 RFC8836 对实时交互式音视频利用的拥塞控制算法需要进行了较为全面的总结,简略概括如下: 延时:拥塞控制算法应该尽可能升高延时,尤其是算法自身引入的延时。与此同时依然须要提供可用的带宽程度。吞吐率:在相应场景下吞吐率应尽可能高。公平性:拥塞控制算法应该可能和其余实时流量和 TCP 流量偏心地共享链路带宽。防止“饿死”:媒体流在与 TCP 流竞争中不应被“饿死”,也不能把 TCP 流“饿死”。收敛速度:在媒体流启动阶段尽可能快地收敛到稳固状态。网络反对:算法不应要求非凡网络个性反对。稳定性:算法应该在媒体流变动时保持稳定,比方媒体流临时的传输中断。疾速响应:算法应该疾速响应网络环境的变动,比方瓶颈带宽变动、链路延时变动等。综合上述需要,拥塞控制算法要解决的问题可归类为两个方面,一是如何疾速精确地进行网络拥塞探测;二是采取适当的拥塞应答措施尽量避免拥塞以及尽可能快地从拥塞状态复原。 拥塞探测算法拥塞探测算法依据观测数据的差别可用分为两类: 基于丢包的算法(Loss-based):通过丢包事件来检测网络拥塞。基于延时的算法(Delay-based):通过对延时的测量来判断网络拥塞。 对于实时音视频交互式利用,基于延时的算法是更优的抉择,次要起因是基于延时的算法可能更早地发现网络拥塞,从而防止因为拥塞导致的丢包。 此外,基于丢包的算法往往为了探测链路容量而一直减少发送带宽,直至丢包事件产生。这种策略将导致无法控制的网络排队延时增长,尤其是网络节点的缓冲区较大时,甚至造成秒级延时的增长。 ...

May 10, 2022 · 2 min · jiezi

关于算法:双指针进阶接雨水Rust语言描述

1 题目42. 接雨水 2 思路之前讲过,只有一一找出每个点左右的最大值,即可失去能够接的雨水;保护左右两个指针,以及left_max, right_max,这篇文章是看到论坛里有个同学用Rust求解该题,后果花了144ms...... 3 代码impl Solution { pub fn trap(height: Vec<i32>) -> i32 { let len = height.len(); let mut left = 0; let mut left_max = height[left]; let mut right = len - 1; let mut right_max= height[right]; let mut res = 0; while left < right { if height[left] <= height[right]{ if height[left] >= left_max{ left_max = height[left]; }else{ res += left_max - height[left]; } left += 1; }else{ if height[right] >= right_max{ right_max = height[right]; }else{ res += right_max - height[right]; } right -= 1; } } return res }} ...

May 9, 2022 · 1 min · jiezi

关于算法:单调栈进阶接雨水最大矩形

1 前言在前阵子的一篇分享里,简略提到了枯燥栈这个数据结构,文章如下↓↓↓ 分享一个简略但挺有意思的算法题2-贪婪-枯燥栈-动静布局 过后只是用枯燥栈解决了股票问题,是最根底的入门示例,算是easy或者勉强medium级别,明天用枯燥栈来解决一些hard题目 2 示例-接雨水42. 接雨水 这是一道经典的面试题,解法有三种,一是正反遍历求出每个点的左右最大高度,勉强算动静布局;二是枯燥栈;三是双指针;其中效率最高的是双指针,最低的是正反遍历,枯燥栈效率和双指针是一样的,只是多应用了一个栈构造,故而空间复杂度不是最优。 2.1 枯燥栈的思路不难想到,每一个点能接到的雨水,取决于该点左右两边的最大高度,两者之间的最小值即雨水的最大高度,办法一的正反遍历也是为了求取左右两边的最大高度,长处是直观好了解,毛病是两次遍历,效率较低。 而认真思考的话,应用枯燥栈,保护一个递加的枯燥栈,也能求取该点左右两边的最大高度,只是不是针对每一个点,而是每一个上坡,只有有上坡,就弹出,并计算雨水; 具体思路是:遇到一个小于栈顶的元素,则入栈,遇到一个大于栈顶的元素,且此时栈非空,则弹出栈顶,此时计算宽度为i - 已弹出的栈顶 - 1,高度为min(height[i], 最新栈顶的高度) - 已弹出的栈顶 2.2 代码var trap = function(height) { let stack = []; let len = height.length let res = 0; for(let i=0;i < len;i++){ while(stack.length > 0 && height[i] > height[stack[stack.length - 1]]){ let top = height[stack.pop()] if(stack.length == 0){ break } let width_ = i - stack[stack.length - 1] - 1 let height_= Math.min(height[i], height[stack[stack.length - 1]]) - top res += width_*height_ } stack.push(i) } return res}; ...

May 9, 2022 · 2 min · jiezi

关于算法:深度学习模型如何正确选择GPU服务器

首先,GPU服务器有什么作用? GPU 减速计算能够提供不凡的应用程序性能,能将应用程序计算密集局部的工作负载转移到 GPU,同时仍由 CPU 运行其余程序代码,从用户的角度来看,应用程序的运行速度显著放慢。 了解 GPU 和 CPU 之间区别的一种简略形式是比拟它们如何解决工作。 CPU 由专为程序串行解决而优化的几个外围组成,而 GPU 则领有一个由数以千计得更小、更高效的外围(专为同时解决多重工作而设计)组成的大规模并行计算架构。 深度学习模型:如何正确抉择GPU服务器其次,GPU服务器的次要利用场景是什么? 深度学习模型: GPU服务器可作为深度学习训练的平台: 1.GPU 服务器可间接减速计算服务,亦可间接与外界连贯通信。 2.GPU 服务器和云服务器搭配应用,云服务器为主 GPU 云服务器提供计算平台。 3.对象存储 COS 能够为 GPU 服务器提供大数据量的云存储服务。 海量计算解决: GPU 服务器超强的计算性能可利用于海量数据处理方面的运算,如搜寻、大数据举荐、智能输入法等: 1.本来须要数天实现的数据量,采纳 GPU 服务器在数小时内即可实现运算。 2.本来须要数十台 CPU 服务器独特运算集群,采纳单台 GPU 服务器可实现。 最初,如何正确抉择GPU服务器? 抉择GPU服务器时首先要思考业务需要来抉择适宜的GPU型号。在HPC高性能计算中还须要依据精度来抉择,比方有的高性能计算须要双精度,这时如果应用P40或者P4就不适合,只能应用V100或者P100;同时也会对显存容量有要求,比方石油或石化勘探类的计算利用对显存要求比拟高;还有些对总线规范有要求,因而抉择GPU型号要先看业务需要。 当GPU型号选定后,再思考用什么样GPU的服务器。这时咱们须要思考以下几种状况: 第一、在边缘服务器租用上须要依据量来抉择T4或者P4等相应的服务器,同时也要思考服务器的应用场景,比方火车站卡口、机场卡口或者公安卡口等;在核心端做Inference时可能须要V100的服务器,须要思考吞吐量以及应用场景、数量等。 第二、须要思考客户自身应用人群和IT运维能力,对于BAT这类大公司来说,他们本人的经营能力比拟强,这时会抉择通用的PCI-e服务器;而对于一些IT运维能力不那么强的客户,他们更关注数字以及数据标注等,咱们称这类人为数据科学家,抉择GPU服务器的规范也会有所不同。 第三、须要思考配套软件和服务的价值。 第四、要思考整体GPU集群零碎的成熟水平以及工程效率,比方像DGX这种GPU一体化的超级计算机,它有十分成熟的从底端的操作系统驱动Docker到其余局部都是固定且优化过的,这时效率就比拟高。 作为国内品牌服务器提供商,服务器在线GPU机架式服务器领有大规模并行处理能力和无可比拟的灵活性。它次要利用于为计算密集型利用提供足够的解决能力。 GPU减速运算的劣势就在于它能够一边由CPU运行利用程序代码,一边由图形处理单元(GPU)解决大规模并行架构的计算密集型工作。服务器在线GPU服务器是医疗成像、播送、视频转码市场的现实抉择。

May 9, 2022 · 1 min · jiezi

关于算法:全球最大的半导体IP产业链你了解多少

GPU发展史 GPU(graphics processing unit):图形处理器,又称显示外围、视觉处理器、显示芯片,是一种在个人电脑、工作站、游戏机和一些挪动设施(如平板电脑、智能手机等)上做图像和图形相干运算工作的微处理器。 1999年 ,NVIDIA公司在公布其标志性产品GeForce256 时,首次提出了 GPU 的概念,但具备GPU性能的处理器在80年代就曾经呈现了。GPU的诞生及尔后一直变革的技术演进,是为了应答日益简单的图形计算需要,达成更加真切、更加活泼的实时感官体验。随着GPU融入硬件T&L性能,Shader的呈现和对立渲染架构的倒退,再到目前GPU光线追踪技术以及向通用计算畛域的拓展,GPU行业经验了一次又一次的改革。 GPU产业链 在GPU乃至整个半导体的产业链中,上游次要是指EDA、IP受权以及GPU芯片设计公司,中游次要是指GPU的制作和封测公司,上游次要是集成商和终端客户。 1.产业链上游 EDA是电子设计自动化,是一种在计算机辅助下,实现芯片设计方案输出、解决、模仿、验证的软件工具。EDA畛域三大巨头,Synopsys、Cadence 和西门子旗下的 Mentor Graphics ,占了寰球65%左右的份额,而在国内这三家的份额更是占到了95%以上,能够说处于相对的垄断位置。尤其是先进制程畛域,简直齐全被Synopsys和Cadence两家垄断。在中国外乡专一于芯片设计EDA工具的企业中,比拟有代表性的有华大九天、广立微、芯禾科技等。 半导体 IP 是指集成电路设计中事后设计、验证好的功能模块,其因为性能高、功耗优、老本适中、技术密集度高、知识产权集中、商业价值低廉,是集成电路设计产业的外围产业因素和竞争力体现。芯片设计公司通过相似搭积木形式购买IP,实现某个特定性能,缩短芯片开发工夫。 ARM是寰球最大的半导体IP提供商。2020寰球半导体IP排行榜中,ARM排名第一。全世界超过95%的智能手机和平板电脑都采纳ARM架构,国产SoC中有95%是基于ARM处理器技术。 国内GPUIP的次要供应商有芯原股份、芯动科技、芯来科技。 芯片设计公司使用EDA工具和IP模块,通过零碎设计和电路设计,将设定的芯片规格造成芯片的设计幅员。目前,寰球芯片设计仍处于高度垄断的格局,美国占据着最大市场份额。 国内上出名的芯片设计公司次要包含英伟达、AMD、英特尔、ARM、高通等公司,而国内目前在GPU畛域曾经做出成熟产品的只有景嘉微一家。 2.产业链中游 晶圆制作是指在制备的晶圆资料上构建残缺的物理电路。过程包含掩模制作、切片、研磨、扩散、光刻、刻蚀、离子注入等外围工艺。封测是在晶圆设计、制作实现之后,对测试合格的晶圆进行封装检测失去独立芯片的过程。 次要的芯片制造商有台积电、中芯国内、三星、英特尔。国内最先进的是中芯国内的14nm工艺,而三星和台积电5nm曾经量产,差距在3代左右。 封测在芯片整个产业链绝对简略,也是国内优先发展的方向,目前国内在封测畛域处于领先地位。大陆的封测厂次要有长电科技、通富微电、华天科技、日月光电。 总结:GPU产业链中上游的供应波及设计、制作、封测三个次要环节,整体供应模式有IDM和Fab+Fabless两种。 IDM模式将设计、制作和封测集中在一起,代表厂商有英特尔。Fab+Fabless模式的代表有(1)AMD设计,台积电制作,通富微电封测;(2)ARM营垒的苹果设计,台积电制作,日月光封测。**3.产业链上游** GPU产业链的上游次要是包含显卡集成商以及终端客户。 一个残缺的显卡包含主芯片、显存、供电模块等,通常将采纳NVIDIA显示芯片的显卡称为N卡,而将采纳AMD显示芯片的显卡称为A卡。这些显卡组装生产工厂负责将由AMD或者是NVIDIA(AMD和NVIDIA个别只负责提供外围)提供的显卡外围局部依照AMD或者是NVIDIA的技术要求整合在一块显卡版上。 GPU的终端客户次要包含PC、手机、服务器、无人驾驶、虚构货币矿机、AI芯片和军事畛域。 以AI为卖点的初创GPU企业掀起融资潮 2019年9月成立的壁仞科技已实现B轮融资,成立两年多累计融资超过47亿,估值超10亿美元。 2020年6月成立的摩尔线程取得数十亿元融资,其GPU产品线笼罩通用图形计算和高性能计算。 2020年9月成立的沐曦集成电路实现十亿元A轮融资,公司的开创团队次要来自AMD等国内公司。 2019年11月成立的芯瞳半导体将在南京投资1.5亿元,开发国产自主GPU和人工智能芯片。 2018年12月在上海成立的瀚博半导体曾经实现总计5亿人民币的A+轮融资,其产品实用多个人工智能畛域。 2017年11月成立的登临科技最近实现A+轮融资,其首款GPU+(软件定义的片内异构通用AI处理器)产品已胜利回片通过测试。 2015年12月成立的上海天数智芯近期实现12亿元的C轮融资,其7纳米通用(GPGPU)云端计算芯片BI于 2020 年 5 月流片、11 月回片并于12月胜利 “点亮”。 总结: 在AI减速计算、国产半导体自主翻新和风投资本的多重驱动下,本来惊涛骇浪的国产GPU忽然风生水起,在本就躁动不安的中国半导体业界掀起一股风浪。 国家信创市场需求和工业管制等特定畛域对GPU的需要增长将给景嘉微等国产GPU厂商带来增长和扩充市场的时机。 至于以AI为次要利用市场的这些GPU新贵们,除了拿出真正能够比照的GPU芯片外,还须要在生态建设和AI场景落地方面下功夫,证实本人拿到这么多钱的确是“物有所值”。

May 7, 2022 · 1 min · jiezi

关于算法:QSO570-时序分析

Advanced Module 2: Time Series This notebook contains a short overview of the Time Series module for QSO370/QSO570. It is important to note that this is indeed only an overview. In order to master this content you'll be required to read and understand Chapters 16, 17 and 18 of our textbook. You should expect to follow along with the examples in the text as well as to pursue additional tutorials to help you implement the techniques you've learned. Module Overview Assignments Note that all assignments are individual and that collaboration is not permitted. To be clear, no document or code sharing is allowed. If you have questions they can be discussed during the weekly discussion meetings with me and with classmates. I've also added a channel associated with this module to Slack and it is okay to have public conversations there. You should cite any sources you use outside of our textbook in completing assignments. All of the work you submit for this module must be your own -- copying and pasting from the textbook is not acceptable and no credit will be awarded for this. Simply reproducing a walkthrough or completing a web-based tutorial for the capstone section of this module will be considered academic dishonesty. Any such cases will be awarded no credit and will be reported to the Dean's O ...

May 7, 2022 · 2 min · jiezi

关于算法:CSci-4203-算法介绍

CSci 4203/EE4367, Spring 2021Homework Assignment III (Issued March 30, 2021)Instructions:1.You can type in your solutions by downloading this MS Word file. Or, write your solutions, scan the file and upload your PDF file.2.Label your assignment with your name and UMN email address3.Submit assignments via Canvas course web page. Note: No late submissions accepted.4.Due Date: 11:59 pm Thursday 4/22/2021 (Central Standard Time)5.For each problem, please show all of your work to get full credits. Without showing your work, up to half of the total credits could be deducted.6.Due to TA resource limitations, we will be able to grade only a subset of the assigned problems (same subset for everyone).7.Homework must be done individually. Please pay specific attention to the “Student Academic Integrity and Scholastic Dishonesty” noted in the syllabus. Failing the class because of cheating on a homework is not worth it. ...

May 7, 2022 · 7 min · jiezi

关于算法:智能客服闲聊模块三种方案对比

以后市场上智能客服及其NLP畛域,闲聊模块是其十分重要的钻研畛域。目前业界针对于闲聊模块的计划个别以下三个计划 基于固定模板咱们都晓得业务问答通用计划是基于模板式问答,同理模板式问答也实用于闲聊零碎,这种形式的劣势在于易于控制,用大量的模板满足多种问题需要,劣势在于呈现答非所问的概率比拟大 基于语料库这种做法是先收集-整顿一批闲聊库,个别状况是一个用意对于一个规范问题及相应问题的泛化,针对问题有多个答案,造成相似一问多答的成果,这种做法的劣势在于答复内容是可控,不会呈现意料之外的答案,目前市场上闲聊语料库作法是比拟宽泛,如针对于金融保险行业做的比拟好的竹间机器人、安全等,针对儿童畛域做的比拟好北京光年的图灵机器人、狗尾草的公子小白等都是应用这种形式,劣势在于答复的内容十分无限,毕竟都是在设计的语料库内的答案。基于生成式生成式始终都是NLP畛域钻研的前沿方向,晚期的微软小冰及各大研究院推出的闲聊零碎都是生成式的,生成式对话零碎的劣势在于基于无限的语料,通过深度学习/神经网络能够取得额定的答案,从而实现无中生有的成果,劣势在于答复的内容不可控,谁都无奈预估到会呈现什么样的答案,目前该种形式只能应用钻研及局部真正的“闲聊”中,无奈应用到企业业务中,毕竟没人能真正管制的了答复的是什么内容,如果呈现性别,种族歧视呐?总结,这三种形式各有各的劣势,在咱们理论应用,须要依据业务需要采取相应的设施,以下是三种计划的比照1、答复内容可控性:基于语料库 > 基于固定模板> 基于生成式2、答复内容丰盛度:基于生成式 > 基于固定模板 > 基于语料库3、答复内容的牢靠度性:基于语料库 > 基于固定模板> 基于生成式 目前企业生产的应用度来看,大多数企业采纳的是语料库+模板两种计划联合一起,既能达到内容的可控性,又能在肯定水平上满足丰盛度。

May 6, 2022 · 1 min · jiezi

关于算法:LeetCode-386-字典序排数

给你一个整数 n ,按字典序返回范畴 [1, n] 内所有整数。你必须设计一个工夫复杂度为 O(n) 且应用 O(1) 额定空间的算法。相干标签:深度优先搜寻,字典树;提醒:1 <= n <= 5 * 10^4 。 Tire树(又称单词查找树)简介:是一种树形构造,是一种哈希树的变种。典型利用于统计,排序和保留大量的字符串(但不仅限于字符串),所以常常被搜索引擎零碎用于文本词频统计。它的长处是利用字符串的公共前缀来缩小查问工夫,最大限度地缩小无谓的字符串比拟,查问效率比哈希树高,毛病是空间复杂度比拟大。优化:咱们能够用链表来动静开拓空间,达到空间上利用率的最大化。 Tire树的性质:根结点不蕴含字符,其余的每一个节点只蕴含一个字符;从根结点到某一节点,门路上通过的字符连接起来,为该节点对应的字符串(如果某个节点为一个字符串的结尾,对其打个标记即可)。每个节点的所有子节点蕴含的字符都不雷同。 请留神在这题咱们用一个trie树来示意所有的数,如果以后数是在1−n范畴内的,就插入到答案中。因为示意了所有数,所以没必要模仿一个trie数并且插入。所以咱们只须要模仿一个在trie上树搜寻即可。工夫复杂度O(N)。tire树还不懂的本人轻易在网上找张tire树的图看看就了解了。 这题的话就是给咱们n个数,让咱们把n个数依照字典序排一下,留神不是按数的大小来排而是按字典序的大小来排。力扣这题本来的数据范畴很大有5,000,000(五百万)然而当初只剩下50,000(五万)了。 字典序的含意比较简单,这里就不放长概念了粗略的阐明一下。比如说88和123,依照数字大小来比拟的话88必定是小于123的,然而依照字典序的话88就大于123,因为是比拟每一位的字符大小,简略粗犷的了解就是这个意思,想晓得更多的话就本人去百度吧。 接下来咱们探讨解题办法,首先最暴力的做法就是把1~n个数先转化为string看成字符串,而后你对string排序就能够了。那么这么做的工夫复杂度是多少呢?首先每一个数的长度是log n是吧,而后快排的工夫复杂度是nlog n,所以总共的工夫复杂度就是一乘就是nlog n^2,这是暴力做法。而后比拟优良的做法是能够用tire来做,留神此tire非彼tire,tire啥意思呢。 tire的意思咱们上文曾经讲过了,个别字符串排序用tire排序的话工夫复杂度能少一个log n,tire其实就相似于桶排序。那么这个tire是怎么样的一个思路呢,就是这样咱们先将所有数看成一个字符串。比方123、124还有12都是一个字符串,而后咱们把他们插到这个树外面,而后咱们能够设想一下将1~n插入到这个串外面,而不是咱们在程序设计中真的插入这些数。 设想完把下面数插入到这个串外面,而后插完之后怎么去依照字典序从小到大输入呢?这个其实就是一个树的遍历,如果咱们想找到tire外面所有数的话,其实就是一个树的遍历,那么为了可能从小到大的去输入所有数,就比方咱们有几个分支是吧,为了保障咱们的字典序最小,那么咱们再搜的时候第一个数应该是越小越好是吧,所以咱们在搜的时候要从小到大搜寻每一个分支,那这样只有你依照咱们这个思路来搜的话,那么你搜到的后果肯定是依照字典序的后果。 因为咱们会先搜1再搜2再搜3是吧,那么以1结尾的子树必定会比左边的树都要小,因为它第一个曾经小了是吧。所以说咱们只有依照字典序去搜这棵树,咱们就能够把所有数依照字典序搜进去。好吧,那么这个就是tire树的一个大略的思路,那么这个思路的话首先遍历整个树的工夫复杂度是n logn是吧,因为整棵树外面的结点的个数就是n log n是吧,而后咱们找进去所有数的工夫复杂度也是nlog n,所以整个整个算法工夫复杂度就是nlog n,比咱们之前的暴力做法要小一个log n。留神咱们在写的时候不须要真的把咱们所有的数插入到咱们这个tire树外面。它插入到时候很有法则是1~n间断插入,所以咱们就不须要插入了。而后咱们在搜的时候咱们假如每个分支都有,只不过咱们去判断一下如果以后这个分支的数大于n了,那么这个前面的数也肯定大于n是吧,就间接进行就能够了就不必持续往下搜了,所以这题咱们是不须要真正的插入的,咱们只须要在查问的时候限定一下范畴就能够了。 而后是代码怎么写: class Solution {public: vector<int> res; vector<int> lexicalOrder(int n) { for(int i=1;i<=9;i++) dfs(i,n); return res; } void dfs(int cur,int n) { if(cur <= n) res.push_back(cur); else return; for(int i=0;i<=9;i++) dfs(cur*10+i,n); }};

May 6, 2022 · 1 min · jiezi

关于算法:MATH-2109数学计算

School of SciencesMATH 2109 – Mathematical Computing Week 6 – Hand in Lab Class –Due 5 : 00pm Friday 23rd April 2021. Write a function in an m-file for y = cos5(x) sin3(x) + 2 that will accept a row vector of xvalues as input and output a row vector of y values. Now generate a row vector of x values inthe interval [0, 7] (use 100 points) and input this into your function to find the correspondingy values. Plot the function using the plot() command. Also by looking up the xlabel()and ylabel() functions label the x and y axes.A sequence is given by a5 = 2, a6 = −4, and a7 = 1, and the recurrence relationan = 5 an−1 − 3 an−2 + 6 an−3an−2when n ≥ 8.Write a function in an m-file that has n as its only input, where n > 5, and returns the valuean. Put in a check that n ≥ 5 and exit with a printed error if this is not the case, assigningan the value NaN.Call your function in a main program, so that it prints, using fprintf, a table of values forn and f(n), for n = 5, 6, . . . 13. Your table should have headers.The symbolic toolbox allows us to integrate symbolic expressions using the following commands(as an example):f = @(x) cos(x). 5.*sin(x). 3syms x ;int(f(x),x)ans =(cos(x) 5(5cos(x) 2 - 7))/35Write a function call IntFunct in an m-file that takes as input a function of one variableand values of a and b for x. As outputs it returns the value of the definite integral over theinterval [a, b] and (only if asked for) additionally a symbolic expression for its derivative. Alsoinclude a check that not more than 2 outputs are requested and if they are, return a printederror message (of your making) and cease execution before Matlab complains. Test this bycalculating the integral of y = cos5(x) sin3(x) over [0, 2]. You need to pass the function fand the values a = 0 and b = 2 as parameters when you call the function from the commandwindow.[Hint: Use double(subs(Sym_expression, x, a)) to get a number after substituting. ]The intersection of a circular cylinder of unit radius, oriented around the xn axis, and thesphere centred at the point e1 = (1, 0, . . . , 0) correspond to the points (x1, x2, . . . , xn) (inn-dimensions) that satisfy the equations:Write a function area_approx = Monte_Carlo_Test(n,N) that inputs the dimension nand the number of random samples N in the following Monte-Carlo estimation of the volume1of the intersection. Generate N uniformly distributed random samples in the following ndimensional box that contains the region defined in (1):and count the number k, of the N, events that land inside the region defined in (1). Include this function as a sub-functions (place it atthe end of your work) and call it to print a table of the areas associated with the dimensionsn = 3, 4, 5, 6 using N = 106.[Hint: Watch the week 5 Wednesday Lectorial Collaborate Ultra recording.]NOTE : Note that M-File functions MUST NOT contain any fprintf() or disp() commands,or echo print any values inside the function (other than for error messages). The Function MUSTreturn a value or values, NOT just print them with a disp() command.You MUST include listings of your functions in your published output as follows. If your functionis contained in the M-file with name myfunction.m, just include the linetype myfunction.mat the point in your code where you want the listing of the function to appear.

May 5, 2022 · 3 min · jiezi

关于算法:COSC420图像分类算法

COSC420 Assignment 1Classifying text from imagesWeight:20% Lecturer: Lech SzymanskiFor this assignment, you will be building and training neural network models usingTensorflow’s Keras library. Datasets for your training and testing will be provided andthey correspond to three different types of classification.Simple classificationIn this task you are given 28x28 pixel colour images of letters from the English alphabetwritten in different fonts. The task is to identify the letter in the image, meaning 26classes (same class for the lower and upper case character). There are two variants of thisdataset – one with black characters over uniform light background (20000 train images,4000 test images), and the other of multi-colour characters over random imagebackground (60000 train images, 12000 test images).Figure 1: Simple classification dataset – ‘clean’ on the left, ‘noisy’ on the right.Fine-grained classificationIn this task you are given the same set of images as in simple classification, but the labelsindicate which font the text is written in. There are 8 fonts in total. The differencebetween this task and simple classification is that the nature of differences betweenrepresentatives of different classes are more subtle, and (presumably) harder for thenetwork to distinguish.1Figure 2: Fine-grained classification dataset – ‘clean’ on the left, ‘noisy’ on the right.Multi-label classificationIn this task you are given 48x48 pixel colour images of three-letter words made of randomletters written in one of possible 8 choices of font types. The label indicates the lettersfound in the image (order is of no significance for this task) as well as the font type.There are variants of this dataset – one with black characters over uniform lightbackground (20000 train images, 4000 test images), and the other of multi-colourcharacters over random image background (60000 train images, 12000 test images).Figure 3: Multi-label classification dataset – ‘clean’ on the left, ‘noisy’ on the right.2Task 1, Implementation (10 marks)Select two classification tasks you want to work with, devise a neural networkarchitecture(s), build the network(s) in Tensorflow and test their performance. The orderof tasks, as presented above, is roughly in the increasing order of difficulty ofclassification. That is, simple classification should be pretty easy (in terms of the networkachieving good accuracy) and multi-label classification will most likely be the hardest toget the network to perform well. If you manage to build a network that performs well onthe ‘clean’ version of the data, train it also on the ‘noisy‘ version. Try to come up withstrategies for the network architecture, data augmentation, and anything else that youcan think of to get the best accuracy.The point of this exercise is not necessarily to attempt all tasks, but rather to find achallenging problem and have a go at trying to solve it with a neural network.Specifically, you should aim to have a go at two of the tasks. You might need to considerdifferent architectures for different tasks.Don’t forget to clean up your code before submission and add comments. Make sure tosave your model after training, and it would be very helpful if you set up your script sothat it loads pre-trained network when I run it (so that I don’t have to wait for them totrain).I will test the accuracy of your model on completely new set of test images.Task 2, Report (10 marks)Write a report of what you have done. What I am looking for here is a justification forchoices made in your implementation and a methodical approach to your investigation. Ifyou attempt different types of regularisations, record the results, report what happenedand provide some justification for why you think it did (or did not) work. This is meantto be a technical report – concise, but clear. Including diagrams and figures, such as plotsof training and validation accuracy over the course of training, is a good way to give memore insight into what you have done, and to back up any decisions made abouthyper-parameters, strategies, etc.3Importing the data into PythonDownload cosc420_assig1_data.py into the folder of your Python scripts project. Inyour own script you can import the load_data function and invoke it (as shown below)to load training data, testing data and a list of class names.from cosc420 assig1 data import load data ...

May 5, 2022 · 7 min · jiezi

关于算法:深入理解二分算法

二分这个算法,刚开始的时候看起来感觉很简略,但其实很多人都没有了解透二分的实质。 我最开始学二分的时候,感觉这个挺简略的,很容易了解,然而在写代码的时候总是要思考半天什么状况下 l 等于什么,什么状况下 r 等于什么,而后还总是 corner case 想不分明。 起初就看书系统性地学了一遍二分,看着书里的二分模板在那了解半天,搜索枯肠地想为什么有的模板这里要是 l = mid + 1,为什么那里是 r = mid,为什么这个模板 while 循环里写的不是 l <= r,而后也刷了很多二分的题,自认为弄懂了二分,但其实仍旧没有看清楚二分的实质。 其实我的关注点就错了,注意力全放在二分的模板上了,基本没有想分明什么状况下能用二分以及怎么用二分,只是认为学会了二分的模板就会写二分的题了,导致前面有时候碰到二分的题,还是要思考半天,还是要去看一下笔记里的二分模板,要套上模板才会写。 直到前面,我真正系统性地又学了一遍二分,并且刷了大量二分的题,我才真正了解透了二分的实质。而上面,我会联合二分的题深刻解说二分的实质,带你们看清二分这个算法最外围的货色。 二分的模板这里先给出两个二分模板,我见过一些不同的二分模板,然而这两个模板是我认为应用起来最不便也最容易了解二分实质的,它们出自 AcWing @yxc。这里须要阐明一下,二分的不同模板只是实现,其本质才是要害,这里我会先解释上面的二分模板,而后再联合例子论述二分的实质,与模板联合起来解说会更容易把握二分。 留神:l, r 是初始化成闭区间,即 [l, r]。循环完结的条件是 l == r,所以 l, r 都一样,都是最初的后果所在位置。 while (l < r) { int mid = (l + r) >> 1; if (check()) r = mid; else l = mid + 1;}如果把 check() 替换成 a[mid] >= target,则二分的后果是第一个大于等于 target 的数的地位。while (l < r) { int mid = (l + r + 1) >> 1; if (check()) l = mid; else r = mid - 1;}如果把 check() 替换成 a[mid] <= target,则二分的后果是最初一个小于等于 target 的数的地位。模板里的 check() 示意的是是否满足某种性质(前面二分的实质里会具体介绍),如果是查找一般的有序数组中的一个数 target,那么对于第一个模板,能够把性质定义为“大于等于 target”,而后用 a[mid] >= target 替换掉 check(),则第一个模板能够查找到第一个大于等于 target 的数的地位。对于第二个模板,能够把性质定义为“小于等于 target”,而后用 a[mid] <= target 替换掉 check(),则第二个模板能够查找到最初一个小于等于 target 的数的地位。 ...

May 4, 2022 · 2 min · jiezi

关于算法:COMP1805ABC离散结构

COMP1805ABC (Winter 2021) − "Discrete Structures I"Practice Questions for the Final ExamThis semester, the final exam for COMP1805ABC will be completed online as a multiple-choice activity incuLearn. The exam will be 2 hours long. It will open up at 7:00 pm. You can start your exam between 7:00 pmand 7:30 pm. Once you begin the exam you will have 2.0 hours to complete and submit it. Please follow thislink for the exact dates and times. https://carleton.ca/ses/exam-... The exam will be open-book (in thatyou may refer to the lecture slides, the textbook, the discrete math study center website, or your handwrittennotes) and basic, non-graphing calculators will be permitted. Any other electronic devices or unauthorized websites will be prohibited.This collection of questions is presented here to help prepare for your final exam. Solutions will not be providedbut you may email your instructors and/or teaching assistants with any questions you might have. Best of luckwith your preparations!Is a logical expression like (¬ ( ¬ ((( → ) ∨ ) ∨ ))) a tautology, a contradiction, or a contingency?Justify your answer using only truth tables and then again using only the logical equivalences.Is ( ¬ (( ∨ ( ∧ )) ∨ ( → ))) logically equivalent to (¬ ((( ¬ (¬)) ∨ ) ∨ ))?How would you justify your answer if the answer was yes? What if the answer was no?What are the dimensions required for a truth table of (¬ (¬ ( ∨ ((¬ ) → ))))?Complete the truth table and use it to construct the full disjunctive normal form of this expression.COMP1805ABC (Winter 2021) − "Discrete Structures I"Practice Questions for the Final ExamUsing only the rules of inference and the logical equivalences from class and the notes, show that thefollowing argument is valid. You may assume that all the premises given are true. Make sure that you includeboth the rule and the line number(s) to which that rule is applied. ...

May 4, 2022 · 5 min · jiezi

关于算法:CMPUT-201解题技巧

CMPUT 201 - Winter 2021Assignment 3Dynamic memory allocationLinked ListsProgram organizationHeader files and MakefilesAdhering to provided code stubsProgram testingAssertsIF YOU HAVE NOT EXPLICITLY TOLD US YOU WANT TO WORK IN A PAIR, THENYOU ARE WORKING INDIVIDUALLY FOR THIS ASSIGNMENT. You will still have a teamname assigned to you but this team will only have 1 member: you.Before clicking on the github classroom link below, please check your assigned team nameon eClass first. The process for joining a team is as before (if you are the first one to join,you will create the team on GitHub classroom; if you are working with a partner and theyalready joined, you will simply find the team name on the list and click on it).The github classroom assignment invitation link ishttps://classroom.github.com/... READ BELOW BEFORE CLICKING ON THISLINKAt thte end, you will have a repository with the following name:https://gihub.com/cmput201-w2... .Please update the LICENSE.md file with only your name (if working individually) or bothpartner names (if working in a pair) where it says <student name>Your GitHub starter repo is a bit different this time: you will already find the two foldersConcepts CoveredGitHub Instructionsfor Part 1 and Part 2 of the assignment. In each part, you will find the header file you needto adhere to and a sample C client file. Additionally, you will find a script calledcheck.sh in the main directory. Simply run ./check.sh to run the script againstyour code. Documentation on what the script checks for can be found at the top of thescript. Note that your program should not fail any of the assert checks we have in the clientcode. Please read the RepoStructure.md to understand the files provided in therepo and how to find and interpret the Github Actions build statusMake sure to continuously commit and to your repository as you are developing yourassignment and not simply when you are done. This serves two purposes: (1) you alwayshave a backup of your code and can navigate through history to see your changes or revertback to an old version of the code that worked better and (2) showing your progressthrough the assignment allows us to see each partner's contribution. Additionally, thesecommits are a great way to show your changes and contributions if you are suspected ofplagiarism. To avoid overloading GitHub actions, you can commit locally as much as youwant but push only once every hour or at the end of your current working session (or whenyou want to communicate your changes to your partner). We strongly recommend that youwatch the git tutorials on YouTube to avoid running into merge conflicts while working withyour partner on the assignment.This assignment consists of two parts. For both parts of the assignment, we will bechecking for memory leaks; if you remove an element or nuke a list, or anything likethat, don’t forget to clean up and free any allocated memory as necessary. Thegeneral rule is if you dynamically allocate any memory yourself, you need to free it yourselftoo. You can use valgrind to check for memory leaks.You must use dynamic memory allocation in this assignment. If you do not, you willget a 0, even if your program behaves correctlyYour program must compile using -std=c99 -Wall without any warnings or errors. Ifwe cannot compile your program or if it compiles with a warning, you will receive a 0for the assignment.Any missing files will result in a 0 in the assignment. Please check the list of files your needto submit for each part. If you forget the README, Makefile, etc., you will get a 0. Pleasemake use of the script we already provide you in your repo to check the format ofyour submission.You need only 1 ReadMe file in the root folder of your repository. Please seehttps://www.makeareadme.com/ for information about how to create a good ReadMe file,especially in markdown notation. Your README file should also have a references sectionImportant Informationthat lists your references (e.g., any online resources you used) and the contributions of bothpartners (if working in a team).You must adhere to the provided function prototypes. You are free to add extra helperfunctions, but you must implement the given functions without changing their signature.Credits: This assignment has been adapted from one of Mike Godfrey's assignments.We’re going to implement a data structure called Squeue , because it’s a bit like both a Stackand a Queue, that allows new elements to be added / removed / peeked at both ends of the list.A Squeue supports the following operations (details to follow): initSqueue ,isEmpty , addFront , leaveFront , mergeFront , peekFront , addBack ,leaveBack , peekBack , mergeBack , print , and nuke . initSqueue andisEmpty do the obvious things.The four operations addFront , leaveFront , mergeFront and peekFrontoperate on the front of the list.The four operations addBack , leaveBack , peekBack and mergeBack operateon the back of the list.It is essential that you use the EXACT function prototypes provided. Otherwise, we willnot be able to compile and test your code and you will get a 0.We’re going to implement our Squeue by using Nodes that have links in both directions(forwards and backwards), plus we are going to keep two special pointers: one to the firstelement and one to the last element. The following shows the structs we expect.struct Node{ char* val; struct Node* next; struct Node* prev;};typdef struct{ struct Node* first; struct Node* last;} Squeue;You must implement the Squeue using the exact structs above. We have provided you with aPart I (50 marks)header file that contains all the signatures of all functions you need to implement. You will findthis header file in a folder called Part1 in your GitHub repo. Here is the list again anyways(detailed description of the functions follows):void initSqueue (Squeue **squeue);bool isEmpty (const Squeue *squeue);void addFront (Squeue squeue, char val);void addBack (Squeue squeue, char val);void leaveFront (Squeue *squeue);char peekBack (const Squeue squeue);void leaveBack (Squeue *squeue);char peekFront (const Squeue squeue);void print (const Squeue * squeue, char direction);void nuke (Squeue * squeue);void mergeFront(Squeue* squeue, char direction);void mergeBack(Squeue* squeue, char direction);void reverse(Squeue* squeue);void destroySqueue(Squeue **squeue);The following is an example of a main program that shows what is expected from each function.int main1 () { Squeue *s1 = NULL; initSqueue (&s1); addFront (s1, "alpha"); addFront (s1, "beta"); addFront (s1, "gamma"); addBack (s1, "delta"); printf("This prints \"gamma beta alpha delta\" across four lines with a tab before each element, and preceded by \"squeue is:\" on its own line:\n"); print (s1, 'f'); printf("This prints \"delta alpha beta gamma\" across four lines with a tab before each element, and preceded by \"stack is:\" on its own line:\n"); print (s1, 'r'); mergeFront(s1, 'f'); printf("This prints \"gammabeta alpha delta\" across three lines with a tab before each element, and preceded by \"squeue is:\" on its own line:\n"); print(s1, 'f'); mergeBack(s1, 'r'); printf("This prints \"gammabeta deltaalpha\" across two lines with a tab before each element, and preceded by \"squeue is:\" on its own line:\n"); print(s1, 'f'); leaveFront (s1); printf("This prints \"deltaalpha\" in one line with a tab before each element, and preceded by \"squeue is:\" on its own line:e\n"); print(s1, 'f'); addFront(s1, "zeta"); addFront(s1, "eta"); leaveBack (s1);void initSqueue (struct Squeue ** squeue);initSqueue initializes the given squeue to an empty squeue. After calling initSqueueon a given squeue , we should be able to add elements to that squeue by callingaddFront or addBack .bool isEmpty (const struct Squeue * squeue);isEmpty checks if the given squeue is empty. Returns true if it is empty and false ifnot.void addFront (struct Squeue squeue, char val);addFront adds the given string (i.e., val ) to the front of the given squeue. Make sure youadjust all pointers of the squeue appropriately. You need to dynamically allocate memoryfor the new string. You cannot assume any maximum size for the string. printf("This prints \"eta zeta\" across two lines with a tab before each element, and preceded by \"squeue is:\" on its own line:\n"); print(s1, 'f'); printf("This prints \"eta zeta\" in one line \n"); printf("%s %s\n", peekFront(s1), peekBack(s1)); printf("This nuke has no output, but is good form to call when done\n"); nuke (s1); printf("This assertion should succeed\n"); assert (isEmpty (s1)); printf("Illegal direction should cause error message\n"); print (s1, 'k'); addBack (s1, "alpha"); addBack (s1, "beta"); addBack (s1, "gamma"); reverse(s1); printf("This prints \"gamma beta alpha\" across two lines with a tab before each element, and preceded by \"squeue is:\" on its own line:\n"); print(s1, 'f'); destroySqueue(&s1); //we will always call this for any squeue we test with so make sure it is implemented correctly to free any allocated memory return 0;}Detailed function descriptionsvoid addBack (struct Squeue squeue, char val);addBack adds the given string (i.e., val) to the back of the given squeue. Make sure youadjust all pointers of the squeue appropriately. You need to dynamically allocate memoryfor the new string. You cannot assume any maximum size for the string.void leaveFront (struct Squeue * squeue);leaveFront deletes the first element from the front of the given squeue. Make sure youadjust all pointers of the squeue appropriately and delete any unneeded struct instances.The first line of the function should be: assert (!isEmpty(s)); to ensure that you don'ttry accessing elements from an empty squeue.void leaveBack (struct Squeue *squeue);leaveBack deletes the last element at the back of the given squeue. Make sure you adjustall pointers appropriately and delete any unneeded struct instances. The first line of the functionshould be: assert (!isEmpty(s)); to ensure that you don't try accessing elements froman empty squeue.char peekFront (const struct Squeue squeue);peekFront returns the value of the first element from the front of the squeue withoutchanging the squeue. The first line of the function should be: assert (!isEmpty(s)); toensure that you don't try accessing elements from an empty squeue.char peekBack (const struct Squeue squeue);peekBack returns the value of the last element from the back of the squeue withoutchanging the squeue. The first line of the function should be: assert (!isEmpty(s)); toensure that you don't try accessing elements from an empty squeue.void print (const struct Squeue * squeue, char direction);print takes a Squeue and a single char that represents the direction, f for forwardand r for reverse, and then prints the squeue in the desired direction. If the direction passedin is not 'f' or 'r', then print the following message to stderr:Error, illegal direction <entered direction> . Note that<entered direction> must be replaced by the direction passed in as an arugment. Forexample, if the function was called with direction b , the message printed to stderr will beError, illegal direction b . If an illegal direction is detected, just print thatmessage; do not try to print the contents of squeue , and do not exit the program ormake an assertion that could cause the program to abort. To output elements of the stack,the function prints squeue is: on a line, followed by each element on its own line. Eachelement is preceded with a tab. See example code.void nuke (struct Squeue * squeue);nuke takes a Squeue , deletes all of the internal Nodes, and sets the first and last pointersof the Squeue instance to NULL .void mergeFront(struct Squeue* squeue, char direction);mergeFront takes a Squeue and a single char that represents the direction, f forforward and r for reverse. It concatenates the two strings contained in the first two nodes ofthe squeue in the desired direction, stores the concatenated string in the first node, and thendeletes the second node. See the provided main function example above to understand whatmergeFront does. Note that it is an error if you call mergeFront on a squeue withless than 2 nodes. You should have an assert to check for this. If the direction passed in isnot 'f' or 'r', then print the following message to stderr:Error, illegal direction <entered direction> . Note that<entered direction> must be replaced by the direction passed in as an arugment. Forexample, if the function was called with direction b , the message printed to stderr will beError, illegal direction b . If an illegal direction is detected, just print thatmessage; do not try to do the merge, and do not exit the program or make an assertionthat could cause the program to abort.void mergeBack(struct Squeue* squeue, char direction);mergeBack takes a Squeue and a single char that represents the direction, f forforward and r for reverse. It concatenates the two strings contained in the last two nodes ofthe squeue in the desired direction, stores the concatenated string in the node before last, andthen deletes the last node. See the provided main function example above to understand whatmergeBack does. Note that it is an error if you call mergeBack on a squeue with lessthan 2 nodes. You should have an assert to check for this. If the direction passed in is not 'f'or 'r', then print the following message to stderr:Error, illegal direction <entered direction> . Note that<entered direction> must be replaced by the direction passed in as an arugment. Forexample, if the function was called with direction b , the message printed to stderr will beError, illegal direction b . If an illegal direction is detected, just print thatmessage; do not try to do the merge, and do not exit the program or make an assertionthat could cause the program to abort.void reverse(Squeue* squeue);reverses the elements in the given squeue. If the squeue was a->b->c->d , where firstpoints to a and last points to d , calling reverse would change the squeue contents tod->c->b->a , and make first point to d and last point to a .void destroySqueue(Squeue **squeue);destroySqueue safely deletes all members of the given squeue as well as any memoryallocated for squeue. After calling destroySqueue on a given squeue , that squeuewould point to NULL .In the Part1 folder on GitHub, you must submit the following files:squeue.h -- already there. Do not change the prototypes we provide; you mayadd prototypes for your helper functions though.squeue.c . This file contains the definitions of all the functions declared insqueue.h . This is the file that contains all your implementation code.squeue_client.c . This file must contain ONLY the main function and ...

May 3, 2022 · 20 min · jiezi

关于算法:COMP5349云计算

School of Computer ScienceCOMP5349: Cloud Computing Sem. 1/2021Assignment 1: Data Analysis with Spark RDD APIIndividual Work: 20% 01.04.20211 IntroductionThis assignment tests your ability to implement simple data analytic workload using SparkRDD API. The data set you will work on is adapted from Trending Youtube Video Statisticsdata from Kaggle. There are two workloads you should design and implement againstthe given data set. You are required to designed and implement both workloads usingONLY basic Spark RDD API. You should not use Spark SQL or other advanced features.2 Input Data Set DescriptionThe dataset contains several months’ records of daily top trending YouTube video in thefollowing ten countries: Canada,France, Germany, India,Japan, Mexico, Russia, South Korea,United Kingdom and United States of America. There are up to 200 trending videoslisted per day.In the original data set, each country’s data is stored in a separate CSV file, with eachrow representing a trending video record. If a video is listed as trending in multiple days,each trending appearance has its own record. The category names are stored in a fewseparate JSON files.The following preprocessing have been done to ensure that you can focus on the mainworkload design.• Merge the 10 individual CSV files into a single CSV file;• Add a column category to store the actual category name based on the mapping• Add a column country to store the trending country, each country is represented bytwo capital letter code.• Remove rows with invalid video id values• Remove most columns that are not relevant to the workloadsThe results is a CSV file AllVideos.csv with 8 columns and no header row. Thecolumns are as follows. The trending date column has the date format: yy.dd.mmvideo_id,trending_date,category,views,likes,dislikes,country13 Analysis Workload Description3.1 Controversial Trending Videos IdentificationListing a video as trending would help it attract more views. However, not all trendingvideos are liked by viewers. For some video, listing it as trending would increase itsdislikes number more than the increase of its likes number. This workload aims to identifysuch videos. Below are a few records of a particular video demonstrating the changeof various numbers over time:video id trending date views likes dislikes countryQwZT7T-TXT0 2018-01-03 13305605 835378 629120 USQwZT7T-TXT0 2018-01-04 23389090 1082422 1065772 USQwZT7T-TXT0 ... ... ... ... USQwZT7T-TXT0 2018-01-09 37539570 1402578 1674420 USQwZT7T-TXT0 2018-01-03 13305605 835382 629123 GBQwZT7T-TXT0 ... ... ... ... GBQwZT7T-TXT0 2018-01-18 45349447 1572111 1944971 GBThe video has multiple trending appearances in US and GB. In both countries, its views,likes and dislikes all increase over time with each trending appearance. As highlightedin the table above, the dislikes number grows much faster than the likes numbers. Inboth countries, the video ended with higher number of dislikes than likes albeit startingwith higher likes number.In this workload, you are asked to find out the top 10 videos with fastest growthof dislikes number between its first and last trending appearances. Here we measurethe growth of dislikes number by the difference of dislikes increase and likes increasebetween the first and last trending appearances in the same country. For instance, thedislikes growth of video QwZT7T-TXT0 in US is computed as follows:(1674420 − 629120) − (1402578 − 835378) = 478100The result of this workload should show the video id, dislike growth value and countrycode. Below is the sample results.’QwZT7T-TXT0’, 579119, ’GB’’QwZT7T-TXT0’, 478100, ’US’’BEePFpC9qG8’, 365862, ’DE’’RmZ3DPJQo2k’, 334390, ’KR’’q8v9MvManKE’, 299044, ’IN’’pOHQdIDds6s’, 160365, ’CA’’ZGEoqPpJQLE’, 151913, ’RU’’84LBjXaeKk4’, 134836, ’FR’’84LBjXaeKk4’, 134834, ’DE’’84LBjXaeKk4’, 121240, ’RU’23.2 Category and Trending CorrelationSome videos are trending in multiple countries. We are interested to know if there isany correlation between video category and trending popularity among countries. Forinstance, we may expect to see a common set of trending music videos in many countriesand a distinctive set of trending political videos in each country. In this workload, you areasked to find out the average country number for videos in each category.The following sample data set contains five videos belonging to category “Sports”,their trending data are as follows:video id category trending date views country1 Sports 18.17.02 700 US1 Sports 18.18.02 1500 US2 Sports 18.11.03 3000 US2 Sports 18.11.03 2000 CA2 Sports 18.11.03 5000 IN2 Sports 18.12.03 7000 IN3 Sports 18.17.04 2000 JP4 Sports 18.16.04 3000 KR4 Sports 18.17.04 9000 KR5 Sports 18.16.04 4000 RUWe can see that video 1,3,4,5, each appears in one country; video 2 appears in threecountries; If they are the only videos in Sports category, the average country numberwould be (1 + 3 + 1 + 1 + 1)/5 = 1.4 You should print out the final result sorted by theaverage country number. The sample output of this work load is as follows.(’Trailers’, 1.0),(’Autos & Vehicles’, 1.0190448285965426),(’News & Politics’, 1.052844979051223),(’Nonprofits & Activism’, 1.057344064386318),(’Education’, 1.0628976994615762),(’People & Blogs’, 1.0640343760329336),(’Pets & Animals’, 1.0707850707850708),(’Howto & Style’, 1.0876256925918326),(’Travel & Events’, 1.0929411764705883),(’Gaming’, 1.0946163477016635),(’Sports’, 1.1422245184146431),(’Entertainment’, 1.1447534885477444),(’Science & Technology’, 1.1626835588828102),(’Film & Animation’, 1.1677314564158094),(’Comedy’, 1.2144120659156503),(’Movies’, 1.25),(’Music’, 1.310898044427568),(’Shows’, 1.614678899082569)3A small number of videos have more than one category name. The category name maychange over time. For instance video id “119YrPUNM28” has changed its category name from“News & Politics” to “Entertainment”. A video may be given different category namesin different countries. For instance, video id “7klO0p092Y” is under category “People &Blogs” in CA and DE but under category “Entertainment” in US. As the number is quitesmall, you do not need to identify and handle them separately. The sample answer doublecount them in all categories they appear.4 Coding and Execution RequirementBelow are requirements on coding and Execution:• You should implement both workloads in PySpark using Spark RDD API.• You should implement both workloads in a single Jupyter notebook. There shouldbe clear indication which cells belong to which workload.• You should not modify the input data file in any way and your code should read thedata file from the same directory as the notebook file.5 Deliverable and DemoThe source code should be submitted as a single Jupyter notebook file. The due date isweek 7 Wednesday 21/04/21 23:59. Please name your notebook file as<labCode>-<uniKey>-<firstName>-<lastName>.ipynb.There will be a 10 minutes demo in week 7/8. You need to attend the demo toreceive mark for this assignment!During the demo, the marker will run your notebook on their own environment tocheck the correctness of the result. You should also have your environment ready to runyour code and to answer questions. The marker may ask you to explain the overall computationgraph or certain part of the implementation. You may be asked to add somestatement in your code to show the structure of an intermediate RDD, or to apply variousfilters on intermediate RDDs to provide slightly different result. ...

May 3, 2022 · 5 min · jiezi

关于算法:不同类型AI服务器比较分析

不同类型AI服务器之比拟剖析,通过上面这张二维图中咱们能够对不同架构的服务器进行简略的比拟。 首先看下不同类型AI服务器的比拟,从左上方到右下角顺次是CPU、GPU、FPGA、TPU、ASIC,从横轴来看,越往右性能(Performance)越好。 纵轴 Programmability/Flexibility是指服务器的可编程性和灵活性, ASIC的性能最好,因为它是将算法固化在芯片上,算法是比拟固定的,所以它的性能最好的,然而它的编程性和灵活性就绝对比拟弱。而CPU的灵活性和编程性最好,但性能最弱。 总的来说,GPU的灵活性比CPU弱,但它的性能更好。往下顺次是FPGA、TPU以及ASIC。 在理论抉择时须要思考到功耗、老本、性能、实时性等各方面因素,尤其是一些具备专用目标的处理器,如果算法曾经固化并且很简略,能够思考ASIC,因为ASIC性能好且功耗低。如果是在训练或者通用状况下,GPU则是更好的抉择。 抉择GPU服务器的根本准则 在介绍抉择GPU服务器的根本准则之前,先来跟大家介绍下常见的GPU和GPU服务器。 常见的GPU,按总线接口类型能够分为NV-Link接口、传统总线接口以及传统PCI-e总线三种。 NV-Link接口类型的GPU典型代表是NVIDIA V100,采纳SXM2接口,在DGX-2上有SXM3的接口。 NV-Link总线规范的GPU服务器能够分为两类,一类是NVIDIA公司设计的DGX超级计算机,另一类是合作伙伴设计的NV-Link接口的服务器。DGX超级计算机不仅仅提供硬件,还有相干的软件和服务。 传统总线接口的GPU,目前支流的有这几款产品,比方采纳了PCI-e接口的V100、 P40(P结尾指的是上一代PASCAL架构)和P4,以及最新的图灵架构T4等。其中比拟薄和只占一个槽位的P4和T4,通常用于Inference,目前也曾经有成熟的模型进行推理和辨认。 传统PCI-e总线的GPU服务器也分为两类,一类是OEM服务器,比方曙光、浪潮、华为等其余国际品牌;另一类是非OEM的服务器,也包含很多品种。 抉择服务器时除了分类,还要思考性能指标,比方精度、显存类型、显存容量以及功耗等,同时也会有一些服务器是须要水冷、降噪或者对温度、移动性等等方面有非凡的要求,就须要非凡的服务器。 抉择GPU服务器时首先要思考业务需要来抉择适宜的GPU型号。在HPC高性能计算中还须要依据精度来抉择,比方有的高性能计算须要双精度,这时如果应用P40或者P4就不适合,只能应用V100或者P100;同时也会对显存容量有要求,比方石油或石化勘探类的计算利用对显存要求比拟高;还有些对总线规范有要求,因而抉择GPU型号要先看业务需要。 GPU服务器人工智能畛域的利用也比拟多。 GPU服务器的次要利用场景 海量计算解决 GPU 服务器超强的计算性能可利用于海量数据处理方面的运算,如搜寻、大数据举荐、智能输入法等: • 本来须要数天实现的数据量,采纳 GPU 服务器在数小时内即可实现运算。 • 本来须要数十台 CPU 服务器独特运算集群,采纳单台 GPU 服务器可实现。 深度学习模型 GPU服务器可作为深度学习训练的平台: 1.GPU 服务器可间接减速计算服务,亦可间接与外界连贯通信。 2.GPU 服务器和云服务器搭配应用,云服务器为主 GPU 云服务器提供计算平台。 3.对象存储 COS 能够为 GPU 服务器提供大数据量的云存储服务。 当GPU型号选定后,再思考用什么样GPU的服务器。这时咱们须要思考以下几种状况: 第一、在边缘服务器上须要依据量来抉择T4或者P4等相应的服务器,同时也要思考服务器的应用场景,比方火车站卡口、机场卡口或者公安卡口等;在核心端做Inference时可能须要V100的服务器,须要思考吞吐量以及应用场景、数量等。 第二、须要思考客户自身应用人群和IT运维能力,对于BAT这类大公司来说,他们本人的经营能力比拟强,这时会抉择通用的PCI-e服务器;而对于一些IT运维能力不那么强的客户,他们更关注数字以及数据标注等,咱们称这类人为数据科学家,抉择GPU服务器的规范也会有所不同。 第三、须要思考配套软件和服务的价值。 第四、要思考整体GPU集群零碎的成熟水平以及工程效率,比方像DGX这种GPU一体化的超级计算机,它有十分成熟的从底端的操作系统驱动Docker到其余局部都是固定且优化过的,这时效率就比拟高。

April 29, 2022 · 1 min · jiezi

关于算法:SoftPool基于Softmax加权的池化操作-2021新文

SoftPool应用softmax进行加权池化,可能放弃特色的表白性并且是可微操作。从性能和准确率来看,SoftPool是目前的惯例池化办法的一个不错的替代品 起源:晓飞的算法工程笔记 公众号论文: Refining activation downsampling with SoftPool 论文地址:https://arxiv.org/abs/2101.00440v2论文代码:https://github.com/alexandrosstergiou/SoftPoolIntroduction 池化层是当今卷积神经网络的根底算子,用于升高特色图的大小以及网络的计算量,可能达成平移不变性以及增大后续卷积的感触域。目前的池化办法大多基于最大池化或均匀池化,尽管计算很快内存占用少,但其有很大的晋升空间,次要在于更好地维持特色图的重要信息。 为此,论文提出了SoftPool,基于softmax增强进行特色图的池化操作。从试验后果来看,SoftPool在放弃计算和内存高效的状况下,可能很好的保留特色图的重要信息,晋升模型的准确率。 SoftPool Downsampling 定义大小为$C\times H\times W$的特色图$a$的部分区域$R$,$R$为2D空间区域,大小等同于池化核大小$|R|=k^2$,输入为$\tilde{a}_R$,对应的梯度为$\Delta \tilde{a}_i$。 Exponential maximum kernels SoftPool的核心思想在于softmax的利用,依据特征值非线性地计算区域$R$的特征值权重: 权重$w_i$可能保障重要特色的传递,区域$R$内的特征值在反向传递时都至多会有预设的最小梯度。在失去权重$w_i$后,通过加权区域$R$内的特征值失去输入: SoftPool可能很好地参照区域内的激活值散布,遵从肯定的概率分布,而基于最大池化和均匀池化的办法的输入则是无散布的。 Gradient calculation SoftPool是可微的,在反向流传计算时,SoftPool梯度依据前向时的激活值比例进行计算,若梯度过小,将间接赋予预设的非零最小梯度值。 Feature preservation 下采样的目标是在放弃特色表白的同时升高分辨率,如果损失了特色的表白,势必会升高整体网络的性能。而论文通过可视化发现,绝对于其它池化操作,SoftPool可能很好的保留特色表白,算是最大池化和均匀池化的折中。 Spatio-temporal kernels 论文提到,CNN网络能够扩大解决3D输出,SoftPool也能够进行对应的适配。假如输出的特色维度为$C\times H\times W\times T$,$T$为工夫维度,SoftPool的解决区域则从原来的2D区域加上工夫维度。 Experiment[外链图片转存失败,源站可能有防盗链机制,倡议将图片保留下来间接上传(img-uvngvuyN-1651209067982)(https://upload-images.jianshu...)] SSI、Pix Sim和EMD为3种不同的类似度度量办法,这里次要比照特色的失落以及计算性能。SoftPool尽管退出了softmax加权,但其速度仍然很快。在实现时,先对整图计算$e^x$,而后将失去的图特色图与原图进行element-wise相乘,而后进行均匀池化。 多种池化办法的比照。 多个骨干网络上的分类准确率比照。 Discussion 论文列举了许多池化操作的示意图,从图中能够看到,其实SoftPool和早前提出的LIP很像,都是用到了softmax加权,只是LIP额定加了一个小网络对激活值进行线性变换,这么看来,SoftPool能够算是LIP的一个特例。感觉整体论文的内容以及亮点不够多,另外试验局部的baseline的准确率有点低,不晓得作者是怎么得来的。 Conclusion SoftPool应用softmax进行加权池化,可能放弃特色的表白性并且是可微操作。从性能和准确率来看,SoftPool是目前的惯例池化办法的一个不错的替代品。 如果本文对你有帮忙,麻烦点个赞或在看呗~ 更多内容请关注 微信公众号【晓飞的算法工程笔记】

April 29, 2022 · 1 min · jiezi

关于算法:EasyCV开源|开箱即用的视觉自监督Transformer算法库

简介:EasyCV是阿里巴巴开源的基于Pytorch,以自监督学习和Transformer技术为外围的 all-in-one 视觉算法建模工具。EasyCV在阿里巴巴团体内撑持了搜寻、淘系、优酷、飞猪等多个BU业务,同时也在阿里云上服务了若干企业客户,通过平台化组件的模式,满足客户自定定制化模型、解决业务问题的需要。 作者 | 临在、谦言起源 | 阿里开发者公众号 一 导读近年来,自监督学习和Transformer在视觉畛域大放异彩。图像自监督预训练极大升高了图像工作沉重的标注工作,节俭大量人力老本,而transormer技术在NLP畛域的巨大成功也为CV模型成果进一步晋升提供了十分大的设想空间。为推动自监督学习和视觉Transformer在阿里团体、阿里云上的落地,阿里云机器学习平台PAI 打造了 EasyCV all-in-one视觉建模工具,搭建了丰盛欠缺的自监督算法体系,提供了成果SOTA的视觉Transformer预训练模型,modelzoo笼罩图像自监督训练、图像分类、度量学习、物体检测、关键点检测等畛域,并且面向开发者提供开箱即用的训练、推理能力,同时在训练/推理效率上也做了深度优化。此外,EasyCV对阿里灵杰零碎做了全面兼容,用户能够十分不便的在阿里云环境下应用EasyCV的全副性能。 在通过阿里外部业务充沛打磨当前,咱们心愿把EasyCV框架推向社区,进一步服务宽广的CV算法开发者以及爱好者们,使其可能十分疾速不便的体验最新的图像自监督以及transformer技术,并落地到本人的业务生产当中。 EasyCV背地的算法框架如何设计?开发者能够怎么应用?将来有哪些布局?明天一起来深刻理解。 二 什么是EasyCVEasyCV是阿里巴巴开源的基于Pytorch,以自监督学习和Transformer技术为外围的 all-in-one 视觉算法建模工具。EasyCV在阿里巴巴团体内撑持了搜寻、淘系、优酷、飞猪等多个BU业务,同时也在阿里云上服务了若干企业客户,通过平台化组件的模式,满足客户自定定制化模型、解决业务问题的需要。 我的项目开源地址:https://github.com/alibaba/Ea... 1 我的项目背景 近两年,基于无标注训练数据的图像自监督预训练技术倒退迅猛,在各个视觉工作的成果上曾经媲美甚至超过需大量标注的有监督训练的成果;另一方面,在NLP畛域大获胜利的Transformer技术在各个图像工作上进一步刷新SOTA成果,其利用呈现出井喷式的暴发。作为二者的联合,自监督视觉Transformer的预训练也应运而生。 业界自监督学习和视觉Transformer算法技术更新迭代十分快,同时也给CV算法开发者带来了诸多困扰,比方相干开源代码零散,实现形式和格调参差不齐导致学习和复现老本过高,训练、推理性能低下等等。阿里云PAI团队通过搭建灵便易用的算法框架EasyCV,体系化地积淀SOTA的自监督算法和Transformer预训练模型,封装对立、简洁易用的接口,针对自监督大数据训练方面进行性能优化,不便用户尝试最新的自监督预训练技术和Transformer模型,推动在业务上的利用和落地。 此外,基于PAI团队多年积攒的深度学习训练、推理减速技术,在EasyCV中也集成了IO优化,模型训练减速、量化裁剪等性能,在性能上具备本人的劣势。基于阿里云的PAI产品生态,用户能够不便地进行模型治理、在线服务部署、大规模离线推理工作。 2 次要个性丰盛欠缺的自监督算法体系:囊括业界有代表性的图像自监督算法SimCLR, MoCO, Swav, Moby, DINO等,以及基于mask图像预训练方法MAE,同时提供了具体的benchmark工具及复现后果。丰盛的预训练模型库:提供丰盛的预训练模型,在以transformer模型为主的根底上,也蕴含了支流的CNN 模型, 反对ImageNet预训练和自监督预训练。兼容PytorchImageModels反对更为丰盛的视觉Transformer backbone。易用性和可扩展性 :反对配置形式、API调用形式进行训练、评估、模型导出;框架采纳支流的模块化设计,灵便可扩大。高性能 :反对多机多卡训练和评估,fp16训练减速。针对自监督场景数据量大的特点,利用DALI和TFRecord文件进行IO方面的减速。对接阿里云机器学习PAI平台训练减速、模型推理优化。三 次要技术特点1 技术架构EasyCV 架构图 EasyCV 底层引擎基于Pytorch,接入Pytorch训练加速器进行训练减速。算法框架局部次要分为如下几层: 框架层:框架层复用目前开源畛域应用较为宽泛的openmmlab/mmcv 接口,通过Trainer管制训练的次要流程,自定义Hooks进行学习率控制、日志打印、梯度更新、模型保留、评估等操作,反对分布式训练、评估。Evaluators模块提供了不同工作的评估指标,反对多数据集评估,最优ckpt保留,同时反对用户自定义评估指标。可视化反对预测后果可视化、输出图像可视化。数据层:提供了不同数据源(data_source)的形象,反对多种开源数据集例如Cifar、ImageNet、CoCo等,反对raw图片文件格式和TFrecord格局,TFrecord格局数据反对应用DALI进行数据处理减速,raw格局图片反对通过缓存机制减速数据读取。数据预处理(数据加强)过程形象成若干个独立的pipeline,反对配置文件形式灵便配置不同的预处理流程。模型层:模型层分为模块和算法,模块提供根底的backbone,罕用的loss,neck和各种上游工作的head,模型ModelZoo涵盖了自监督学习算法、图像分类、度量学习、指标检测和关键点检测算法,后续会持续裁减反对更多的high-level算法。推理:EasyCV提供了端到端的推理API接口,反对PAI-Blade进行推理优化,并在云上产品反对离在线推理。API层:提供了对立的训练、评估、模型导出、预测的API。EasyCV反对在本地环境不便的运行和调试,同时,如果用户想跑大规模生产工作,咱们也反对在aliyun PAI产品中不便的进行部署。 2 欠缺的自监督算法体系自监督学习无需数据标注,比照学习的引入使其成果逐渐迫近监督学习,成为近年来学术界和工业界关注的重点之一。EasyCV囊括了支流的基于比照学习的自监督算法,包含SimCLR、MoCo v1/v2、Swav, Moby, DINO。也复现了基于mask image modeling的MAE算法。此外,咱们提供了欠缺的benchmark工具,进行自监督预训练模型在ImageNet上成果的评估。 基于体系化的自监督算法和benchmark工具,用户能够不便的进行模型改良,成果比照,进行模型翻新。同时也能够基于本人的大量无标注的数据,训练适宜本人业务畛域的更好的预训练模型。 下表展现了已有自监督算法基于ImageNet数据预训练的速度和在ImageNet验证集上linear eval/finetune的成果。 3 丰盛的预训练模型库CNN作为骨干网络,配合各种上游工作的head,是CV模型罕用的构造。EasyCV提供了多种传统的CNN网络结构,包含resnet、resnext、hrNet、darknet、inception、mobilenet、genet、mnasnet等。随着视觉Transformer的倒退,Transformer在越来越多的畛域代替CNN,成为表达能力更强的骨干网络。框架实现了罕用的ViT、SwinTransformer等, 同时引入了PytorchImageModel(Timm) 用于反对更为全面的Transformer构造。 联合自监督算法,所有的模型反对自监督预训练和ImageNet数据监督训练,为用户提供了丰盛的预训练backbone,用户能够在框架预置的上游工作中简略配置进行应用,同时也能够接入自定义的上游工作中。 4 易用性1、框架提供参数化形式和python api接口启动训练、评估、模型导出,并且提供了齐备的预测接口反对端到端推理。 # 配置文件形式python tools/train.py configs/classification/cifar10/r50.py --work_dir work_dirs/classification/cifar10/r50 --fp16# 繁难传参形式python tools/train.py --model_type Classification --model.num_classes 10 --data.data_source.type ClsSourceImageList --data.data_source.list data/train.txtAPI形式 ...

April 28, 2022 · 2 min · jiezi

关于算法:智能开放搜索上线定制分词器

简介:智能凋谢搜寻上线定制召回模型-定制分词器性能,满足各行业、垂类、业务非凡,对搜寻有较高分词要求的客户,晋升语义理解能力,精准召回用户搜寻用意。 NLP算法在搜寻链路中的利用这是一个残缺的从查问词到搜寻后果的链路,其中自然语言解决(NLP)算法发挥作用的中央次要在第二阶段的查问剖析,该阶段蕴含多个NLP算法模块,如分词、纠错、实体辨认、词权重、同义词以及语义向量等。凋谢搜寻联合了文本和语义向量实现多路召回,从而满足不同业务场景的搜寻成果需要。 查问剖析NLP算法能够在这几个子模块发挥作用: 分词,精准的分词能进步检索效率,让召回后果更加精准。拼写纠错,对用户输出query中呈现的拼写错误进行主动纠错,晋升用户搜寻体验。实体辨认,为query 中的每个词打上对应的实体标签,从而为后续的query改写和排序提供要害特色。词权重,会对每个词划分不同的权重,在查问后果时去做丢词的重查,晋升搜寻准确率并升高无后果率。同义词,扩大出雷同、相近意思的词来扩充召回范畴。最初,通过残缺的查问剖析模块之后,进行整体的query改写,将用户输出query转换成向量和查问串,到相应搜索引擎中进行查问。自研NLP模型难点自建模型畛域适配难自研搜寻在具体场景业务中成果差强人意; 例如:开源IK分词VS电商行业增强版 公开行业模型少云服务产商根本只提供通用模型,公开行业数据集也次要笼罩通用畛域; 自主参加畛域模型优化难度大构建一个行业搜寻NLP模型次要蕴含一下流程: 首先是标注数据集,这一步对于行业常识的要求十分高,同时数据量也至多须要达到万级别,标注这些数据的耗时可能长达数月。接着是模型训练,这一步须要业余的算法从业人员进行开发调试,如果对算法不相熟,将大幅升高模型成果与迭代效率。最初是模型上线,这一步须要工程、算法人员独特部署运维,如果波及到深度模型,还需进行工程性能相干的效率优化。从零开始自主开发行业模型困难重重,在数据集标注阶段其实就曾经存在了很多的挑战: 标注难点分词标注畛域常识要求高,穿插歧义判断难; 例如:药物的名称:利多卡因氯己定气雾剂 | 利多卡因 氯己定 气雾剂 地址:南召县四棵树乡王营村 | 南召 县 四棵树 乡 王营 村 洗衣服粉 | 洗衣 服 粉b 实体辨认标注畛域常识要求高; 例如:澳洲爱他美(母婴品牌)金装一段、科比(球鞋系列) pytorch实现GAN(算法模型) 针对分词、查问分析模型影响搜寻成果,行业模型训练开发难度大等问题,凋谢搜寻提供了轻量化客户定制解决方案: 凋谢搜寻轻量化客户定制解决方案计划成果介绍及选型 搜寻召回和相关性排序在理论利用中最突出的问题之一就是NLP工作的畛域适配问题。上图为凋谢搜寻依据不同业务痛点和诉求提供的解决思路及对应成果分数参考;(下面提到的分数不是严格的技术指标) 间接应用通用模型大略能达到60分的成果;凋谢搜寻产品联合阿里经济体内数据资源积攒,提供开箱即用的行业模型(电商、内容、教育、游戏、互娱等)对客户场景具备不错的适用性,能够达到80分的成果;当客户有针对性优化,团队资源短缺状况下,能够自主定制,进行畛域模型优化,但NLP工作的标注门槛绝对较高,标注品质不可控,模型训练难度大、周期长,很难冲破85分;轻量化客户定制能够缩小客户标注量级,实现齐全无标注或大量简略标注。同时基于行业、垂类、业务的非凡数据,联合原有成熟的NLP模型,让定制与扩大更简略,从而间接达到85分成果;轻量化客户定制召回模型-定制分词器分词是搜索引擎的重要根底组件,分词成果会间接影响搜寻召回和最终后果。因为业务场景的多样性,不同行业、垂类、业务都有各自的特殊性,通用、开源的分词器很难满足具体到每个客户的分词要求。 阿里云智能凋谢搜寻(OpenSearch)提供了丰盛的行业分析器,基于对应的行业分析器,通过简略的配置、训练,失去业务专属的定制分析器。整个定制过程无需进行额定的数据对接工作,召回定制模型训练会主动抽取已有数据进行适配。 通过定制召回模型-业务定制分析器性能,客户能够基于预训练行业NLP模型和本身业务数据,定制专属分析器,减小非凡行业、垂类、业务分词场景下的bad case,无需进行数据标注,实现一站式搜索引擎开发与NLP模型定制,智能化晋升搜寻成果。 实用客户搜寻为外围业务重要场景,对搜寻有更高成果要求的客户行业、垂类、业务非凡,有较多专属名词的客户搜寻投入人力无限,算法同学绝对较少的客户凋谢搜寻后续还会上线更多定制召回模型,例如:定制拼写纠错、定制同义词等,敬请期待~ 成果比照电商社区场景 智能凋谢搜寻(OpenSearch)提供的电商行业模型尽管曾经能正确处理大部分的case,但仍存在一些切错的状况。联合客户数据,基于电商行业模型训练定制分词模型后,badcase根本都被修复。 地址场景产品目前尽管还未凋谢地址行业模型,通用模型对于一些语义歧义多的case解决不好,然而联合客户数据,基于通用模型训练定制分词模型后,也能够修复大部分badcase。 小结: 如果您的业务目前正在或筹备应用凋谢搜寻(OpenSearch)的行业版,能够在行业模型的根底上进行定制分词模型的训练;如果凋谢搜寻还没有提供与您业务靠近的行业版,倡议抉择在通用版模型的根底上进行定制,这种状况须要数据尽量多,散布尽量全面平衡,有助于晋升定制分词模型的成果。模型接入流程创立并训练模型; 创立模型,训练模型 其中根底分析器包含:中文-通用剖析、中文-电商剖析、IT内容分析、行业-游戏通用剖析,行业-教育搜题、行业-内容IT剖析、行业-电商通用剖析 创立自定义分析器(可选)在搜索算法核心>分析器治理页面,抉择文本分析器创立,抉择分析器类型为定制模型剖析 创立实现后,可应用定制自定义分析器进行分词测试,以及词条治理等性能: 配置定制分析器模型定制分析器创立实现后,即可通过线下变更将已配置定制召回模型的定制化分析器利用到索引中;在配置索引构造页面,找到对应的索引,替换成已配置定制召回模型的定制化分析器,并抉择须要失效的模型版本; 索引重建完结,即可在搜寻测试界面测试成果; 原文链接本文为阿里云原创内容,未经容许不得转载。

April 27, 2022 · 1 min · jiezi

关于算法:国产GPU的发展历程及芯片性能详解

一、国产GPU的倒退历程 二、国产GPU进口代替的紧迫性 三、景嘉微:具备齐全自主知识产权,突破国外GPU长期垄断 四、景嘉微国产GPU芯片概述 五、景嘉微国产GPU芯片性能详解 六、景嘉微国产GPU生态 七:景嘉微国产GPU后续研发 八、景嘉微:GPU业务高增长 九、国产GPU IP 龙头:芯原股份 十、航锦科技:收买长沙韶光,进军GPU畛域 十一、共事把握GPU、CPU、芯片组三大核心技术 十二、兆芯KX6000处理器 十三、兆芯处理器后续倒退 十四、中船重工709所:凌久电子GPU概述 十五、中船重工716研究所:JARI G12 GPU 十六、国产芯片定制先驱:芯动科技 十七、芯动科技:携手Imagination,“风华”诞生 十八、华为海思:GPUTurbo 十九、龙芯:GPU突击队 二十、芯瞳半导体:高性能GPU设计新星 二十一、天数智芯:国产GPG PU领跑者 二十二、国产GPU新星:壁仞科技和沐曦集成电路 二十三、国产GPU新星:登临科技和摩尔线程 二十四、国产GPU新星:韩博半导体 二十五、国产GPU新星:燧原科技

April 26, 2022 · 1 min · jiezi

关于算法:面试算法题记录

电话面试算法问答记录问:一个数组,先递增后递加,要返回最大的一个数,怎么实现?答:顺次遍历第i个数,如果第i个数大于第i + 1个数,那么返回第i个数,这个数就是最大值。(这么简略,大一学生都会)问:还能优化吗?答:啊。。。。。。(比o(n)工夫复杂度还快的算法就是o(logn),那应该就是二分法,要害是怎么判断一个数是否是最大的那个数察看数组,1 2 3 4 5 4 3,如果如果第i个数小于第i + 1个数,那么阐明第i个数在递增那局部,最大数在后半局部,咱们放大一半范畴再去后半局部找最大数,如果第i个数大于第i + 1个数那么他有可能就是最大数,也有可能在递加那局部,如果在递加那局部,阐明最大数在前半部分,咱们放大一半范畴再去前半部分找最大数。然而如何判断是否就是最大数呢?那就再减少一个判断条件。咱们看第i个数,第i - 1个数,第i + 1个数三个数的法则。如果三个数顺次递增,那么第i个数就在递增局部,如果三个数顺次递加,那么第i个数就在递加局部,如果三个数顺次先增后减,那么第i个数就是最大数。)应用二分法查找,设两头数下表为i,如果第i个数大于第i - 1个数并且第i + 1个数大于第i个数,那么第i个数处于递增序列局部,应用后半局部数组持续进行查找;如果第i个数小于第i - 1个数且第i + 1个数大于第i个数,那么第i个数处于递加序列局部,应用前半部分数组持续进行查找;如果第i个数大于第i - 1个数并且第i个数大于第i + 1个数,那么这个数就是最大数。问:工夫复杂度多少?答:logn。问:你口试那道三数之和题(给一个无序数组和一个目标值,判断数组中是否找到三个数,使三个数之和为目标值)怎么做的,工夫复杂度多少?答:那个用了HashMap将数组的数key = 值,value = 值第下表形式全副存储进去,而后用一个二重循环,一层i循环一层j循环,判断HashMap中是否含有(目标值 - 第i个数 - 第j个数)。工夫复杂度是o(n^2)。问:还有别的办法吗?答:啊。。。。。。 (对于一个无序数组,先快排成一个有序数组,工夫复杂度为o(nlogn),而后定义三个指针i,j,k初始别为0,如果第i个数 + 第j个数 + 第k个数小于指标数,那么就k++,如果第i个数 + 第j个数 + 第k个数大于指标数,那么再将k++就没有意义了,那么就去去挪动j,不对,这么做工夫复杂度还是n^3,无非是在做剪枝工作。再想想。对于一个固定的i,如果初始化j 和 k为一个靠近的值,那么就能够更快了。有了,固定i为0,设j为1,k为最大下标值n - 1,如果第i个数 + 第j个数 + 第k个数大于目标值,那么就将j++,如果第i个数 + 第j个数 + 第k个数小于目标值,那么就将k--,当k == j时跳出循环将i++再次进行判断)。 设三个指针i = 0;j = i + 1;k = n - 1;固定i,对于寻找第二个数和第三个数应用双指针形式,如果三个指针对应数之和小于指标数,就将j指针向后挪动一位,如果三个指针对应数之和大于指标数,就讲k指针向前挪动一位。如果j == k。那么就跳出循环,将i++,接着进行判断。这样工夫复杂度为o(n^2)。问:还有别的办法吗?答:(面试官你别太过分!)想不到了。 ...

April 25, 2022 · 1 min · jiezi

关于算法:全球GPU市场竞争格局分析

一、寰球GPU市场规模喝各子市场趋势 二、寰球GPU市场竞争格局 三、寰球GPU龙头:英伟达概述 四、寰球GPU龙头:英伟达游戏业务 五、寰球GPU龙头:英伟达业余视觉业务 六:寰球GPU龙头:英伟达并购ARM 七:寰球GPU先驱:AMD 八、寰球GPU先驱:AMD集成GPU 九、寰球GPU先驱:AMD游戏独立GPU 十、寰球GPU先驱:AMD数据中心GPU 十一、寰球GPU先驱:AMD其余独立GPU 十二、寰球GPU追赶者:英特尔 十三、寰球GPU追赶者:英特尔集成GPU 十四、寰球GPU追赶者:英特尔独立GPU 十五、寰球GPU IP龙头:ARM Mali 十六、寰球GPU IP龙头:ARM Mali-G78 十八、寰球GPU IP龙头:Imagination 十九、寰球挪动GPU先驱:高通Adreno 二十、寰球挪动GPU新秀:苹果

April 25, 2022 · 1 min · jiezi

关于算法:LeetCodeGolang-5-最长回文子串

题目:给你一个字符串 s,找到 s 中最长的回文子串。 示例 1: 输出:s = "babad"输入:"bab"解释:"aba" 同样是合乎题意的答案。示例 2: 输出:s = "cbbd"输入:"bb"题解:首先咱们应用核心扩大法解决,先贴代码(Go): func longestPalindrome(s string) string { n := len(s) if n < 2 { return s } begin, end := 0, 0 //[begin,end] maxLen := 1 for i := 0; i < n; i++ { curMaxLen := max(expandAroundCenter(&s, i, i), expandAroundCenter(&s, i, i+1)) if curMaxLen > maxLen { maxLen = curMaxLen begin = i - (maxLen-1)/2 end = begin + maxLen - 1 } } return s[begin : end+1]}func expandAroundCenter(s *string, left int, right int) int { for ; left >= 0 && right < len(*s) && (*s)[left] == (*s)[right]; left, right = left-1, right+1 { } return right - left - 1}func max(a int, b int) int { if a > b { return a } return b}核心思想就是,以每个字符(奇数子串)或每两个字符(偶数子串)为核心,而后判断可造成的最大回文长度。 ...

April 24, 2022 · 1 min · jiezi

关于算法:COMP1433-解码统计

COMP1433: Introduction to Data AnalyticsCOMP1003: Statistical Tools and ApplicationsAssignmentSpring 2021Answers Submission Due: 23:59, Apr 11, 2021.Important Notes.• This is an individual assessment. So, no discussion (in any forms) is allowedamong classmates.• You should only use R language for the implementation.• Please submit the compressed folder (in zip or rar) with all the questionanswers. Grateful if the folder can be named as the student ID, such as“20123456D.zip” or ““20123456D.rar”. For the i-th question below, youmay create a folder named as “Qi” (e.g., Q1), which contains the code answersfor Qi and the readme.txt file indicating how to run the code.• It is highly recommended that the codes are well commented, so that the TAcan easily read them. It is for the case that the implementation is imperfect(with bugs) and we need to somehow find scores from the codes to see ifyour algorithm is designed in a correct way.• The compressed folder should be submitted to the blackboard.1 The fullmark is 100’ and submission entry is: Assessments/Assignment. For Question1 and 3 below, we’ll also provide the input data in the form of thecompressed folder “Assignment Data” available in the same entry. You’llfind two folders there, one named as Q1 and the other Q3, for the input ofQuestion 1 and 3 respectively.• No late submission is allowed and don’t forget to double check if the submissionis saved successfully before leaving.1learn.polyu.edu.hk1• When handling the paths for file loading and saving, please use relativepaths for the TAs to run your codes easily in a different environment.• When visualizing the data or results with the graphs, label the axes, legends,and titles properly, if any, for easy reading.• Last but not least, best of the luck for this assignment! :)Question 1. We learned the K-means clustering methods in the class. You canimplement the algorithm from scratch (without using external packages or thekmeans() functions in R system) and group the points in 3 clusters. The inputpoints are put in a file named as “Points.csv”: each line shows a 2D vector (point)where the first and second entry are separated by the comma “,”. When runningthe codes, it is required to generate a figure visualizing the clustering results.In visualization, you can first draw a scatter plot with the input vectors (x-axiscorresponding to the first entry while y-axis the second entry), and then coloreach point in red, green, and blue, indicating the cluster it belongs to.Note. It is assumed that the “Points.csv” file is put in the same folder as thecodes (with the main function). In K-means implementation, everything should behandled from scratch, while for visualization purpose, you can attach any graphicsor visualization packages you want. For initialization, the representatives of thethree classes are (40,40), (100,0), and (0,100), respectively. (20’)Question 2. Recall that in the test held on Mar 18, we discussed the samplingof a list with replacement, where it is possible to sample repeated letters. Inthe test, has only two letters i.e., A and B, while here we consider a with26 alphabetic letters, from A to Z. Still, we will repeat the process to sampleletters randomly from and maintain another list to record the sampled letters.For example, if the letters we sequentially sampled from is DT TA, then =hD,T,T,Ai. Once a letter is drawn from in a sampling step, a copy will beinserted into and in the next step, it is likely that the same letter will be drawnagain (in other words may contain repeated letters).In each sampling step, each letter has equal chances, i.e., 126 , to be drawn andthe sampling process won’t stop until A appears in . Let X denote the length of (the number of letters therein) when the sampling process stops (X = 4 in theexample of = hD,T,T,Ai, where we observe A at the forth sampling and stops).(1) Use sampling to estimate X and visualize the distribution with the histogram.(20’)(2) In the context of (1), there are 26 letters in . Here we assume containsN letters, where N = 2,3,4,...,26. Use sampling to estimate E[X] (X’s expected2value) given varying numbers of N. Visualize the relations between N and E[X]with some graph (pick up one that you think is suitable) (10’)Question 3. We are interested in examining the employee’s salaries via lookinginto 35 samples, with their salaries, ages, and whether they hold a MBA degree.(1) The sample data can be found in attachment Q3/Salaries.csv containing 36lines, where the title is at the first line (the names of these attributes are “Salary”,“Age”, and “MBA”) and the data at the rest (a record a line). Different attributesare separated with comma (,). To analyze the data, the first step is to load the datainto the R system and put it into a data frame for further analyses. Here we assumethat Salaries.csv is at the same level as the R script corresponding to Q3. (10’)(2) Add one column named as “ID” from 1 to 35 to the data frame in (1). Writethe data frame (including the column names) to a file “newSalaries.csv”, which isin the same folder as codes and the input “Salaries.csv”. (10’)(3) Calculate the mean, standard deviation, median value, minimum value,and maximum value for salaries. Print the results on the screen with the followingtemplate (6 lines altogether) on the screen. Try to use the built-in functions in Rsystem if possible. (10’)The statistics for salaries are:mean value=xxx;standard deviation=xxx;median value=xxxminimum value=xxxmaximum value=xxx(4) Select the correct graph to visualize the pair-wise relation between Salariesand Ages, and that between Salaries and MBA. Further, visualize the relationsamong Salaries, Ages, and MBA in one figure. (10’)(5) Use the barplot to visualize the comparison between the median salariesfor employees with and without the MBA degree. Then, visualize the averagesalaries, still with the barplot, for employees in the group of age < 30, [30−40),[40,50), and ≥ 50. (10’) ...

April 24, 2022 · 5 min · jiezi

关于算法:CS-3114算法分析

CS 3114 Data Structures & Algorithms J4: Geographic Information SystemVersion 6.00 This is a purely individual assignment! 1Geographic Information SystemGeographic information systems organize information pertaining to geographic features and provide various kinds of accessto the information. A geographic feature may possess many attributes (see below). In particular, a geographic feature has aspecific location. There are a number of ways to specify location. For this project, we will use latitude and longitude, whichwill allow us to deal with geographic features at any location on Earth. A reasonably detailed tutorial on latitude andlongitude can be found in the Wikipedia at en.wikipedia.org/wiki/Latitude and en.wikipedia.org/wiki/Longitude.The GIS record files were obtained from the website for the USGS Board on Geographic Names (www.usgs.gov/corescience-systems/ngp/board-on-geographic-names/download-gnis-data).The file begins with a descriptive header line,followed by a sequence of GIS records, one per line, which contain the following fields in the indicated order:Figure 1: Geographic Data Record FormatName Type Length/Decimals Short DescriptionFeature ID Integer 10Permanent, unique feature record identifier and official feature name FeatureName String 120FeatureClass String 50 See Figure 3 later in this specificationState Alpha String 2State The unique two letter alphabetic code and the unique two number code for a US StateNumeric String 2CountyName String 100The name and unique three number code for a county or county equivalentCountyNumeric String 3PrimaryLatitudeDMSString 7The official feature locationDMS-degrees/minutes/secondsDEC-decimal degrees.Note: Records showing "Unknown" and zeros for the latitude and longitude DMS anddecimal fields, respectively, indicate that the coordinates of the feature are unknown.They are recorded in the database as zeros to satisfy the format requirements of anumerical data type. They are not errors and do not reference the actual geographiccoordinates at 0 latitude, 0 longitude.PrimaryLongitudeDMSString 8PrimaryLatitudeDECRealNumber 11/7PrimaryLongitudeDECRealNumber 12/7SourceLatitudeDMSString 7Source coordinates of linear feature only (Class = Stream, Valley, Arroyo)DMS-degrees/minutes/secondsDEC-decimal degrees.Note: Records showing "Unknown" and zeros for the latitude and longitude DMS anddecimal fields, respectively, indicate that the coordinates of the feature are unknown.They are recorded in the database as zeros to satisfy the format requirements of anumerical data type. They are not errors and do not reference the actual geographiccoordinates at 0 latitude, 0 longitude.SourceLongitudeDMSString 8SourceLatitudeDECRealNumber 11/7SourceLongitudeDECRealNumber 12/7CS 3114 Data Structures & Algorithms J4: Geographic Information SystemVersion 6.00 This is a purely individual assignment! 2Elevation(meters) Integer 5 Elevation in meters above (-below) sea level of the surface at the primary coordinatesElevation(feet) Integer 6 Elevation in feet above (-below) sea level of the surface at the primary coordinatesMap Name String 100 Name of USGS base series topographic map containing the primary coordinates.DateCreated String The date the feature was initially committed to the database.Date Edited String The date any attribute of an existing feature was last edited.Notes: See https://geonames.usgs.gov/dom... for the full field descriptions. The type specifications used here have been modified from the source (URL above) to better reflect the realities ofyour programming environment. Latitude and longitude may be expressed in DMS (degrees/minutes/seconds, 0820830W) format, or DEC (realnumber, -82.1417975) format. In DMS format, latitude will always be expressed using 6 digits followed by a singlecharacter specifying the hemisphere, and longitude will always be expressed using 7 digits followed by ahemisphere designator. Although some fields are mandatory, some may be omitted altogether. Best practice is to treat every field as if itmay be left unspecified. Certain fields are necessary in order to index a record: the feature name and the primarylatitude and primary longitude. If a record omits any of those fields, you may discard the record, or index it as far aspossible.In the GIS record file, each record will occur on a single line, and the fields will be separated by pipe ('|') symbols. Emptyfields will be indicated by a pair of pipe symbols with no characters between them. See the posted VA_Monterey.txt filefor many examples.GIS record files are guaranteed to conform to this syntax, so there is no explicit requirement that you validate the files. Onthe other hand, some error-checking during parsing may help you detect errors in your parsing logic.The file can be thought of as a sequence of bytes, each at a unique offset from the beginning of the file, just like the cells ofan array. So, each GIS record begins at a unique offset from the beginning of the file.Line TerminationEach line of a text file ends with a particular marker (known as the line terminator). In MS-DOS/Windows file systems, theline terminator is a sequence of two ASCII characters (CR + LF, 0X0D0A). In Unix systems, the line terminator is a singleASCII character (LF). Other systems may use other line termination conventions.Why should you care? Which line termination is used has an effect on the file offsets for all but the first record in the datafile. As long as we’re all testing with files that use the same line termination, we should all get the same file offsets. But ifyou change the file format (of the posted data files) to use different line termination, you will get different file offsets than areshown in the posted log files. Most good text editors will tell you what line termination is used in an opened file, and also letyou change the line termination scheme.All that being said, this project is not auto-graded, and the grading of correctness will depend on whether you report thecorrect search results, not on the file offsets you report.CS 3114 Data Structures & Algorithms J4: Geographic Information SystemVersion 6.00 This is a purely individual assignment! 3Figure 2: Sample Geographic DataRecordsNote that some record fields are optional, and thatwhen there is no given value for a field, there arestill delimiter symbols for it.Also, some of the lines are "wrapped" to fit intothe text box; lines are never "wrapped" in theactual data files.FEATURE_ID|FEATURE_NAME|FEATURE_CLASS|STATE_ALPHA|STATE_NUMERIC|COUNTY_NAME|COUNTY_NUMERIC|PRIMARY_LAT_DMS|PRIM_LONG_DMS|PRIM_LAT_DEC|PRIM_LONG_DEC|SOURCE_LAT_DMS|SOURCE_LONG_DMS|SOURCE_LAT_DEC|SOURCE_LONG_DEC|ELEV_IN_M|ELEV_IN_FT|MAP_NAME|DATE_CREATED|DATE_EDITED1479116|Monterey Elementary School|School|VA|51|Roanoke (city)|770|371906N|0795608W|37.3183753|- 79.9355857|||||323|1060|Roanoke|09/28/1979|09/15/20101481345|Asbury Church|Church|VA|51|Highland|091|382607N|0793312W|38.4353981|-79.5533807|||||818|2684|Monterey|09/28/1979|1481852|Blue Grass|Populated Place|VA|51|Highland|091|383000N|0793259W|38.5001188|-79.5497702|||||777|2549|Monterey|09/28/1979|1481878|Bluegrass Valley|Valley|VA|51|Highland|091|382953N|0793222W|38.4981745|-79.539492|382601N|0793800W|38.4337309|- 79.6333833|759|2490|Monterey|09/28/1979|1482110|Buck Hill|Summit|VA|51|Highland|091|381902N|0793358W|38.3173452|-79.5661577|||||1003|3291|Monterey SE|09/28/1979|1482176|Burners Run|Stream|VA|51|Highland|091|382509N|0793409W|38.4192873|-79.5692144|382531N|0793538W|38.4252778|- 79.5938889|848|2782|Monterey|09/28/1979|1482324|Mount Carlyle|Summit|VA|51|Highland|091|381556N|0793353W|38.2656799|-79.5647682|||||698|2290|Monterey SE|09/28/1979|1482434|Central Church|Church|VA|51|Highland|091|382953N|0793323W|38.4981744|-79.5564371|||||773|2536|Monterey|09/28/1979|1482557|Claylick Hollow|Valley|VA|51|Highland|091|381613N|0793238W|38.2704021|-79.5439343|381733N|0793324W|38.2925|- 79.5566667|573|1880|Monterey SE|09/28/1979|1482785|Crab Run|Stream|VA|51|Highland|091|381707N|0793144W|38.2854018|-79.528934|381903N|0793415W|38.3175|-79.5708333|579|1900|MontereySE|09/28/1979|1482950|Davis Run|Stream|VA|51|Highland|091|381824N|0793053W|38.3067903|-79.5147671|382057N|0793505W|38.3491667|-79.5847222|601|1972|MontereySE|09/28/1979|1483281|Elk Run|Stream|VA|51|Highland|091|382936N|0793153W|38.4934524|-79.5314362|383121N|0793056W|38.5226185|- 79.5156027|757|2484|Monterey|09/28/1979|1483492|Forks of Waters|Locale|VA|51|Highland|091|382856N|0793031W|38.4823417|-79.5086575|||||705|2313|Monterey|09/28/1979|1483527|Frank Run|Stream|VA|51|Highland|091|382953N|0793310W|38.4981744|-79.5528258|383304N|0793341W|38.5512285|- 79.5614381|780|2559|Monterey|09/28/1979|1483647|Ginseng Mountain|Summit|VA|51|Highland|091|382850N|0793139W|38.480675|-79.527547|||||978|3209|Monterey|09/28/1979|1483860|Gulf Mountain|Summit|VA|51|Highland|091|382940N|0793103W|38.4945636|-79.5175468|||||1006|3300|Monterey|09/28/1979|1483916|Hamilton Chapel|Church|VA|51|Highland|091|381740N|0793707W|38.2945677|-79.6186591|||||823|2700|Monterey SE|09/28/1979|1484097|Highland High School|School|VA|51|Highland|091|382426N|0793444W|38.4071387|-79.5789333|||||879|2884|Monterey|09/28/1979|09/15/20101484099|Highland Wildlife Management Area|Park|VA|51|Highland|091|381905N|0793439W|38.3181785|-79.577547|||||954|3130|Monterey SE|09/28/1979|. . .CS 3114 Data Structures & Algorithms J4: Geographic Information SystemVersion 6.00 This is a purely individual assignment! 4AssignmentYou will implement a system that indexes and provides search features for a file of GIS records, as described above.Your system will build and maintain several in-memory index data structures to support these operations: Importing new GIS records into the database file Retrieving data for all GIS records matching given geographic coordinates Retrieving data for all GIS records matching a given feature name and state Retrieving data for all GIS records that fall within a given (rectangular) geographic region Displaying the in-memory indices in a human-readable mannerYou will implement a single software system in Java to perform all system functions.Program InvocationThe program will take the names of three files from the command line, like this:java GIS <database file name> <command script file name> <log file name>Note that this implies your main class must be named GIS, and must be in the default Java package.The database file should be created as an empty file; note that the specified database file may already exist, in which case theexisting file should be truncated or deleted and recreated. If the command script file is not found the program should write anerror message to the console and exit. The log file should be rewritten every time the program is run, so if the file alreadyexists it should be truncated or deleted and recreated.System OverviewThe system will create and maintain a GIS database file that contains all the records that are imported as the program runs.The GIS database file will be empty initially. All the indexing of records will be done relative to this file.There is no guarantee that the GIS record file will not contain two or more distinct records that have the same geographiccoordinates. In fact, this is natural since the coordinates are expressed in the usual DMS system. So, we cannot treatgeographic coordinates as a primary (unique) key.The GIS records will be indexed by the Feature Name and State (abbreviation) fields. This name index will supportfinding offsets of GIS records that match a given feature name and state abbreviation.The GIS records will also be indexed by geographic coordinate. This coordinate index will support finding offsets of GISrecords that match a given primary latitude and primary longitude.The system will include a buffer pool, as a front end for the GIS database file, to improve search speed. See the discussion ofthe buffer pool below for detailed requirements. When performing searches, retrieving a GIS record from the database filemust be managed through the buffer pool. During an import operation, when records are written to the database file, thebuffer pool will be bypassed, since the buffer pool would not improve performance during imports.When searches are performed, complete GIS records will be retrieved from the GIS database file that your programmaintains. The only complete GIS records that are stored in memory at any time are those that have just been retrieved tosatisfy the current search, or individual GIS records created while importing data or GIS records stored in the buffer pool.Aside from where specific data structures are required, you may use any suitable Java library containers you like.Each index should have the ability to write a nicely-formatted display of itself to an output stream. CS 3114 Data Structures & Algorithms J4: Geographic Information SystemVersion 6.00 This is a purely individual assignment! 5Name Index InternalsThe name index will use a hash table for its physical organization. Each hash table entry will store a feature name and stateabbreviation (separately or concatenated, as you like) and the file offset(s) of the matching record(s). Since each GIS recordoccupies one line in the file, it is a trivial matter to locate and read a record given nothing but the file offset at which therecord begins.Your table will use chaining to resolve collisions, with a contiguous physical structure (physical array) to store the chains.The initial size of the table will be 1024, and the table will resize itself automatically, by doubling its size whenever the tablebecomes 70% full. Obviously, you should base this on a slight modification of the hash table you implemented for J3.You will use the same hash function that was supplied for J2, and apply it to a concatenation of the feature name and stateabbreviation field of the data records. Precisely how you form the concatenation is up to you.You must be able to display the contents of the hash table in a readable manner.Coordinate Index InternalsThe coordinate index will use a bucket PR quadtree for the physical organization. In a bucket PR quadtree, each leaf storesup to K data objects (for some fixed value of K). Upon insertion, if the added value would fall into a leaf that is already full,then the region corresponding to the leaf will be partitioned into quadrants and the K+1 data objects will be inserted intothose quadrants as appropriate. As is the case with the regular PR quadtree, this may lead to a sequence of partitioning steps,extending the relevant branch of the quadtree by multiple levels. In this project, K will probably equal 4, but I reserve theright to specify a different bucket size with little notice, so this should be easy to modify.The index entries held in the quadtree will store a geographic coordinate and a collection of the file offsets of the matchingGIS records in the database file. Obviously, this is derived directly from your solution to J2.Note: do not confuse the bucket size with any limit on the number of GIS records that may be associated with a singlegeographic coordinate. A quadtree node can contain index objects for up to K different geographic coordinates. Each suchindex object can contain references to an unlimited number of different GIS records.The PR quadtree implementation should follow good design practices, and its interface should be somewhat similar to that ofthe BST. You are expected to implement different types for the leaf and internal nodes, with appropriate data membershipfor each, and an abstract base type from which they are both derived. Of course, these were all requirements for the relatedminor project.You must be able to display the PR quadtree in a readable manner. PR quadtree display code is given in the course notes.The display must clearly indicate the structure of the tree, the relationships between its nodes, and the data objects in the leafnodes.Buffer Pool DetailsThe buffer pool for the database file should be capable of buffering up to 15 records, and will use LRU replacement. Youmay use any structure you like to organize the pool slots; however, since the pool will have to deal with record replacements,some structures will be more efficient (and simpler) to use. You may use any classes from the Java library you think areappropriate.It is up to you to decide whether your buffer pool stores interpreted or raw data; i.e., whether the buffer pool stores GISrecord objects or just strings.You must be able to display the contents of the buffer pool, listed from MRU to LRU entry, in a readable manner. The orderin which you retrieve records when servicing a multi-match search is not specified, so such searches may result in differentorderings of the records within the buffer pool. That is OK.CS 3114 Data Structures & Algorithms J4: Geographic Information SystemVersion 6.00 This is a purely individual assignment! 6A Note on Coordinates and Spatial RegionsIt is important to remember that there are fundamental differences between the notion that a geographic feature has specificcoordinates (which may be thought of as a point) and the notion that each node of the PR quadtree corresponds to a particularsub-region of the coordinate space (which may contain many geographic features).In this assignment, coordinates of geographic features are specified as latitude/longitude pairs, and the minimum resolution isone second of arc. Thus, you may think of the geographic coordinates as being specified by a pair of integer values.On the other hand, the boundaries of the sub-regions are determined by performing arithmetic operations, including division,starting with the values that define the boundaries of the “world”. Unless the dimensions of the world happen to be powersof 2, this can quickly lead to regions whose boundaries cannot be expressed exactly as integer values. You should usefloating-point values to represent region boundaries, when carrying out splitting operations and quadtree traversals.Your implementation should view the boundary between regions as belonging to one of those regions. The choice of aparticular rule for handling this situation is left to you. The specification for the PR quadtree project describes how I madethat decision, but there is absolutely no requirement that you follow the same approach.When carrying out a region search, you must determine whether the search region overlaps with the region corresponding toa subtree node before descending into that subtree. The Java libraries include a Rectangle class which could be (too) useful.You may make use of the Rectangle class, but you will be penalized 10% if your submitted solution makes use of any of thefollowing Rectangle methods: contains(), intersection(), and intersects(). Note though, that it is acceptable to make useof those methods during development, but you must implement your own versions of them in your final submission.Other System ElementsThere should be an overall controller that validates the command line arguments and manages the initialization of the varioussystem components. The controller should hand off execution to a command processor that manages retrieving commandsfrom the script file, and making the necessary calls to other components in order to carry out those commands.Naturally, there should be a data type that models a GIS record.There may well be additional system elements, whether data types or data structures, or system components that are notmentioned here. The fact no additional elements are explicitly identified here does not imply that you will not be expected toanalyze the design issues carefully, and to perhaps include such elements.Aside from the command-line interface, there are no specific requirements for interfaces of any of the classes that will makeup your GIS; it is up to you to analyze the specification and come up with an appropriate set of classes, and to design theirinterfaces to facilitate the necessary interactions. It is probably worth pointing out that an index (e.g., a geographiccoordinate index) should not simply be a naked container object (e.g, quadtree); if that's not clear to you, think more carefullyabout what sort of interface would be appropriate for an index, as opposed to a container.Command FileThe execution of the program will be driven by a script file. Lines beginning with a semicolon character (';') are commentsand should be ignored. Blank lines are possible. Each line in the command file consists of a sequence of tokens, which willbe separated by single tab characters. A line terminator will immediately follow the final token on each line. The commandfile is guaranteed to conform to this specification, so you do not need to worry about error-checking when reading it.The first non-comment line will specify the world boundaries to be used:world<tab><westLong><tab><eastLong><tab><southLat><tab><northLat>This will be the first command in the file, and will occur once. It specifies the boundaries of the coordinate space to bemodeled. The four parameters will be longitude and latitudes expressed in DMS format, representing the vertical andhorizontal boundaries of the coordinate space.It is certainly possible that the GIS record file will contain records for features that lie outside the specified coordinatespace. Such records should be ignored; i.e., they will not be indexed.CS 3114 Data Structures & Algorithms J4: Geographic Information SystemVersion 6.00 This is a purely individual assignment! 7Each subsequent non-comment line of the command file will specify one of the commands described below. One commandis used to load records into your database from external files:import<tab><GIS record file>Add all the valid GIS records in the specified file to the database file. This means that the records will be appended tothe existing database file, and that those records will be indexed in the manner described earlier. When the import iscompleted, log the number of entries added to each index, and the longest probe sequence that was needed wheninserting to the hash table. (A valid record is one that lies within the specified world boundaries.)Another command requires producing a human-friendly display of the contents of an index structure:debug<tab>[ quad | hash | pool ]Log the contents of the specified index structure in a fashion that makes the internal structure and contents of the indexclear. It is not necessary to be overly verbose here, but you should include information like key values and file offsetswhere appropriate.Another simply terminates execution, which is handy if you want to process only part of a command file:quit<tab>Terminate program execution.The other commands involve searches of the indexed records:what_is_at<tab><geographic coordinate>For every GIS record in the database file that matches the given <geographic coordinate>, log the offset atwhich the record was found, and the feature name, county name, and state abbreviation. Do not log any other datafrom the matching records.what_is<tab><feature name><tab><state abbreviation>For every GIS record in the database file that matches the given <feature name> and <stateabbreviation>, log the offset at which the record was found, and the county name, the primary latitude, and theprimary longitude. Do not log any other data from the matching records.what_is_in<tab><geographic coordinate><tab><half-height><tab><half-width>For every GIS record in the database file whose coordinates fall within the closed rectangle with the specified heightand width, centered at the <geographic coordinate>, log the offset at which the record was found, and thefeature name, the state name, and the primary latitude and primary longitude. Do not log any other data from thematching records. The half-height and half-width are specified as seconds.If a <geographic coordinate> is specified for a command, it will be expressed as a pair of latitude/longitude values,expressed in the same DMS format that is used in the GIS record files.For all the commands, if a search results in displaying information about multiple records, you may display that data in anyorder that is natural to your design.Sample command scripts, and corresponding log files, will be provided on the website. As a general rule, every commandshould result in some output. In particular, a descriptive message should be logged if a search yields no matching records.CS 3114 Data Structures & Algorithms J4: Geographic Information SystemVersion 6.00 This is a purely individual assignment! 8Log File DescriptionSince this assignment will be graded by TAs, rather than script automation, the format of the output is left up to you. Ofcourse, your output should be clear, concise, well labeled, and correct. You should begin the log with a few lines identifyingyourself, and listing the names of the input files that are being used. No one will object if you use the posted log files as amodel for formatting your own output, but you are certainly not expected to match the formatting of those exactly.The remainder of the log file output should come directly from your processing of the command file. You are required toecho each comment line, and each command that you process to the log file so that it's easy to determine which commandeach section of your output corresponds to. Each command (except for "world") should be numbered, starting with 1, andthe output from each command should be well formatted, and delimited from the output resulting from processing othercommands. A complete sample log will be posted shortly on the course website.A zip file is posted, containing scripts, GIS data files, and reference log files you can use in testing. The grading will be doneusing files in exactly the same format (perhaps even including some of the posted files).Administrative IssuesSubmissionYou will submit this assignment to the Curator System (read the Student Guide), where it will be archived for grading by acourse TA.For this assignment, you must submit a single zip file containing all the Java source code files for your implementation (i.e.,.java files). Submit only the Java source files. Do not submit Java bytecode (class) files. If you use packages in yourimplementation (and that's good practice), your zip file must include the correct directory structure for those packages, andyour GIS.java file must be in the top directory when the tar file is unpacked. That's easy to verify by running "unzip –l" on the tar file you are planning to submit.In order to correct submission errors and late-breaking implementation errors, you will be allowed up to five submissions forthis assignment. By default, we will grade the last submission you make.The Student Guide and link to the submission client can be found at: http://www.cs.vt.edu/curator/EvaluationThe quality of the OO design in your solution will be evaluated; you are expected to identify and implement a soundcollection of classes, whether the specification mentions them or not. The quality of your internal documentation will beevaluated. Finally, the correctness of your solution will be evaluated by executing your solution on a collection of test datafiles. Be sure to test your solution with all of the data sets that will be posted, since we will use a variety of data sets,including at least one very large data one (perhaps hundreds of thousands of records) in our evaluation.The quality of your design and internal documentation will determine approximately 30% of your grade for this assignment.Pay attention to the design discussion in class for J1.We will compile and test your solution on CentOS 8, using version 11.0.8 of the JDK. The choice of operating systemshould not matter with a Java program (write once, run everywhere, right?), but you should compile and test your solution onrlogin before submitting it.Late submissions will be penalized at a rate of 10% per day or fraction thereof. There will also be a final deadline, afterwhich we will not accept submissions.CS 3114 Data Structures & Algorithms J4: Geographic Information SystemVersion 6.00 This is a purely individual assignment! 9Pedagogic PointsThe goals of this assignment include, but are not limited to: implementation of a hash table generic in Java (as in J3) implementation of a bucket PR quadtree generic in Java (as in J2) implementation of a buffer pool in Java design of appropriate index classes to wrap the containers design of appropriate data objects to store in each index understanding how to navigate a file in Java understanding how to parse delimited strings in Java (based on your solutions to J1 and J3) creation of a sensible OO design for the overall system, including the identification of a number of useful classes notexplicitly named in this specification implementation of such an OO design into a working system incremental testing of the basic components of the system in isolation satisfaction when the entire system comes together in good working orderPledgeEach of your program submissions must be pledged to conform to the Honor Code requirements for this course. Specifically,you must include the pledge statement provided below. The pledge statement should be in the file that contains your mainclass (which must be named GIS.java).// On my honor://// - I have not discussed the Java language code in my program with// anyone other than my instructor or the teaching assistants// assigned to this course.//// - I have not used Java language code obtained from another student,// or any other unauthorized source, including the Internet, either// modified or unmodified.//// - If any Java language code or documentation used in my program// was obtained from another source, such as a text book or course// notes, that has been clearly noted with a proper citation in// the comments of my program.//// - I have not designed this program in such a way as to defeat or// interfere with the normal operation of the grading code.//// <Student's Name>// <Student's VT email PID>We reserve the option of assigning a score of zero to any submission that is undocumentedor does not contain this statement.Change LogVersion Date Page Change(s)6.00 Mar 8 Base document6.10 Mar 11 5 Changes to the hash table requirements to bring it in line with J3; other minor changes ...

April 24, 2022 · 20 min · jiezi

关于算法:LeetCodeGolang-647-回文子串

题目:给你一个字符串 s ,请你统计并返回这个字符串中 回文子串的数目。回文字符串是正着读和倒过去读一样的字符串。子字符串是字符串中的由间断字符组成的一个序列。 具备不同开始地位或完结地位的子串,即便是由雷同的字符组成,也会被视作不同的子串。 示例: 输出: s = "aaa"输入: 6解释: 6个回文子串: "a", "a", "a", "aa", "aa", "aaa"1 <= s.length <= 1000s 由小写英文字母组成题解概述:本题目有两种解题思路,别离是: 枚举出所有的子串,而后再判断这些子串是否是回文;枚举每一个可能的回文核心,而后用两个指针别离向左右两边拓展,当两个指针指向的元素雷同的时候就拓展,否则进行拓展。官网题解中给出了从第二种思路登程的题解,咱们这篇文章次要从第一种思路登程,给出三种办法。这三种办法层层优化,从暴力解法,到应用 动静布局 的解法,再对 动静布局 进行空间上的优化。心愿可能帮忙大家了解 动静布局 的应用办法。题解一:(暴力法)咱们最直观能想到的就是,枚举出所有的子串,而后再判断这些子串是否是回文。上面给出暴力解法的代码(Go): func countSubstrings(s string) int { // 暴力法 工夫复杂度O(n^3) n := len(s) sum := 0 for i := 0; i < n; i++ { for j := i; j < n; j++ { if isPalindromic(s, i, j) { sum++ } } } return sum}func isPalindromic(s string, l int, r int) bool { for l < r { if s[l] != s[r] { return false } l++ r-- } return true}暴力法天然是思考难度最低的解法,置信的加都可能想到。然而咱们能够看到遍历所有子字符串须要破费 O(n^2) 的工夫,对于每个子字符串判断是否为回文须要破费 O(n) 的工夫,那么这个算法的工夫复杂度为 O(n^3) ,显然对于咱们最求性能极致的程序设计师而言,这样的后果无奈承受。接下来咱们将应用 动静布局 的办法进行进一步的优化。 ...

April 23, 2022 · 3 min · jiezi

关于算法:Leetcode-04-Median-of-Two-Sorted-Arrays

[4] Median of Two Sorted ArraysDifficulty: Hard (33.87%) Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). example: Input: nums1 = [1,3], nums2 = [2]Output: 2.00000Explanation: merged array = [1,2,3] and median is 2.Input: nums1 = [1,2], nums2 = [3,4]Output: 2.50000Explanation: merged array = [1,2,3,4] and median is (2 + 3) / 2 = 2.5.为了解决这个问题,首先咱们将其合成为两个字问题 ...

April 22, 2022 · 1 min · jiezi

关于算法:01-背包问题

最近在温习算法常识写下这篇文章帮忙本人了解记忆 01 背包问题01背包问题的指标是在固定的容量限度内,达到最大的物品价值01对含意:无奈宰割物品01背包问题通常有暴力回溯法和动静布局两种形式来解决 Brute Force回溯法查看所有组合 工夫复杂度为指数级很容易工夫就爆表,这里就不看了 动静布局动静布局的外围在于寻找子问题,在这个题中咱们首先去寻找子问题 寻找子问题假如背包最大分量为5物品信息如下 分量价值物品147物品235物品356物品433物品528dp表的每一个地位存储的是这么大的背包,最大收益是多少咱们首先思考,如果只有物品1, 如果装不下,收益就是0如果咱们的背包能够装下,那么最大收益就是7,咱们更新第一行 012345物品1000077物品2 物品3 物品4 物品5 通过解决子问题取得到全局问题的解当初思考物品2,如果装不下,收益就是上一行雷同地位的后果 如果能装下:判断上一行雷同地位的后果 此物品价值加上上一行去掉此物品分量后的分量最多能装的价值由此咱们取得状态转移方程 dp[i][j] = max(dp[i-1][j], dp[i-1][j-weight[i]]+values[i]) 012345物品100 (4 - weight of item 2)0077物品20005max(7, (5 + 0)) 物品3 物品4 物品5 一直迭代 ...

April 22, 2022 · 1 min · jiezi