自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 numpy.pad()和numpy.transpose()用法

一、卷积神经网络中,在卷积之前经常进行zero-padding操作,其底层实现可以用numpy.pad()函数来实现>>> a=np.array([[1,1],[1,1]])>>> aarray([[1, 1], [1, 1]])>>> np.pad(a,((1,),(1,)),'constant')array([[...

2018-10-17 16:48:05 235

原创 Numpy中argsort()、bincount()、argmax()函数用法

 np.argsort():可以对数组排序并返回排序后数据的下标,默认为从小到达的排序>>> import numpy as np>>> a = [1,2,3,4,2,3,1]>>> a = np.array(a)>>> order = np.argsort(a)>>> order

2018-09-27 22:19:28 787

原创 Python Opencv学习笔记

Python使用Opencv首先要导入包cv2import cv2一、图片读取img = imread("")二、获取图片尺寸img = imread("")print(img.shape)三、在图片中画矩形框img = cv2.imread("img_1001.jpg")cv2.rectangle(img, (20,242), (390,305), (0, 255,0),5)plt.i...

2018-07-11 14:26:45 292

原创 笔记:约束问题的最优化:拉格朗日乘子法、KKT条件

约束条件可以分为:(1)等式约束、(2)不等式约束等式约束的优化问题,可直接使用拉格朗日乘子法去求最优解;不等式约束的优化问题,可以转化为满足KKT约束条件下应用拉格朗日乘子法求解。其次,拉格朗日求得的不一定是最优解,只有在凸优化的情况下,才能保证得到的是最优解,否则可能是局部解无约束优化 对于变量x属于R ,需求问题:根据Fermat定理,对该函数求导,找到使其导数为0的点,即如果不存在此点,可...

2018-07-09 21:29:08 1420

转载 机器学习——参数和超参数

参数:从训练数据中学习出的变量。    如,网络中的权重,偏差等超参数:就是用来确定模型的一些参数,超参数不同,模型是不同的。超参数一般就是根据经验确定的变量。    (choice about the algorithm that we set rather than learn)这些参数无法直接从数据中学习到,需要我们设置   在深度学习中,超参数有:学习速率,迭代次数,层数,...

2018-05-05 18:08:34 1742

转载 Python--yield理解

yield 的作用就是把一个函数变成一个 generator,带有 yield 的函数不再是一个普通函数,Python 解释器会将其视为一个 generator,调用将不会执行函数,而是返回一个 iterable 对象!def Generator() : list = range(3) for i in list : yield i*i运行:结果:运行:结果:第一次...

2018-05-04 20:57:23 148

原创 python--计算两个中文字符串的编辑距离

#计算两个中文字符串的编辑距离def levenshtein(string1,string2): if len(string1) > len(string2): string1,string2 = string2,string1 if len(string1) == 0: return len(string2) if len(str...

2018-05-04 17:04:15 3189

原创 python 将txt内容导入 mysql(pyhton3.6 pymysql模块)

import pymysqlf = open('class','r')header = Trueconn = pymysql.connect('localhost','root','your password','database',charset = 'utf8')cur = conn.cursor()m = f.readlines()for lines in m: line...

2018-04-23 20:50:20 2846

转载 矩阵求导学习记录

西瓜书中,利用最小二乘法来对多元线性回归中的w和b进行估计。∂(y−Xw)T(y−Xw)∂w∂(y−Xw)T(y−Xw)∂w∂(y−Xw)T(y−Xw)∂w需对下式进行偏导说明: y、w为列向量,X为矩阵此为矩阵之间的求导,与大学课本中多项式的求导不同,故查询了一下求导方法以此记录矩阵的求导多通过查表来选择方法维基百科 Matrix calculus表中将各种情况的矩阵的求导公式都一一列出。针对上...

2018-04-07 17:51:52 255

原创 【leetcode】Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".#Approach one: Bit Manipulationdef addBinary(self, a, b): """ :type a: str ...

2018-04-05 21:51:38 87

原创 【leetcode】Perfect Number

We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself.Now, given an integer n, write a function that returns true when it is a perfect ...

2018-04-05 16:33:52 145

原创 [leetcode]Arranging Coins

You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins.Given n, find the total number of full staircase rows that can be formed.n is a n...

2018-04-04 14:11:21 110

转载 【leetcode】Ugly Number

Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors (因子)only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since ...

2018-04-03 23:39:42 90

转载 [leetcode]Happy Number

Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of ...

2018-04-03 23:10:38 79

原创 Assign Cookies

#Approach one :O(nlogn)--greedy solutiondef findContentChildren(self, g, s): """ :type g: List[int] :type s: List[int] :rtype: int """ g.sort() ...

2018-03-31 21:52:38 93

转载 Whether the Array contains duplicate

It should return false if every element is distinct#Approach one: Linear Searchdef containsDuplicate(self, nums): """ :type nums: List[int] :rtype: bool """ for...

2018-03-30 21:35:37 100

空空如也

空空如也

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

TA关注的人

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