本文整理匯總了Python中neptune.OfflineBackend方法的典型用法代碼示例。如果您正苦於以下問題:Python neptune.OfflineBackend方法的具體用法?Python neptune.OfflineBackend怎麽用?Python neptune.OfflineBackend使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類neptune
的用法示例。
在下文中一共展示了neptune.OfflineBackend方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _create_or_get_experiment
# 需要導入模塊: import neptune [as 別名]
# 或者: from neptune import OfflineBackend [as 別名]
def _create_or_get_experiment(self):
if self.offline_mode:
project = neptune.Session(backend=neptune.OfflineBackend()).get_project('dry-run/project')
else:
session = neptune.Session.with_default_backend(api_token=self.api_key)
project = session.get_project(self.project_name)
if self._experiment_id is None:
exp = project.create_experiment(
name=self.experiment_name,
params=self.params,
properties=self.properties,
tags=self.tags,
upload_source_files=self.upload_source_files,
**self._kwargs)
else:
exp = project.get_experiments(id=self._experiment_id)[0]
self._experiment_id = exp.id
return exp
示例2: __init__
# 需要導入模塊: import neptune [as 別名]
# 或者: from neptune import OfflineBackend [as 別名]
def __init__(self, *args, **kwargs):
try:
import neptune
except ImportError:
raise RuntimeError(
"This contrib module requires neptune-client to be installed. "
"You may install neptune with command: \n pip install neptune-client \n"
)
if kwargs.get("offline_mode", False):
self.mode = "offline"
neptune.init(project_qualified_name="dry-run/project", backend=neptune.OfflineBackend())
else:
self.mode = "online"
neptune.init(api_token=kwargs.get("api_token"), project_qualified_name=kwargs.get("project_name"))
kwargs["name"] = kwargs.pop("experiment_name", None)
self._experiment_kwargs = {
k: v for k, v in kwargs.items() if k not in ["api_token", "project_name", "offline_mode"]
}
self.experiment = neptune.create_experiment(**self._experiment_kwargs)
示例3: neptune_experiment_cls
# 需要導入模塊: import neptune [as 別名]
# 或者: from neptune import OfflineBackend [as 別名]
def neptune_experiment_cls(self):
import neptune
neptune.init(project_qualified_name="tests/dry-run",
backend=neptune.OfflineBackend())
return neptune.create_experiment
示例4: __init__
# 需要導入模塊: import neptune [as 別名]
# 或者: from neptune import OfflineBackend [as 別名]
def __init__(
self,
metric_names: List[str] = None,
log_on_batch_end: bool = True,
log_on_epoch_end: bool = True,
offline_mode: bool = False,
**logging_params,
):
"""
Args:
metric_names (List[str]): list of metric names to log,
if none - logs everything
log_on_batch_end (bool): logs per-batch metrics if set True
log_on_epoch_end (bool): logs per-epoch metrics if set True
offline_mode (bool): whether logging to Neptune server should
be turned off. It is useful for debugging
"""
super().__init__(
order=CallbackOrder.logging,
node=CallbackNode.master,
scope=CallbackScope.experiment,
)
self.metrics_to_log = metric_names
self.log_on_batch_end = log_on_batch_end
self.log_on_epoch_end = log_on_epoch_end
if not (self.log_on_batch_end or self.log_on_epoch_end):
raise ValueError("You have to log something!")
if (self.log_on_batch_end and not self.log_on_epoch_end) or (
not self.log_on_batch_end and self.log_on_epoch_end
):
self.batch_log_suffix = ""
self.epoch_log_suffix = ""
else:
self.batch_log_suffix = "_batch"
self.epoch_log_suffix = "_epoch"
if offline_mode:
neptune.init(
project_qualified_name="dry-run/project",
backend=neptune.OfflineBackend(),
)
else:
neptune.init(
api_token=logging_params["api_token"],
project_qualified_name=logging_params["project_name"],
)
logging_params.pop("api_token")
logging_params.pop("project_name")
self.experiment = neptune.create_experiment(**logging_params)