Hua*_*eng 0 python numpy tensorflow
我想改变张量的值t到a哪里它的价值是b,它可以在numpy的作为来表示:
t[t == b] = a
Run Code Online (Sandbox Code Playgroud)
这将创建一个指定的新张量:
t2 = tf.where( tf.equal( b, t ), a * tf.ones_like( t ), t )
Run Code Online (Sandbox Code Playgroud)
如果你想改变你的值,t你只能这样做 ift是一个变量,而不是一个简单的张量,然后你可以使用assign:
tf.assign( t, t2 )
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2298 次 |
| 最近记录: |