def __validateExperimentControl(self, control): """ Validates control dictionary for the experiment context""" # Validate task list taskList = control.get('tasks', None) if taskList is not None: taskLabelsList = [] for task in taskList: validateOpfJsonValue(task, "opfTaskSchema.json") validateOpfJsonValue(task['taskControl'], "opfTaskControlSchema.json") taskLabel = task['taskLabel'] assert isinstance(taskLabel, str), \ "taskLabel type: %r" % type(taskLabel) assert len( taskLabel) > 0, "empty string taskLabel not is allowed" taskLabelsList.append(taskLabel.lower()) taskLabelDuplicates = [ x for x in taskLabelsList if taskLabelsList.count(x) > 1 ] assert len(taskLabelDuplicates) == 0, \ "Duplcate task labels are not allowed: %s" % taskLabelDuplicates return
def __validateExperimentControl(self, control): """ Validates control dictionary for the experiment context""" # Validate task list taskList = control.get('tasks', None) if taskList is not None: taskLabelsList = [] for task in taskList: validateOpfJsonValue(task, "opfTaskSchema.json") validateOpfJsonValue(task['taskControl'], "opfTaskControlSchema.json") taskLabel = task['taskLabel'] assert isinstance(taskLabel, types.StringTypes), \ "taskLabel type: %r" % type(taskLabel) assert len(taskLabel) > 0, "empty string taskLabel not is allowed" taskLabelsList.append(taskLabel.lower()) taskLabelDuplicates = filter(lambda x: taskLabelsList.count(x) > 1, taskLabelsList) assert len(taskLabelDuplicates) == 0, \ "Duplcate task labels are not allowed: %s" % taskLabelDuplicates return
def __init__(self, model, task, cmdOptions): """ Constructor Args: model: The OPF Model instance against which to run the task task: A dictionary conforming to opfTaskSchema.json cmdOptions: ParseCommandLineOptionsResult namedtuple """ validateOpfJsonValue(task, "opfTaskSchema.json") # Set up our logger self.__logger = logging.getLogger(".".join( ['com.numenta', self.__class__.__module__, self.__class__.__name__])) #self.__logger.setLevel(logging.DEBUG) self.__logger.debug(("Instantiated %s(" + \ "model=%r, " + \ "task=%r, " + \ "cmdOptions=%r)") % \ (self.__class__.__name__, model, task, cmdOptions)) # Generate a new dataset from streamDef and create the dataset reader streamDef = task['dataset'] datasetReader = opf_basic_environment.BasicDatasetReader(streamDef) self.__model = model self.__datasetReader = datasetReader self.__task = task self.__cmdOptions = cmdOptions self.__predictionLogger = opf_basic_environment.BasicPredictionLogger( fields=model.getFieldInfo(), experimentDir=cmdOptions.experimentDir, label=task['taskLabel'], inferenceType=self.__model.getInferenceType()) taskControl = task['taskControl'] # Create Task Driver self.__taskDriver = OPFTaskDriver( taskControl=taskControl, model=model) loggedMetricPatterns = taskControl.get('loggedMetrics', None) loggedMetricLabels = matchPatterns(loggedMetricPatterns, self.__taskDriver.getMetricLabels()) self.__predictionLogger.setLoggedMetrics(loggedMetricLabels) # Create a prediction metrics logger self.__metricsLogger = opf_basic_environment.BasicPredictionMetricsLogger( experimentDir=cmdOptions.experimentDir, label=task['taskLabel'])
def __validateNupicControl(self, control): """ Validates control dictionary for the nupic engine context""" validateOpfJsonValue(control, "nupicControlSchema.json")