Python 2.7 计算Theano中两个热图之间的交叉熵损失

Python 2.7 计算Theano中两个热图之间的交叉熵损失,python-2.7,theano,Python 2.7,Theano,我对计算Theano中的交叉熵损失有一个问题 具体来说,对于我的网络: Input: (20,14,90,60) (batchsize,channels,h,w) filter: (14,14,9,9) output: (20,1,90,60) groundtruth: (20,1,90,60) 我想计算每个输出的交叉熵: for i in xrange(20): sum(category_crossentropy(output[i,:,:,:],groundtruth[i,:,:,:

我对计算Theano中的交叉熵损失有一个问题

具体来说,对于我的网络:

Input: (20,14,90,60) (batchsize,channels,h,w)
filter: (14,14,9,9)
output: (20,1,90,60)
groundtruth: (20,1,90,60)
我想计算每个输出的交叉熵:

for i in xrange(20):
    sum(category_crossentropy(output[i,:,:,:],groundtruth[i,:,:,:]))
在编号、
类别交叉熵(编码距离、真实距离)
中,输入必须是矩阵。 然而,当程序调用cost时,
自身输出
[20,1,90,60]
,基本事实是
张量矩阵

def crossEntropy(self,groundtruth):
    error = crossentropy(self.output,groundtruth)
    return error

y = T.matrix('y')
cost = refine_Net.crossEntropy(y)
    train_model = theano.function(
            inputs=[index],
            outputs=cost,
            updates=updates,
            given={
                x: train_Data[index*batch_size:(index+1)*batch_size],
                y: train_Target[index*batch_size:(index+1)*batch_size]
                })
TypeError:argument:coding\u dist需要矩阵