- 博客(13)
- 收藏
- 关注
原创 罗马数字_ 转整数13
题目:代码一:思路:1)先找到字符串中的大的子串,统计个数 * 对应的数值 -> 加入求和list,找到后用“”空字符替换,2)再对更小的子串,进行搜索
2019-03-30 20:53:52 461
原创 python 赋值,浅拷贝,深拷贝
感谢前辈:学习连接来自:图解Python深拷贝和浅拷贝总结:本文介绍了对象的赋值和拷贝,以及它们之间的差异:Python中对象的赋值都是进行对象引用(内存地址)传递 使用copy.copy(),可以进行对象的浅拷贝,它复制了对象,但对于对象中的元素,依然使用原始的引用. 如果需要复制一个容器对象,以及它里面的所有元素(包含元素的子元素),可以使用copy.deepcopy()进...
2019-03-30 14:45:14 226
原创 7. Reverse Integer
题目:答案:总结:1)# 自己写的方法:能用,但不够好,# 1) 没有考虑越界# 2)采用字符串方式操作,感觉有点啰嗦2)# 正确的姿势,利用 10进制,移动位置来操作,方便快捷!# @TIME : 2019/3/28 下午11:14# @File : Reverse_integer.py# 自己写的方法:能用,但不够好,# 1)...
2019-03-29 08:56:25 85
原创 python 动态绑定属性方法
import types# 定义类class Person(object): num = 0 def __init__(self, name, age=None): self.name = name self.age = age def eat(self): print('eat food')# 定义实例...
2019-03-28 19:41:25 456
转载 crf-lijie
import torchimport torch.autograd as autogradimport torch.nn as nnimport torch.optim as optimtorch.manual_seed(1)def argmax(vec): # return the argmax as a python int _, idx = torch.max...
2019-03-20 10:02:30 125
转载 crf_lianxi
crf:# @TIME : 2019/3/17 下午10:52# @File : chainer_implementation.py# 参考:https://github.com/createmomo/CRF-Layer-on-the-Top-of-BiLSTMimport numpy as npimport chainerimport chainer.links as ...
2019-03-18 08:32:37 179
原创 lianxi
代码import torchimport torch.nn as nnimport torch.nn.functional as Fimport torch.optim as optimtorch.manual_seed(1)# 1) 准备数据def prepare_sentence(seq, to_ix): idx = [to_ix[w] for w in seq...
2019-03-08 21:59:59 222
原创 lstm parctice
代码:# @TIME : 2019/3/5 上午8:07# @File : LSTM_3_5.pyimport torchimport torch.nn as nnimport torch.nn.functional as Fimport torch.optim as optimtorch.manual_seed(1)# # 0) 定义 input 3, output ...
2019-03-07 09:03:17 163
原创 merge_intervals
合并区间 pythonclass Interval(object): def __init__(self, s=0, e=0): self.start = s self.end = eclass Solution(object): def merge(self, intervals): """ :...
2019-03-05 12:00:12 79
原创 fuxi cbow
# @TIME : 2019/3/4 上午00:38# @File : CBOW_2.pyimport torchimport torch.nn as nnimport torch.nn.functional as Fimport torch.optim as optimclass CBOW(nn.Module): def __init__(self, vocab_si...
2019-03-04 08:30:26 109
转载 CBOW 更新
代码:import torchimport torch.nn as nnimport numpy as npdef make_context_vector(context, word_to_ix): idxs = [word_to_ix[w] for w in context] return torch.tensor(idxs, dtype=torch.long)...
2019-03-02 16:40:11 441
原创 word-embedding
代码import torchimport torch.nn as nnimport torch.nn.functional as Fimport torch.optim as optimtorch.manual_seed(1)CONTEXT_SIZE = 2EMBEDDING_DIM = 30EPOCH = 100VERVOSE = 5# 0) 文本分开corpus_...
2019-03-02 16:30:23 337
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人