03 2019 档案
摘要:'''找出数组的第k大的数:[6,7,8,9, 3, 2, 4, 8]第3大的数是4'''class Solution: def call(self, nums, k): if nums ==...
阅读全文
摘要:class Solution: ''' 找到数组中结果与k接近的3个元素 ''' def threeSumClosest(self, numbers, target): # ...
阅读全文
摘要:'''在数组中找到3个元素的索引,满足和为k,且找到多个解'''class Solution: def call(self, nums, target): ''' 在nums中找...
阅读全文
摘要:'''找出数组中和为某个数的两个数的序号思路:和为k等价与k-a=b,建立字典,遍历每个元素ai如果k-ai不存在字典中就记下ai的位置i来,到下一个数如果k-aj=ai在字典中,那么结果就是(i,j)'''cl...
阅读全文
摘要:'''Given an unsorted integer array, find the smallest missing positive integer.Example 1:Input: [1,2,0]Out...
阅读全文
摘要:'''1:用一个变量right保存 left and nums[right] > k: right -= 1 if left < right: ...
阅读全文
摘要:'''除了数字本身的其它数累乘,替换本身数字'''class Solution: def productExcludeItself(self, nums): nums_size = len(n...
阅读全文
摘要:class Solution: """ @param nums: The rotated sorted array @return: nothing """ def recoverR...
阅读全文
摘要:来源于课程:http://www.tensorinfinity.com/index.php?r=space/viewmedia&lesson_id=105&id=11621 总体层次通常就是由输入(一般是矩阵形式...
阅读全文
摘要:data = [16, 25, 39, 27, 12, 8, 45, 63]SIZE = len(data)def show(data): for i in range(len(data)): ...
阅读全文
摘要:原理:https://blog.csdn.net/u013384984/article/details/79496052Python实现:def sort(array): # 遍历非叶子节点 for ...
阅读全文
摘要:保存: model = LinearRegression()# ......各种操作model.eval()#训练完成,保存状态字典到linear.pkltorch.save(model.state_dict()...
阅读全文
摘要:来自:https://morvanzhou.github.io/tutorials/machine-learning/torch/3-05-train-on-batch/ import torchimport t...
阅读全文
摘要:1.前向传播引用一个网站的图:具体来说,就是2行代码,图片中的f为激活函数,这里用sigmoid作为激活函数,事实上有很多其它的套路,这里只讲神经网络的数学原理及初级使用,不会做任何深入扩展:def feedf...
阅读全文
摘要:1.概念特征选择是一个重要 “数据预处理”过程,机器学习任务中,获得数据之后通常先进行特征选择,此后再训练学习器。特征选择需要确保不丢失重要特征。“无关特征”:与当前学习任务无关;“冗余特征”:所包含信息能从其它...
阅读全文
摘要:1.PCA主成分分析PCA是不考虑样本类别输出的无监督降维技术,实现的是高维数据映射到低维的降维。PCA原理这个介绍的不错:https://www.cnblogs.com/pinard/p/6239403.htm...
阅读全文
摘要:class list_node: def __init__(self): self.val = 0 self.next = Nonehead = [list_node] * 6...
阅读全文
摘要:目录1.聚类概念2.聚类结果的“好坏”评价指标2.1外部指标2.2内部指标2.3距离的计算3聚类类算法3.1 k均值算法3.2 LVQ学习向量量化算法3.3 高斯混合GMM3.3.1EM算法3.3.2 GMM中参...
阅读全文
摘要:import numpy as npimport matplotlib.pyplot as pltdef height(x, y): return (1 - x / 2 + x ** 5 + y ** 3)...
阅读全文
摘要:'''Given an array and a value, remove all occurrences of that value in place and return the new length.The...
阅读全文
摘要:'''Given an integer array, find a subarray where the sum of numbers is zero.Your code should return the in...
阅读全文
摘要:import hashlib# hash转换print(hash('aa'))print(hash('aa'))print(hash(111))print(hash(str([1, 2, 3, 4])))# md...
阅读全文
摘要:from queue import PriorityQueueclass Job(object): def __init__(self, priority, description): sel...
阅读全文

浙公网安备 33010602011771号