TypeError: loop of ufunc does not support argument 0 of type Tensor which has no callable sqrt met

使用tensorflow时出现的一错误

  • 利用CNN预测时,计算均方根误差报错如下:
cross_entropy = np.sqrt(tf.reduce_mean(tf.reduce_sum(tf.square(ys - prediction), reduction_indices=[1])))

错误如下:
TypeError: loop of ufunc does not support argument 0 of type Tensor which has no callable sqrt met
原因应该是numpy要求输入的是矩阵,输入类型不对,改为:

cross_entropy = tf.sqrt(tf.reduce_mean(tf.reduce_sum(tf.square(ys - prediction), reduction_indices=[1])))

就可以了

你可能感兴趣的:(tensorflow)