Creates experiment function.
482956
def create_teacher_experiment(run_config, hparams, argv):
  """"""
  tf.logging.info("training teacher")
  tf.logging.set_verbosity(tf.logging.INFO)
  trainer_lib.set_random_seed(FLAGS.random_seed)
  usr_dir.import_usr_dir(FLAGS.t2t_usr_dir)
  t2t_trainer.maybe_log_registry_and_exit()

  if FLAGS.cloud_mlengine:
    return cloud_mlengine.launch()

  if FLAGS.generate_data:
    t2t_trainer.generate_data()

  if cloud_mlengine.job_dir():
    FLAGS.output_dir = cloud_mlengine.job_dir()

  if argv:
    t2t_trainer.set_hparams_from_args(argv[1:])

  hparams.distill_phase = "train"
  exp_fn = t2t_trainer.create_experiment_fn()
  exp = exp_fn(run_config, hparams)
  return exp
235452
def experiment(f=None, local_dependencies=None, start_chiboard=True, default_logdir=""):
  
  if not f:
    return lambda f: experiment(f, local_dependencies, start_chiboard, default_logdir)
  else:
    if sys.modules[f.__module__].__name__ == '__main__':
      a = Experiment(f, local_dependencies, start_chiboard, default_logdir)
      a.parse_args_and_run()

    return Experiment(f, local_dependencies, start_chiboard, default_logdir).run
373536
def _function(self):
        

        # some generic function
        import time
        import random
        self.data['random data'] = None
        self.data['image data'] = None
        count = self.settings['count']
        name = self.settings['name']
        wait_time = self.settings['wait_time']

        data = []
        self.log('I ({:s}) am a test function counting to {:d} and creating random values'.format(self.name, count))
        for i in range(count):
            time.sleep(wait_time)
            self.log('{:s} count {:02d}'.format(self.name, i))
            data.append(random.random())
            self.data = {'random data': data}
            self.progress = 100. * (i + 1) / count
            self.updateProgress.emit(self.progress)


        self.data = {'random data':data}


        # create image data
        Nx = int(np.sqrt(len(self.data['random data'])))
        img = np.array(self.data['random data'][0:Nx ** 2])
        img = img.reshape((Nx, Nx))
        self.data.update({'image data': img})
993614
def create(fs, channels, application):
    """"""

    result_code = ctypes.c_int()

    result = _create(fs, channels, application, ctypes.byref(result_code))
    if result_code.value is not constants.OK:
        raise OpusError(result_code.value)

    return result
429453
def create_iteration(self, num_suggestions=0):
        """"""
        from db.models.experiment_groups import ExperimentGroupIteration

        search_manager = self.experiment_group.search_manager
        iteration_config = self.experiment_group.iteration_config

        if iteration_config is None:
            iteration = 0
            bracket_iteration = 0
        else:
            should_reschedule = search_manager.should_reschedule(
                iteration=iteration_config.iteration,
                bracket_iteration=iteration_config.bracket_iteration)
            should_reduce_configs = search_manager.should_reduce_configs(
                iteration=iteration_config.iteration,
                bracket_iteration=iteration_config.bracket_iteration)
            if should_reschedule:
                iteration = iteration_config.iteration + 1
                bracket_iteration = 0
            elif should_reduce_configs:
                iteration = iteration_config.iteration
                bracket_iteration = iteration_config.bracket_iteration + 1
            else:
                raise ValueError(
                    'Hyperband create iteration failed for `{}`, '
                    'could not reschedule ot reduce configs'.format(self.experiment_group.id))

        # Create a new iteration config
        iteration_config = HyperbandIterationConfig(
            iteration=iteration,
            num_suggestions=num_suggestions,
            bracket_iteration=bracket_iteration)
        iteration_config.experiment_ids = []
        return ExperimentGroupIteration.objects.create(
            experiment_group=self.experiment_group,
            data=iteration_config.to_dict())
1024896
def main(args,parser,subparser=None):
    '''

    '''

    # First priority to args.base
    base = args.base
    if base is None:
        base = os.environ.get('EXPFACTORY_BASE')

    # Does the base folder exist?
    if base is None:
        bot.error("You must set a base of experiments with --base" % base)
        sys.exit(1)

    if not os.path.exists(base):
        bot.error("Base folder %s does not exist." % base)
        sys.exit(1)

    # Export environment variables for the client
    experiments = args.experiments
    if experiments is None:
        experiments = " ".join(glob("%s/*" % base))

    os.environ['EXPFACTORY_EXPERIMENTS'] = experiments

    # If defined and file exists, set runtime variables
    if args.vars is not None:
        if os.path.exists(args.vars):
            os.environ['EXPFACTORY_RUNTIME_VARS'] = args.vars
            os.environ['EXPFACTORY_RUNTIME_DELIM'] = args.delim
        else:
            bot.warning('Variables file %s not found.' %args.vars)


    subid = os.environ.get('EXPFACTORY_STUDY_ID')
    if args.subid is not None:
        subid = args.subid 
        os.environ['EXPFACTORY_SUBID'] = subid

    os.environ['EXPFACTORY_RANDOM'] = str(args.disable_randomize)
    os.environ['EXPFACTORY_BASE'] = base
    
    from expfactory.server import start
    start(port=5000)
803239
def _creation_function(self, idx, seed, preset):
        
        return lambda: self.env.instantiate(seed=seed, serial_id=idx, preset=preset)
59336
def do_experiment(self, params):
        
        paramlist = self.expand_param_list(params)
        
        # create directories, write config files
        for pl in paramlist:
            # check for required param keys
            if ('name' in pl) and ('iterations' in pl) and ('repetitions' in pl) and ('path' in pl):
               self.create_dir(pl, self.options.delete)
            else:
                print 'Error: parameter set does not contain all required keys: name, iterations, repetitions, path'
                return False
            
        # create experiment list 
        explist = []
            
        # expand paramlist for all repetitions and add self and rep number
        for p in paramlist:
            explist.extend(zip( [self]*p['repetitions'], [p]*p['repetitions'], xrange(p['repetitions']) ))
                
        # if only 1 process is required call each experiment seperately (no worker pool)
        if self.options.ncores == 1:
            for e in explist:
                mp_runrep(e)
        else:
            # create worker processes    
            pool = Pool(processes=self.options.ncores)
            pool.map(mp_runrep, explist)
        
        return True
1320554
def add_experiment_choice(experiment, choice):
    """"""
    redis = oz.redis.create_connection()
    oz.bandit.Experiment(redis, experiment).add_choice(choice)
542450
def add_experiment(experiment):
    """"""
    redis = oz.redis.create_connection()
    oz.bandit.add_experiment(redis, experiment)
432096
def _make_symbol_function(handle, name, func_name):
    """"""
    code, doc_str = _generate_symbol_function_code(handle, name, func_name)

    local = {}
    exec(code, None, local)  # pylint: disable=exec-used
    symbol_function = local[func_name]
    symbol_function.__name__ = func_name
    symbol_function.__doc__ = doc_str
    symbol_function.__module__ = 'mxnet.symbol'
    return symbol_function
781962
def _create_exprs_using_func(self, f, columns):
        """"""
        expressions = map(lambda c: f(c).alias(c),
                          self._columns)
        return expressions
837315
function createCondition(name, value) {
    // FIXME name?
    value = value.replace(r, function (w) {
        w = w.replace('{{', '').replace('}}', '');
        return 'item["' + w + '"]';
    });
    //console.log('createCondition', name, value);
    return function (item) {
        return eval(value);
    };
}
772476
def _maybe_init_run(self, experiment_name, run_name):
    
    experiment_id = self._maybe_init_experiment(experiment_name)
    cursor = self._db.cursor()
    cursor.execute(
        """
        SELECT run_id FROM Runs
        WHERE experiment_id = ? AND run_name = ?
        """,
        (experiment_id, run_name))
    row = cursor.fetchone()
    if row:
      return row[0]
    run_id = self._create_id()
    # TODO: track actual run start times
    started_time = 0
    cursor.execute(
        """
        INSERT INTO Runs (
          experiment_id, run_id, run_name, inserted_time, started_time
        ) VALUES (?, ?, ?, ?, ?)
        """,
        (experiment_id, run_id, run_name, time.time(), started_time))
    return run_id
967003
def set_function(self, f):
        

        def samples(self):
            return (('', {}, float(f())),)

        self._child_samples = types.MethodType(samples, self)
99721
def _createFuture(func, *args, **kwargs):
    """"""
    assert callable(func), (
        "The provided func parameter is not a callable."
    )

    if scoop.IS_ORIGIN and "SCOOP_WORKER" not in sys.modules:
        sys.modules["SCOOP_WORKER"] = sys.modules["__main__"]

    # If function is a lambda or class method, share it (or its parent object)
    # beforehand
    lambdaType = type(lambda: None)
    funcIsLambda = isinstance(func, lambdaType) and func.__name__ == '<lambda>'
    # Determine if function is a method. Methods derived from external
    # languages such as C++ aren't detected by ismethod.
    funcIsMethod = ismethod(func)
    if funcIsLambda or funcIsMethod:
        from .shared import SharedElementEncapsulation
        func = SharedElementEncapsulation(func)

    return Future(control.current.id, func, *args, **kwargs)
98941
def run_experiment(self):
        
        data=self.data
        options=self.options
        result=self.result

        command = open(self.options.experiment_script).read()
        result["experiment_script"]=command
        t0=time.time()
        exec(command)   #creates variable result
        t1=time.time()
        print(("Elapsed time for running the experiment is %.2f seconds" % (t1-t0)))
        self.result=result
        return self.result