Keras K.mean

Keras K.mean

>>> bb
<tf.Tensor: shape=(5,), dtype=int32, numpy=array([1, 1, 1, 0, 0])>
>>> tf.reduce_mean(bb)
<tf.Tensor: shape=(), dtype=int32, numpy=0>
>>> bb = tf.convert_to_tensor([1,1,1,0,0],dtype=tf.float32)
>>> tf.reduce_mean(bb)
<tf.Tensor: shape=(), dtype=float32, numpy=0.6>
>>>
 

 

 

如果,tensor类型是int类型的话,那么不管是tf.redunce_mean(),还是说使用K.mean(),都直接会是0