scan函数
theano.scan(fn, sequences=None, outputs_info=None,non_sequences=None, n_steps=None, truncate_gradient=-1,go_backwards=False, mode=None, name=None, profile=False)
fn是每一步所用的函数,sequence是输入,outputs_info是scan输出在起始的状态。
shared
variables相当于全局变量,The value can be accessed and modified by
the.get_value() and .set_value() methods.
在function里用updata来修改可以并行。
Debug:
http://deeplearning.net/software/theano/tutorial/debug_faq.html
theano.config.compute_test_value = ‘warn‘
import theano def inspect_inputs(i, node, fn): print i, node, "input(s) value(s):", [input[0] for input in fn.inputs], def inspect_outputs(i, node, fn): print "output(s) value(s):", [output[0] for output in fn.outputs] x = theano.tensor.dscalar(‘x‘) f = theano.function([x], [5 * x], mode=theano.compile.MonitorMode( pre_func=inspect_inputs, post_func=inspect_outputs)) f(3)
mode = ‘DEBUG_MODE‘ 很慢,无效?
使用print
x = theano.tensor.dvector(‘x‘) x_printed = theano.printing.Print(‘this is a very important value‘)(x) f = theano.function([x], x * 5) f_with_print = theano.function([x], x_printed * 5) #this runs the graph without any printing assert numpy.all( f([1, 2, 3]) == [5, 10, 15]) #this runs the graph with the message, and value printed assert numpy.all( f_with_print([1, 2, 3]) == [5, 10, 15])
原文:http://www.cnblogs.com/huashiyiqike/p/3553325.html