torch.CharStorage 不提供 size 时不能从文件中读取数据

我在尝试模仿这里提供的例子here。然而,在我的情况下,当我执行 torch.CharStorage('hello.txt') 时,我得到了 [torch.CharStorage of size 0]。下面是完整的输出

$ echo "Hello World" > hello.txt
$ th

   ______             __   |  Torch7
  /_  __/__  ________/ /   |  Scientific computing for Lua.
   / / / _ \/ __/ __/ _ \  |  Type ? for help
  /_/  \___/_/  \__/_//_/  |  https://github.com/torch
                           |  http://torch.ch

th> x = torch.CharStorage('hello.txt')
                                                                  [0.0001s]
th> x
[torch.CharStorage of size 0]

我还注意到当我执行 torch.CharStorage('hello.txt', false, 11) 时,数据被正确地读取。但是,在 documentation 中,sharedsize参数被指定为可选参数。难道这份文档已经不是最新版了,或者我做错了些什么?

点赞
用户7509065
用户7509065

你好像遇到了 distro bug #245,这是由提交 6a35cd9 引入的。根据 torch7 bug #1064 的说明,你可以通过将你的 pkg/torch 子模块更新到提交 89ede3b 或更新版本,或将其回滚到提交 2186e41 或旧版本来解决。

2020-05-18 00:14:32