Slicing a tensor by using indices in Tensorflow

冷暖自知 提交于 2019-11-30 03:47:12

问题


Basically I have a 2d array and I want to do this nice numpy-like thing

noise_spec[:rows,:cols]

in Tensorflow. Here rows and cols are just two integers.


回答1:


Indeed, TensorFlow now has better support for slicing, so you can use the exact same syntax as NumPy:

result = noise_spec[:rows, :cols]



回答2:


found out, it's

tf.slice(noise_spec, [0,0],[rows, cols])


来源:https://stackoverflow.com/questions/41715511/slicing-a-tensor-by-using-indices-in-tensorflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!