def dcost_fun(y, t, phi, batch_size):
"""computes the gradient of the cost wrt. the weights
Args:
y, t: the predicted probability and target variable tensors of shape (N_examples, K_classes)
phi: feature tensor of shape (N_examples, dim_phi)
Returns:
The gradient tensor of shape (dim_phi, K_classes).
"""
return tf.tensordot(phi, (y - t), axes=([0],[0]))/batch_size
logistic_regression_tf.py 文件源码
python
阅读 30
收藏 0
点赞 0
评论 0
评论列表
文章目录