20151126

感觉是一直在挖坑,根本没有填坑。。今天来填一下上周的一些坑、、(但是上次的那个lstm和acl那篇paper并不能填。。。)

这段时间还在做leetcode的数组的题,上次提到的constant space,在这周同样遇到了,果然直接用的他的输入可以减少空间。
每天做几道编程题感觉还是不错的。另一方面也在思考,需要多总结才能摆脱单纯的做题。
今天可能要说的一点事动归,确实动归有专门的一类,但我发现一个问题是,在遇到多维度的情况,可以考虑一下动归的可能性。

今天在arxiv上看到Li Deng他们又占了一篇Stacked Attention Networks for Image Question Answering
感觉也是疯狂灌水。。一篇论文CNN + RNN + SAN(stacked attention network),这个任务是啥呢,就是给个图片,提个问题,做回答。
比如论文里的例子是,几条狗做做自行车的篮子里,问 what are sitting in the basket on a bicycle? 最后给出答案, dogs.
cnn用来抽图像里面的feature,cnn+lstm从question里面的feature。然后用san来做answer,前两个任务,大概是有概念的。
今天重点说一下san吧。attention network我需要再研究一下,大概作者做的事儿就是第一篇算出question对image 的feature的weight,
这时候更多的是在图片中出现的物品,然后在上一次的结果在attention。。反正我觉得说不通。。。

看论文果然是花时间。。

再说一个Python decorator吧。之前感觉这个很难理解,今天仔细看了一下,感觉这个还是很好理解的。直接干货:

1
2
3
4
5
6
7
8
9
10
11
12
def hello(fn):
def wrapper():
print "hello, %s" % fn.__name__
fn()
print "goodby, %s" % fn.__name__
return wrapper
@hello
def foo():
print "i am foo"
foo()

其中@hello就是Python的decorator了,下面这段就是修饰器的本质了:

1
2
3
4
5
6
7
@hello
def foo():
print "i am foo"
# -- >
foo = hello(foo)

也就是说刚才的源码可以看作:

1
2
3
4
5
6
7
8
9
10
def hello(fn):
def wrapper():
print "hello, %s" % fn.__name__
fn()
print "goodby, %s" % fn.__name__
return wrapper
foo = hello(foo)
foo()

这样的话输出结果也很好理解了,
hello, foo
i am foo
goodby, foo

对于多个decorator:

1
2
3
4
5
6
7
@decorator_one
@decorator_two
def func():
pass
func = decorator_one(decorator_two(func))

带参数的decorator:

1
2
3
4
5
@decorator(arg1, arg2)
def func():
pass
func = decorator(arg1, arg2)(func)

挖坑不断