本文整理汇总了Python中comet_ml.Experiment方法的典型用法代码示例。如果您正苦于以下问题:Python comet_ml.Experiment方法的具体用法?Python comet_ml.Experiment怎么用?Python comet_ml.Experiment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comet_ml
的用法示例。
在下文中一共展示了comet_ml.Experiment方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: experiment
# 需要导入模块: import comet_ml [as 别名]
# 或者: from comet_ml import Experiment [as 别名]
def experiment(self, *args, **kwargs):
import comet_ml
try:
self.cometml_experiment = comet_ml.Experiment(log_code=False)
except Exception:
self.cometml_experiment = None
logger.error(
"comet_ml.Experiment() had errors. Perhaps you need to define COMET_API_KEY")
return
logger.info("comet.experiment() called......")
cli = self._make_command_line(args)
self.cometml_experiment.set_code(cli)
self.cometml_experiment.set_filename("Ludwig CLI")
self._log_html(cli)
config = comet_ml.get_config()
self._save_config(config)
示例2: train
# 需要导入模块: import comet_ml [as 别名]
# 或者: from comet_ml import Experiment [as 别名]
def train(self, *args, **kwargs):
import comet_ml
try:
self.cometml_experiment = comet_ml.Experiment(log_code=False)
except Exception:
self.cometml_experiment = None
logger.error(
"comet_ml.Experiment() had errors. Perhaps you need to define COMET_API_KEY")
return
logger.info("comet.train() called......")
cli = self._make_command_line(args)
self.cometml_experiment.set_code(cli)
self.cometml_experiment.set_filename("Ludwig CLI")
self._log_html(cli)
config = comet_ml.get_config()
self._save_config(config)
示例3: init_callbacks
# 需要导入模块: import comet_ml [as 别名]
# 或者: from comet_ml import Experiment [as 别名]
def init_callbacks(self):
self.callbacks.append(
ModelCheckpoint(
filepath=os.path.join(self.config.callbacks.checkpoint_dir, '%s-{epoch:02d}-{val_loss:.2f}.hdf5' % self.config.exp.name),
monitor=self.config.callbacks.checkpoint_monitor,
mode=self.config.callbacks.checkpoint_mode,
save_best_only=self.config.callbacks.checkpoint_save_best_only,
save_weights_only=self.config.callbacks.checkpoint_save_weights_only,
verbose=self.config.callbacks.checkpoint_verbose,
)
)
self.callbacks.append(
TensorBoard(
log_dir=self.config.callbacks.tensorboard_log_dir,
write_graph=self.config.callbacks.tensorboard_write_graph,
)
)
if hasattr(self.config,"comet_api_key"):
from comet_ml import Experiment
experiment = Experiment(api_key=self.config.comet_api_key, project_name=self.config.exp_name)
experiment.disable_mp()
experiment.log_multiple_params(self.config)
self.callbacks.append(experiment.get_keras_callback())
示例4: __init__
# 需要导入模块: import comet_ml [as 别名]
# 或者: from comet_ml import Experiment [as 别名]
def __init__(self, experiment=None, api_key=None, tags=None, **kwargs):
"""
Args:
experiment (comet_ml.Experiment): if provided, invalidate all other arguments
api_key (str): your comet.ml API key
tags (list[str]): experiment tags
kwargs: other arguments passed to :class:`comet_ml.Experiment`.
"""
if experiment is not None:
self._exp = experiment
assert api_key is None and tags is None and len(kwargs) == 0
else:
from comet_ml import Experiment
kwargs.setdefault('log_code', True) # though it's not functioning, git patch logging requires it
kwargs.setdefault('auto_output_logging', None)
self._exp = Experiment(api_key=api_key, **kwargs)
if tags is not None:
self._exp.add_tags(tags)
self._exp.set_code("Code logging is impossible because there are too many files ...")
self._exp.log_dependency('tensorpack', __git_version__)
示例5: init_comet
# 需要导入模块: import comet_ml [as 别名]
# 或者: from comet_ml import Experiment [as 别名]
def init_comet(params, trainer):
if params['comet_key']:
from comet_ml import Experiment
experiment = Experiment(api_key=params['comet_key'], project_name=params['comet_project_name'], log_code=False)
hyperparams = {
name: str(params[name]) for name in params
}
experiment.log_multiple_params(hyperparams)
trainer.register_plugin(CometPlugin(
experiment, [
'G_loss.epoch_mean',
'D_loss.epoch_mean',
'D_real.epoch_mean',
'D_fake.epoch_mean',
'sec.kimg',
'sec.tick',
'kimg_stat'
] + (['depth', 'alpha'] if params['progressive_growing'] else [])
))
else:
print('Comet_ml logging disabled.')
示例6: __init__
# 需要导入模块: import comet_ml [as 别名]
# 或者: from comet_ml import Experiment [as 别名]
def __init__(self, experiment=None, tags=None, **kwargs):
"""
Args:
experiment (comet_ml.Experiment): if provided, invalidate all other arguments
tags (list[str]): experiment tags
kwargs: arguments used to initialize :class:`comet_ml.Experiment`,
such as project name, API key, etc.
Refer to its documentation for details.
"""
if experiment is not None:
self._exp = experiment
assert tags is None and len(kwargs) == 0
else:
from comet_ml import Experiment
kwargs.setdefault('log_code', True) # though it's not functioning, git patch logging requires it
kwargs.setdefault('auto_output_logging', None)
self._exp = Experiment(**kwargs)
if tags is not None:
self._exp.add_tags(tags)
self._exp.set_code("Code logging is impossible ...")
self._exp.log_dependency('tensorpack', __git_version__)
示例7: init_comet
# 需要导入模块: import comet_ml [as 别名]
# 或者: from comet_ml import Experiment [as 别名]
def init_comet(params, trainer):
if params['comet_key'] is not None:
from comet_ml import Experiment
from trainer.plugins import CometPlugin
experiment = Experiment(api_key=params['comet_key'], log_code=False)
hyperparams = {
name: param_to_string(params[name]) for name in tag_params
}
experiment.log_multiple_params(hyperparams)
trainer.register_plugin(CometPlugin(
experiment, [
('training_loss', 'epoch_mean'),
'validation_loss',
'test_loss'
]
))
示例8: experiment
# 需要导入模块: import comet_ml [as 别名]
# 或者: from comet_ml import Experiment [as 别名]
def experiment(self):
"""
The :class:`comet_ml.Experiment` instance.
"""
return self._exp
示例9: run_main_loop
# 需要导入模块: import comet_ml [as 别名]
# 或者: from comet_ml import Experiment [as 别名]
def run_main_loop(args, train_estimator, predict_estimator):
total_steps = 0
train_steps = math.ceil(args.train_examples / args._batch_size)
eval_steps = math.ceil(args.eval_examples / args._batch_size)
if args.use_comet:
experiment = Experiment(api_key=comet_ml_api_key, project_name=comet_ml_project, workspace=comet_ml_workspace)
experiment.log_parameters(vars(args))
experiment.add_tags(args.tag)
experiment.set_name(model_name(args))
else:
experiment = None
prefetch_inception_model()
with tf.gfile.Open(os.path.join(suffixed_folder(args, args.result_dir), "eval.txt"), "a") as eval_file:
for epoch in range(0, args.epochs, args.predict_every):
logger.info(f"Training epoch {epoch}")
train_estimator.train(input_fn=train_input_fn, steps=train_steps * args.predict_every)
total_steps += train_steps * args.predict_every
if args.use_comet:
experiment.set_step(epoch)
# logger.info(f"Evaluate {epoch}")
# evaluation = predict_estimator.evaluate(input_fn=eval_input_fn, steps=eval_steps)
# logger.info(evaluation)
# save_evaluation(args, eval_file, evaluation, epoch, total_steps)
# if args.use_comet:
# experiment.log_metrics(evaluation)
logger.info(f"Generate predictions {epoch}")
predictions = predict_estimator.predict(input_fn=predict_input_fn)
logger.info(f"Save predictions")
save_predictions(args, suffixed_folder(args, args.result_dir), eval_file, predictions, epoch, total_steps, experiment)
logger.info(f"Completed {args.epochs} epochs")
示例10: experiment
# 需要导入模块: import comet_ml [as 别名]
# 或者: from comet_ml import Experiment [as 别名]
def experiment(self) -> CometBaseExperiment:
r"""
Actual Comet object. To use Comet features in your
:class:`~pytorch_lightning.core.lightning.LightningModule` do the following.
Example::
self.logger.experiment.some_comet_function()
"""
if self._experiment is not None:
return self._experiment
if self.mode == "online":
if self.experiment_key is None:
self._experiment = CometExperiment(
api_key=self.api_key,
workspace=self.workspace,
project_name=self.project_name,
**self._kwargs
)
self.experiment_key = self._experiment.get_key()
else:
self._experiment = CometExistingExperiment(
api_key=self.api_key,
workspace=self.workspace,
project_name=self.project_name,
previous_experiment=self.experiment_key,
**self._kwargs
)
else:
self._experiment = CometOfflineExperiment(
offline_directory=self.save_dir,
workspace=self.workspace,
project_name=self.project_name,
**self._kwargs
)
return self._experiment