日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

学习使用bilstm_crf_model出现的bug

發布時間:2023/12/31 编程问答 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 学习使用bilstm_crf_model出现的bug 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1. TypeError: Tensors in list passed to 'values' of 'ConcatV2' Op have types [bool, float32] that don't all match.

出現地方:

bilstm_crf_model = Embedding(input_dim=n_words + 1, output_dim=20,input_length=max_len, mask_zero=True)(input) # 20-dim embedding

解決:刪掉mask_zero=True

bilstm_crf_model = Embedding(input_dim=n_words + 1, output_dim=20,input_length=max_len)(input) # 20-dim embedding

2.TensorFlow與Keras,CUDA版本問題

2.1 AttributeError: module 'keras.backend' has no attribute 'slice'

2.2 attributeerror: 'node' object has no attribute 'output_masks'

2.3?typeerror: __init__() got an unexpected keyword argument 'ragged'

2.4?keras_contrib attributeerror: module 'tensorflow' has no attribute 'get_default_graph'

2.5?importerror: cannot import name 'saving'

2.6?futurewarning: from version 0.24, get_params will raise an attributeerror if a parameter cannot be retrieved as an instance attribute. previously it would return none. futurewarning)

TensorFlow與Keras,CUDA,CUDNN,Python相應版本相對應很重要

我這邊目前是:CUDA Version 10.0.130,CUDNN:7.5 ,Python 3.6.10,GCC 7.3.0

我安裝的: TensorFlow:2.0.0,Keras:2.3.1

查看CUDA的方法:

第一種.:nvidia-smi

第二種:

cat /usr/local/cuda/version.txt

查看CUDNN的方法:

cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

查看python,GCC版本:

python?

CUDA,CUDNN與TensorFlow版本對應:https://tensorflow.google.cn/install/source

TensorFlow與Keras版本對應:https://docs.floydhub.com/guides/environments/

3.KeyError: 'accuracy'

出現地方:

model.compile(optimizer="rmsprop", loss=crf.loss_function, metrics=["accuracy"]) history = model.fit(X_train, np.array(y_train), batch_size=32, epochs=5,validation_split=0.1, verbose=1) hist = pd.DataFrame(history.history) plt.figure(figsize=(12,12)) plt.plot(hist["acc"]) plt.plot(hist["val_acc"]) plt.show()

解決:列名要注意

?

plt.plot(hist["accuracy"]) plt.plot(hist["val_accuracy"])

?4.typeerror: load_model() missing 1 required positional argument: 'filepath'

出現地方: model=load_model(filepath="../result/bi-lstm.h5")

解決:

filepath = "result/bi-lstm.h5" model = load_model(filepath)

5.attributeerror: 'float' object has no attribute 'lower'

出現原因:遇到了數據為NaN的情況

解決:用空格去填充缺失值

data=data.fillna('')

?

?

?

總結

以上是生活随笔為你收集整理的学习使用bilstm_crf_model出现的bug的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。