Saturday, April 14, 2018

latex tips

\advance\leftskip-1cm  move figure to the left

如何用texstudio:
1. 直接打开主文件,会自动识别所有相关的文件的。
2. overleaf上面是bib 文件,本地的是bbl文件,overleaf 的生成bbl 文件需要点击log 按钮,拉到最下面,会有一个下载bbl 文件的地方。
3. citation undefined warning 解决方法:I know that this question has been answered here Undefined citation warnings, which states that the user should compile the code with the following process:
  1. latex
  2. bibtex
  3. latex
  4. latex

对应的命令行为 pdflatex ijcai19; bibtex ijcai19

Wednesday, March 14, 2018

实习学到的 知识

UDF,HIVE
为了写UDF,需要Eclipse装插件。IntelliJ 的话 需要把setting file 改一下。这样数据仓库的路径可以到公司的maven 数据仓库。


build-build artifacts 就会在 项目目录下面的out里面看到一个打包好的jar file
然后上传到D2 ->new resource jar 最后要点击submit 就能在开发环境下面操作了




命令:正确找到有多少个分区
odpscmd -e "Show PARTITIONS search_kg.item_vectorial_aspects ;"

新建表格然后插入:
http://help.aliyun-inc.com/internaldoc/detail/27863.html?spm=a2c1f.8259796.2.66.PZtDOm
  1. insert into table srcp partition (p='abc') values ('a',1),('b',2),('c',3);




insert into table partition(ds='xxx')
select 'a','b' from dual;



odpscmd -e "jar -libjars zheng_content_free_sentiment_analysis.jar -classpath /Users/zhenggao/Documents/workspace/zheng_content_free_sentiment_analysis.jar -resources commons-math3-3.6.1.jar correlationAnalysis.PredictionCorrelationAnalysis zhenggao_normalized_item_aspect_predicted zhenggao_normalized_item_aspect zhenggao_pearson_correlation;"

odpscmd -e "add jar /Users/zhenggao/Documents/workspace/zheng_content_free_sentiment_analysis.jar -f"



odpscmd -e "set odps.graph.use.multiple.input.output=true;set odps.graph.worker.num=550;set odps.graph.worker.memory=32768; jar -libjars zheng_graph_random_walk.jar -classpath /Users/zhenggao/Documents/workspace/zheng_graph_random_walk.jar -resources commons-math3-3.6.1.jar,zhenggao_edge_type_transition_matrix UserBehaviorBasedContentGraph graph_vertex_filter_2 graph_edge_filter_2 zhenggao_edge_type_transition_matrix 2;"


SQL 语句:
read gaozheng_title_segment 1

insert overwrite table gaozheng_title_segment select item as id, alinlp_segment(regexp_replace(title,' ',''),"MAINSE"," ") as segment from tmp_filtered_item_title;

select regexp_replace('ac d',' ','') from dual



read search_kg_dev.user_aspect_item_temp partition(ds='20180603') 5;

tunnel

  1. tunnel upload log.txt test_project.test_table/p1="b1",p2="b2"
tunnel download -fd ### review_content_for_each_period/period=20180610-20180615 review_content.txt;


没有权限的话,可以在后面加上--user
比如安装 pip 或者 用pip install 其他Package的时候,可以用e.g. pip install numpy --user 就可以了

服务器上面用虚拟环境,不然不能pip3安装各种package
用python3, pip3
进入 source /home/zheng.gz/env/bin/activate
离开 deactivate

只是安装pip 见 https://pip.pypa.io/en/stable/installing/#id7
tmux 只有root 用户能用sudo yum install tmux



Sunday, March 11, 2018

Friday, March 9, 2018

pytorch


此外有些操作会导致tensor不连续,这时需调用tensor.contiguous方法将它们变成连续的数据,该方法会使数据复制一份,不再与原来的数据共享storage。 

e.is_contiguous()


https://github.com/chenyuntc/pytorch-book/blob/master/chapter3-Tensor%E5%92%8Cautograd/Tensor.ipynb 里面最后linear regression 实战的部分 db = dy.sum() 可以理解为 y = wx + b*Tensor((1,1,1,1)). 所以在求矩阵导数的时候,db = Tensor(1,1,1,1)的逆矩阵*dy 也就是求dy.sum()

用autograd的时候如何保留非叶子节点的grad,具体有两种,见https://github.com/chenyuntc/pytorch-book/blob/master/chapter3-Tensor%E5%92%8Cautograd/Autograd.ipynb
这里面还介绍了 自己怎么写一个function 函数来自定义Backward 反向传播

Thursday, February 22, 2018

Wednesday, November 22, 2017

deep learning methods and text mining related concepts for Alibaba interview 2

word2vec & GloVe



递归神经网络(Re- cursive Neural Network)的相关工作。该方法被证实在构建句子级语义时较为有 效。然而,递归神经网络需要按照一个树形结构来构建句子的语义,其性能依 赖于构建文本树的精度。而且,构建这棵树需要至少 O(n2) 的时间复杂度,其 中 n 表示句子的长度。当模型在处理长句子或者文档时,所花费的时间往往是 不可接受的。更进一步地,在做文档表示时,两个句子之间的关系不一定能构 成树形结构。因此递归神经网络可能不适合构建长句子或者文档的语义。 


循环神经网络(Recurrent Neural Network)可以在 O(n) 时间内构建文本的 语义 [26]。该模型逐词处理整个文档,并把所有上文的语义保存到一个固定大 小的隐藏层中。循环神经网络的优势在于它可以更好地捕捉上下文信息,对长 距离的上下文信息进行建模。然而,循环神经网络是一个有偏的模型,如对于 正向的循环神经网络而言,文本中靠后的词相对靠前的词占据了更主导的地位。 由于这一语义偏置的特性,循环神经网络在构建整个文本的语义时,会更多地 包含文本后面部分的信息。但是实际上并非所有文本的重点都放在最后,这可 能会影响其生成的语义表示的精确度。
为了解决语义偏置的问题,有人提出用卷积神经网络(Convolutional Neural Network)来构建文本语义 [18]。卷积神经网络利用最大池化技术能从文本中找 出最有用的文本片段,其复杂度也是 O(n)。因此卷积神经网络在构建文本语义 时有更大的潜力。然而,现有卷积神经网络的模型总是使用比较简单的卷积核, 如固定窗口 [18, 46]。在使用这类模型时,如何确定窗口大小是一个关键问题。 当窗口太小时,可能导致上下文信息保留不足,难以对词进行精确刻画;而当 窗口太大时,会导致参数过多,增加模型优化难度。因此,需要考虑,如何构 建模型,才能更好地捕获上下文信息,减少选择窗口大小带来的困难。并以此 为基础来更好地完成文本分类的任务。