- 博客(29)
- 收藏
- 关注
原创 《21天实战caffe》 读书笔记(六)
第六天 运行手写体数字识别例程1、MNIST数据集MNIST数据集包括60000个训练集和10000个测试集,每张图都已经进行尺寸归一化、数字居中处理,固定尺寸为28像素*28像素。2、下载MNIST数据集MNIST数据集可以在Caffe源码框架的data/mnist下用get_mnist.sh脚本下载。MNIST原始数据为4个文件,数据格式描述见下图。
2017-11-18 16:30:05
301
原创 机器学习实战读书笔记(二) K-近邻算法
K-近邻算法2.1 K-近邻算法概述K-近邻算法是一种基本分类与回归方法。本节只讨论分类问题中的K-近邻算法。K-近邻算法假设给定一个训练数据集,其中的实例类别已定。对新的实例分类时,根据其K个最近邻的训练实例的类别,通过多数表决等方式进行预测。因此,K-近邻算法不具有显示的学习过程。K-近邻算法实际上利用训练数据集对特征向量空间进行划分,并作为其分类的“模型”。K值的选择、距
2017-10-23 20:50:27
266
原创 机器学习实战读书笔记(一)
监督学习监督学习中,给定输入样本集,机器从中推演指定目标变量的可能结果。目标变量类型:标称型(有限目标集中取值,常用于分类)、数值型(无限数值集中取值,常用于回归)何谓机器学习把无序数据转换成有用的信息::地震预测、推荐系统关键术语训练集:用于训练机器学习算法的数据样本集合,每个训练样本包括特征属性和目标变量测试集:用于测试机器学习算法的数据样本集合,每
2017-10-22 11:03:33
234
原创 leetcode Swap Nodes in Pairs(Java)
题目链接:点击打开链接类型:链表解法:递归/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public class Solution
2017-06-27 14:26:42
280
原创 leetcode Merge k Sorted Lists(Java)
题目链接:点击打开链接类型:合并解法:分治/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public class Solution
2017-06-27 09:17:04
222
原创 leetcode Generate Parentheses(Java)
题目链接:点击打开链接类型:DFS解法:public class Solution { public List generateParenthesis(int n) { List res = new ArrayList<>(); dfs(res, "", n, n); return res;
2017-06-24 22:46:01
252
原创 leetcode Merge Two Sorted Lists(Java)
题目链接:点击打开链接类型:合并解法:递归/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public class Solution
2017-06-24 22:08:37
158
原创 leetcode Valid Parentheses(Java)
题目链接:点击打开链接类型:数据结构解法:创建栈数据结构public class Solution { public boolean isValid(String s) { if (s == null || s.length() < 1) return false; Stack x = new Stack (); for (
2017-06-22 22:05:11
172
原创 leetcode 4Sum(Java)
题目链接:点击打开链接类型:数学处理解法:public class Solution { public List> fourSum(int[] nums, int target) { List> result = new ArrayList>(); int len = nums.length; if (nums == null || len < 4) retu
2017-06-21 10:46:26
184
原创 leetcode Remove Nth Node From End of List(Java)
题目链接:点击打开链接类型:Remove Nth Node From End of List解法:/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; }
2017-06-20 18:02:57
168
原创 leetcode Letter Combinations of a Phone Number(Java)
题目链接:点击打开链接类型:字符串处理解法:建立词典库,将新来的每个数字字符对应的多个字符加到每个结果字符串中public class Solution { public List letterCombinations(String digits) { List s = new LinkedList<>(); String[] map = {"","","abc","d
2017-06-19 10:46:40
191
原创 leetcode 3Sum Closest(Java)
题目链接:点击打开链接类型:数学处理解法:先排序,再比较。public class Solution { public int threeSumClosest(int[] nums, int target) { if (nums == null || nums.length < 3) return 0; Arrays.sort(nums); int le
2017-06-18 10:55:17
183
原创 leetcode 3Sum(Java)
题目链接:点击打开链接类型:数学处理解法:public class Solution { public List> threeSum(int[] nums) { List> result = new ArrayList>(); if (nums == null || nums.length < 3) return result;
2017-06-17 23:19:16
200
原创 leetcode Longest Common Prefix(Java)
题目链接:点击打开链接类型:字符串处理解法:找到最短的字符串长度,依次进行处理public class Solution { public String longestCommonPrefix(String[] strs) { if (strs.length < 1) return ""; int min_l
2017-06-16 13:21:01
152
原创 leetcode Roman to Integer(Java)
题目链接:点击打开链接类型:数学处理解法:public class Solution { public int romanToInt(String s) { int len = s.length(); int[] nums = new int[len]; for(int i = 0 ; i < len ; ++i
2017-06-16 10:49:07
210
原创 leetcode Integer to Roman(Java)
题目链接:点击打开链接类型:数学处理解法:构建转换词库(从大到小)public class Solution { private static int[] intCompare = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1}; private static String[] romanCompare = {"M",
2017-06-16 09:32:40
172
原创 leetcode Container With Most Water(Java)
题目链接:点击打开链接类型:two points解法:遍历(超时)public class Solution { public int maxArea(int[] height) { int len = height.length; int max = 0; if (len < 2) return 0; int side = 0; int curr
2017-06-14 20:49:58
153
原创 leetcode Regular Expression Matching(Java)
题目链接:点击打开链接类型:双字符串处理解法:递归public class Solution { public boolean isMatch(String s, String p) { if (p.length() < 1) return s.length() == 0; if (p.length() == 1) return (s.length(
2017-06-13 22:11:13
156
原创 leetcode Palindrome Number(Java)
题目链接:点击打开链接类型:数学处理解法:Reverse Integerpublic class Solution { public boolean isPalindrome(int x) { if (x < 0) return false; int reverse = 0; int compa
2017-06-12 15:28:47
175
原创 leetcode String to Integer (atoi)(Java)
题目链接:点击打开链接类型:字符串处理,边界处理解法:public class Solution { public int myAtoi(String str) { if (str == null || str.length() < 1 ) return 0; str = str.trim(); int len
2017-06-12 10:01:00
166
原创 leetcode Reverse Integer(Java)
题目链接:点击打开链接类型:数学运算解法:移位运算public class Solution { public int reverse(int x) { long result = 0; boolean negative = false; if (x < 0) { x = -x; negative = true; }
2017-06-11 22:53:58
221
原创 leetcode ZigZag Conversion(Java)
题目链接:点击打开链接类型:字符串处理解法:观察法public class Solution { public String convert(String s, int numRows) { int len = s.length(); if (numRows == 1 || len <= numRows) return s; StringBuilder
2017-06-11 20:25:13
246
原创 leetcode Longest Palindromic Substring(Java)
题目链接:点击打开链接题目类型:字符串处理解法:暴力遍历,但是超时了。。。public class Solution { private String curr; public int isPalidrome(int start, int end) { int i = start; int j = end; while (i < j) { if (
2017-06-09 22:24:41
156
原创 leetcode Median of Two Sorted Arrays(Java)
题目链接:点击打开链接类型:合并数组解法:遍历数组,排列生成新的数组public class Solution { public double findMedianSortedArrays(int[] nums1, int[] nums2) { int len1 = nums1.length; int len2 = nums2.length;
2017-06-08 16:01:23
152
原创 leetcode Longest Substring Without Repeating Character(Java)
题目链接:点击打开链接类型:解法:记录每一子串起始位置和长度,并与当前最大长度进行比较public class Solution { public int lengthOfLongestSubstring(String s) { if (s.length() == 0) return 0; if (s.length() == 1) return 1; int max
2017-06-07 19:36:28
150
原创 leetcode Add Two Numbers(Java)
题目链接:点击打开链接类型:数学运算关键字:倒序相加、进位/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public class
2017-06-06 16:17:45
205
原创 leetcode Two Sum(Java)
题目链接:https://leetcode.com/problems/two-sum/#/description遍历问题暴力解法:遍历数组,算法复杂度O(n²)public class Solution { public int[] twoSum(int[] nums, int target) { int[] test = {0,0}; for(
2017-06-05 16:19:50
166
原创 PAT1002.A+B for Polynomials
#include #include int main(int argc, char *argv[]) { typedef struct { int ni; double ani; }poly; poly a[11],b[11],c[23]; int k1,k2; int i,j,p; int m; double n; while(
2015-12-23 15:19:03
232
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人