【问题标题】:torch.CharStorage doesn't read data from a file when size isn't provided未提供大小时,torch.CharStorage 不会从文件中读取数据
【发布时间】:2020-09-03 05:40:02
【问题描述】:

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

【问题讨论】:

    标签: lua torch


    【解决方案1】:

    您似乎遇到了distro bug #245,由提交6a35cd9 引入。如torch7 bug #1064 中所述,您可以通过更新您的pkg/torch 子模块以提交89ede3b 或更新版本,或将其回滚以提交2186e41 或更早版本来解决此问题。

    【讨论】:

    • 是的,我的pkg/torch 目前介于这两个提交之间。你知道我更新到89ede3b 后是否需要重新运行torch/install.sh 脚本吗?
    • @MaxShvets 是的,你会的。但是,如果您按原样运行它,它将撤消您的更新。快速/简单的解决方法是先注释掉the line with git submodule update --init --recursive
    • 我还没有机会尝试你的建议,但我很确定这个问题的原因正如你所描述的那样。我会接受你的回答
    猜你喜欢
    • 2018-08-31
    • 2018-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多