运行tensorflow代码:
loss = tf.reduce_mean(tf.reduce_sum(tf.square(ys - prediction), reduction_indices=[1]))
错误提示: TypeError: reduce_sum() got an unexpected keyword argument ‘reduction_indice’
出错原因: 在reduce_sum()函数中参数:reduction_indices已经被废弃,取而代之的是参数:axis
修改tensorflow代码为:
loss = tf.reduce_mean(tf.reduce_sum(tf.square(ys - prediction), axis=[1]))
运行成功。
本文解决了在使用TensorFlow进行机器学习编程时遇到的TypeError问题,详细介绍了如何将已废弃的reduction_indices参数替换为新的axis参数,确保代码正常运行。
8万+

被折叠的 条评论
为什么被折叠?



