使用相同的输入调用单独的theano函数?

时间:2015-09-09 18:51:58

标签: theano

我有这样的事情:

    x=T.matrix('x')
    params = [self.W, self.b1, self.b2]
    hidden = self.activation_function(T.dot(x, self.W)+self.b1)
    output = T.dot(hidden,T.transpose(self.W))+self.b2
    output = self.output_function(output)

    L = -T.sum(x*T.log(output) + (1-x)*T.log(1-output), axis=1)
    cost=L.mean()       
    th_train = th.function(inputs=[index], outputs=[cost], updates=updates,
                        givens={x:self.X[index:index+mini_batch_size,:]})

这很好用。我现在想看看隐藏单位的意思是什么。我尝试在声明L = -T.sum...的行之前添加它:

    hm = T.mean(hidden)
    hidden_mean_func = th.function(inputs=[hm], outputs=[hm], name="hidden_mean_function_printer")
    print hidden_mean_func(hm)

我收到以下错误:

TypeError: ('Bad input argument to theano function with name "hidden_mean_function_printer" at index 0(0-based)', 'Expected an array-like object, but found a Variable: maybe you are trying to call a function on a (possibly shared) variable instead of a numeric array?')

我真的有两个问题:1)为什么我不能这样做? 2)达到我想要的正确方法是什么?

谢谢

0 个答案:

没有答案
相关问题