类似于this的东西,它说用Keras不可能(或非常困难)定义依赖于训练模型的损失函数。我想知道是否可以在TensorFlow或pyTorch中定义这种损失函数。
一个简化的示例问题如下:
基本上,模型采用两个输入(x,p)并产生一个输出(c)。即c = f(x,p)。模型的输入和输出是
"Cats are like dogs"
当然,模型与样本数i和时间t无关。因此,目标是找到从(x,y)到(c)的转换,使得c是时间的不变性。
损失函数应构建为
Input data = x(i,t), p(i,t)
output data = c(i,t)
i=1,2,3,...N is the sample number
t=1,2,3,...T is the time series
例如,我们可以将损失函数构建为
c(i,t) is same for all t (i.e., constant of motion)
但是,如您所见,损失函数取决于c(t)= f(x(i,t),p(i,t))
更简单的情况是
loss = sum_over_t (c(i,0)-c(i,t))**2