符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
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)
创新互联是一家专注于成都网站设计、网站建设与策划设计,钟山网站建设哪家好?创新互联做网站,专注于网站建设10年,网设计领域的专业建站公司;建站业务涵盖:钟山等地区。钟山做网站价格咨询:028-86922220outputs_info is the list of Theano variables or dictionaries describing the initial state of the outputs computed recurrently.
fn是每一步所用的函数,sequences是输入,outputs_info是scan输出在起始的状态。sequences and outputs_info are all parameters of fn in ordered sequence.
scan(fn, sequences = [ dict(input= Sequence1, taps = [-3,2,-1]) , Sequence2 , dict(input =Sequence3, taps = 3) ] , outputs_info = [ dict(initial =Output1, taps = [-3,-5]) , dict(initial = Output2, taps = None) , Output3 ] , non_sequences = [ Argument1, Argument2])
fn should expect the following arguments in this given order:
import theano
import theano.tensor as T
mode = theano.Mode(linker='cvm')
import numpy as np
def fun(a,b):
return a+b
input=T.vector("input")
output,update=theano.scan(fun,sequences=input,outputs_info=[T.as_tensor_variable(np.asarray(1,input.dtype))])
out=theano.function(inputs=[input],outputs=output)
in1=numpy.array([1,2,3])
print out(in1)
def fun(a,b):
return a+b
input=T.matrix("input")
output,update=theano.scan(fun,sequences=input,outputs_info=[T.as_tensor_variable(np.asarray([0,0,0],input.dtype))])
out=theano.function(inputs=[input,],outputs=output)
in1=numpy.array([[1,2,3],[4,5,6]])
print(in1)
print out(in1)
shared variables相当于全局变量,The value can be accessed and modified by the.get_value() and .set_value() methods. 在function里用updata来修改可以并行。
scan的输出是一个symbol,用来在后面的theano function里作为output和update的规则。当sequences=None时,n_steps应有一个值来限制对后面theano function里的input的循环次数。当sequences不为空时,theano function直接对sequences循环:
components, updates = theano.scan(fn=lambda coefficient, power, free_variable: coefficient * (free_variable ** power), outputs_info=None, sequences=[coefficients, theano.tensor.arange(max_coefficients_supported)], non_sequences=x)
这个例子中,
theano.tensor.arange(max_coefficients_supported)类似于enumerate的index,coefficientes相当与enumerate里到序列值。这里根据顺序,x为free_variable.
Debug:
http://deeplearning.net/software/theano/tutorial/debug_faq.html
theano.config.compute_test_value = 'warn'
import theanodef 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 printingassert numpy.all( f([1, 2, 3]) == [5, 10, 15])#this runs the graph with the message, and value printedassert numpy.all( f_with_print([1, 2, 3]) == [5, 10, 15])