torch.CharStorage 在未提供大小时不从文件中读取数据

torch.CharStorage doesn't read data from a file when size isn't provided

我正在尝试复制提供的示例 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 参数被指定为可选参数。是文档不是最新的还是我做错了什么?

您似乎 运行 到 distro bug #245, introduced by commit 6a35cd9. As stated in torch7 bug #1064, you can work around it by either updating your pkg/torch submodule to commit 89ede3b or newer, or rolling it back to commit 2186e41 或更老。