提交 f0bba396 编写于 作者: Z Zeyu Chen

correct log info grammar

上级 dae2ef9b
export CUDA_VISIBLE_DEVICES=0 export CUDA_VISIBLE_DEVICES=0
CKPT_DIR="./ckpt_question_matching" CKPT_DIR="./ckpt_question_matching"
python -u sentiment_cls.py \ python -u question_matching.py \
--batch_size 32 \ --batch_size 32 \
--weight_decay 0.00 \ --weight_decay 0.0 \
--checkpoint_dir $CKPT_DIR \ --checkpoint_dir $CKPT_DIR \
--num_epoch 3 \ --num_epoch 3 \
--max_seq_len 128 \ --max_seq_len 128 \
......
...@@ -12,9 +12,13 @@ ...@@ -12,9 +12,13 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# NLP Dataset
from .dataset import InputExample, HubDataset from .dataset import InputExample, HubDataset
from .chnsenticorp import ChnSentiCorp from .chnsenticorp import ChnSentiCorp
from .msra_ner import MSRA_NER from .msra_ner import MSRA_NER
from .nlpcc_dbqa import NLPCC_DBQA from .nlpcc_dbqa import NLPCC_DBQA
from .lcqmc import LCQMC
# CV Dataset
from .dogcat import DogCatDataset as DogCat from .dogcat import DogCatDataset as DogCat
from .flowers import FlowersDataset as Flowers from .flowers import FlowersDataset as Flowers
...@@ -24,7 +24,7 @@ from paddlehub.common.logger import logger ...@@ -24,7 +24,7 @@ from paddlehub.common.logger import logger
DATA_URL = "https://paddlehub-dataset.bj.bcebos.com/lcqmc.tar.gz" DATA_URL = "https://paddlehub-dataset.bj.bcebos.com/lcqmc.tar.gz"
class NLPCC_DBQA(HubDataset): class LCQMC(HubDataset):
def __init__(self): def __init__(self):
self.dataset_dir = os.path.join(DATA_HOME, "lcqmc") self.dataset_dir = os.path.join(DATA_HOME, "lcqmc")
if not os.path.exists(self.dataset_dir): if not os.path.exists(self.dataset_dir):
...@@ -79,6 +79,6 @@ class NLPCC_DBQA(HubDataset): ...@@ -79,6 +79,6 @@ class NLPCC_DBQA(HubDataset):
if __name__ == "__main__": if __name__ == "__main__":
ds = NLPCC_DBQA() ds = LCQMC()
for e in ds.get_train_examples(): for e in ds.get_train_examples():
print("{}\t{}\t{}\t{}".format(e.guid, e.text_a, e.text_b, e.label)) print("{}\t{}\t{}\t{}".format(e.guid, e.text_a, e.text_b, e.label))
...@@ -154,16 +154,16 @@ class ModuleChecker: ...@@ -154,16 +154,16 @@ class ModuleChecker:
if not os.path.exists(file_path): if not os.path.exists(file_path):
if file_info.is_need: if file_info.is_need:
logger.error( logger.error(
"module lack of necessary file [%s]" % file_path) "Module incompleted! Missing file [%s]" % file_path)
return False return False
else: else:
if file_type == check_info_pb2.FILE: if file_type == check_info_pb2.FILE:
if not os.path.isfile(file_path): if not os.path.isfile(file_path):
logger.error("file type error %s" % file_path) logger.error("File type error %s" % file_path)
return False return False
if file_type == check_info_pb2.DIR: if file_type == check_info_pb2.DIR:
if not os.path.isdir(file_path): if not os.path.isdir(file_path):
logger.error("file type error %s" % file_path) logger.error("File type error %s" % file_path)
return False return False
return True return True
...@@ -61,13 +61,14 @@ class LocalModuleManager: ...@@ -61,13 +61,14 @@ class LocalModuleManager:
self.all_modules(update=True) self.all_modules(update=True)
if module_name in self.modules_dict: if module_name in self.modules_dict:
module_dir = self.modules_dict[module_name] module_dir = self.modules_dict[module_name]
tips = "module %s already install in %s" % (module_name, module_dir) tips = "Module %s already installed in %s" % (module_name,
module_dir)
return True, tips, module_dir return True, tips, module_dir
url = hub.default_hub_server.get_module_url( url = hub.default_hub_server.get_module_url(
module_name, version=module_version) module_name, version=module_version)
#TODO(wuzewu): add compatibility check #TODO(wuzewu): add compatibility check
if not url: if not url:
tips = "can't found module %s" % module_name tips = "Can't find module %s" % module_name
if module_version: if module_version:
tips += " with version %s" % module_version tips += " with version %s" % module_version
return False, tips, None return False, tips, None
......
...@@ -128,7 +128,7 @@ class Module(object): ...@@ -128,7 +128,7 @@ class Module(object):
self._generate_module_info(module_info) self._generate_module_info(module_info)
self._init_with_signature(signatures=signatures) self._init_with_signature(signatures=signatures)
else: else:
raise "Error! HubModule can't init with nothing" raise ValueError("Error! Module initialized parameter is empty")
def _init_with_name(self, name): def _init_with_name(self, name):
logger.info("Try installing module %s" % name) logger.info("Try installing module %s" % name)
...@@ -191,7 +191,8 @@ class Module(object): ...@@ -191,7 +191,8 @@ class Module(object):
def _init_with_module_file(self, module_dir): def _init_with_module_file(self, module_dir):
checker = ModuleChecker(module_dir) checker = ModuleChecker(module_dir)
if not checker.check(): if not checker.check():
logger.error("Module init failed on {}".format(module_dir)) logger.error(
"Module initialization failed on {}".format(module_dir))
exit(1) exit(1)
self.helper = ModuleHelper(module_dir) self.helper = ModuleHelper(module_dir)
...@@ -223,7 +224,9 @@ class Module(object): ...@@ -223,7 +224,9 @@ class Module(object):
self.program = signatures[0].inputs[0].block.program self.program = signatures[0].inputs[0].block.program
for sign in signatures: for sign in signatures:
if sign.name in self.signatures: if sign.name in self.signatures:
raise "Error! signature array contains repeat signatrue %s" % sign raise ValueError(
"Error! Signature array contains duplicated signatrues %s" %
sign)
if self.default_signature is None and sign.for_predict: if self.default_signature is None and sign.for_predict:
self.default_signature = sign self.default_signature = sign
self.signatures[sign.name] = sign self.signatures[sign.name] = sign
...@@ -265,7 +268,7 @@ class Module(object): ...@@ -265,7 +268,7 @@ class Module(object):
self.module_info = {} self.module_info = {}
else: else:
if not utils.is_yaml_file(module_info): if not utils.is_yaml_file(module_info):
logger.critical("module info file should in yaml format") logger.critical("Module info file should be yaml format")
exit(1) exit(1)
self.module_info = yaml_parser.parse(module_info) self.module_info = yaml_parser.parse(module_info)
self.author = self.module_info.get('author', 'UNKNOWN') self.author = self.module_info.get('author', 'UNKNOWN')
...@@ -532,7 +535,7 @@ class Module(object): ...@@ -532,7 +535,7 @@ class Module(object):
return self.get_name_prefix() + var_name return self.get_name_prefix() + var_name
def _check_signatures(self): def _check_signatures(self):
assert self.signatures, "signature array should not be None" assert self.signatures, "Signature array should not be None"
for key, sign in self.signatures.items(): for key, sign in self.signatures.items():
assert isinstance(sign, assert isinstance(sign,
......
...@@ -47,13 +47,11 @@ class Signature: ...@@ -47,13 +47,11 @@ class Signature:
self.name = name self.name = name
for item in inputs: for item in inputs:
assert isinstance( assert isinstance(
item, item, Variable), "the item of inputs list shoule be Variable"
Variable), "the item of inputs list shoule be paddle Variable"
for item in outputs: for item in outputs:
assert isinstance( assert isinstance(
item, item, Variable), "the item of outputs list shoule be Variable"
Variable), "the item of outputs list shoule be paddle Variable"
self.inputs = inputs self.inputs = inputs
self.outputs = outputs self.outputs = outputs
......
...@@ -12,5 +12,5 @@ ...@@ -12,5 +12,5 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
""" PaddleHub version string """ """ PaddleHub version string """
hub_version = "0.3.1.alpha" hub_version = "0.4.0.alpha"
module_proto_version = "0.1.0" module_proto_version = "1.0.0"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册