Acumos:不能用numpy和Acumos,有诀窍吗?

2024-05-16 23:11:12 发布

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

当我尝试用acumos生成模型时,我得到以下错误:

  File "/Users/fredericchantrel/.pyenv/versions/ticl-v2-virtualenv-3.6.5/lib/python3.6/site-packages/acumos/pickler.py", line 245, in wrapped_save

...

  File "/Users/fredericchantrel/.pyenv/versions/ticl-v2-virtualenv-3.6.5/lib/python3.6/site-packages/tensorflow/python/ops/resource_variable_ops.py", line 687, in numpy
    "numpy() is only available when eager execution is enabled.")
NotImplementedError: numpy() is only available when eager execution is enabled.

与acumos的numpy有不兼容之处吗?你知道吗

下面是我的一段代码:

def classify_ticket(inText: str) -> str:
    text = normalise(inText)
    current_vec = get_sentence_vector(text)
    x_predict = []
    x_predict.append(current_vec)
    X_predict = np.asarray(x_predict)
    result = current_model.predict(X_predict)
    predict = get_meilleure_reponse(result[0])
return predict

def get_sentence_vector(sentence):
    words = sentence.split()
    array_vector = []
    for word in words:
        try:
            current_vec = get_word_vector(word)
            array_vector.append(current_vec)
        except KeyError as e:
            print(f"token non trouvé dans le dico : {word}")

    np_array = np.asarray(array_vector)    
    retour = np.mean(np_array, dtype=np.float64, axis=0)
    return retour

Tags: innumpygetisnpcurrentarrayusers
1条回答
网友
1楼 · 发布于 2024-05-16 23:11:12

如果有人有同样的错误,这个错误表明我们必须添加“tf.enable\u eager\u执行()". 但当这一步完成时,我们会遇到另一个错误。为了解决这个问题,我不得不用tensorflow.python.keras文件.models从导入顺序,…“by”keras.型号导入顺序,“,”和“从tensorflow.python.keras文件.layers导入Dropout,Dense,BatchNormalization“by”fromkeras.层导入退出、密集、批处理规范化”。你知道吗

相关问题 更多 >