Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'WS' object has no attribute 'model' #45

Open
freezexpert opened this issue Apr 1, 2023 · 3 comments
Open

'WS' object has no attribute 'model' #45

freezexpert opened this issue Apr 1, 2023 · 3 comments

Comments

@freezexpert
Copy link

如題,我在執行github上的demo.py時,總是會出現這個錯誤訊息,想知道有什麼解決辦法

@doggy8088
Copy link

我也遇到一樣的問題:

WARNING:tensorflow:From C:\Python312\Lib\site-packages\ckiptagger\api.py:8: The name tf.logging.set_verbosity is deprecated. Please use tf.compat.v1.logging.set_verbosity instead.

Traceback (most recent call last):
  File "C:\Projects\CkipTaggerDemo\demo.py", line 9, in <module>
    ws = WS("./data")
         ^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\ckiptagger\api.py", line 52, in __init__      
    model = model_ws.Model(config)
            ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\ckiptagger\model_ws.py", line 213, in __init__
    self.create_encoder()
  File "C:\Python312\Lib\site-packages\ckiptagger\model_ws.py", line 252, in create_encoder
    self.bilstm = Cross_BiLSTM(
                  ^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\ckiptagger\model_ws.py", line 98, in __init__
    self.create_cell(current_input_d, hidden_d, is_top_cell, f"lstm_cell_{layer+1}")
  File "C:\Python312\Lib\site-packages\ckiptagger\model_ws.py", line 106, in create_cell
    cell = tf.compat.v1.nn.rnn_cell.LSTMCell(hidden_d, name=name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\tensorflow\python\util\lazy_loader.py", line 207, in __getattr__      
    raise AttributeError(
AttributeError: `LSTMCell` is not available with Keras 3.
Exception ignored in: <function WS.__del__ at 0x000001AE64306700>
Traceback (most recent call last):
  File "C:\Python312\Lib\site-packages\ckiptagger\api.py", line 65, in __del__
    self.model.sess.close()
    ^^^^^^^^^^
AttributeError: 'WS' object has no attribute 'model'

@doggy8088
Copy link

我改安裝 Python 到 3.7 版就解決了,因為 TensorFlow 1.x 不支援 Python 3.8 以上版本。

若要成功執行,還要安裝比較舊版的 protobuf 套件:

pip install protobuf=3.20

@wastu01
Copy link

wastu01 commented Sep 20, 2024

我在 python 3.10, tensorflow 2.17.0 環境執行一樣遇到同樣問題
WS object has no attribute 'mode
不過我是使用 Mac 沒辦法裝 TensorFlow 1.x 版本要另外想辦法

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants