OpenNMT 玩具示例 (Python3.9) 的问题

如何解决OpenNMT 玩具示例 (Python3.9) 的问题

我最近安装了 opennmt,但在浏览玩具示例时出现以下错误

我有 macOS Big Sur 11.2.1 我安装了python2.7和python3.9。

pip install --upgrade opennmt-py==2.0.0rc1

wget https://s3.amazonaws.com/opennmt-trainingdata/toy-ende.tar.gz

tar xf toy-ende.tar.gz

cd toy_ende

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/bin/onmt_build_vocab",line 8,in <module>
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/onmt/bin/build_vocab.py",line 63,in main
    build_vocab_main(opts)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/onmt/bin/build_vocab.py",line 23,in build_vocab_main
    ArgumentParser.validate_prepare_opts(opts,build_vocab_only=True)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/onmt/utils/parse.py",line 127,in validate_prepare_opts
    cls._validate_data(opt)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/onmt/utils/parse.py",line 42,in _validate_data
    cls._validate_file(path_src,info=f'{cname}/path_src')
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/onmt/utils/parse.py",line 18,in _validate_file
    raise IOError(f"Please check path of your {info} file!")
OSError: Please check path of your corpus_1/path_src file!

解决方法

您可以按照以下步骤操作:

message.channel.send(embed).then((m) => {
     m.react('?'); //reacts with ?

     const filter = (reaction,user) => {
         return user.id != 'put bot id here' || user.id === message.author.id && reaction.emoji.name === '?';
     };
     //this filter is to make sure only the user that called the command can react,and the only emoji collected is ?

     m.awaitReactions(filter,{ max: 1,time: 15000,errors: ['time'] })
     .then(collected => {
         if (collected.first().emoji.name === '?') {
             m.channel.send(`:white_check_mark: you reacted with "?"`).then(m => m.delete({ timeout: 3000 }));
             //when the user reacts with ? - this code is executed
         } else {
             //if the user reacts with any other emoji - remove if you dont want this
             m.channel.send(":x: Command cancelled").then(m => m.delete({ timeout: 3000 }));
         };
     })
        .catch(collected => {
            //if the user does not react in time
            m.channel.send(":x: Command cancelled").then(m => m.delete({ timeout: 3000 }));
     });
});

如果您没有 GPU,则需要删除或注释以下几行:

pip install --upgrade OpenNMT-py==2.0.0rc1;
wget https://s3.amazonaws.com/opennmt-trainingdata/toy-ende.tar.gz;
tar xf toy-ende.tar.gz;
echo '## Where the samples will be written
save_data: toy-ende/run/example
## Where the vocab(s) will be written
src_vocab: toy-ende/run/example.vocab.src
tgt_vocab: toy-ende/run/example.vocab.tgt
# Prevent overwriting existing files in the folder
overwrite: False

# Corpus opts:
data:
    corpus_1:
        path_src: toy-ende/src-train.txt
        path_tgt: toy-ende/tgt-train.txt
    valid:
        path_src: toy-ende/src-val.txt
        path_tgt: toy-ende/tgt-val.txt
' > toy_en_de.yaml;
mkdir toy-ende/run;
touch toy-ende/run/example.vocab.src;
touch toy-ende/run/example.vocab.tgt;
onmt_build_vocab -config toy_en_de.yaml -n_sample 10000;

echo '# Vocabulary files that were just created
src_vocab: toy-ende/run/example.vocab.src
tgt_vocab: toy-ende/run/example.vocab.tgt

# Train on a single GPU
world_size: 1
gpu_ranks: [0]

# Where to save the checkpoints
save_model: toy-ende/run/model
save_checkpoint_steps: 500
train_steps: 1000
valid_steps: 500
' >> toy_en_de.yaml;
onmt_train -config toy_en_de.yaml;

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?