版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Arctic_Beacon/article/details/84344987
import tensorflow as tf
def MSE_cost(out,Y):
cost = tf.reduce_mean(tf.square(out-Y))
return cost
def multiclass_cost(out,Y):
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=out,labels=Y))
return cost
tf.reduce_mean就是求平均值,默认axis情况下:矩阵(不分行列)所有元素求平均。