- 博客(11)
- 收藏
- 关注
原创 逻辑回归总结
Logistic Regression逻辑回归与线性回归的联系与区别联系都是监督学习。都无法解决非线性问题区别逻辑回归:虽然有regression一词,但实际上是分类问题(classification)。输出值是离散变量。线性回归:回归问题,输出值是连续变量。逻辑回归的原理逻辑回归损失函数推导及优化1逻辑回归的优缺点优点: 从实现几种常见算法的经验来看,个人认为该方法...
2020-02-18 22:39:29 115
原创 笔记1
线性回归用线性函数去拟合目标函数。Pytorch 的实现更简洁一些,因为使用到了向量运算简化。过拟合和欠拟合过拟合 - 在训练集上的训练误差远小于在测试集上的泛化误差。欠拟合 - 训练集上的训练误差始终比较高。过拟合常用 regularization 来解决,有 l1, l2 等常见正则方式。...
2020-02-13 21:46:29 109
转载 二叉树&堆
二叉树实现一个二叉查找树,并且支持插入、删除、查找操作from queue import Queueimport mathclass TreeNode: def __init__(self, val=None): self.val = val self.left = None self.right = None s...
2019-05-22 12:24:53 133
转载 hash table & strings
散列表(哈希表)实现一个基于链表法解决冲突问题的散列表# credit: http://ywtail.github.ioclass _ListNode(object): def __init__(self,key): self.key=key self.next=Noneclass HashMap(object): def __init__...
2019-05-20 11:01:57 122
转载 排序&二分查找
排序归并排序def merge_sort(a: List[int]): _merge_sort_between(a, 0, len(a) - 1)def _merge_sort_between(a: List[int], low: int, high: int): # The indices are inclusive for both low and high. ...
2019-05-20 10:50:17 161
转载 栈、队列、递归
栈用数组实现一个顺序栈class Stack: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, item): self.items.append(item) ...
2019-05-15 22:04:48 186
转载 数组&链表
数组实现一个支持动态扩容的数组import ctypes# provides low-level arraysclass DynamicArray: """A dynamic array class akin to a simplified Python list.""" def __init__(self, capacity=1): """Cre...
2019-05-12 09:25:09 88
原创 Dependency Parser (Pytorch)
因为上一次作业已经写过Logistic Regression了,这次就写parser好了。原理都是差不多的,主要是加了dropout。class ParserModel(nn.Module): def __init__(self, config, word_embeddings=None, pos_embeddings=None,dep_embeddings=None): super(Pa...
2019-04-10 21:49:36 851 1
转载 PyTorch 2
Logistic Regressionimport torchConstruct a unintialized tensor.x = torch.empty(5, 3)## 5 indicates the number of rows## 3 indicates the number of columnsConstruct a tensor initialized with zer...
2019-04-08 22:00:20 188
原创 Palindrome Integers 回文数字
题算法因为要考虑负号,因此考虑把数字先转换成字符串进行处理。因为是回文,只需要循环前半部分即可,尾部的索引只需要满足length−1−leftindex2\frac{length-1-left_{index}}{2}2length−1−leftindex即可(昨天的中位数是+1,今天是-1)。判断条件设为不等于,这样若跑完循环则一定是回文,直接返回True即可。另:一开始习惯性思维直接跑...
2019-04-06 16:25:24 200 2
原创 Median of Two Sorted Arrays
题:There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).算法:一个解法是把逐个比较两个列表中的数字然后按...
2019-04-05 20:55:19 238
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人