自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(119)
  • 收藏
  • 关注

原创 Transformer详解(李沐大神文字版,干货满满!)

使用图和文字记录下了李沐大神的Transformer论文逐段精度视频,方便大家后续快速复习。

2023-03-09 10:19:13 4710 5

原创 深入解析Tensor索引中的Indexing Multi-dimensional arrays问题

写在前面最近小弟做了一些实验,但是发现我写的代码虽然能够跑通,但是对于gpu的利用率始终在一个比较低的水平,这就很难受,别人的代码2h就跑完了,我得10h,经过排查发现究其原因就是代码的并行化成都不高,在代码中使用了大量的for循环,没有采用矩阵运算,就导致计算非常的慢,于是最近在学习一些大神的代码,遇到了这个在Tensor中的Indexing Multi-dimensional arrays问题。前置知识在解决这个问题之前,需要了解torch中的boardcast机制,详情可见pytorch官网。

2022-05-15 18:49:49 1407 2

原创 使用IPython在服务器上打断点(交互式编程)

写在前面自从本地的显卡已经不能满足模型的计算需求过后,小弟我就只能在服务器上训练自己的模型,但是其debug实在是令人头大,由于无法像在本地一样打断点,我只能笨笨的print参数的维度来查看自己是否写错,或者运行一波再查看报错信息,这是在是太拉了。我也尝试过在本地使用服务器的显卡运行代码,这样可以打断点,但是由于其内存占用太高,导致非常卡顿,debug的效果也不理想。所以最近有时间就来寻找一些亲民的debug方法。目前已找到一个,日后会持续更新。IPython本次介绍的方法就是使用IPython这个库

2022-02-08 17:50:01 1538 4

原创 在PyCharm中使用git上传项目(看了不会来找我)

写在前面不知道是不是倒霉区up看多了,导致我现在也倒霉。几天前我电脑的硬盘突然爆炸,导致我费了很大的劲才把数据全部找回,虽然之前我也有备份的习惯,但是都是物理备份,拷到我的移动硬盘上,但是要是哪天电脑硬盘和移动硬盘全爆炸了那直接人没了,所以思考良久还是要云端备份一波,所以就记录了一下对于一个纯小白萌新如何一步步成功把项目上传到GitHub上的,中间也踩了一些坑,都记录下来了。前置工作有GitHub账号,有pycharmGit的下载与安装直接到官网进行下载双击exe进行安装,一直无脑next

2022-01-29 20:22:39 8383 17

原创 1114 Family Property (25 分)(并查集模板)

This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we need to know the size of each f...

2019-02-28 16:09:02 219

原创 1122 Hamiltonian Cycle (25 分)(图论)

The "Hamilton cycle problem" is to find a simple cycle that contains every vertex in a graph. Such a cycle is called a "Hamiltonian cycle".In this problem, you are supposed to tell if a given cycle ...

2019-02-27 20:42:00 302 1

原创 1126 Eulerian Path (25 分)(dfs,连通图)

In graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similarly, an Eulerian circuit is an Eulerian path which starts and ends on the same vertex. They were firs...

2019-02-27 19:24:06 142

原创 1130 Infix Expression (25 分)(dfs,数的遍历,中序)

Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators.Input Specification:Each input file contai...

2019-02-27 17:17:10 156

原创 1134 Vertex Cover (25 分)(hash散列)

A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell if e...

2019-02-27 16:32:53 181

原创 1138 Postorder Traversal (25 分)(树的先序中序转后序)

Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to output the first number of the postorder traversal se...

2019-02-26 20:16:58 160

原创 1147 Heaps (30 分)(层序转后序,堆,树的遍历)

In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (i...

2019-02-26 18:13:41 143

原创 1146 Topological Order (25 分)(拓扑排序)

This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order obtained from the given directed graph? Now you are supposed to write a program to test...

2019-02-25 21:09:06 121

原创 1145 Hashing - Average Search Time (25 分)(哈希散列,平方探测法)

The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer keys from the table and output the average sea...

2019-02-25 20:31:50 215

原创 1151 LCA in a Binary Tree (30 分)(数的遍历,LCA算法)

The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.Given any two nodes in a binary tree, you are supposed to find their LCA.In...

2019-02-25 20:00:44 220

原创 1150 Travelling Salesman Problem (25 分)(图论,连通图)

The "travelling salesman problem" asks the following question: "Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city and retu...

2019-02-25 18:32:28 164

原创 1094 The Largest Generation (25 分)(树的遍历,BFS,DFS)

A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population.Input ...

2019-02-22 14:04:58 132

原创 1093 Count PAT's (25 分)(逻辑题,水题)

The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and the 6th characters.Now ...

2019-02-22 13:02:03 269

原创 1092 To Buy or Not to Buy (20 分)(Hash散列)

Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the owner of the shop would only sel...

2019-02-22 12:47:47 115

原创 1091 Acute Stroke (30 分)(BFS)

One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to c...

2019-02-22 12:43:22 205

原创 1090 Highest Price in Supply Chain (25 分)(树的遍历,dfs)

A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on th...

2019-02-22 12:23:06 157

原创 1089 Insert or Merge (25 分)(插入还是归并)

According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data,...

2019-02-22 11:57:05 318

原创 1088 Rational Arithmetic (20 分)(分数四则运算)

For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient.Input Specification:Each input file contains one test c...

2019-02-22 11:40:07 214

原创 1087 All Roads Lead to Rome (30 分)(Dijksrtra+DFS,最短路径)

Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness.Input Specification:Each ...

2019-02-22 11:09:43 170

原创 1086 Tree Traversals Again (25 分)(树的遍历,前中序转后序)

An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, the stac...

2019-02-21 02:14:34 133

原创 1085 Perfect Sequence (25 分)(二分法)

Given a sequence of positive integers and another positive integer p. The sequence is said to be a perfect sequence if M≤m×p where M and m are the maximum and minimum numbers in the sequence, respecti...

2019-02-21 01:42:20 300

原创 1084 Broken Keyboard (20 分)(Hash散列,字符串)

On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.Now given a string that you are supposed to...

2019-02-21 01:17:02 115

原创 1083 List Grades (25 分)(排序,水题)

Given a list of N student records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the grades ...

2019-02-21 00:53:55 149

原创 1081 Rational Sum (20 分)(分数四则运算,gcd辗转相除)

Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum.Input Specification:Each input file contains one test case. Each case starts with a positive int...

2019-02-21 00:40:07 158

原创 1080 Graduate Admission (30 分)(排序,set)

It is said that in 2011, there are about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could write a program to automate the admission...

2019-02-21 00:17:03 185

原创 1079 Total Sales of Supply Chain (25 分)(DFS,BFS,树的遍历)

A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on th...

2019-02-20 22:50:38 161

原创 1077 Kuchiguse (20 分)(字符串,getchar)

The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called ...

2019-02-20 20:37:35 193

原创 1076 Forwards on Weibo (30 分)(图的遍历,BFS)

Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with followers relations. When a ...

2019-02-19 22:06:57 109

原创 1075 PAT Judge (25 分)(排序)

The ranklist of PAT is generated from the status list, which shows the scores of the submissions. This time you are supposed to generate the ranklist for PAT.Input Specification:Each input file co...

2019-02-19 19:48:21 95

原创 1074 Reversing Linked List (25 分)(链表)

Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K=3, then you must output 3→2→1→6→5→4; if K=4,...

2019-02-19 19:46:48 223

原创 1073 Scientific Notation (20 分)(字符串处理)

Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [+-][1-9].[0-9]+E[+-][0-9]+ which means that the inte...

2019-02-19 19:28:39 165

原创 1072 Gas Station (30 分)(dijkstra,字符串处理)

A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the hou...

2019-02-19 17:42:04 163

原创 1071 Speech Patterns (25 分)(map,STL)

People often have a preference among synonyms of the same word. For example, some may prefer "the police", while others may prefer "the cops". Analyzing such patterns can help to narrow down a speaker...

2019-02-19 09:37:54 97

原创 1070 Mooncake (25 分)(贪心)

Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the region's culture. Now ...

2019-02-19 09:13:56 168

原创 1069 The Black Hole of Numbers (20 分)(cmp函数,insert,字符串处理)

For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decreasing order, a new number can be obtained by takin...

2019-02-19 08:50:16 261

原创 1067 Sort with Swap(0, i) (25 分)(贪心,环)

Given any permutation of the numbers {0, 1, 2,..., N−1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation that is allowed to use? For example, to sort {4, 0, 2...

2019-02-19 08:38:42 111

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除