当前位置: 首页>>代码示例>>Python>>正文


Python Configuration.get方法代码示例

本文整理汇总了Python中nupic.support.configuration.Configuration.get方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.get方法的具体用法?Python Configuration.get怎么用?Python Configuration.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nupic.support.configuration.Configuration的用法示例。


在下文中一共展示了Configuration.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: newPosition

# 需要导入模块: from nupic.support.configuration import Configuration [as 别名]
# 或者: from nupic.support.configuration.Configuration import get [as 别名]
  def newPosition(self, globalBestPosition, rng):
    """See comments in base class."""
    # First, update the velocity. The new velocity is given as:
    # v = (inertia * v)  + (cogRate * r1 * (localBest-pos))
    #                    + (socRate * r2 * (globalBest-pos))
    #
    # where r1 and r2 are random numbers between 0 and 1.0
    lb=float(Configuration.get("nupic.hypersearch.randomLowerBound"))
    ub=float(Configuration.get("nupic.hypersearch.randomUpperBound"))

    self._velocity = (self._velocity * self._inertia + rng.uniform(lb, ub) *
                      self._cogRate * (self._bestPosition - self.getPosition()))
    if globalBestPosition is not None:
      self._velocity += rng.uniform(lb, ub) * self._socRate * (
          globalBestPosition - self.getPosition())

    # update position based on velocity
    self._position += self._velocity

    # Clip it
    self._position = max(self.min, self._position)
    self._position = min(self.max, self._position)

    # Return it
    return self.getPosition()
开发者ID:runt18,项目名称:nupic,代码行数:27,代码来源:permutationhelpers.py

示例2: __init__

# 需要导入模块: from nupic.support.configuration import Configuration [as 别名]
# 或者: from nupic.support.configuration.Configuration import get [as 别名]
  def __init__(self, clamodel, anomalyParams=None):
    if anomalyParams is None:
      anomalyParams = {}
    if anomalyParams is None:
      anomalyParams = {}
    self.clamodel = clamodel

    self._version = CLAModelClassifierHelper.__VERSION__

    self._classificationMaxDist = 0.1

    if 'autoDetectWaitRecords' not in anomalyParams or \
        anomalyParams['autoDetectWaitRecords'] is None:
      self._autoDetectWaitRecords = int(Configuration.get(
        'nupic.model.temporalAnomaly.wait_records'))
    else:
      self._autoDetectWaitRecords = anomalyParams['autoDetectWaitRecords']

    if 'autoDetectThreshold' not in anomalyParams or \
        anomalyParams['autoDetectThreshold'] is None:
      self._autoDetectThreshold = float(Configuration.get(
        'nupic.model.temporalAnomaly.auto_detect_threshold'))
    else:
      self._autoDetectThreshold = anomalyParams['autoDetectThreshold']

    if 'anomalyCacheRecords' not in anomalyParams or \
        anomalyParams['anomalyCacheRecords'] is None:
      self._history_length = int(Configuration.get(
        'nupic.model.temporalAnomaly.window_length'))
    else:
      self._history_length = anomalyParams['anomalyCacheRecords']

    if 'anomalyVectorType' not in anomalyParams or \
        anomalyParams['anomalyVectorType'] is None:
      self._vectorType = str(Configuration.get(
        'nupic.model.temporalAnomaly.anomaly_vector'))
    else:
      self._vectorType = anomalyParams['anomalyVectorType']

    self._activeColumnCount = \
      self.clamodel._getSPRegion().getSelf().getParameter('numActiveColumnsPerInhArea')

    # Storage for last run
    self._anomalyVectorLength = None
    self._classificationVector = numpy.array([])
    self._prevPredictedColumns = numpy.array([])
    self._prevTPCells = numpy.array([])

    # Array of CLAClassificationRecord's used to recompute and get history
    self.saved_states = []
    self.saved_categories = []
开发者ID:runt18,项目名称:nupic,代码行数:53,代码来源:clamodel_classifier_helper.py

示例3: _getCommonSteadyDBArgsDict

# 需要导入模块: from nupic.support.configuration import Configuration [as 别名]
# 或者: from nupic.support.configuration.Configuration import get [as 别名]
def _getCommonSteadyDBArgsDict():
  """ Returns a dictionary of arguments for DBUtils.SteadyDB.SteadyDBConnection
  constructor.
  """

  return dict(
      creator = pymysql,
      host = Configuration.get('nupic.cluster.database.host'),
      port = int(Configuration.get('nupic.cluster.database.port')),
      user = Configuration.get('nupic.cluster.database.user'),
      passwd = Configuration.get('nupic.cluster.database.passwd'),
      charset = 'utf8',
      use_unicode = True,
      setsession = ['SET AUTOCOMMIT = 1'])
开发者ID:AI-Cdrone,项目名称:nupic,代码行数:16,代码来源:Connection.py

示例4: __init__

# 需要导入模块: from nupic.support.configuration import Configuration [as 别名]
# 或者: from nupic.support.configuration.Configuration import get [as 别名]
    def __init__(self, steps="1", alpha=0.001, clVerbosity=0, implementation=None, maxCategoryCount=None):

        # Set default implementation
        if implementation is None:
            implementation = Configuration.get("nupic.opf.sdrClassifier.implementation")

        self.implementation = implementation
        # Convert the steps designation to a list
        self.steps = steps
        self.stepsList = [int(i) for i in steps.split(",")]
        self.alpha = alpha
        self.verbosity = clVerbosity

        # Initialize internal structures
        self._sdrClassifier = None
        self.learningMode = True
        self.inferenceMode = False
        self.maxCategoryCount = maxCategoryCount
        self.recordNum = 0

        # Flag to know if the compute() function is ever called. This is to
        # prevent backward compatibilities issues with the customCompute() method
        # being called at the same time as the compute() method. Only compute()
        # should be called via network.run(). This flag will be removed once we
        # get to cleaning up the clamodel.py file.
        self._computeFlag = False
开发者ID:rhyolight,项目名称:nupic,代码行数:28,代码来源:SDRClassifierRegion.py

示例5: __setstate__

# 需要导入模块: from nupic.support.configuration import Configuration [as 别名]
# 或者: from nupic.support.configuration.Configuration import get [as 别名]
  def __setstate__(self, state):
    version = 1
    if "_version" in state:
      version = state["_version"]

    # Migrate from version 1 to version 2
    if version == 1:
      self._vectorType = str(Configuration.get(
        'nupic.model.temporalAnomaly.anomaly_vector'))
      self._autoDetectWaitRecords = state['_classificationDelay']
    elif version == 2:
      self._autoDetectWaitRecords = state['_classificationDelay']
    elif version == 3:
      pass
    else:
      raise Exception("Error while deserializing %s: Invalid version %s"
                      %(self.__class__, version))

    if '_autoDetectThreshold' not in state:
      self._autoDetectThreshold = 1.1

    for attr, value in state.iteritems():
      setattr(self, attr, value)

    self._version = CLAModelClassifierHelper.__VERSION__
开发者ID:0x0all,项目名称:nupic,代码行数:27,代码来源:clamodel_classifier_helper.py

示例6: __init__

# 需要导入模块: from nupic.support.configuration import Configuration [as 别名]
# 或者: from nupic.support.configuration.Configuration import get [as 别名]
    def __init__(self, steps="1", alpha=0.001, verbosity=0, implementation=None, maxCategoryCount=None):

        # Set default implementation
        if implementation is None:
            implementation = Configuration.get("nupic.opf.claClassifier.implementation")

        # Convert the steps designation to a list
        self.classifierImp = implementation
        self.steps = steps
        self.stepsList = eval("[%s]" % (steps))
        self.alpha = alpha
        self.verbosity = verbosity

        # Initialize internal structures
        self._claClassifier = CLAClassifierFactory.create(
            steps=self.stepsList, alpha=self.alpha, verbosity=self.verbosity, implementation=implementation
        )
        self.learningMode = True
        self.inferenceMode = False
        self.maxCategoryCount = maxCategoryCount
        self.recordNum = 0
        self._initEphemerals()

        # Flag to know if the compute() function is ever called. This is to
        # prevent backward compatibilities issues with the customCompute() method
        # being called at the same time as the compute() method. Only compute()
        # should be called via network.run(). This flag will be removed once we
        # get to cleaning up the clamodel.py file.
        self._computeFlag = False
开发者ID:csbond007,项目名称:nupic,代码行数:31,代码来源:CLAClassifierRegion.py

示例7: dbValidator

# 需要导入模块: from nupic.support.configuration import Configuration [as 别名]
# 或者: from nupic.support.configuration.Configuration import get [as 别名]
def dbValidator():
  """
    Let the user know what NuPIC config file is being used
    and whether or not they have mysql set up correctly for
    swarming.
  """
  fileused = getFileUsed()

  # Get the values we need from NuPIC's configuration
  host = Configuration.get("nupic.cluster.database.host")
  port = int(Configuration.get("nupic.cluster.database.port"))
  user = Configuration.get("nupic.cluster.database.user")
  passwd = "*" * len(Configuration.get("nupic.cluster.database.passwd"))


  print "This script will validate that your MySQL is setup correctly for "
  print "NuPIC. MySQL is required for NuPIC swarming. The settings are"
  print "defined in a configuration file found in  "
  print "$NUPIC/src/nupic/support/nupic-default.xml Out of the box those "
  print "settings contain MySQL's default access credentials."
  print
  print "The nupic-default.xml can be duplicated to define user specific "
  print "changes calling the copied file "
  print "$NUPIC/src/nupic/support/nupic-site.xml Refer to the "
  print "nupic-default.xml for additional instructions."
  print
  print "Defaults: localhost, 3306, root, no password"
  print
  print "Retrieved the following NuPIC configuration using: ", fileused
  print "    host   :    ", host
  print "    port   :    ", port
  print "    user   :    ", user
  print "    passwd :    ", passwd


  if testDbConnection(host, port, user, passwd):
    print "Connection successful!!"
  else:
    print ("Couldn't connect to the database or you don't have the "
           "permissions required to create databases and tables. "
           "Please ensure you have MySQL\n installed, running, "
           "accessible using the NuPIC configuration settings, "
           "and the user specified has permission to create both "
           "databases and tables.")
开发者ID:BornOfHope,项目名称:nupic,代码行数:46,代码来源:test_db.py

示例8: create

# 需要导入模块: from nupic.support.configuration import Configuration [as 别名]
# 或者: from nupic.support.configuration.Configuration import get [as 别名]
 def create(*args, **kwargs):
     impl = kwargs.pop("implementation", None)
     if impl is None:
         impl = Configuration.get("nupic.opf.claClassifier.implementation")
     if impl == "py":
         return SequenceClassifier(*args, **kwargs)
     elif impl == "cpp":
         raise ValueError("cpp version not yet implemented")
     else:
         raise ValueError("Invalid classifier implementation (%r). Value must be " '"py" or "cpp".' % impl)
开发者ID:numenta,项目名称:nupic.cloudbrain,代码行数:12,代码来源:sequence_classifier_factory.py

示例9: create

# 需要导入模块: from nupic.support.configuration import Configuration [as 别名]
# 或者: from nupic.support.configuration.Configuration import get [as 别名]
 def create(*args, **kwargs):
   impl = kwargs.pop('implementation', None)
   if impl is None:
     impl = Configuration.get('nupic.opf.claClassifier.implementation')
   if impl == 'py':
     return SequenceClassifier(*args, **kwargs)
   elif impl == 'cpp':
     raise ValueError('cpp version not yet implemented')
   else:
     raise ValueError('Invalid classifier implementation (%r). Value must be '
                      '"py" or "cpp".' % impl)
开发者ID:akhilaananthram,项目名称:nupic.research,代码行数:13,代码来源:sequence_classifier_factory.py

示例10: __init__

# 需要导入模块: from nupic.support.configuration import Configuration [as 别名]
# 或者: from nupic.support.configuration.Configuration import get [as 别名]
  def __init__(self, min, max, stepSize=None, inertia=None, cogRate=None,
               socRate=None):
    """Construct a variable that permutes over floating point values using
    the Particle Swarm Optimization (PSO) algorithm. See descriptions of
    PSO (i.e. http://en.wikipedia.org/wiki/Particle_swarm_optimization)
    for references to the inertia, cogRate, and socRate parameters.

    Parameters:
    -----------------------------------------------------------------------
    min:          min allowed value of position
    max:          max allowed value of position
    stepSize:     if not None, the position must be at min + N * stepSize,
                    where N is an integer
    inertia:      The inertia for the particle.
    cogRate:      This parameter controls how much the particle is affected
                    by its distance from it's local best position
    socRate:      This parameter controls how much the particle is affected
                    by its distance from the global best position

    """
    super(PermuteFloat, self).__init__()
    self.min = min
    self.max = max
    self.stepSize = stepSize

    # The particle's initial position and velocity.
    self._position = (self.max + self.min) / 2.0
    self._velocity = (self.max - self.min) / 5.0


    # The inertia, cognitive, and social components of the particle
    self._inertia = (float(Configuration.get("nupic.hypersearch.inertia"))
                     if inertia is None else inertia)
    self._cogRate = (float(Configuration.get("nupic.hypersearch.cogRate"))
                     if cogRate is None else cogRate)
    self._socRate = (float(Configuration.get("nupic.hypersearch.socRate"))
                     if socRate is None else socRate)

    # The particle's local best position and the best global position.
    self._bestPosition = self.getPosition()
    self._bestResult = None
开发者ID:runt18,项目名称:nupic,代码行数:43,代码来源:permutationhelpers.py

示例11: create

# 需要导入模块: from nupic.support.configuration import Configuration [as 别名]
# 或者: from nupic.support.configuration.Configuration import get [as 别名]
 def create(*args, **kwargs):
   impl = kwargs.pop('implementation', None)
   if impl is None:
     impl = Configuration.get('nupic.opf.claClassifier.implementation')
   if impl == 'py':
     return CLAClassifier(*args, **kwargs)
   elif impl == 'cpp':
     return FastCLAClassifier(*args, **kwargs)
   elif impl == 'diff':
     return CLAClassifierDiff(*args, **kwargs)
   else:
     raise ValueError('Invalid classifier implementation (%r). Value must be '
                      '"py" or "cpp".' % impl)
开发者ID:KairiL,项目名称:nupic,代码行数:15,代码来源:cla_classifier_factory.py

示例12: create

# 需要导入模块: from nupic.support.configuration import Configuration [as 别名]
# 或者: from nupic.support.configuration.Configuration import get [as 别名]
    def create(*args, **kwargs):
        """
    Create a SDR classifier factory.
    The implementation of the SDR Classifier can be specified with
    the "implementation" keyword argument.

    The SDRClassifierFactory uses the implementation as specified in
     src/nupic/support/nupic-default.xml
    """
        impl = kwargs.pop("implementation", None)
        if impl is None:
            impl = Configuration.get("nupic.opf.sdrClassifier.implementation")
        if impl == "py":
            return SDRClassifier(*args, **kwargs)
        else:
            raise ValueError("Invalid classifier implementation (%r). Value must be " '"py".' % impl)
开发者ID:csbond007,项目名称:nupic,代码行数:18,代码来源:sdr_classifier_factory.py

示例13: create

# 需要导入模块: from nupic.support.configuration import Configuration [as 别名]
# 或者: from nupic.support.configuration.Configuration import get [as 别名]
  def create(*args, **kwargs):
    """
    Create a SDR classifier factory.
    The implementation of the SDR Classifier can be specified with
    the "implementation" keyword argument.

    The SDRClassifierFactory uses the implementation as specified in
     `Default NuPIC Configuration <default-config.html>`_.
    """
    impl = kwargs.pop('implementation', None)
    if impl is None:
      impl = Configuration.get('nupic.opf.sdrClassifier.implementation')
    if impl == 'py':
      return SDRClassifier(*args, **kwargs)
    elif impl == 'cpp':
      return FastSDRClassifier(*args, **kwargs)
    else:
      raise ValueError('Invalid classifier implementation (%r). Value must be '
                       '"py" or "cpp".' % impl)
开发者ID:mrcslws,项目名称:nupic,代码行数:21,代码来源:sdr_classifier_factory.py

示例14: run

# 需要导入模块: from nupic.support.configuration import Configuration [as 别名]
# 或者: from nupic.support.configuration.Configuration import get [as 别名]
    def run(self):
        """ Run this worker.

    Parameters:
    ----------------------------------------------------------------------
    retval:     jobID of the job we ran. This is used by unit test code
                  when calling this working using the --params command
                  line option (which tells this worker to insert the job
                  itself).
    """
        # Easier access to options
        options = self._options

        # ---------------------------------------------------------------------
        # Connect to the jobs database
        self.logger.info("Connecting to the jobs database")
        cjDAO = ClientJobsDAO.get()

        # Get our worker ID
        self._workerID = cjDAO.getConnectionID()

        if options.clearModels:
            cjDAO.modelsClearAll()

        # -------------------------------------------------------------------------
        # if params were specified on the command line, insert a new job using
        #  them.
        if options.params is not None:
            options.jobID = cjDAO.jobInsert(
                client="hwTest",
                cmdLine="echo 'test mode'",
                params=options.params,
                alreadyRunning=True,
                minimumWorkers=1,
                maximumWorkers=1,
                jobType=cjDAO.JOB_TYPE_HS,
            )
        if options.workerID is not None:
            wID = options.workerID
        else:
            wID = self._workerID

        buildID = Configuration.get("nupic.software.buildNumber", "N/A")
        logPrefix = "<BUILDID=%s, WORKER=HW, WRKID=%s, JOBID=%s> " % (buildID, wID, options.jobID)
        ExtendedLogger.setLogPrefix(logPrefix)

        # ---------------------------------------------------------------------
        # Get the search parameters
        # If asked to reset the job status, do that now
        if options.resetJobStatus:
            cjDAO.jobSetFields(
                options.jobID,
                fields={
                    "workerCompletionReason": ClientJobsDAO.CMPL_REASON_SUCCESS,
                    "cancel": False,
                    #'engWorkerState': None
                },
                useConnectionID=False,
                ignoreUnchanged=True,
            )
        jobInfo = cjDAO.jobInfo(options.jobID)
        self.logger.info("Job info retrieved: %s" % (str(clippedObj(jobInfo))))

        # ---------------------------------------------------------------------
        # Instantiate the Hypersearch object, which will handle the logic of
        #  which models to create when we need more to evaluate.
        jobParams = json.loads(jobInfo.params)

        # Validate job params
        jsonSchemaPath = os.path.join(os.path.dirname(__file__), "jsonschema", "jobParamsSchema.json")
        validate(jobParams, schemaPath=jsonSchemaPath)

        hsVersion = jobParams.get("hsVersion", None)
        if hsVersion == "v2":
            self._hs = HypersearchV2(
                searchParams=jobParams,
                workerID=self._workerID,
                cjDAO=cjDAO,
                jobID=options.jobID,
                logLevel=options.logLevel,
            )
        else:
            raise RuntimeError("Invalid Hypersearch implementation (%s) specified" % (hsVersion))

        # =====================================================================
        # The main loop.
        try:
            exit = False
            numModelsTotal = 0
            print >>sys.stderr, "reporter:status:Evaluating first model..."
            while not exit:

                # ------------------------------------------------------------------
                # Choose a model to evaluate
                batchSize = 10  # How many to try at a time.
                modelIDToRun = None
                while modelIDToRun is None:

                    if options.modelID is None:
                        # -----------------------------------------------------------------
#.........这里部分代码省略.........
开发者ID:arabenjamin,项目名称:nupic,代码行数:103,代码来源:HypersearchWorker.py

示例15: main

# 需要导入模块: from nupic.support.configuration import Configuration [as 别名]
# 或者: from nupic.support.configuration.Configuration import get [as 别名]
        jobID = None
        completionReason = ClientJobsDAO.CMPL_REASON_SUCCESS
        completionMsg = "Success"

        try:
            jobID = hst.run()
        except Exception, e:
            jobID = hst._options.jobID
            completionReason = ClientJobsDAO.CMPL_REASON_ERROR
            completionMsg = "ERROR: %s" % (e,)
            raise
        finally:
            if jobID is not None:
                cjDAO = ClientJobsDAO.get()
                cjDAO.jobSetCompleted(jobID=jobID, completionReason=completionReason, completionMsg=completionMsg)

    return jobID


if __name__ == "__main__":
    logging.setLoggerClass(ExtendedLogger)
    buildID = Configuration.get("nupic.software.buildNumber", "N/A")
    logPrefix = "<BUILDID=%s, WORKER=HS, WRKID=N/A, JOBID=N/A> " % buildID
    ExtendedLogger.setLogPrefix(logPrefix)

    try:
        main(sys.argv)
    except:
        logging.exception("HypersearchWorker is exiting with unhandled exception; " "argv=%r", sys.argv)
        raise
开发者ID:arabenjamin,项目名称:nupic,代码行数:32,代码来源:HypersearchWorker.py


注:本文中的nupic.support.configuration.Configuration.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。