Python Theano二维直方图

Python Theano二维直方图,python,theano,Python,Theano,theano抱怨当我试图用它来计算二维直方图时,从未使用过x0 fth是不起作用的theano实现fnp是按预期工作的numpy实现 import theano import theano.tensor as T import numpy as np def fth(a,b,c): x0 = T.lvector('x0') x1 = T.lvector('x1') z = T.lvector('z') x1 *= x0.size x0 += x1

theano
抱怨当我试图用它来计算二维直方图时,从未使用过
x0

fth
是不起作用的
theano
实现
fnp
是按预期工作的
numpy
实现

import theano
import theano.tensor as T
import numpy as np
def fth(a,b,c):
    x0 = T.lvector('x0')
    x1 = T.lvector('x1')
    z = T.lvector('z')

    x1 *= x0.size
    x0 += x1
    T.subtensor.AdvancedIncSubtensor1(z, x0)
    f = theano.function([x0, x1, z], z)
    return f(a, b, c, on_unused_input='ignore')

def fnp(a, b, c):
    np.add.at(c, a+b*a.size, 1)
    return c

a = np.array([0, 1, 2, 3], dtype=np.int64)
b = np.array([0, 1, 0, 1], dtype=np.int64)
c = np.zeros(16, dtype=np.int64)
print(fnp(a, b, c))
print(fth(a, b, c))
错误:

theano.compile.function_module.UnusedInputError: theano.function
was asked to create a function computing outputs given certain 
inputs, but the provided input variable at index 0 is not part of 
the computational graph needed to compute the outputs: 

    Elemwise{add,no_inplace}.0.

To make this error into a warning, you can pass the parameter 
on_unused_input='warn' to theano.function. To disable it 
completely, use on_unused_input='ignore'.

我猜从gpu获取直方图很难。我猜从gpu获取直方图很难。