当我尝试使用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.
难道不是从智囊团得到麻木吗?
这是我的一部分代码:
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
答案 0 :(得分:0)
如果某人有相同的错误,则此错误表明我们必须添加“ tf.enable_eager_execution()”。但是完成此操作后,我们会遇到另一个错误。为了解决这个问题,我必须将“从tensorflow.python.keras.models导入序列,...”替换为“从keras.models导入序列,...”和“从tensorflow.python.keras.layers导入Dropout, “来自keras.layers导入Dropout,Dense,BatchNormalization”的“密集,批量标准化”。