张量流创建不同长度的掩码 [英] tensorflow creating mask of varied lengths

查看:132
本文介绍了张量流创建不同长度的掩码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在tensorflow中有一个长度的张量,让我们说它看起来像这样:

I have a tensor of lengths in tensorflow, let's say it looks like this:

[4, 3, 5, 2]

我希望创建一个1和0的掩码,其1的数量与该张量的条目相对应,用0填充到总长度8.我想创建这个张量:

I wish to create a mask of 1s and 0s whose number of 1s correspond to the entries to this tensor, padded by 0s to a total length of 8. I.e. I want to create this tensor:

[[1,1,1,1,0,0,0,0],
 [1,1,1,0,0,0,0,0],
 [1,1,1,1,1,0,0,0],
 [1,1,0,0,0,0,0,0]
]

我该怎么办?

推荐答案

可以使用各种 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆