python - 如何使用 tensorflow 对 Tensor 阶段进行切片
问题描述
如何使用 tensorflow 对 Tensor 阶段进行切片:
tensor = tf.constant([[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5] ] )
list = [0,2]
我想得到结果张量:
result_tensor = [[1,2,3],[1,2,3],[1,2,3]]
解决方案
tensor =tf.constant([[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5] ] )
lst = [0,2]
tensor[:, lst[0]:lst[1]+1]
推荐阅读
- firebase - 避免向使用 Firebase 函数构建的 API 发送垃圾邮件
- android - 在 RecyclerView 中自动调整 TextView 会导致文本大小减小
- php - 从插入的表字段更新数据库
- java - 在java中使用Robot类上传照片
- magento - 如何在自定义结帐步骤中添加动态单选按钮?
- ibm-cloud-infrastructure - REST API 用于检索读/写字节数的块存储指标
- windows - Windows批处理文件,如何重命名和删除部分文件名
- git - How can I remove all commits in git?
- javascript - 隐藏输入字段时,Jquery将文本复制到剪贴板
- android - 如何从 Fragment 类中的 AsyncTask 类的 onPostExecute 函数中删除片段