Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python theano中的倾斜损失_Python_Theano_Keras - Fatal编程技术网

Python theano中的倾斜损失

Python theano中的倾斜损失,python,theano,keras,Python,Theano,Keras,我试图计算倾斜损失,这反过来将用于Keras。然而,我一定是做错了什么,因为我得到了负的损失值(这应该是不可能的)。谁能指出我做错了什么。我想我弄错的是theano语法 损失在数学上定义为: 其中$\xi_i=y_i-f_i$,其中$y_i$是观测值,$f_i$是预测值。此外,我追求的是平均损失,因此我将损失函数定义为: $$ \mathcal{L} = \frac{\alpha\sum \xi_i-\sum I(\xi_i<0)\xi_i}{N} $$ $$ \mathcal{L}=\

我试图计算倾斜损失,这反过来将用于Keras。然而,我一定是做错了什么,因为我得到了负的损失值(这应该是不可能的)。谁能指出我做错了什么。我想我弄错的是theano语法

损失在数学上定义为: 其中$\xi_i=y_i-f_i$,其中$y_i$是观测值,$f_i$是预测值。此外,我追求的是平均损失,因此我将损失函数定义为:

$$
\mathcal{L} = \frac{\alpha\sum \xi_i-\sum I(\xi_i<0)\xi_i}{N}
$$
$$

\mathcal{L}=\frac{\alpha\sum\xi_i-\sum i(\xi_i您不能这样切片

您需要按如下方式更改损失函数:

def tilted_loss2(y,f):
    q = 0.05
    e = (y-f)
    return (q*tt.sum(e)-tt.sum(e[e<0]))/e.shape[0]
def tilted_loss2(y,f):
    q = 0.05
    e = (y-f)
    return (q*tt.sum(e)-tt.sum(e[(e<0).nonzero()]))/e.shape[0]

你不能这样切

您需要按如下方式更改损失函数:

def tilted_loss2(y,f):
    q = 0.05
    e = (y-f)
    return (q*tt.sum(e)-tt.sum(e[e<0]))/e.shape[0]
def tilted_loss2(y,f):
    q = 0.05
    e = (y-f)
    return (q*tt.sum(e)-tt.sum(e[(e<0).nonzero()]))/e.shape[0]