简体   繁体   中英

comet (comet-ml) fails to run with Keras

Im running the keras examples from Comet github project .

I add the import and create a new experiment:

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)

and when i run my training code it fails.

error:

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

what am I missing?

I don't see start of the code but it looks like you have imported Keras before you have imported Comet.

From the error message it looks like just need to switch the import lines (Comet first Keras second), like in your example:

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 

view the full source code example .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM