脚本错误:没有命名的模块通用.超参数

2024-05-23 19:52:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试运行以下代码:

#!/usr/bin/env python

if __name__ == "__main__":
**import common.hyperparameters, common.options**
HYPERPARAMETERS = common.hyperparameters.read("language-model")
HYPERPARAMETERS, options, args, newkeystr = common.options.reparse(HYPERPARAMETERS)
import hyperparameters

import vocabulary
import common.idmap

words = []

import string
for i, l in enumerate(common.file.myopen(HYPERPARAMETERS["MONOLINGUAL_VOCABULARY"])):
    if HYPERPARAMETERS["INCLUDE_UNKNOWN_WORD"] and i+1 >= HYPERPARAMETERS["MONOLINGUAL_VOCABULARY_SIZE"]:
        break
    if not HYPERPARAMETERS["INCLUDE_UNKNOWN_WORD"] and i >= HYPERPARAMETERS["MONOLINGUAL_VOCABULARY_SIZE"]:
        break
    (cnt, w) = string.split(l)
    words.append(w)

v = common.idmap.IDmap(words, allow_unknown=HYPERPARAMETERS["INCLUDE_UNKNOWN_WORD"])
assert v.len == HYPERPARAMETERS["MONOLINGUAL_VOCABULARY_SIZE"]
vocabulary.write(v)

这里有一个包含超参数.py,即使这样,它也无法将该脚本合并到我的主程序中。我不知道怎么把这个加到我的程序里。在


Tags: importsizeifincludecommonunknownwordoptions