摘要: 在机器学习中,我们常常会遇到不均衡的数据集。比如癌症数据集中,癌症样本的数量可能远少于非癌症样本的数量;在银行的信用数据集中,按期还款的客户数量可能远大于违约客户的样本数量。 比如非常有名的德国信用数据集,正负样本的分类就不是很均衡: 如果不做任何处理简单地进行训练,那么训练结果中(以SVM为例), 阅读全文
posted @ 2018-08-22 21:27 rgvb178 阅读(2474) 评论(0) 推荐(0) 编辑
摘要: 原文地址:http://www.cnblogs.com/rgvb178/p/6055213.html 版权声明:本文为博主原创文章,未经博主允许不得转载。 激活函数的作用 首先,激活函数不是真的要去激活什么。在神经网络中,激活函数的作用是能够给神经网络加入一些非线性因素,使得神经网络可以更好地解决较 阅读全文
posted @ 2016-11-11 23:07 rgvb178 阅读(62603) 评论(6) 推荐(9) 编辑
摘要: 一、卷积 卷积神经网络(Convolutional Neural Networks)是一种在空间上共享参数的神经网络。使用数层卷积,而不是数层的矩阵相乘。在图像的处理过程中,每一张图片都可以看成一张“薄饼”,其中包括了图片的高度、宽度和深度(即颜色,用RGB表示)。 在不改变权重的情况下,把这个上方 阅读全文
posted @ 2016-11-07 23:22 rgvb178 阅读(4531) 评论(2) 推荐(4) 编辑
摘要: 引入 快慢指针经常用于链表(linked list)中环(Cycle)相关的问题。LeetCode中对应题目分别是: 1. "141. Linked List Cycle" 判断linked list中是否有环 1. "142. Linked List Cycle II" 找到环的起始节点(entr 阅读全文
posted @ 2018-10-23 11:44 rgvb178 阅读(1080) 评论(1) 推荐(0) 编辑
摘要: 本博客属个人学习笔记,如有疏漏,欢迎在评论留言指出~转载请注明。 在自然语言处理中,TFIDF常常被人提及。很多材料都提及TFIDF中的“普遍重要性”,但很少有材料去简单解释其中的原理。TFIDF其实分为两个部分:TF与IDF。 (1)词频 TF TF即Term Frequency,中文也叫词频。这 阅读全文
posted @ 2018-08-02 00:24 rgvb178 阅读(826) 评论(0) 推荐(0) 编辑
摘要: Keyword: Reject Inference Suppose there is a dataset of several attributes, including working conditions, credit history, and property, that have been 阅读全文
posted @ 2018-06-14 09:55 rgvb178 阅读(269) 评论(0) 推荐(0) 编辑
摘要: References: 1. Stanford University CS97SI by Jaehyun Park 2. Introduction to Algorithms 3. Kuangbin's ACM Template 4. Data Structures by Dayou Liu 5. 阅读全文
posted @ 2018-01-26 15:00 rgvb178 阅读(277) 评论(0) 推荐(0) 编辑
摘要: 1. 思路 这题实际上是个几何问题——两个外相切的圆,由勾股定理,他们的纵坐标有以下的规律: 则有$$y_{n+1} = y_{n} + \sqrt{(2r)^2 - (x_{n} - x_{n+1})^2}$$ 其中x代表横坐标,y代表纵坐标,r代表半径。 简略画了个图: 2. 容易错的地方 非常 阅读全文
posted @ 2018-01-25 10:25 rgvb178 阅读(289) 评论(0) 推荐(0) 编辑
摘要: 1. 题目描述Description Link: https://leetcode.com/problems/majority-element/description/ Given an array of size n, find the majority element. The majority 阅读全文
posted @ 2017-12-12 09:27 rgvb178 阅读(369) 评论(0) 推荐(0) 编辑
摘要: 1) Link to the problem: http://codeforces.com/contest/888/problem/C 2) Description: You are given a string s consisting of lowercase Latin letters. Ch 阅读全文
posted @ 2017-11-13 13:18 rgvb178 阅读(403) 评论(0) 推荐(0) 编辑
摘要: 1. 问题 231. Power of Two: 判断一个整数是否是2的n次方,其中n是非负整数 342. Power of Four: 判断一个整数是否是4的n次方,其中n是非负整数 326. Power of Three: 判断一个整数是否是3的n次方,其中n是非负整数 2. 思路 1)2的n次 阅读全文
posted @ 2017-08-30 01:46 rgvb178 阅读(606) 评论(0) 推荐(0) 编辑
摘要: 1. 题目:https://leetcode.com/problems/reverse-words-in-a-string-iii/discuss/ 反转字符串中的所有单词。 2. 思路: 这题主要是要注意空格的影响。比方说,string首尾和单词之间可能有一或多个空格。看到有人逐个对空格判断,但是 阅读全文
posted @ 2017-08-27 02:51 rgvb178 阅读(711) 评论(0) 推荐(0) 编辑
摘要: 1. 题目链接:https://leetcode.com/problems/hamming-distance/description/ 2.思路 常规做法做完看到评论区一个非常有意思的做法。用了n&=(n-1),这个地方的意思是,将最右边的1变成0。比方说: 最简单的例子: 原数字: 101011 阅读全文
posted @ 2017-08-26 07:04 rgvb178 阅读(621) 评论(0) 推荐(0) 编辑
摘要: 1. 题目大意 根据给定矩阵,重塑一个矩阵,r是所求矩阵的行数,c是所求矩阵的列数。如果给定矩阵和所求矩阵的数据个数不一样,那么返回原矩阵。否则,重塑矩阵。其中两个矩阵中的数据顺序不变(先行后列)。 2. 思路 由于矩阵中数据顺序不变,因此我们考虑按顺序做。原矩阵中的第i行第j列(从0开始)的数据可 阅读全文
posted @ 2017-08-26 06:43 rgvb178 阅读(598) 评论(1) 推荐(0) 编辑
摘要: 问题的出现 Question 这个问题是我基于TensorFlow使用CNN训练MNIST数据集的时候遇到的。关键的相关代码是以下这部分: 学习速率是$(1e 4)$的时候是没有问题,但是当我把学习速率调到$0.01/0.5$的时候,很快就会报错。 分析 Analysis 学习速率 Learning 阅读全文
posted @ 2017-07-24 04:33 rgvb178 阅读(4131) 评论(0) 推荐(0) 编辑
摘要: 原题 [原题链接][1] Description: Count the number of prime numbers less than a non negative number, n. 计算小于非负数n的素数个数。 思路 这题用[埃拉托斯特尼筛法][2]来做效果比较好,普通的方法基本会TLE。 阅读全文
posted @ 2017-01-10 01:08 rgvb178 阅读(931) 评论(0) 推荐(0) 编辑
摘要: 文章内容均来自斯坦福大学的Andrew Ng教授讲解的Machine Learning课程,本文是针对该课程的个人学习笔记,如有疏漏,请以原课程所讲述内容为准。感谢博主Rachel Zhang 的个人笔记,为我做个人学习笔记提供了很好的参考和榜样。 § 4.正则化与过拟合问题 Regularizat 阅读全文
posted @ 2016-12-23 09:34 rgvb178 阅读(1066) 评论(0) 推荐(0) 编辑
摘要: 原题 [原题链接][1] You are given a map in form of a two dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected ho 阅读全文
posted @ 2016-12-01 11:41 rgvb178 阅读(1013) 评论(0) 推荐(0) 编辑
摘要: 题目 [题目链接][1] Given a non empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring togeth 阅读全文
posted @ 2016-11-19 23:33 rgvb178 阅读(2155) 评论(0) 推荐(0) 编辑
摘要: 题目 [题目链接][1] 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 th 阅读全文
posted @ 2016-11-17 09:44 rgvb178 阅读(2449) 评论(0) 推荐(0) 编辑
摘要: [上一篇笔记][1]主要介绍了卷积神经网络相关的基础知识。在本篇笔记中,将参考[TensorFlow官方文档][5]使用mnist数据集,在TensorFlow上训练一个多层卷积神经网络。 下载并导入mnist数据集 首先,利用[input_data.py][8]来下载并导入mnist数据集。在这个 阅读全文
posted @ 2016-11-10 23:01 rgvb178 阅读(19868) 评论(0) 推荐(0) 编辑
摘要: 1.题目:原题链接 Given an integer, write a function to determine if it is a power of two. 给定一个整数,判断该整数是否是2的n次幂。 2.思路 如果一个整数是2的n次幂,那么首先其应当是正数,其次该数的二进制表示必定是以1开 阅读全文
posted @ 2016-11-08 14:28 rgvb178 阅读(1207) 评论(0) 推荐(0) 编辑
摘要: 1.题目大意 Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For examp 阅读全文
posted @ 2016-10-29 12:19 rgvb178 阅读(707) 评论(0) 推荐(0) 编辑
摘要: 1.题目: 原题:Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. Subscribe to see which companies 阅读全文
posted @ 2016-10-28 22:51 rgvb178 阅读(806) 评论(0) 推荐(0) 编辑
摘要: 1.题目大意 Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more let 阅读全文
posted @ 2016-10-18 19:18 rgvb178 阅读(1960) 评论(2) 推荐(0) 编辑
摘要: 1.题目大意 A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements 阅读全文
posted @ 2016-10-16 23:38 rgvb178 阅读(1423) 评论(0) 推荐(0) 编辑
摘要: 1.题目大意 Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The f 阅读全文
posted @ 2016-10-16 13:01 rgvb178 阅读(1109) 评论(0) 推荐(0) 编辑
摘要: 1.题目大意 Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of th 阅读全文
posted @ 2016-10-15 15:13 rgvb178 阅读(2942) 评论(0) 推荐(0) 编辑
摘要: 1.题目大意 Given an array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a linear runtime 阅读全文
posted @ 2016-10-13 22:47 rgvb178 阅读(1778) 评论(0) 推荐(0) 编辑
摘要: 1.题目大意 求一个长度不超过80的字符串的最小周期. 2.思路 非常简单,基本就是根据周期的定义做出来的,几乎不需要过脑. 3.应该注意的地方 (1) 最后输出的方式要注意,不然很容易就PE了.不过个人认为,其实这题Sample Output给的不好 (2) 注意输出的要求是最小周期 4.代码 参 阅读全文
posted @ 2016-10-11 22:57 rgvb178 阅读(2172) 评论(1) 推荐(0) 编辑
摘要: 1.题目大意 把前n$(n\le 10000)$个整数顺次写在一起:12345678910111213……计算0~9各出现了多少次。 2.思路 第一想法是打表,然而觉得稍微有点暴力。不过暂时没有想到更好的办法了,写完看了一下其它人的思路好像也差不多是打表的思路。 3.应注意的问题 (1)首先是格式问 阅读全文
posted @ 2016-10-11 20:29 rgvb178 阅读(1324) 评论(0) 推荐(0) 编辑
摘要: 关键在于判断数字是两位数还是单位数,其他部分没有难度。 参考书目:算法竞赛入门经典(第2版) 刘汝佳 编著 阅读全文
posted @ 2016-10-11 15:01 rgvb178 阅读(1184) 评论(0) 推荐(0) 编辑
摘要: 1.题目大意 给出一个由O和X组成的字符串(长度为80以内),每个O的得分为目前连续出现的O的数量,X得分为0,统计得分。 2.思路 实在说不出了,这题没过脑AC的。直接贴代码吧。=_= 3.代码 参考书目:算法竞赛入门经典(第2版) 刘汝佳 编著 阅读全文
posted @ 2016-10-11 14:06 rgvb178 阅读(1508) 评论(0) 推荐(0) 编辑
摘要: 1.题目大意 输入长度为n$(2\le n\le 100)$的环状DNA串,找出该DNA串字典序最小的最小表示。 2.思路 这题特别简单,一一对比不同位置开始的字符串的字典序,更新result。 3.代码 参考书目:算法竞赛入门经典(第2版) 刘汝佳 编著 阅读全文
posted @ 2016-10-11 12:52 rgvb178 阅读(1013) 评论(0) 推荐(0) 编辑
摘要: 1.题目大意 如果a加上a的各个数字之和得到b,则说a是b的生成元。给出n其中$1\le n\le 100000$,求其最小生成元,若没有解则输出0。 2.思路 使用打表的方法打出各个数字a对应的b,存入s[b]中。 3.应注意的问题 (1) 没有解时输出0,也就意味着在开始打表前要把数组s[max 阅读全文
posted @ 2016-10-10 23:25 rgvb178 阅读(1688) 评论(0) 推荐(0) 编辑
摘要: 1.题目大意 比较给定序列和用户猜想的序列,统计有多少数字位置正确(x),有多少数字在两个序列中都出现过(y)但位置不对。 2.思路 这题自己思考的思路跟书上给的思路差不多。第一个小问题——位置正确的数字数量可以很容易求出,第二个小问题——在两个序列中都出现过但位置不对的数字数量则要由“y-x=在两 阅读全文
posted @ 2016-10-10 19:29 rgvb178 阅读(1113) 评论(0) 推荐(0) 编辑
摘要: 1.题目大意 输入字符串,判断其是否为回文串或镜像串。其中,输入的字符串中不含0,且全为合法字符。以下为所有的合法字符及其镜像: 2.思路 (1)考虑使用常量数组而不是if或switch来实现对镜像的判断,由此避免过于繁琐的过程。 (2)" -- is not a palindrome."," -- 阅读全文
posted @ 2016-10-10 10:48 rgvb178 阅读(1599) 评论(0) 推荐(0) 编辑
摘要: 1.题目大意: 输入一个错位的字符串(字母全为大写),输出原本想打出的句子。 2.思路: 如果将每个输入字符所对应的应输出字符一一使用if或者switch,则过于繁琐。因此考虑使用常量数组实现。 3.应该注意的问题: (1) 在对常量数组赋值时,应考虑字符转义符的影响,反斜杠"\"的转义符应为"\\ 阅读全文
posted @ 2016-10-09 22:27 rgvb178 阅读(1362) 评论(0) 推荐(0) 编辑
摘要: 文章内容均来自斯坦福大学的Andrew Ng教授讲解的Machine Learning课程,本文是针对该课程的个人学习笔记,如有疏漏,请以原课程所讲述内容为准。感谢博主Rachel Zhang 的个人笔记,为我做个人学习笔记提供了很好的参考和榜样。 § 2. 多变量线性回归 Linear Regre 阅读全文
posted @ 2016-10-04 13:48 rgvb178 阅读(1442) 评论(0) 推荐(0) 编辑
摘要: 文章内容均来自斯坦福大学的Andrew Ng教授讲解的Machine Learning课程,本文是针对该课程的个人学习笔记,如有疏漏,请以原课程所讲述内容为准。感谢博主Rachel Zhang 的个人笔记,为我做个人学习笔记提供了很好的参考和榜样。 § 3. 逻辑回归 Logistic Regres 阅读全文
posted @ 2016-09-07 00:49 rgvb178 阅读(2228) 评论(0) 推荐(0) 编辑