# Path: minos/experiment/training.py
# class AccuracyDecreaseStoppingCondition(object):
#     """ Stop training when the metric observed has stopped improving.
#         # Arguments
#         noprogress_count: number of epochs with no improvement
#             after which training will be stopped.
#         min_epoch: minimum number of epochs.
#         max_epoch: maximum number of epochs.
#     """
# 
#     def __init__(self, max_epoch, metric='accuracy',
#                  validation_metric=True, noprogress_count=3, min_epoch=0):
#         self.metric = metric
#         self.validation_metric = validation_metric
#         self.noprogress_count = noprogress_count
#         self.min_epoch = min_epoch
#         self.max_epoch = max_epoch
#         self.epoch = 0
# 
#     def get_monitor_metric(self):
#         if self.validation_metric:
#             return get_associated_validation_metric(self.metric)
#         return self.metric
# 
#     def is_min_epoch_defined(self):
#         return self.min_epoch and self.min_epoch > 0
# 
#     def is_max_epoch_defined(self):
#         return self.max_epoch and self.max_epoch > 0
# 
#     def is_at_least_min_epoch(self):
#         return self.is_min_epoch_defined()\
#             and self.epoch >= self.min_epoch
# 
#     def is_at_most_max_epoch(self):
#         return self.is_max_epoch_defined()\
#             and self.epoch <= self.max_epoch
# 
#     def todict(self):
#         return dict(vars(self))
# 
# Path: minos/model/parameter.py
# class Parameter(object):
# 
#     def __init__(self, param_type, values=None,
#                  lo=None, hi=None, default=None, optional=False, mutable=True):
#         self.param_type = param_type
#         self.values = values
#         self.lo = lo
#         self.hi = hi
#         self.default = default
#         self.optional = optional
#         self.mutable = mutable
# 
# def str_param_name(element):
#     if isinstance(element, str):
#         return element
#     if isclass(element) or isfunction(element):
#         return element.__name__
#     return str(element)
# 
# def expand_param_path(path):
#     path = [
#         e
#         for p in path
#         for e in p.split('.')]
#     return path
# 
# Path: minos/model/parameters.py
# def is_custom_layer(name):
# def is_custom_activation(name):
# def get_custom_layers():
# def get_custom_layer(name):
# def get_custom_activations():
# def get_custom_activation(name):
# def register_custom_layer(name, layer, params=None, stackable=False):
# def register_custom_activation(name, activation):
# 
# Path: minos/train/utils.py
# class Environment(object):
# 
#     def __init__(self, devices=None, n_jobs=None,
#                  data_dir=None, tf_logging_level=tf.logging.ERROR):
#         self.devices = devices
#         self.n_jobs = n_jobs
#         if devices and n_jobs and not isinstance(n_jobs, list):
#             self.n_jobs = [n_jobs for _ in devices]
#         self.data_dir = data_dir or self._init_minos_dir()
#         self.tf_logging_level = tf_logging_level
# 
#     def _init_minos_dir(self):
#         base_dir = path.expanduser('~')
#         if not access(base_dir, W_OK):
#             base_dir = path.join('/tmp')
#         minos_dir = join(base_dir, 'minos')
#         if not path.exists(minos_dir):
#             makedirs(minos_dir)
#         return minos_dir
# 
# Path: minos/utils.py
# def setup_logging(filename, level='INFO', resume=False):
#     if not resume and isfile(filename):
#         remove(filename)
#     print('Logging to %s, level=%s' % (filename, level))
#     logging_configuration = {
#         'version': 1,
#         'formatters': {
#             'standard': {
#                 'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s',
#                 'datefmt': '%Y-%m-%d %H:%M:%S'
#             },
#         },
#         'handlers': {
#             'file': {
#                 'level': level,
#                 'class': 'logging.FileHandler',
#                 'formatter': 'standard',
#                 'filename': filename
#             }
#         },
#         'loggers': {
#             '': {
#                 'handlers': ['file'],
#                 'level': level,
#                 'propagate': True
#             }
#         }
#     }
#     dictConfigClass(logging_configuration).configure()


from copy import deepcopy
from os import path, makedirs
from os.path import join
from minos.experiment.training import AccuracyDecreaseStoppingCondition
from minos.model.parameter import Parameter, str_param_name, expand_param_path
from minos.model.parameters import reference_parameters, get_custom_layers,\
    get_custom_activations
from minos.train.utils import Environment
from minos.utils import setup_logging
        from minos.train.trainer import MultiProcessModelTrainer
import json
import logging
import pickle
            value)

    def _set_node_parameter(self, node, path, value):
        node = node or dict()
        path = expand_param_path(path)
        if len(path) > 1:
            node[path[0]] = self._set_node_parameter(
                node[path[0]],
                path[1:],
                value)
        else:
            node[path[0]] = value
        return node

    def layout_parameter(self, name, value):
        return self._set_parameter(
            ['layout', name],
            value)

    def get_layout_parameter(self, name):
        return self.get_parameter('layout', name)

    def layer_parameter(self, name, value):
        return self._set_parameter(
            ['layers', name],
            value)

    def add_activation(self, name):
        for _layer_name, parameters in self.get_parameter('layers').items():
            for param_name, param_value in parameters.items():

# Path: minos/experiment/training.py
# class AccuracyDecreaseStoppingCondition(object):
#     """ Stop training when the metric observed has stopped improving.
#         # Arguments
#         noprogress_count: number of epochs with no improvement
#             after which training will be stopped.
#         min_epoch: minimum number of epochs.
#         max_epoch: maximum number of epochs.
#     """
# 
#     def __init__(self, max_epoch, metric='accuracy',
#                  validation_metric=True, noprogress_count=3, min_epoch=0):
#         self.metric = metric
#         self.validation_metric = validation_metric
#         self.noprogress_count = noprogress_count
#         self.min_epoch = min_epoch
#         self.max_epoch = max_epoch
#         self.epoch = 0
# 
#     def get_monitor_metric(self):
#         if self.validation_metric:
#             return get_associated_validation_metric(self.metric)
#         return self.metric
# 
#     def is_min_epoch_defined(self):
#         return self.min_epoch and self.min_epoch > 0
# 
#     def is_max_epoch_defined(self):
#         return self.max_epoch and self.max_epoch > 0
# 
#     def is_at_least_min_epoch(self):
#         return self.is_min_epoch_defined()\
#             and self.epoch >= self.min_epoch
# 
#     def is_at_most_max_epoch(self):
#         return self.is_max_epoch_defined()\
#             and self.epoch <= self.max_epoch
# 
#     def todict(self):
#         return dict(vars(self))
# 
# Path: minos/model/parameter.py
# class Parameter(object):
# 
#     def __init__(self, param_type, values=None,
#                  lo=None, hi=None, default=None, optional=False, mutable=True):
#         self.param_type = param_type
#         self.values = values
#         self.lo = lo
#         self.hi = hi
#         self.default = default
#         self.optional = optional
#         self.mutable = mutable
# 
# def str_param_name(element):
#     if isinstance(element, str):
#         return element
#     if isclass(element) or isfunction(element):
#         return element.__name__
#     return str(element)
# 
# def expand_param_path(path):
#     path = [
#         e
#         for p in path
#         for e in p.split('.')]
#     return path
# 
# Path: minos/model/parameters.py
# def is_custom_layer(name):
# def is_custom_activation(name):
# def get_custom_layers():
# def get_custom_layer(name):
# def get_custom_activations():
# def get_custom_activation(name):
# def register_custom_layer(name, layer, params=None, stackable=False):
# def register_custom_activation(name, activation):
# 
# Path: minos/train/utils.py
# class Environment(object):
# 
#     def __init__(self, devices=None, n_jobs=None,
#                  data_dir=None, tf_logging_level=tf.logging.ERROR):
#         self.devices = devices
#         self.n_jobs = n_jobs
#         if devices and n_jobs and not isinstance(n_jobs, list):
#             self.n_jobs = [n_jobs for _ in devices]
#         self.data_dir = data_dir or self._init_minos_dir()
#         self.tf_logging_level = tf_logging_level
# 
#     def _init_minos_dir(self):
#         base_dir = path.expanduser('~')
#         if not access(base_dir, W_OK):
#             base_dir = path.join('/tmp')
#         minos_dir = join(base_dir, 'minos')
#         if not path.exists(minos_dir):
#             makedirs(minos_dir)
#         return minos_dir
# 
# Path: minos/utils.py
# def setup_logging(filename, level='INFO', resume=False):
#     if not resume and isfile(filename):
#         remove(filename)
#     print('Logging to %s, level=%s' % (filename, level))
#     logging_configuration = {
#         'version': 1,
#         'formatters': {
#             'standard': {
#                 'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s',
#                 'datefmt': '%Y-%m-%d %H:%M:%S'
#             },
#         },
#         'handlers': {
#             'file': {
#                 'level': level,
#                 'class': 'logging.FileHandler',
#                 'formatter': 'standard',
#                 'filename': filename
#             }
#         },
#         'loggers': {
#             '': {
#                 'handlers': ['file'],
#                 'level': level,
#                 'propagate': True
#             }
#         }
#     }
#     dictConfigClass(logging_configuration).configure()


# Path: minos/experiment/experiment.py
from copy import deepcopy
from os import path, makedirs
from os.path import join
from minos.experiment.training import AccuracyDecreaseStoppingCondition
from minos.model.parameter import Parameter, str_param_name, expand_param_path
from minos.model.parameters import reference_parameters, get_custom_layers,\
    get_custom_activations
from minos.train.utils import Environment
from minos.utils import setup_logging
        from minos.train.trainer import MultiProcessModelTrainer
import json
import logging
import pickle

            value)

    def _set_node_parameter(self, node, path, value):
        node = node or dict()
        path = expand_param_path(path)
        if len(path) > 1:
            node[path[0]] = self._set_node_parameter(
                node[path[0]],
                path[1:],
                value)
        else:
            node[path[0]] = value
        return node

    def layout_parameter(self, name, value):
        return self._set_parameter(
            ['layout', name],
            value)

    def get_layout_parameter(self, name):
        return self.get_parameter('layout', name)

    def layer_parameter(self, name, value):
        return self._set_parameter(
            ['layers', name],
            value)

    def add_activation(self, name):
        for _layer_name, parameters in self.get_parameter('layers').items():
            for param_name, param_value in parameters.items():

                if 'activation' == param_name and isinstance(param_value, Parameter):