【发布时间】:2017-10-25 03:34:10
【问题描述】:
我正在使用相同的逻辑代码将 tensorflow 与 numpy 进行比较。
在实现 tf.where 时,我无法得到与 np.where 相同的结果
下面的代码或用法有什么问题?
数据:
X_batch = np.concatenate([np.arange(10).reshape(1, -1) for i in range(10)], axis=0)
tensorflow tf.where 玩具代码:
X = tf.placeholder(dtype=tf.int32, shape=[10, 10])
with tf.Session() as sess:
print(sess.run(tf.where(X > 5, tf.zeros([10, 10], dtype=tf.int32),
X), feed_dict={X: X_batch}))
numpy np.where 玩具代码:
np.where(X_batch > 5, np.zeros([10,10]), X_batch)
代码有一些拼写错误。修正完成
【问题讨论】:
标签: python numpy tensorflow