Tensorflow框架两种cost函数:MSE和Multi-class

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情况下:矩阵(不分行列)所有元素求平均。

你可能感兴趣的:(T型牌坊)