算法
kongkongqixi
技术技术技术,非要科班嘛
展开
-
证明以一个数为素数
证明一个数a为素数只要让a除以2到a√\sqrt a的整数,因为如果a为合数必须要整数b*整数c,则 b<=a√\sqrt a,c>= a√\sqrt a或者 c<= a√\sqrt a,b<=a√\sqrt a当且仅当b == c时等号成立,所以只要除以小于a√\sqrt a的整数就能证明一个数a为素数。 python代码实现求100000以内所有的素数,不考虑性能实现:b = 3c = 100原创 2017-05-17 09:34:28 · 1266 阅读 · 0 评论 -
SVM的函数距离和几何距离
1.函数距离函数距离:在超平面上我们定义函数距离γ^\hat{\gamma}表达式γ^\hat{\gamma} = yi(wTx+by_{i}(w^T x+ b),其中yi∈y_{i}\in {-1,1},ww为向量,bb为实数,当yi(wTx+by_{i}(w^T x+ b)=0时,表示点在超平面,当yi(wTx+by_{i}(w^T x+ b)>0时,表示点在与法向量w同方向一侧,当yi(wTx原创 2017-07-05 10:30:10 · 3871 阅读 · 1 评论 -
ValueError: Length of feature_names, 4 does not match number of features, 2解决方式
运行tree.export_graphviz()方法时报错ValueError: Length of feature_names, 4 does not match number of features, ,是方法里的feature_names参数出问题,featture_names定义的列不包括标签列,而且要和训练集的列数相同。...原创 2018-07-15 19:56:40 · 13915 阅读 · 9 评论 -
LDA主题模型学习总结
本篇主要总结隐含狄利克雷分布(Latent Dirichlet Allocation,以下简称LDA)1.贝叶斯定理贝叶斯定理是关于随机事件A和B的条件概率的定理。 在贝叶斯定理中:P(A|B)是在事件B发生的条件下事件A发生的条件概率,也由于得自B的取值而...原创 2018-09-29 14:01:47 · 13541 阅读 · 0 评论 -
copying a param of torch.Size([128]) from checkpoint, where the shape is torch.Size([1, 128])解决方式
关于torch的在加载bn_inception、x_inception时出现copying a param of torch.Size([128]) from checkpoint, where the shape is torch.Size([1, 128])类型的错误,观察发现可以用过修改加载模型中权重维度解决问题。例如:bn_inception中都是两维元组的数据转为一维:如(1,128...原创 2019-03-05 15:11:23 · 9252 阅读 · 1 评论