使用Tensorflow中的索引切片张量 [英] Slicing a tensor by using indices in Tensorflow
本文介绍了使用Tensorflow中的索引切片张量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基本上我有一个二维数组,我想做一些类似numpy的事情
Basically I have a 2d array and I want to do this nice numpy-like thing
noise_spec[:rows,:cols]
在Tensorflow中.这里的行和列只是两个整数.
in Tensorflow. Here rows and cols are just two integers.
推荐答案
实际上,TensorFlow现在对切片具有更好的支持,因此您可以使用与NumPy完全相同的语法:
Indeed, TensorFlow now has better support for slicing, so you can use the exact same syntax as NumPy:
result = noise_spec[:rows, :cols]
这篇关于使用Tensorflow中的索引切片张量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文