- theano.tensor.nnet.nnet.binary_crossentropy(output, target)
计算如下的公式:
公式中t对应target且只能从0和1里取值,o代表output。
T.arange
-T.mean(T.log(self.p_y_given_x)[T.arange(y.shape[0]), y])
self.p_y_given_x :二维矩阵,每行代表一个样本;
y :向量
T.arange(L) 得到 [0,1…,L-1]
所以[T.arange(y.shape[0]), y]) 相当于[[0, 1…, L-1], [ y[0], y[1]…, y[L-1] ]]