gpt4 book ai didi

python - Acumos : can't use numpy with acumos, 有什么窍门吗?

转载 作者:太空宇宙 更新时间:2023-11-03 21:07:33 24 4
gpt4 key购买 nike

当我尝试使用 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

最佳答案

如果有人有同样的错误,这个错误表明我们必须添加“tf.enable_eager_execution()”。但完成此操作后,我们遇到另一个错误。为了解决这个问题,我必须将“from tensorflow.python.keras.models import Sequential, ...”替换为“from keras.models import Sequential, ...”和“from tensorflow.python.keras.layers import Dropout,密集,BatchNormalization”通过“from keras.layers import Dropout,密集,BatchNormalization”。

关于python - Acumos : can't use numpy with acumos, 有什么窍门吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55301023/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com