↓ Skip to main content

Posts

2017

20170819近况

·979 words·2 mins
一转眼…暑假就要结束了… 秋招似乎也可以告一段落了… 投了蛮多的,但是昨天突然发现我用gmail邮箱发邮件有概率发不出去。。所以我也不知道到底哪些简历根本没有发出去orz

tensorflow Session 学习笔记

·439 words·1 min
tensorflow-session官方文档 说下我自己的理解: session中文一般叫会话,可以理解成op执行时候需要的一层虚拟化的封装。 op必须在session中才能执行。 tensor也是在tensor中才可以存在(tf.variable和tensor几乎是一回事,只是tf.variable的会话不要求session,也可以理解成tf.variable在session中就成了tensor.

leetcode 146. LRU Cache(list+unordered_map)

·457 words·1 min
请实现最近最少使用缓存(Least Recently Used (LRU) cache)类,需要支持 get, set,操作。 get 操作,给出 key,获取到相应的 value (value 为非负数),如果不存在返回-1, 如果存在此 key 算作被访问过。 set 操作,设置 key,如果 key 存在则覆盖之前的 value (此时相当于访问过一次)。 如果 key 不存在,需要进行插入操作,如果此时已经 key 的数量已经到达 capacity, 这样需要淘汰掉最近最少使用(也就是上次被使用的时间距离现在最久的)的那 一项。

python只获取当前目录下的文件夹及文件名

·237 words·1 min
list = os.listdir(rootdir)#列出目录下的所有文件和目录 1for line in list: 2 filepath = os.path.join(rootdir,line) 3 if os.path.isdir(filepath):#如果filepath是目录 4 print "dir:" + filepath 5 else: 6 print "file:" + filepath 如果需要遍历文件夹下的所以文件,可以使用os.walk()方法。

Distributed Tensorflow : Cannot assign a device for operation save

·211 words·1 min
是在使用分布式tensorflow遇到的一个错误 报错如下: InvalidArgumentError (see above for traceback): Cannot assign a device for operation ‘save/Rest│| 2 GeForce GTX 1080 On | 0000:08:00.0 Off | N/A | oreV2_888’: Operation was explicitly assigned to /job:worker/task:0/device:CPU:0 but available │| 24% 39C P8 12W / 180W | 0MiB / 8114MiB | 0% Default | devices are [ /job:localhost/replica:0/task:0/cpu:0, /job:localhost/replica:0/task:0/gpu:0 ]. Make sure the device specification refers to a valid device.

分布式 tensorflow 学习笔记(非最终版)

·1758 words·4 mins
感觉资料不是很多,先收集资料好了。 tf-distributed官网文档 SO-between-graph和in-graph的区别 inception.README.md SyncReplicasOptimizer SO_How does ps work in distribute Tensorflow? update:在多个nodes(机)上跑。。。tf默认是异步更新的。。。同步的话。。大概需要syncreplicasoptimizer?

tensorflow Supervisor 学习笔记

·944 words·2 mins
update:supervisor的缺点是遇到问题只会抛异常,所以现在有一个better的管理工具,MonitoredSession master,chief worker,Supervisor 这几个概念有点搞不清(我最菜.jpg 因此来学习一下。 概述 # 原生的tensorflow 是各种东西都需要自己手动,如果是小规模的训练问题倒是不大,但是如果是训练的数据量比较大,可能需要训练几天或者几个月。。。

k-means clustering 学习笔记

·440 words·1 min
其实这算法巨简单。。。。让我想到了均分纸牌(noip200? 还是大致说一下: 对于有 features 但是 **没有 **labels 的数据,没办法用监督学习,但是可以使用非监督学习的聚类算法。 所谓聚类,简单理解,就是把相似的分成一组。。。

TensorFlow Architecture 学习笔记(二)Adding a New Op

·2722 words·6 mins
Adding a New Op # * [目录](https://www.tensorflow.org/extend/adding_an_op#top_of_page) * [定义运算的接口](https://www.tensorflow.org/extend/adding_an_op#define_the_ops_interface) * [实现运算的核心部分(kernels)](https://www.tensorflow.org/extend/adding_an_op#implement_the_kernel_for_the_op) * [多线程cpu kernels](https://www.tensorflow.org/extend/adding_an_op#multi-threaded_cpu_kernels) * [GPU kernels](https://www.tensorflow.org/extend/adding_an_op#gpu_kernels) * [构建运算库](https://www.tensorflow.org/extend/adding_an_op#build_the_op_library) * [用系统编译器编译你的运算(TensorFlow binary installation)](https://www.tensorflow.org/extend/adding_an_op#compile_the_op_using_your_system_compiler_tensorflow_binary_installation) * [使用bazel编译你的运算(TensorFlow source installation)](https://www.tensorflow.org/extend/adding_an_op#compile_the_op_using_bazel_tensorflow_source_installation) * [在 Python 中使用你的运算](https://www.tensorflow.org/extend/adding_an_op#use_the_op_in_python) * [验证你添加的运算可以工作](https://www.tensorflow.org/extend/adding_an_op#verify_that_the_op_works) * [在你的运算中添加高级特性](https://www.tensorflow.org/extend/adding_an_op#building_advanced_features_into_your_op) * [条件检查和验证](https://www.tensorflow.org/extend/adding_an_op#conditional_checks_and_validation) * [Op registration](https://www.tensorflow.org/extend/adding_an_op#op_registration) * [GPU Support](https://www.tensorflow.org/extend/adding_an_op#gpu_support) * [用python 实现梯度](https://www.tensorflow.org/extend/adding_an_op#implement_the_gradient_in_python) * [Shape functions in C++](https://www.tensorflow.org/extend/adding_an_op#shape_functions_in_c) 对于要添加原生tensorflow中没有定义的运算的需求,首先建议在python层面,能不能将需要的op用其他原生的op拼凑起来。

峰度(Kurtosis)和偏度(Skewness)

·479 words·1 min
昨天pinduoduo笔试遇到了,看心情蒙的2333,来学习一下 ** 峰度(Kurtosis)和偏度(Skewness)** 重点:正态分布的峰度和偏度都是0 峰度是描述总体中所有取值分布形态陡缓程度的统计量。这个统计量需要与正态分布相比较,峰度为0表示该总体数据分布与正态分布的陡缓程度相同;峰度大于0表示该总体数据分布与正态分布相比较为陡峭,为尖顶峰;峰度小于0表示该总体数据分布与正态分布相比较为平坦,为平顶峰。峰度的绝对值数值越大表示其分布形态的陡缓程度与正态分布的差异程度越大。

TensorFlow Architecture 学习笔记(一)

·2016 words·5 mins
这篇文章不会涉及tensorflow的具体使用,而是专注于介绍tensorflow的架构,目的是让开发者能够对tensorflow现有框架进行自定义的扩展。 tensorflow被设计用来处理大规模分布式训练,但是也足够灵活去处理新的machine learning模型或是系统层面的优化。

Long Short-Term Memory (LSTM) 网络 学习笔记

·761 words·2 mins
参考资料: # 维基百科_长短期记忆(LSTM) Understanding LSTM Networks [译] 理解 LSTM 网络 LSTM笔记 翻译的比较一般,建议看原文….比如cell还是不要翻译成【细胞】比较好吧…让人以为和生物学的【细胞】有什么关系呢orz

hdu 3078 Network (LCA)

·625 words·2 mins
题目链接 题意: # 一棵树,给出点权,问一条树链上第k大的点权,点权可以动态修改。 思路: # 暴力即可orz(数据是真的水啊。

hdu 2815 Mod Tree (扩展BSGS算法)

·463 words·1 min
题意:k^D=n(%p),求最小的D (1<=K, P, N<=10^9) 思路:出题人英文水平捉鸡。。。。 扩展BSGS算法即可,注意p>=n的时候显然是无解的,判掉。 代码实现 1/* *********************************************** 2Author :111qqz 3Created Time :Mon 24 Jul 2017 09:43:41 PM CST 4File Name :2815.cpp 5************************************************ */ 6 7#include <cstdio> 8#include <cstring> 9#include <iostream> 10#include <algorithm> 11#include <vector> 12#include <queue> 13#include <set> 14#include <map> 15#include <string> 16#include <cmath> 17#include <cstdlib> 18#include <ctime> 19#define PB push_back 20#define fst first 21#define sec second 22#define lson l,m,rt<<1 23#define rson m+1,r,rt<<1|1 24#define ms(a,x) memset(a,x,sizeof(a)) 25typedef long long LL; 26#define pi pair < int ,int > 27#define MP make_pair 28 29using namespace std; 30const double eps = 1E-8; 31const int dx4[4]={1,0,0,-1}; 32const int dy4[4]={0,-1,1,0}; 33const int inf = 0x3f3f3f3f; 34LL k,p,n; 35map<LL,LL>mp; 36LL ksm(LL a,LL b,LL p) 37{ 38 LL res = 1LL; 39 while (b) 40 { 41 if (b&1) res = res * a % p; 42 b = b>>1LL; 43 a = a * a % p; 44 } 45 return res; 46} 47LL gcd( LL a,LL b){return b?gcd(b,a%b):a;} 48LL BSGS(LL a,LL b,LL p) 49{ 50 a%=p; 51 b%=p; 52 // if (a==0&&b==0) return 0; 53 // if (a==0) return -1; 54 if (b==1) return 0; 55 int cnt = 0 ; 56 LL t = 1; 57 for (int g = gcd(a,p); g!=1 ; g = gcd(a,p)) 58 { 59 if (b%g) return -1; 60 p/=g; 61 b/=g; 62 t=t*a/g%p; 63 cnt++; 64 if (b==t) return cnt; 65 } 66 mp.clear(); 67 int m = ceil(sqrt(double(p))); 68 LL base = b ; 69 for ( LL i = 0 ; i < m ; i++) 70 { 71 mp[base] = i; 72 base = base * a % p; 73 } 74 base = ksm(a,m,p); 75 LL ret = t ; 76 for ( int i = 1 ; i <= m+1 ; i++) 77 { 78 ret = ret * base % p; 79 if (mp.count(ret)) return i*m-mp[ret]+cnt; 80 } 81 return -1; 82} 83int main() 84{ 85 #ifndef ONLINE_JUDGE 86 freopen("./in.txt","r",stdin); 87 #endif 88 while (~scanf("%lld%lld%lld",&k,&p,&n)) 89 { 90 if (n>=p) 91 { 92 puts("Orz,I can’t find D!"); 93 continue; 94 } 95 if (p==1) 96 { 97 puts("Orz,I can’t find D!"); 98 continue; 99 } 100 LL ans = BSGS(k,n,p); 101 if (ans==-1) puts("Orz,I can’t find D!"); 102 else printf("%lld\n",ans); 103 } 104 105 #ifndef ONLINE_JUDGE 106 fclose(stdin); 107 #endif 108 return 0; 109}

manjaro(archlinux) 安装 YouCompleteMe

·285 words·1 min
来来回回折腾了好多次,aur直接安装或者手动编译,安装后都无法补全 ycm的log文件是在/tmp目录下的。 发现问题是缺少libtinfo.so.5 12017-07-28 17:02:12,667 - ERROR - Error occurred while loading global extra conf /home/coder/.ycm_extra_conf.py 2Traceback (most recent call last): 3 File "/home/coder/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/extra_conf_store.py", line 94, in _CallGlobalExtraConfMethod 4 module = Load( global_ycm_extra_conf, force = True ) 5 File "/home/coder/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/extra_conf_store.py", line 173, in Load 6 module = LoadPythonSource( _RandomName(), module_file ) 7 File "/home/coder/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/utils.py", line 400, in LoadPythonSource 8 return imp.load_source( name, pathname ) 9 File "/home/coder/.ycm_extra_conf.py", line 32, in <module> 10 import ycm_core 11ImportError: libtinfo.so.5: cannot open shared object file: No such file or directory 122017-07-28 17:02:12,667 - ERROR - libtinfo.so.5: cannot open shared object file: No such file or directory 13Traceback (most recent call last): 14 File "/home/coder/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/server_utils.py", line 96, in CompatibleWithCurrentCore 15 ycm_core = ImportCore() 16 File "/home/coder/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/server_utils.py", line 88, in ImportCore 17 import ycm_core as ycm_core 18ImportError: libtinfo.so.5: cannot open shared object file: No such file or directory 解决办法:

BZOJ 2480: Spoj3105 Mod (扩展BSGS算法,模板)

·658 words·2 mins
Description # 已知数a,p,b,求满足a^x≡b(mod p)的最小自然数x。 Input # 每个测试文件中最多包含100组测试数据。 每组数据中,每行包含3个正整数a,p,b。 当a=p=b=0时,表示测试数据读入完全。 Output # 对于每组数据,输出一行。 如果无解,输出“No Solution”(不含引号),否则输出最小自然数解。 Sample Input # 5 58 33 2 4 3 0 0 0

python numpy 用法 简明手册

·8276 words·17 mins
原文链接 感谢stanford,感谢原作者的翻译,我调整了一下代码格式,可以当做手册来用了,毕竟之前没怎么写过py 23333 译者注:本文智能单元首发,翻译自斯坦福CS231n课程笔记Python Numpy Tutorial,由课程教师Andrej Karpathy授权进行翻译。本篇教程由杜客翻译完成,Flood Sung、SunisDown、巩子嘉和一位不愿透露ID的知友对本翻译亦有贡献。

BSGS(Baby steps giant steps)算法学习笔记

·1027 words·3 mins
离散对数(Discrete Logarithm)问题是这样一个问题,它是对于模方程 a^x=b(mod prime),求满足条件的X,或者得出不存在这样的X 最暴力的思路,那么就是枚举x? 根据费马小定理,只需要枚举[0,p-1)