标签:variable square div span oba put array flow nump
import numpy as np import tensorflow as tf y_pred = np.array([[1], [2], [3]],dtype=np.float32) y_real = np.array([[1], [1], [1]]) bias = np.array([1,2,3,4],dtype=np.float32) with tf.Session() as sess: sess.run(tf.global_variables_initializer()) Input = tf.reduce_mean(tf.square(y_pred-y_real)) # ============================================================================= # tf.square(y_pred-y_real) # [[0] # [1] # [4]] # ============================================================================= result = sess.run(Input) print(result)
#返回1.6666666666666667,如果不加轴的话,返回的是一个数
标签:variable square div span oba put array flow nump
原文地址:https://www.cnblogs.com/wzdLY/p/9749068.html