コード例 #1
0
ファイル: neptune_helper.py プロジェクト: d3m0n-r00t/ASL
def _create_or_get_experiment2(self):
    """
  Super bad !!! Dont do this
  """
    proxies = {
        'http': 'http://proxy.ethz.ch:3128',
        'https': 'http://proxy.ethz.ch:3128',
    }
    if self.offline_mode:
        project = neptune.Session(
            backend=neptune.OfflineBackend()).get_project('dry-run/project')
    else:
        #project_qualified_name='jonasfrey96/ASL', api_token=os.environ["NEPTUNE_API_TOKEN"], proxies=proxies
        session = neptune.init(project_qualified_name='jonasfrey96/ASL',
                               api_token=self.api_key,
                               proxies=proxies)  # add your credential
        print(type(session))
        session = neptune.Session(api_token=self.api_key, proxies=proxies)
        project = session.get_project(self.project_name)

    if self.experiment_id is None:
        e = project.create_experiment(name=self.experiment_name,
                                      **self._kwargs)
        self.experiment_id = e.id
    else:
        e = project.get_experiments(id=self.experiment_id)[0]
        self.experiment_name = e.get_system_properties()['name']
        self.params = e.get_parameters()
        self.properties = e.get_properties()
        self.tags = e.get_tags()
    return e
コード例 #2
0
    def __init__(
        self,
        project_qualified_name: Optional[str] = None,
        api_token: Optional[str] = None,
        offline: bool = False,
        experiment_id: Optional[int] = None,
        experiment_name: Optional[str] = None,
        tags: Optional[Collection[str]] = None,
    ):
        """Initialize the Neptune result tracker.

        :param project_qualified_name:
            Qualified name of a project in a form of ``namespace/project_name``.
            If ``None``, the value of ``NEPTUNE_PROJECT`` environment variable will be taken. For testing,
            should be `<your username>/sandbox`
        :param api_token:
            User's API token. If ``None``, the value of ``NEPTUNE_API_TOKEN`` environment variable will be taken.

            .. note::

                It is strongly recommended to use ``NEPTUNE_API_TOKEN`` environment variable rather than
                placing your API token in plain text in your source code.
        :param offline:
            Run neptune in offline mode (uses :class:`neptune.OfflineBackend` as the backend)
        :param experiment_id:
            The identifier of a pre-existing experiment to use. If not given, will rely
            on the ``experiment_name``.
        :param experiment_name:
            The name of the experiment. If no ``experiment_id`` is given, one will be created based
            on the name.
        :param tags: A collection of tags to add to the experiment
        """
        import neptune

        if offline:
            self.session = neptune.Session(backend=neptune.OfflineBackend())
        else:
            self.session = neptune.Session.with_default_backend(
                api_token=api_token)

        self.project = self.session.get_project(project_qualified_name)

        if experiment_id is None and experiment_name is None:
            raise ValueError(
                'need experiment_name if no experiment_id is given')
        if experiment_id is None:
            self.experiment = self.project.create_experiment(
                name=experiment_name)
        else:
            self.experiment = self.project.get_experiments(id=experiment_id)[0]

        if tags:
            self.experiment.append_tags(*tags)
コード例 #3
0
    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,
                                            **self._kwargs)
        else:
            exp = project.get_experiments(id=self._experiment_id)[0]

        self._experiment_id = exp.id
        return exp
コード例 #4
0
    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, **self._kwargs)
            self.experiment_id = exp.id
        else:
            exp = project.get_experiments(id=self.experiment_id)[0]
            self.experiment_name = exp.get_system_properties()['name']
            self.params = exp.get_parameters()
            self.properties = exp.get_properties()
            self.tags = exp.get_tags()

        return exp
コード例 #5
0
ファイル: utils.py プロジェクト: wDaniec/toolkit
def configure_neptune_exp(name):
    global _NEPTUNE
    if 'NEPTUNE_TOKEN' not in os.environ:
        logger.warning(
            "Neptune couldn't be configured. Couldn't find NEPTUNE_TOKEN. ")
        return

    NEPTUNE_TOKEN = os.environ['NEPTUNE_TOKEN']
    NEPTUNE_USER = os.environ['NEPTUNE_USER']
    NEPTUNE_PROJECT = os.environ['NEPTUNE_PROJECT']
    C = copy.deepcopy(_CONFIG)
    C = {k[1].split(".")[-1]: v
         for k, v in C.items()}  # Hacky way to simplify config
    logger.info("Initializing neptune to name " + name)
    project = neptune.Session(NEPTUNE_TOKEN).get_project(
        f'{NEPTUNE_USER}/{NEPTUNE_PROJECT}')
    exp = project.create_experiment(name=name, params=C)
    _NEPTUNE['default'] = exp
    logger.info("Initialized neptune")
コード例 #6
0
ファイル: Neptune.py プロジェクト: yoongi0428/neptune_logger
    def initialize(self):
        # Get experiment
        if self.offline:
            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)

        exp = project.create_experiment(
            name=self.experiment_name,
            description=self.description,
            params=self.hparams,
            tags=self.tags,
            upload_source_files=self.upload_source_files,
            hostname=self.hostname)

        self.experiment = exp
コード例 #7
0
import neptune
from config import EnvConfig
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import pickle
%matplotlib qt
plt.rcParams.update({'font.size': 22})

comet_cfg = EnvConfig()
session = neptune.Session(api_token=comet_cfg.neptune_token)
project = session.get_project(project_qualified_name=comet_cfg.neptune_project_name)

experiments = project.get_experiments("GRID-30")

exp = experiments[0]

vals = exp.get_numeric_channels_values('insurance_cost_1_log_0','step_num_insured_1_log_0')

vals = vals.iloc[36210:36500,:]
vals[['insurance_cost_1_log_0','step_num_insured_1_log_0']].plot()
plt.legend(['Insurance price','Insurance usage'])
plt.xlabel('Timestep t')


experiments = project.get_experiments("GRID-81")

exp = experiments[0]

vals = exp.get_numeric_channels_values('insurance_cost_2_log_0','step_num_insured_2_log_0')
コード例 #8
0
        self.exp.send_metric('epoch end val loss', logs['val_loss'])

        msg_acc = 'End of epoch {}, accuracy is {:.4f}'.format(epoch, logs['accuracy'])
        self.exp.send_text(channel_name='accuracy information', x=epoch, y=msg_acc)

        msg_loss = 'End of epoch {}, categorical crossentropy loss is {:.4f}'.format(epoch, logs['loss'])
        self.exp.send_text(channel_name='loss information', x=epoch, y=msg_loss)

        self.current_epoch += 1


neptune.init(api_token=PARAMS['api_token'],
             project_qualified_name='kunalcgi/sandbox')

# retrieve project
project = neptune.Session(PARAMS['api_token'])\
    .get_project('kunalcgi/sandbox')


# CallBAck
with project.create_experiment(name='repair-replace-classification-exp-v2',
                           params=PARAMS,
                           description=PARAMS['description'],
                           upload_source_files=[]) as npt_exp:
    np_callback = NeptuneMonitor(npt_exp,999999999999)
model_checkpointer = ModelCheckpoint(PARAMS['model_path'], \
        verbose=1, monitor='val_accuracy', mode='max', save_best_only=True, save_weights_only=False)
weight_checkpointer = ModelCheckpoint(PARAMS['weight_path'], \
        verbose=1, monitor='val_accuracy', mode='max', save_best_only=True, save_weights_only=True)
learning_rate_reduction = ReduceLROnPlateau(monitor='val_loss',patience=5,verbose=1,factor=0.2,min_lr=0.0000032, cooldown=20)
earlystopper = EarlyStopping(monitor='val_mean_absolute_error', patience=20, verbose=1, mode='min')
callbacks_list = [CSVLogger(PARAMS['log_file']), model_checkpointer, weight_checkpointer, np_callback, learning_rate_reduction, earlystopper]