相关疑难解决方法(0)

tf.gather_nd直观地做了什么?

您能直观地解释或提供有关tf.gather_nd在Tensorflow中对高维张量进行索引和切片的更多示例吗?

我阅读了API,但它保持非常简洁,我发现自己很难遵循函数的概念.

tensorflow

23
推荐指数
1
解决办法
8015
查看次数

如何在Tensorflow中进行切片分配

我发现Tensorflow提供了scatter_update()为0维度中的张量切片赋值.例如,如果张量T是三维的,我可以赋值v[1, :, :]T[i, :, :].

a = tf.Variable(tf.zeros([10,36,36]))   
value = np.ones([1,36,36])   
d = tf.scatter_update(a,[0],value)

with tf.Session() as sess:
    sess.run(tf.initialize_all_variables())
    print a.eval()
    sess.run(d)
    print a.eval()
Run Code Online (Sandbox Code Playgroud)

但是如何赋值v[1,1,:]T[i,j,:]

a = tf.Variable(tf.zeros([10,36,36]))   
value1 = np.random.randn(1,1,36)    
e = tf.scatter_update(a,[0],value1) #Error

with tf.Session() as sess:
    sess.run(tf.initialize_all_variables())
    print a.eval()
    sess.rum(e)
    print a.eval()
Run Code Online (Sandbox Code Playgroud)

是否有TF提供的其他功能或简单的方法?

python-2.7 tensorflow

21
推荐指数
2
解决办法
2万
查看次数

标签 统计

tensorflow ×2

python-2.7 ×1