- 博客(67)
- 资源 (1)
- 问答 (1)
- 收藏
- 关注
原创 算法之编程语言
文章目录引用、指针列表、元组is和==引用、指针列表、元组区别:元组不可变,列表可变,元组比列表更安全列表不可作为字典的键,元组可以元组占用内存更小,比列表操作跟快is和==python对象三要素:id、type、valueis比较的是id,即是否为同一对象,位于同一地址,==比较的是值,对于...
2019-02-16 00:47:56 1527
原创 算法总结之机器学习
文章目录Logistics RegressionSVMSVM和LR异同Decision TreeEnsemble LearningBagging—Random ForestBoostingAdaboostGBDTXGBoostLogistics Regression推倒SVMSVM和LR异同仅讨论线性SVM相同:都是线性分类器不同:(1) LR边界由所有样本决定,而SVM的边界是由支...
2019-02-15 21:24:35 126
原创 算法总结之深度学习
文章目录深度网络CNNResNetDensNetVGGBatch Normalization梯度弥散、梯度爆炸RNN、LSTM目标检测RCNNFast RCNNFaster RCNNYOLOSSD深度网络CNNResNet问题:当网络加深,学习效果很差动机:在已存在的浅层网络上加入很多恒等映射层,这样能保证学习效果不差于千层网络,受此启发,提出ResNet解释:(1) 保证信息流动。当...
2019-02-15 18:46:35 615
原创 pandas学习记录
目录前言二、使用步骤1. pandas数据结构1.1 Series1.2 DataFrame2. 使用方法2.1 创建对象2.2 查看数据总结前言提示:这里可以添加本文要记录的大概内容:例如:随着人工智能的不断发展,机器学习这门技术也越来越重要,很多人都开启了学习机器学习,本文就介绍了机器学习的基础内容。一、pandas是什么?Pandas是一个强大的分析结构化数据的工具集;它的使用基础是Numpy(提供高性能的矩阵运算);用于数据..
2021-04-20 23:59:36 316
原创 Jupyter 添加Conda环境
进入某个环境,安装相关包安装ipykernelconda install -c anaconda ipykernel将环境添加到jupyter lab中python -m ipykernel install --user --name=myEnv启动jupyter, 在.ipynb文件中就能看到添加的环境
2021-02-23 10:21:33 155
原创 搭建cuda环境
1 安装驱动1.1 前期工作1.1.1 禁用nouveauubuntu 16.04默认安装了第三方开源的驱动程序nouveau,安装nvidia显卡驱动首先需要禁用nouveau,不然会碰到冲突的问题,导致无法安装nvidia显卡驱动。指令如下sudo gedit/etc/modprobe.d/blacklist.conf 打开文件,在最后添加如下两行:blacklist nouveauoptions nouveau modeset=01.1.2 更新系统修改sudo u..
2021-02-06 19:45:44 310
原创 pytorch安装及faster-rcnn.pytorch使用记录
目前所处的办公环境限制较多,对搭建开发环境造成较大阻碍,在安装pytorch时, pip和conda库不能及时更新,很多时候需要手动安装。在这样的背景下,本文记录pytorch和faster-rcnn.pytorch 的在使用过程中的问题。1. pytorch的安装pytorch的安装首先需要确定安装的版本,其次要明确当前cuda的版本,最后还要知道所使用的python版本。一般来讲,如果使用官方库安装,安装的pytorch应该是在对应版本的cuda下编译的,但是由于本人所处的环境,pip和conda库
2020-10-13 11:21:45 326 1
原创 torchvision transform巨坑
最近用到torchvision.transform.Normalize,发现不同版本对输入的改变不同,下面对比torchvision 0.2.1和0.4.2版本0.2.1:def normalize(tensor, mean, std): """Normalize a tensor image with mean and standard deviation. See ``Normalize`` for more details. Args: tensor (Te
2020-08-24 15:28:39 644
原创 mmcv 安装记录
安装mmcv,我选择的是源码安装,按照官方给出的步骤,运行命令MMCV_WITH_OPS=1 pip install -e .出现错误提示,如下:distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse(‘pytest-runner’)于是安装pytest-runner:pip install pytest-runner随后再次运行安装命令,仍然出现错误,于是
2020-07-18 14:55:55 5883 11
原创 LeetCode124 最大路径和
给定一个非空二叉树,返回其最大路径和。本题中,路径被定义为一条从树中任意节点出发,达到任意节点的序列。该路径至少包含一个节点,且不一定经过根节点。示例 1:输入: [1,2,3] 1 / \ 2 3输出: 6示例2:输入: [-10,9,20,null,null,15,7] -10/ \9 20/ ...
2019-10-19 22:13:24 142
原创 开放问题
top k问题一般采用hash统计频率,再来使用堆排序,如果有内存大小限制,则采用分堆的思想,对数字使用比特位,对字符使用hash值除以一个值来分堆,这样相同的元素都在一个堆里面。...
2019-07-07 17:23:21 154
原创 字符串排列相关
All possible permutations of a stringdef permutation(prefix, s): if len(s) == 0: print(prefix) else: visit = set() for i in range(len(s)): if s[i] in vis...
2019-04-26 17:46:48 110
原创 有序数组的交集和并集
define two indexs starting from 0 for the arrays. Compare values the two indexs referring to, and move the indexs under each condition.The union of two sorted arraysdef union(list1, list2): l1...
2019-04-26 16:58:13 488
原创 随机数、概率题
由rand5 (0-4)生成rand7 (0-6)res = 5*rand5 + rand5,这样生成0-24之间的数,能够保证每个数的概率相同,取0-20之间的数,舍弃后面的,然后输出res%7即为rand7的效果扩展:由randA (0-a)生成randB (0-b)若a>b,直接返回0-b之间的数即可;若a<b,res=(a+1)*randA+randA,若res仍小于...
2019-03-25 22:10:27 466
原创 修桌子
Arthur最近搬到了新的别墅,别墅特别大,原先的桌子显得比较小,所以他决定换一张新的桌子。他买了一张特别大的桌子,桌子是由很多条桌腿进行支撑的,可是回到家之后他发现桌子不稳,原来是桌子腿长度不太相同。他想要自己把桌子修理好,所以他决定移除掉一些桌腿来让桌子变得平稳。桌子腿总共有n条腿,第i条腿长度为li,Arthur移除第i桌腿要花费代价为di。假设k条腿桌子平稳的条件:超过一半桌腿能够达...
2019-03-25 13:25:23 312
原创 LeetCode 290: Word Pattern
Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.Example ...
2019-03-15 17:17:22 95
原创 LeetCode 213: House Robber II
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is ...
2019-03-10 13:25:31 68
原创 LeetCode 198: House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house...
2019-03-10 13:23:38 110
原创 LeetCode 69: Sqrt(x)
Implement int sqrt(int x).Compute and return the square root of x, where x is guaranteed to be a non-negative integer.Since the return type is an integer, the decimal digits are truncated and only t...
2019-03-06 22:23:47 188
原创 LeetCode 229: Majority Element II
Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.Note: The algorithm should run in linear time and in O(1) space.Example 1:Input: [3,2,3]Output: [3]Example...
2019-02-28 23:23:15 120
原创 LeetCode 169: Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element alway...
2019-02-28 23:10:12 123
原创 LeetCode 191: Number of 1 Bits
n & (n-1) can remove the last zero 1 in binary format.class Solution(object): def hammingWeight(self, n): """ :type n: int :rtype: int """ res = 0 ...
2019-02-28 00:12:51 132
原创 LeetCode 101: Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But ...
2019-02-27 23:30:23 148
原创 两数相加,不用加减乘除
写一个函数,求两个整数之和,要求在函数体内不得使用+、-、*、/四则运算符号。相加从二进制的角度理解:和为异或结果,如果与运算结果左移为0则输出结果,否则相加的和和与运算向左移继续执行以上。class Solution: def Add(self, num1, num2): while num2!=0: temp=num1^num2 ...
2019-02-25 17:22:32 289
原创 LeetCode 2: Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i...
2019-02-25 16:12:24 103
原创 LeetCode 43: Multiply Strings (大数相乘)
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.Example 1:Input: num1 = "2", num2 = "3"Output: "6"Example 2..
2019-02-25 14:18:55 300
原创 之字形打印二叉树
请实现一个函数按照之字形打印二叉树,即第一行按照从左到右的顺序打印,第二层按照从右至左的顺序打印,第三行按照从左到右的顺序打印,其他行以此类推。类似于层次遍历,只是需要判断奇偶层,如果为偶数层则需要反序输出Common methodclass Solution: def Print(self, pRoot): # write code here i...
2019-02-24 00:01:08 461
原创 LeetCode 392: Is Subsequence
Given a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) string, ...
2019-02-22 22:20:23 74
原创 LeetCode 5: Longest Palindromic Substring
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example 1:Input: "babad"Output: "bab"Note: "aba" is also a valid answer.Example...
2019-02-22 22:15:56 132
原创 LeetCode 94: Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes’ values.Example:Input: [1,null,2,3] 1 \ 2 / 3Output: [1,3,2]Iterationclass Solution: def inorderTraversal...
2019-02-20 13:20:27 140
原创 Print linked list in reverse order
Recursionclass Solution: # 返回从尾部到头部的列表值序列,例如[1,2,3] def printListFromTailToHead(self, listNode): # write code here if listNode: return self.printListFromTailToHe...
2019-02-19 00:18:51 191
原创 Reconstruct binary tree
输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。Recursion is used to solve this problemclass Solution: # 返回构造的TreeNode根节点 ...
2019-02-19 00:09:11 478
原创 LeetCode 3: Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.Example 1:Input: "abcabcbb"Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2:Inpu...
2019-02-17 22:24:46 71
原创 LeetCode 26: Remove Duplicates from Sorted Array
Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifyin...
2019-02-17 21:46:57 196
原创 LeetCode 121: Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), ...
2019-02-16 23:37:21 112
原创 LeetCode 53: Maximum Subarray
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output: 6Explanation:...
2019-02-16 23:34:20 97
原创 LeetCode 718: Maximum Length of Repeated Subarray
Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays.Example 1:Input:A: [1,2,3,2,1]B: [3,2,1,4,7]Output: 3Explanation: The repeated subarray wi...
2019-02-16 23:20:47 88
原创 最大差值
有一个长为n的数组A,求满足0≤a≤b<n的A[b]-A[a]的最大值。给定数组A及它的大小n,请返回最大差值。测试样例:[10,5],2返回:0Greedy algorithm is used in this problem. The max difference is gotten in each step. max[i] = array[i] - minimum value...
2019-02-16 22:46:23 435
原创 LeetCode 442: Find All Duplicates in an Array
Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it without extra sp...
2019-02-16 20:47:24 118
原创 LeetCode 448: Find All Numbers Disappeared in an Array
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array.Could ...
2019-02-16 20:41:06 98
js调用的发http请求的插件
2016-05-26
TA创建的收藏夹 TA关注的收藏夹
TA关注的人