gpt4 book ai didi

python - comet (comet-ml) 无法与 Keras 一起运行

转载 作者:太空宇宙 更新时间:2023-11-04 00:29:24 27 4
gpt4 key购买 nike

我正在运行来自 Comet github project 的 keras 示例.

我添加导入并创建一个新实验:

def train(x_train,y_train,x_test,y_test):
model = build_model_graph()

from comet_ml import Experiment

experiment = Experiment(api_key="XXXX", log_code=True)

model.fit(x_train, y_train, batch_size=128, epochs=50, validation_data=(x_test, y_test))

score = model.evaluate(x_test, y_test, verbose=0)

当我运行我的训练代码时它失败了。

错误:

Using TensorFlow backend.
Traceback (most recent call last):
File "/Users/nimrodlahav/Code/semantica/experiment-logger-client/train-examples/keras-example.py", line 21, in <module>
from comet_ml import Experiment
File ".././comet-client-lib/comet_ml/__init__.py", line 3, in <module>
from .comet import Experiment
File ".././comet-client-lib/comet_ml/comet.py", line 29, in <module>
from comet_ml import keras_logger
File ".././comet-client-lib/comet_ml/keras_logger.py", line 31, in <module>
raise SyntaxError("Please import Comet before importing any keras modules")
SyntaxError: Please import Comet before importing any keras modules

我错过了什么?

最佳答案

我没有看到代码的开头,但看起来您在导入 Comet 之前已经导入了 Keras。

从错误消息看来,只需要切换导入线(Comet 首先是 Keras,其次),就像您的示例一样:

from comet_ml import Experiment

import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras.optimizers import RMSprop

查看完整源代码example .

关于python - comet (comet-ml) 无法与 Keras 一起运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46352435/

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