提交 11bef049 authored 作者: Harm de Vries's avatar Harm de Vries

Introduced softmax_graph and softmax_op

上级 d9fc9d73
......@@ -567,11 +567,14 @@ class Softmax(gof.Op):
def c_code_cache_version():
return (3,)
softmax = Softmax()
softmax_op = Softmax()
def softmax_graph(c):
return tensor.exp(c) / tensor.exp(c).sum(axis=1, keepdims=True)
@opt.register_specialize('fast_compile_gpu')
@gof.local_optimizer([softmax])
@gof.local_optimizer([softmax_op])
def local_softmax_with_bias(node):
"""Try to turn softmax(sum_of_stuff) -> softmax_w_bias(matrix, bias)
"""
......
......@@ -1374,6 +1374,10 @@ class Test_softmax_opt:
# REPEAT 3 CASES in presence of log(softmax) with the advanced indexing
# etc.
def test_softmax():
from theano.tensor.nnet import softmax
def test_stabilize_log_softmax():
mode = theano.compile.mode.get_default_mode()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论