python
hlllllllll
这个作者很懒,什么都没留下…
展开
-
python数据结构——单调栈和单调队列
单调栈数据结构栈遵循先进后出的原则,在python中,利用list就可以实现栈的功能stack = []stack.append(1)stack.append(2)print(stack.pop()) #2单调栈遵循单调增或者单调减的原则,用于处理某些特别的任务,也就是常说的next greater element的问题。class MStack: def __init__(self): self.stack = [] def push(self, value): while原创 2021-05-31 21:58:52 · 1494 阅读 · 0 评论 -
python与数据结构——LRU缓存
LRU缓存机制LRU缓存机制有几个特点:缓存cache是带有容量的缓存必须有顺序之分,以区分最近使用和久未使用的数据(读数据也算使用)读和写数据都比如快,时间复杂度为O(1)为达到上述目的,LRU缓存算法的核心数据结构就是哈希链表,即双向链表和哈希表的结合。双向链表维护的是使用数据的顺序关系,哈希表方便读写操作。# 双向链表class ListNode: def __init__(self, key=None, value=None): self.key = key原创 2021-05-31 10:19:36 · 278 阅读 · 0 评论 -
pyinstaller failed to execute script pyi rth pkgres
pip uninstall pyinstallerpip install https://github.com/pyinstaller/pyinstaller/archive/devel原创 2020-05-19 22:08:10 · 707 阅读 · 0 评论 -
特征选择方法和sklearn中的特征选择应用
数据类型可用方法连续-连续相关系数、假设检验连续-离散相关系数、连续二值化(最小Gini切分、最大熵增益切分)连续-离散相关系数(定序)连续-离散相关系数,熵相关、F分值离散-离散(非二值)熵相关、Gini、相关系数(定序)...原创 2019-08-05 16:41:57 · 675 阅读 · 0 评论 -
神经网络部署--网络压缩技术Network Compression
1 network pruningnetwork pruning技术的思路是:训练一个大的神经网络→评价网络中参数和神经元的重要度→根据重要度排序,移除不重要的weight和神经元(置0)为什么要训练一个大的网络再压缩,而不是直接训练一个小的网络呢?因为研究表明,大的网络比较容易训练,效果也更好。2 knowledge distillation训练一个大的,效果好的神经网络→训练一个小...原创 2020-04-07 11:29:23 · 729 阅读 · 0 评论 -
win10环境下pip install安装报错`OSError:raw write() returned invalid `
参考此链接:https://bugs.python.org/issue32245#msg308012好像是说终端的编码造成的,查看pycharm的Terminal终端chcp,显示936,即美国编码。使用 chcp 65001,改为utf-8编码,依旧报错。使用powershell激活当前虚拟环境,使用 chcp 65001,将当前编码换成utf-8,然后再安装就可以了...转载 2020-03-26 16:13:45 · 387 阅读 · 0 评论 -
python设计模式
单例模式保证某个类在全局只存在一个实例class Singleton: def __new__(cls,*args,**kwargs): if not hasattr(cls,'_instance'): cls._instance= super().__new__(cls,*args,**kwargs) return cls._instance def __init__(se...原创 2019-12-13 15:06:20 · 114 阅读 · 0 评论 -
leetcode:59. Spiral Matrix II
ProblemGiven a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.Example:Input: 3Output:[[ 1, 2, 3 ],[ 8, 9, 4 ],[ 7, 6, 5 ]]Solution解法类似于旋转取值,只...原创 2019-12-05 10:29:27 · 109 阅读 · 0 评论 -
leetcode:57. Insert Interval
ProblemGiven a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times....原创 2019-12-03 09:48:40 · 107 阅读 · 0 评论 -
leetcode:56. Merge Intervals
ProblemGiven a collection of intervals, merge all overlapping intervals.Example 1:Input: [[1,3],[2,6],[8,10],[15,18]]Output: [[1,6],[8,10],[15,18]]Explanation: Since intervals [1,3] and [2,6] ove...原创 2019-12-01 21:34:08 · 135 阅读 · 0 评论 -
leetcode:55. Jump Game
ProblemGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine...原创 2019-11-29 17:40:06 · 117 阅读 · 0 评论 -
leetcode-54. Spiral Matrix
problemGiven a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.Example 1:Input:[[ 1, 2, 3 ],[ 4, 5, 6 ],[ 7, 8, 9 ]]Output: [1,2,3,6,9,8,7,4,5]...原创 2019-11-28 15:19:32 · 140 阅读 · 0 评论