分开张量通道
我正在将大小的张量[1,3,224,224]
倾倒到一个文件中,并希望将大小的3个张量分为
[1,1,1,224,224]
,每个RGB通道一个并将它们倒入3个单独的文件中。我该如何实施?
I am dumping a tensor of size [1,3,224,224]
to a file and would like to split into 3 tensors of size [1,1,224,224]
, one for each RGB channel and dump them into 3 separate files. How do I implement this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为最简单的方法是通过循环:
注意第二个(通道)维度的索引:您希望保存的张量具有单元通道尺寸。如果要使用
x [:,c,...]
进行索引全部)。I think the simplest way is by a loop:
Note the indexing of the second (channel) dimension: you want the saved tensor to have a singleton channel dimension. If you were to index it using
x[:, c, ...]
you will get a tensor of shape[1, 224, 224]
(no channel dimension at all).