- 博客(65)
- 资源 (17)
- 收藏
- 关注
原创 python实现模糊匹配
题目:模糊匹配, ‘?’代表一个字符, *代表任意多个字符。给一段明确字符比如avdjnd 以及模糊字符比如*dj?dji?ejj,判断二者是否匹配。若能匹配输出”Yes”, 否则输出“No”(为了方便阅读,代码里面输出Ture or False)解题的思路:通过明确终止条件通过递归的方式求解终止的条件:(1) Str为空 以及 pattern为空或者pattern元素只有[*], 输出T...
2018-10-17 22:39:30 41141 4
原创 【Python代码】给定正整数,在+-*/的情况下,算法实现24点游戏,计算所有的可能
下面回顾一下前两天面试过程中,做的一到笔试题:题目:计算24 点,输入4 个整数,如何计算得到24,输出所有可能的计算方式; 若不能计算得到则输出None。解题思路:由于不考虑顺序, 括号的位置可以认为有两种[(a, b, c)d ] [(a,b),(c,d)],然后递归地遍历所有的情况。里面有两个小点:(1) a+b和b+a的情况一样,可以去掉一部分的计算(2) 主函数中考虑到浮点计算,...
2018-10-17 22:25:12 1422
原创 对图片进行批处理剪切成需要的大小
“`python import argparse import os from PIL import Imagedef resize_image(image, size): “”“Resize an image to the given size.”“” return image.resize(size, Image.ANTIALIAS)def resize_images(
2017-11-16 21:40:02 1467 1
原创 GAN与NLP的结合相关资料汇总与总结
1.记录一次与大神们的关于GAN应用于NLP的讨论(简书)http://www.jianshu.com/p/32e164883eab 总结 - 目前尝试的内容:纯文本生成,诗歌生成,唐诗生成,机器翻译,IR,中文分词,文本分类 - 主要思路:考虑使用D进行真假判别,然后用RL的policy gradient的方式来打分和更新 - 使用word2vec之类的连续向量,微调之后不能
2017-11-16 17:20:28 1398
原创 激活函数-ReLU
1.介绍ReLU(Recitified Linear Unit,ReLU),称为线性整流函数2.常用的线性整流函数斜坡函数 f(x)=max(0,x)f(x)=max(0,x)Leaky ReLU f(x)={xλxififx>0x<=0f(x)=\begin{cases}x &&&if &x>0\\\lambda x &&&if &x<=0\end{cases} 其中λ\lambda是一个
2017-11-16 10:59:44 7146
原创 synergy软件win10和ubuntu16.04局域网下使用一套键盘鼠标系统
1.下载软件下载地址2.安装2.1 Ubuntu下安装解压对应的文件, 在ubuntu下安装.deb文件,打开命令行,输入下面的命令 sudo dpkg -i synergy-master-stable-ec56ac4-Linux-x86_64.deb安装成功之后按一下win键,搜索可以synergy可以找到,进行相关的配置2.2 Win10下安装运行.msi文件即可3.配置3.1 ubun
2017-11-15 15:48:20 3966
原创 机器翻译论文
(2014)Sequence to sequence learning with neural networks(2014)Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation(2015)NEURAL MACHINE TRANSLATION BY JOINTLY
2017-10-25 23:01:45 2450 1
原创 神经机器翻译中的Attention机制
传统的机器翻译系统通常依赖于基于文本统计特性的复杂特征工程,需要投入大量工程大见他们。 神经机器翻译系统NMT,把一句话的意思映射到一个固定长度的特征向量,然后基于此进行翻译。由于NMT不再依赖于n-gram计数,而是捕捉文本更高层的含义。基于encoder-decoder的模型 NMT系统使用RNN将源语句(比如,一句德语)编码为一个向量,然后同样用RNN将其解码为英语。 如上图中,“Echt
2017-10-17 16:41:20 4502
原创 机器翻译的评价标准BLEU(Evaluation criteria for machine translation)
1.概念BLEU(bilingual evaluation understudy)在这篇论文中被提出BLEU: a Method for Automatic Evaluation of Machine Translation BLEU是一种衡量机器翻译质量的评价标准。一种对精确度修改的算法,先看一下下面的句子:2.1例子:n-gram在机器翻译译文和标准答案中出现次数不一致机器翻译的句子:The
2017-09-29 22:19:49 4951
原创 Python 中glob模块使用笔记
1.介绍glob模块用来查找文件目录和文件,常见的两个方法有glob.glob()和glob.iglob(),可以和常用的find功能进行类比,glob支持*?[]这三种通配符2.三种通配符*代表0个或多个字符?代表一个字符[]匹配指定范围内的字符,如[0-9]匹配数字3.例子import globfilelist=glob.glob(r'./*.py')#返回的数据类型是list,#
2017-08-08 14:51:29 14936
原创 Python 使用matplotlib使用并自定义colormap
0.前言添加colormap的对象是灰度图,可以变成热量图,从而更加明显的发现一些规律,适用于一些雷达图像等from PIL import Image# 将彩色图片转换成黑白图片im=Image.open("./pic.jpg").convert('L')# 保存图片im.save("image.jpg")1.从灰色图片中读取数据,转换成colormap图import matplotlib.
2017-08-07 19:55:18 39088 1
原创 Numpy、matplotlib实现二维数据到图像的转换,添加colormap,无边距显示
1.首先需要得到原始图像的大小 从向量shape到矩阵:import numpy as npdata = np.reshape(vector,(101,101))#101*101是要转换成的图片的大小2.转换from PIL import Imagenew_im = Image.fromarray(data.astype(np.uint8))
2017-08-04 21:27:07 3667
原创 Tensorflow学习笔记(5)-网络结构的构建
# -*- coding: utf-8 -*-# @Time : 17-8-4 上午10:57# @Author : 未来战士biubiu!!# @FileName: 5-buildstructure.py# @Software: PyCharm Community Edition# @Blog :http://blog.csdn.net/u010105243/article
2017-08-04 14:31:23 439
原创 Ubuntu16.04使用笔记
1.命令行运行sudo apt install dconf-editor然后运行下面的命令dconf-editor此时会弹出来一个框 2.依次打开 org→\tognome→\togedit→\toperferences→\toencodings 此时右侧修改candidate-encodings的value: ['GB18030', 'UTF-8', 'ISO-8859-15', 'UTF
2017-08-02 16:10:51 2550
原创 Tensorflow学习笔记(4)-mnist(MultilayerConvolutionalNetwork)
# -*- coding: utf-8 -*-# @Time : 17-8-1 下午9:40# @Author : 未来战士biubiu!!# @FileName: 4-mnist(MultilayerConvolutionalNetwork).py# @Software: PyCharm Community Edition# @Blog :http://blog.csdn.
2017-08-01 23:04:15 578
原创 Tensorflow学习笔记(3)-mnist(softmax regression)
# -*- coding: utf-8 -*-# @Time : 17-8-1 下午8:22# @Author : 未来战士biubiu!!# @FileName: 3-nearest neighbor.py# @Software: PyCharm Community Edition# @Blog :http://blog.csdn.net/u010105243/articl
2017-08-01 21:32:13 292
原创 Tensorflow学习笔记(2)-基本运算
# -*- coding: utf-8 -*-# @Time : 17-8-1 下午8:02# @Author : 未来战士biubiu!!# @FileName: 2-basic operation.py# @Software: PyCharm Community Edition# @Blog :http://blog.csdn.net/u010105243/article
2017-08-01 20:20:16 461
原创 Tensorflow学习笔记(1)-Helloworld
# -*- coding: utf-8 -*-# @Time : 17-8-1 下午7:58# @Author : 未来战士biubiu!!# @FileName: 1-tensorflow.py# @Software: PyCharm Community Edition# @Blog :http://blog.csdn.net/u010105243/article/impo
2017-08-01 19:59:25 377
原创 在Pycharm中自动添加时间日期作者等信息
1.按照下面路径以此打开File→\toSettings→\toEditor→\toFile and code Templates 右侧找到Python Script,如下图 2.设置相关代码如下##!/usr/bin/python3# -*- coding: utf-8 -*-# @Time : ${DATE} ${TIME}# @Author : 未来战士biubiu!!#
2017-07-26 17:26:38 20411 4
原创 20170708-leetcode-258-Add Digits
1.DescriptionGiven a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only
2017-07-08 21:45:52 253
原创 20170615-leetcode-409. Longest Palindrome
1.DescriptionGiven a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example "Aa" is
2017-06-15 23:34:04 199
原创 20170613-leetcode-535-Encode and Decode TinyURL
1.Description Note: This is a companion problem to the System Design problem: Design TinyURL.TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-ti
2017-06-13 10:36:33 904
原创 20170611-leetcode-041-First Missing Positive
1.DescriptionGiven an unsorted integer array, find the first missing positive integer.For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses co
2017-06-12 11:25:03 284
原创 20170612-leetcode-575-Distribute Candies
Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute these
2017-06-12 10:32:53 727
原创 20170607-leetcode-189-Rotate Array
1.DescriptionRotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note: Try to come up as many solutions as
2017-06-07 15:41:22 272
原创 20170606-leetcode-581-Shortest Unsorted Continuous Subarray
1.DescriptionGiven an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too.You nee
2017-06-06 11:24:09 546
原创 20170605-leetcode-532-K-diff Pairs in an Array
1.DescriptionGiven an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are bot
2017-06-05 23:17:30 465
原创 20170604-leetcode-460-LFU Cache
1.DescriptionDesign and implement a data structure for Least Frequently Used (LFU) cache. It should support the following operations: get and put.get(key) - Get the value (will always be positive) of t
2017-06-04 23:34:14 454
原创 20170603-leetcode-560-Subarray Sum Equals K
1.DescriptionGiven an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.Example 1:Input:nums = [1,1,1], k = 2 Output: 2Note:The length
2017-06-03 16:16:06 322
原创 20170602-leetcode-211-Add and Search Word - Data structure design
1.DescriptionDesign a data structure that supports the following two operations:void addWord(word) bool search(word)search(word) can search a literal word or a regular expression string containing onl
2017-06-02 22:32:30 353
原创 201705031-leetcode-155-Min Stack
1.DescriptionDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top
2017-05-31 15:30:57 262
原创 Python 正则表达
1.match和search的区别def re_method():# search vs. Matchs = 'abcd'print(re.search(r'c', s))print(re.match(r'c', s))if __name__ == '__main__':re_method()返回值为 <_sre.SRE_Match object; span=(2, 3), match
2017-05-30 20:36:31 544
原创 20170630-leetcode-225 Implement Stack using Queues
1.DescriptionImplement the following operations of a stack using queues. - push(x) – Push element x onto stack. - pop() – Removes the element on top of the stack. - top() – Get the top element. - e
2017-05-30 10:21:12 360
原创 20170529-leetcode-582-Kill process
1.DescriptionGiven n processes, each process has a unique PID (process id) and its PPID (parent process id). Each process only has one parent process, but may have one or more children processes. This
2017-05-29 21:31:45 1063
原创 Window10+Python3.5安装opencv
1.确定Python版本,电脑64位或者32位打开cmd(window键+R,输入cmd就出现),在命令行输入:打开cmd(window键+R,输入cmd就出现),在命令行输入:pythonPython 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win
2017-05-14 16:47:06 11153 3
原创 Java解析XML文件
1.读取文件<?xml version="1.0" encoding="UTF-8"?><books><book id="001"><title>Harry Potter</title><author>J K. Rowling</author><price>$50.2</price></book><book id="002"><title>Learning XML</title><
2017-04-22 11:11:48 400
原创 20170401-leetcode-435-Non-overlapping Intervals
1.DescriptionGiven a collection of intervals, merge all overlapping intervals.For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18]. Given a collection of intervals, merge all ov
2017-04-04 15:40:58 283
原创 Pyton爬虫实现豆瓣登陆
目标:实现豆瓣登陆;修改签名方法:使用requests.Session 来处理cookies问题:验证码输入关于headers 1.实现登陆# -*- coding: utf-8 -*-import requestsfrom HTMLParser import HTMLParserclass DoubanClient(object): def __init__(self):
2017-04-03 20:05:17 1064
原创 python爬虫获取豆瓣正在热播电影
python爬虫获取豆瓣正在热播电影热播地址:https://movie.douban.com/cinema/nowplaying/beijing/1、使用浏览器查看html文件找到热播电影的标签文件查看tag,可以看到最开始的tag为2、HTMLPaser主要用来解析HTTP数据,其中有几个接口feed: 向解析器喂数据,可以分段提供handler_starttag: 处理html的开始标签
2017-04-03 15:46:58 10037 1
原创 20170403-leetcode-349/50-Intersection of Two Arrays.py
两个同类型的题:349/350. 349:1、2;350:3,41.DescriptionGiven two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the
2017-04-03 10:44:44 716
Python实现模糊匹配
2018-10-17
synergy Ubuntu16.04版和window10局域网下使用同一键盘鼠标
2017-11-15
香港城市大学语料库;微软亚洲研究院语料库;北京大学语料库;
2017-06-14
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人