当我尝试使用 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”。
我是一名优秀的程序员,十分优秀!