![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
Zanciscoco
这个作者很懒,什么都没留下…
展开
-
pandas 将数组格式保存为csv(txt)
np_data = np.array(data_arr)##写入文件pd_data = pd.DataFrame(np_data,columns=['filename','gender'])print(pd_data)pd_data.to_csv('pd_data.csv')原创 2018-11-13 21:02:36 · 3397 阅读 · 0 评论 -
对每句话根据,。!分段
def cut_sentence(a): symbol = '/,/./!' cut_list=[] j=0 for i in range(len(a)): if a[i] in symbol: cut_list.append(a[j:i]) j=i+1;# print(cut_list) ...原创 2018-11-13 21:04:33 · 112 阅读 · 0 评论 -
网络的构建关键代码,词与下一个词实现连接
edges=[]edge=[0]*2for text in cut_list: words=text.lower().split() if len(words)>1: for j in range(0,len(words)-1): edge[0]=neg_dict.get(words[j]) edge[1]=...原创 2018-11-13 21:05:33 · 133 阅读 · 0 评论 -
余弦相似度计算
def cosine_similarity(vector1, vector2): dot_product = 0.0 normA = 0.0 normB = 0.0 for a, b in zip(vector1, vector2): dot_product += a * b normA += a ** 2 normB...原创 2018-11-13 21:55:16 · 249 阅读 · 0 评论 -
jupyter中加载虚拟环境选择
首先进入相应的虚拟环境:activate tensorflow-gpu然后输入以下:python -m ipykernel install --user --name tensorflow-gpu --display-name “Python3(tf-gpu)”原创 2019-02-20 17:07:29 · 652 阅读 · 0 评论