- 博客(133)
- 资源 (1)
- 收藏
- 关注
原创 交叉熵、相对熵、KL散度、JS散度
以前没有从另一个角度理解过熵:用最小的bit位数描述一个分布,这个bit数就是熵交叉熵就是用分布Q(x)拟合真实分布P(x),最常见的就是LR的Loss相对熵就是交叉熵减去真实分布的熵KL散度就是相对熵,但是KL散度不具有对称性JS散度是 JSD(P||Q)=1/2*KL(P||(P+Q)/2) +1/2*KL(Q||(P+Q)/2)可见JS散度是具有对称性的...
2019-03-25 11:49:16
1106
原创 [深度学习] embedding 在test阶段遇到OOV怎么办
即使是char级别的rnn模型,在test阶段也会遇到OOV这种情况肯定是没法用embedding层的lookup的如果OOV情况不多,就可以当做UNK处理有两类思路:1. UNK有对应的embedding 这种情况怎么来的呢,就是把训练集中所有出现频率小于某个阈值的词都标记为UNK,当然也别太多,这样就得到了UNK的embedding,这里的embedding有
2018-04-11 15:42:21
9110
1
原创 [优质论文]伪造共同访问对推荐系统进行攻击
针对推荐系统的攻击个人概要论文原文: Fake Co-visitation Injection Attacks to Recommender Systems 论文解读: [论文学习] 脆弱的推荐系统: 通过伪造共同访问对推荐系统进行攻击 这篇文章写的很清楚,所以如果真的要看就去看它好了,我记下来只是为了让自己印象更深。这篇文章为什么吸引我?因为之前知道广告作弊,搜索作弊等,但是从来没有接触
2017-11-30 20:39:11
1356
原创 开始TensorFlow学习
最近想把扔了一年多的机器学习相关的东西拾起来,看看kaggle,回顾一下各种classifier和regressor以及ensemble。顺便正好看看TensorFlow的东西,毕竟这么火实现cnn做图像识别和文本分类的效果实现了lstm做分类和时序预测的效果实现了word2vec其实说不上实现,只因为用tensorflow做这些工作实在是太简单了,以前的ker
2017-07-28 17:45:15
476
原创 solr的schema中几个特殊参数明细
positionIncrementGap使用场景:multi-value field对应的phrase query场景 Suppose a document has a multi-valued “author” field. Like this: author: John Doe author: Bob Smith With a position increment gap of 0,
2017-07-19 17:56:31
814
原创 solr spellcheck 距离选取方案
spellcheck本质上工作机制是两步:1. ngram进行候选检索2. 选取ngram打分最高的几个,进行距离计算,如果距离大于solrconfig中的accuracy配置项,就返回该纠错结果之前沿用了默认配置项编辑距离,strname="distanceMeasure">org.apache.lucene.search.spell.LevensteinDistan
2017-06-16 17:41:11
795
原创 批量车源解析方案
车商批量资源发布解决方案背景车商发布资源门槛较高,手里的资源想全部转化为平台上的规范资源需要一条一条发布,比较繁琐,但是车商会天天在朋友圈、微信群里发布他们用自然语言“编写”的资源,例如:X1/286000 白,蓝,红,粽⬇14.5点 GT320/398000 矿白黑 ⬇16.5点 525/499600 矿白摩卡 ⬇18.5点 ☎18521707911 全部上海提,店车店票 如果
2017-06-12 21:35:13
832
原创 Solr完整个性化搜索排序方案
Solr个性化搜索排序A厂的排序方案是添加各种各样的排序链,用于支持各个业务场景下的搜索排序功能,之前我们主搜排序以及筛选页的逻辑非常简单,就是文本相关性+业务分(业务加分+业务扣分),搜索结果干预功能也很直接,这些模块都直接添加在SolrIndexSearcher中,为的是最快的支持搜索排序业务,然后就这么撑了6个月。。。我们发现,用到排序的场景越来越多,比如首页很关键的两个入口:推荐资源和推荐寻
2017-02-14 14:45:51
6944
7
原创 solr 4.2 使用插件链来完善、简化增量index逻辑
业务背景之前做村淘的时候开发过一个插件,即动态的根据商品的类目判定该商品是不是要被和谐,所以了解到在update商品信息的时候,商品是肯定会经过一个由若干Processor组成的chain最终进入底层索引的现在遇到的问题是这样的,当前的商品逻辑比较复杂,有很多不是从db里得到的字段,进索引时会根据业务逻辑做相应的处理,例如时间间隔,title,以及离线的一些分数,例如商品预测质量分等。全量索引时逻辑
2016-11-08 21:54:25
1112
原创 ERROR: must be superuser to COPY to or from a file
用COPY需要superuser很麻烦直接用 \copy就可以把file导入到表中了> Hello> > I want to fill in a table from a file, but when I use the COPY command I> > get the following error:> >> > mydb=> COPY weather FROM '
2016-09-02 15:47:43
3840
原创 Solr Lucene Group查询
Solr Group查询背景搜索引擎在某种意义上也是一直数据库,写过sql的应该都知道group这个关键字,在有些场景下我们也需要搜索提供类似group的功能,例如作为基于信息流的电商我们需要按照不同的时间段返回结果,举个例子,就是先展示最近3天的商品,然后再展示3-7天的商品,那么group在solr里,或者说在lucene里是怎么实现的呢?group思路先介绍下大体思路,当然这个思路也是参考过s
2016-07-06 20:39:49
920
原创 solr 的commit, soft commit等
背景最近又被soft commit 和 hard commit搞得有点迷糊,其实都怪自己没有早点看源代码。问题出自这段代码,这也是我一开始接触solr时,查到的代码sample(事实证明问题都出在这里,引以为戒,有问题真的不要不求甚解)if (rs.next()){ while (true) { NiuniuSolrInputDocument doc = new Niuniu
2016-07-01 14:50:57
3978
原创 lucene中的Filter
前言用Lucene一定不能不知道Filter,Filter在合适的场景下能大大提升搜索性能背景最近在折腾solr,这个3年前“玩过”的东西,现在又来玩了,3年前是瞎比玩,只知道最上层的一些接口,却不知其所以然,而现在的目标就是要把solr以及lucene底层的核心代码都分析一遍,并成功的部署一套电商搜索解决方案。Filter逻辑Filter的构造逻辑其实本身和Query的构造逻辑差距不大,唯一一点不
2016-06-23 21:28:57
1260
原创 solr 个性化打分
背景搜索排序怎么排呢,如果还是想着怎么改similarity或者SchemaSimilarityFactory就范围太小了,similarity只能提供一个文本相关性得分,不管你怎么boost去调整,最后你会发现这他妈根本不是你想要的打分逻辑,tf, idf, lengthnorm, coord,boost,甚至还涉及到lucene-core 下SmallFloat的精度问题,一团乱麻。方案可以扩展
2016-06-14 21:32:36
2746
1
原创 solr 自定义QueryParser 用户查询解析方案
背景一个完整的搜索流程,query其实是最关键的角色,它甚至比人的标签等信息更加关键,这也是PPC这种搜索广告赚钱的基本保障。 我们作为搜索服务提供商,能够怎么应对这些query,并且根据用户输入的query构造出不同的lucene布尔查询,这是非常关键的一个问题。拿之前做过的地图检索为例,用户输入:上海市浦东新区罗山路28号,我们的底层schema存有省,市,县,区,街道等信息,那么我们如果把用
2016-06-14 18:33:05
3169
翻译 怎样检测和应对数据集的Outliers
怎样检测和应对数据集的Outliers什么是OutlierOutlier中文可以叫做异常样本,但是一般还是直接称呼Outlier,它就是大量观测样本中那些量较少的、偏离整体的模式样本,这些样本很容易就能够让你得到偏差很大的模型,导致欠拟合,所以需要格外关注它们。 举个例子,我们在做消费者画像时,需要统计消费者的平均收入,大家的平均年薪可能只有20w,但是这时样本中冒出来了马云和王健林,它们的收入远
2015-12-30 11:50:58
12234
翻译 逻辑回归,决策树,支持向量机 选择方案
逻辑回归 vs 决策树 vs 支持向量机分类是我们在工业界经常遇到的场景,本文探讨了3种常用的分类器,逻辑回归LR,决策树DT和支持向量机SVM。 这三个算法都被广泛应用于分类(当然LR,DT和SVR也可以用于回归,但是本文先不讨论)。我经常看到人们会问,这个问题我该使用LR呢还是决策树(或者GBDT)还是SVM呢。然后你会听到一个“经典”而且“绝对正确”的答案:”It depends.”这个答案
2015-12-01 15:23:51
12844
原创 Solr为不同的fieldType配置Similarity
Similarity业务需要,想对不同的field使用不同的similarity。继承DefaultSimilarity实现里面的方法,重写了tf, idf,toString这三个方法,直接在schema中替换就可以对不同的field使用不同的similarity在schema中可以设置similarity,发现不太行,solr4.2并不支持这么细粒度的similarity用法,不过可以支持不同的f
2015-11-06 00:04:52
3314
转载 ssh的连接重用
http://www.fwolf.com/blog/post/385原理很简单,开一个ssh连接在后台放着,以后再有需要用到ssh到同样主机的时候,直接使用这个连接的socket文件,不用再创建连接了,同理,也不需要再进行用户身份验证。默认是关闭的,可以在~/.ssh/config中打开:Host * ControlMaster auto ControlPa
2015-09-08 11:18:08
1159
原创 ubuntu software center install button gray
虚拟机受不了了滚粗双系统网卡驱动network manager搞不定于是换了wicdubuntu软件中心的install按键变灰色,sb了不能用这个装很多app其实也蛮蛋疼查了一下http://askubuntu.com/questions/470270/cannot-install-any-softwares-from-software-center-in-ubunt
2015-07-11 01:20:04
1080
原创 solr4.2 索引路径设定 修改solr/home
最近在ubuntu下折腾tomcat7+solr4.2由于之前有一些经验,知道我可以把索引的路径在solr/home的solr.xml文件中设置,例如: 这一步没有问题。但是如何设置我的solr/home呢?也就是问,怎么样指定我的solr.xml的路径。因为默认该文件会放在tomcat的bin下,所以如果想要灵活一些,需要找到这个的指
2015-05-06 16:30:51
2800
原创 Min Stack
Design 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() -- Get
2014-11-10 10:22:11
958
原创 某F面试
class DeviceReader { public: // Reads upto 4 bytes of data into the given buffer. // Returns the number of bytes read (zero if no more data). virtual int read4(char *buffer) = 0;};/*--- s
2014-11-04 08:48:37
976
原创 Find Minimum in Rotated Sorted Array II
Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Suppose a sorted array is rotated at some pivot unk
2014-10-21 13:20:40
1259
原创 Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1]
2014-10-20 22:15:39
548
原创 某G电面题
先吐槽一下Google Doc。。还不如在collabedit上写呢。。拿word来coding伤不起。。Hi, did you receive my phone call?nope...hmm, ok, please hold on for a momentsure, 15121012322f(x) = ax^2 + bx +carr[
2014-10-17 11:21:39
982
原创 Find Minimum in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate exists in the ar
2014-10-16 11:35:46
791
原创 Binary Tree Postorder Traversal
Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].Note: Recursive solut
2014-10-16 09:45:32
616
转载 ubuntu terminal修改ls的颜色
zz1. 利用dircolors命令,查看我们的系统当前的文件名称显示颜色的值,然后利用管道重定向到用户目录下的任意一个文件(这里我们创建了一个.dir_colors文件) 命令1: cd ~ 命令2: dircolors -p > .dir_colors2. 用vim打开.dir_colors文件,然后找到“DIR 01;34” //这里的01表
2014-09-29 09:42:01
1272
原创 Maximum Product Subarray
Leetcode又更新了Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray
2014-09-24 13:56:16
1170
1
原创 Populating Next Right Pointers in Each Node
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node.
2014-09-22 20:47:14
581
原创 Populating Next Right Pointers in Each Node II
Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant
2014-09-22 20:42:29
601
原创 Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is
2014-09-14 00:04:53
541
原创 Pascal's Triangle II
Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space?class So
2014-09-07 21:11:29
528
原创 Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Y
2014-09-06 17:30:36
453
原创 Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of convertin
2014-09-05 16:36:37
465
原创 Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe
2014-09-05 16:05:10
651
原创 Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy t
2014-09-04 22:41:32
790
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人