BrikerMan / Kashgari

Kashgari is a production-level NLP Transfer learning framework built on top of tf.keras for text-labeling and text-classification, includes Word2Vec, BERT, and GPT2 Language Embedding.
http://kashgari.readthedocs.io/
Apache License 2.0
2.39k stars 441 forks source link

[Question] No such layer: Embedding-Token #218

Closed captain2017 closed 5 years ago

captain2017 commented 5 years ago

Check List

Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.

You can post pictures, but if specific text or code is required to reproduce the issue, please provide the text in a plain text format for easy copy/paste.

Environment

Question

from kashgari.tasks.labeling import BiLSTM_Model
import tensorflow as tf

# 还可以选择 `CNN_LSTM_Model`, `BiLSTM_Model`, `BiGRU_Model` 或 `BiGRU_CRF_Model`

model = BiLSTM_Model(bert_embed)
model.build_multi_gpu_model(gpus=2,cpu_merge= False,cpu_relocation=False,x_train=train_x,y_train=train_y)
model.compile_model(optimizer=tf.keras.optimizers.Adam(lr=0.05))
model.fit(train_x,
          train_y,
          x_validate=valid_x,
          y_validate=valid_y,
          epochs=20,
          batch_size=512)

image image image 我跑了你的colab都行,不知道我的为什么不行

BrikerMan commented 5 years ago

可能和环境有关系,麻烦按照规范编辑一下 issue,补全信息。否则作为无效 issue 处理。

captain2017 commented 5 years ago

帮忙看一下,谢谢

BrikerMan commented 5 years ago

使用命令 pip list 对比一下依赖版本号吧。

captain2017 commented 5 years ago

Package Version


absl-py 0.7.1
astor 0.8.0
attrs 19.1.0
backcall 0.1.0
bert-base 0.0.9
bert-serving-client 1.9.3
bert-serving-server 1.9.3
bleach 3.1.0
boto 2.49.0
boto3 1.9.188
botocore 1.12.188 certifi 2019.6.16 chardet 3.0.4
Click 7.0
colorama 0.4.1
cycler 0.10.0
decorator 4.4.0
defusedxml 0.6.0
Django 2.2.4
docutils 0.14
entrypoints 0.3
et-xmlfile 1.0.1
facets 1.1.0
gast 0.2.2
gensim 3.8.0
google-pasta 0.1.7
GPUtil 1.4.0
grpcio 1.22.0
h5py 2.9.0
html5lib 1.0.1
idna 2.8
ipykernel 5.1.2
ipython 7.7.0
ipython-genutils 0.2.0
jdcal 1.4.1
jedi 0.13.3
jieba 0.39
Jinja2 2.10.1
jmespath 0.9.4
joblib 0.13.2
JPype1 0.7.0
jsonschema 3.0.1
jupyter-client 5.3.1
jupyter-contrib-core 0.3.3
jupyter-contrib-nbextensions 0.5.1
jupyter-core 4.5.0
jupyter-highlight-selected-word 0.2.0
jupyter-latex-envs 1.4.4
jupyter-nbextensions-configurator 0.4.1
kashgari-tf 0.5.3
Keras 2.2.4
keras-adaptive-softmax 0.6.0
Keras-Applications 1.0.8
keras-bert 0.68.2
keras-embed-sim 0.7.0
keras-gpt-2 0.12.0
keras-layer-normalization 0.12.0
keras-multi-head 0.20.0
keras-pos-embd 0.11.0
keras-position-wise-feed-forward 0.6.0
Keras-Preprocessing 1.1.0
keras-rectified-adam 0.4.0
keras-self-attention 0.41.0
keras-transformer 0.28.0
keras-transformer-xl 0.7.0
keras-xlnet 0.0.3
kiwisolver 1.1.0
lxml 4.4.1
Markdown 3.1.1
MarkupSafe 1.1.1
matplotlib 3.1.0
mistune 0.8.4
mkl-fft 1.0.12
mkl-random 1.0.2
nb-conda 2.2.1
nb-conda-kernels 2.2.2
nbconvert 5.6.0
nbformat 4.4.0
neobolt 1.7.13
neotime 1.7.4
notebook 6.0.0
numpy 1.16.4
openpyxl 2.6.2
pandas 0.25.0
pandas-profiling 1.4.0
pandocfilters 1.4.2
parso 0.5.0
pexpect 4.7.0
pickleshare 0.7.5
Pillow 6.1.0
pip 19.1.1
prometheus-client 0.7.1
prompt-toolkit 2.0.9
protobuf 3.9.0
ptyprocess 0.6.0
py2neo 4.3.0
Pygments 2.4.2
pyhanlp 0.1.48
pyparsing 2.4.0
pyrsistent 0.14.11
python-dateutil 2.8.0
pytorch-transformers 1.0.0
pytz 2019.1
PyYAML 5.1.2
pyzmq 18.0.2
regex 2019.6.8 requests 2.22.0
s3transfer 0.2.1
scikit-learn 0.21.2
scipy 1.3.0
Send2Trash 1.5.0
sentencepiece 0.1.82
seqeval 0.0.10
setuptools 41.0.1
six 1.12.0
smart-open 1.8.4
sqlparse 0.3.0
tensorboard 1.14.0
tensorboardX 1.8
tensorflow-estimator 1.14.0
tensorflow-gpu 1.14.0
termcolor 1.1.0
terminado 0.8.2
testpath 0.4.2
torch 1.1.0
torchvision 0.3.0
tornado 6.0.3
tqdm 4.32.2
traitlets 4.3.2
urllib3 1.24.3
wcwidth 0.1.7
webencodings 0.5.1
Werkzeug 0.15.4
wheel 0.33.4
wrapt 1.11.2
xgboost 0.90
xlrd 1.2.0
Note: you may need to restart the kernel to use updated packages.

BrikerMan commented 5 years ago

Package Version

absl-py 0.7.1 astor 0.8.0 attrs 19.1.0 backcall 0.1.0 bert-base 0.0.9 bert-serving-client 1.9.3 bert-serving-server 1.9.3 bleach 3.1.0 boto 2.49.0 boto3 1.9.188 botocore 1.12.188 certifi 2019.6.16 chardet 3.0.4 Click 7.0 colorama 0.4.1 cycler 0.10.0 decorator 4.4.0 defusedxml 0.6.0 Django 2.2.4 docutils 0.14 entrypoints 0.3 et-xmlfile 1.0.1 facets 1.1.0 gast 0.2.2 gensim 3.8.0 google-pasta 0.1.7 GPUtil 1.4.0 grpcio 1.22.0 h5py 2.9.0 html5lib 1.0.1 idna 2.8 ipykernel 5.1.2 ipython 7.7.0 ipython-genutils 0.2.0 jdcal 1.4.1 jedi 0.13.3 jieba 0.39 Jinja2 2.10.1 jmespath 0.9.4 joblib 0.13.2 JPype1 0.7.0 jsonschema 3.0.1 jupyter-client 5.3.1 jupyter-contrib-core 0.3.3 jupyter-contrib-nbextensions 0.5.1 jupyter-core 4.5.0 jupyter-highlight-selected-word 0.2.0 jupyter-latex-envs 1.4.4 jupyter-nbextensions-configurator 0.4.1 kashgari-tf 0.5.3 Keras 2.2.4 keras-adaptive-softmax 0.6.0 Keras-Applications 1.0.8 keras-bert 0.68.2 keras-embed-sim 0.7.0 keras-gpt-2 0.12.0 keras-layer-normalization 0.12.0 keras-multi-head 0.20.0 keras-pos-embd 0.11.0 keras-position-wise-feed-forward 0.6.0 Keras-Preprocessing 1.1.0 keras-rectified-adam 0.4.0 keras-self-attention 0.41.0 keras-transformer 0.28.0 keras-transformer-xl 0.7.0 keras-xlnet 0.0.3 kiwisolver 1.1.0 lxml 4.4.1 Markdown 3.1.1 MarkupSafe 1.1.1 matplotlib 3.1.0 mistune 0.8.4 mkl-fft 1.0.12 mkl-random 1.0.2 nb-conda 2.2.1 nb-conda-kernels 2.2.2 nbconvert 5.6.0 nbformat 4.4.0 neobolt 1.7.13 neotime 1.7.4 notebook 6.0.0 numpy 1.16.4 openpyxl 2.6.2 pandas 0.25.0 pandas-profiling 1.4.0 pandocfilters 1.4.2 parso 0.5.0 pexpect 4.7.0 pickleshare 0.7.5 Pillow 6.1.0 pip 19.1.1 prometheus-client 0.7.1 prompt-toolkit 2.0.9 protobuf 3.9.0 ptyprocess 0.6.0 py2neo 4.3.0 Pygments 2.4.2 pyhanlp 0.1.48 pyparsing 2.4.0 pyrsistent 0.14.11 python-dateutil 2.8.0 pytorch-transformers 1.0.0 pytz 2019.1 PyYAML 5.1.2 pyzmq 18.0.2 regex 2019.6.8 requests 2.22.0 s3transfer 0.2.1 scikit-learn 0.21.2 scipy 1.3.0 Send2Trash 1.5.0 sentencepiece 0.1.82 seqeval 0.0.10 setuptools 41.0.1 six 1.12.0 smart-open 1.8.4 sqlparse 0.3.0 tensorboard 1.14.0 tensorboardX 1.8 tensorflow-estimator 1.14.0 tensorflow-gpu 1.14.0 termcolor 1.1.0 terminado 0.8.2 testpath 0.4.2 torch 1.1.0 torchvision 0.3.0 tornado 6.0.3 tqdm 4.32.2 traitlets 4.3.2 urllib3 1.24.3 wcwidth 0.1.7 webencodings 0.5.1 Werkzeug 0.15.4 wheel 0.33.4 wrapt 1.11.2 xgboost 0.90 xlrd 1.2.0 Note: you may need to restart the kernel to use updated packages.

麻烦你自己和正常的 colab 对比一下,要么提供一个可以复现问题的 colab

captain2017 commented 5 years ago

embedding: Embedding = embed_class._load_saved_instance(embed_info, model_path, model.tf_model)

captain2017 commented 5 years ago

这段话什么意思?model.tf_model是干什么的

captain2017 commented 5 years ago

我是不是还需要储存一下bertembedding

captain2017 commented 5 years ago

image 用人民日报的存储的模型就能跑,自己的模型就读不了

captain2017 commented 5 years ago

model.build_multi_gpu_model(gpus=2,cpu_merge= False,cpu_relocation=False,x_train=train_x,y_train=train_y) 删了这句话就能用,能解释一下吗,是不能用多gpu吗

QGB commented 4 years ago

Package Version absl-py 0.7.1 astor 0.8.0 attrs 19.1.0 backcall 0.1.0 bert-base 0.0.9 bert-serving-client 1.9.3 bert-serving-server 1.9.3 bleach 3.1.0 boto 2.49.0 boto3 1.9.188 botocore 1.12.188 certifi 2019.6.16 chardet 3.0.4 Click 7.0 colorama 0.4.1 cycler 0.10.0 decorator 4.4.0 defusedxml 0.6.0 Django 2.2.4 docutils 0.14 entrypoints 0.3 et-xmlfile 1.0.1 facets 1.1.0 gast 0.2.2 gensim 3.8.0 google-pasta 0.1.7 GPUtil 1.4.0 grpcio 1.22.0 h5py 2.9.0 html5lib 1.0.1 idna 2.8 ipykernel 5.1.2 ipython 7.7.0 ipython-genutils 0.2.0 jdcal 1.4.1 jedi 0.13.3 jieba 0.39 Jinja2 2.10.1 jmespath 0.9.4 joblib 0.13.2 JPype1 0.7.0 jsonschema 3.0.1 jupyter-client 5.3.1 jupyter-contrib-core 0.3.3 jupyter-contrib-nbextensions 0.5.1 jupyter-core 4.5.0 jupyter-highlight-selected-word 0.2.0 jupyter-latex-envs 1.4.4 jupyter-nbextensions-configurator 0.4.1 kashgari-tf 0.5.3 Keras 2.2.4 keras-adaptive-softmax 0.6.0 Keras-Applications 1.0.8 keras-bert 0.68.2 keras-embed-sim 0.7.0 keras-gpt-2 0.12.0 keras-layer-normalization 0.12.0 keras-multi-head 0.20.0 keras-pos-embd 0.11.0 keras-position-wise-feed-forward 0.6.0 Keras-Preprocessing 1.1.0 keras-rectified-adam 0.4.0 keras-self-attention 0.41.0 keras-transformer 0.28.0 keras-transformer-xl 0.7.0 keras-xlnet 0.0.3 kiwisolver 1.1.0 lxml 4.4.1 Markdown 3.1.1 MarkupSafe 1.1.1 matplotlib 3.1.0 mistune 0.8.4 mkl-fft 1.0.12 mkl-random 1.0.2 nb-conda 2.2.1 nb-conda-kernels 2.2.2 nbconvert 5.6.0 nbformat 4.4.0 neobolt 1.7.13 neotime 1.7.4 notebook 6.0.0 numpy 1.16.4 openpyxl 2.6.2 pandas 0.25.0 pandas-profiling 1.4.0 pandocfilters 1.4.2 parso 0.5.0 pexpect 4.7.0 pickleshare 0.7.5 Pillow 6.1.0 pip 19.1.1 prometheus-client 0.7.1 prompt-toolkit 2.0.9 protobuf 3.9.0 ptyprocess 0.6.0 py2neo 4.3.0 Pygments 2.4.2 pyhanlp 0.1.48 pyparsing 2.4.0 pyrsistent 0.14.11 python-dateutil 2.8.0 pytorch-transformers 1.0.0 pytz 2019.1 PyYAML 5.1.2 pyzmq 18.0.2 regex 2019.6.8 requests 2.22.0 s3transfer 0.2.1 scikit-learn 0.21.2 scipy 1.3.0 Send2Trash 1.5.0 sentencepiece 0.1.82 seqeval 0.0.10 setuptools 41.0.1 six 1.12.0 smart-open 1.8.4 sqlparse 0.3.0 tensorboard 1.14.0 tensorboardX 1.8 tensorflow-estimator 1.14.0 tensorflow-gpu 1.14.0 termcolor 1.1.0 terminado 0.8.2 testpath 0.4.2 torch 1.1.0 torchvision 0.3.0 tornado 6.0.3 tqdm 4.32.2 traitlets 4.3.2 urllib3 1.24.3 wcwidth 0.1.7 webencodings 0.5.1 Werkzeug 0.15.4 wheel 0.33.4 wrapt 1.11.2 xgboost 0.90 xlrd 1.2.0 Note: you may need to restart the kernel to use updated packages.

麻烦你自己和正常的 colab 对比一下,要么提供一个可以复现问题的 colab

In [86]: pip install --user onedrivesdk Looking in indexes: http://mirrors.tencentyun.com/pypi/simple Collecting onedrivesdk Downloading http://mirrors.tencentyun.com/pypi/packages/b3/76/9a3fe5b36079f5c40b33c89ad6f7737e3b8609010a80c9ed24d762ddb93e/onedrivesdk-2.0.tar.gz ERROR: Command errored out with exit status 1: command: /root/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_3o6v858/onedrivesdk/setup.py'"'"'; file='"'"'/tmp/pip-install-_3o6v858/onedrivesdk/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info cwd: /tmp/pip-install-_3o6v858/onedrivesdk/ Complete output (5 lines): Traceback (most recent call last): File "", line 1, in File "/tmp/pip-install-_3o6v858/onedrivesdk/setup.py", line 9, in with open(NOTICE, 'r', encoding='utf-8') as f: NotADirectoryError: [Errno 20] Not a directory: '/tmp/pip-install-_3o6v858/onedrivesdk/setup.py/../NOTICE.rst'

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. Note: you may need to restart the kernel to use updated packages.

mike-sino commented 4 years ago

It seems that multi-GPUs still not work.

This solution works for me : https://github.com/BrikerMan/Kashgari/issues/218#issuecomment-525624068

@BrikerMan Has the problem already been sloved?