def run(self, name, model, recorder, trainingOrder, moreHyperParameters) :
		"""
			:param str runName: The name of this run
			:param Recorder recorder: A recorder object
			:param int trainingOrder:
				* DefaultTrainer.SEQUENTIAL_TRAINING: Each output will be trained indipendetly on it's own epoch
				* DefaultTrainer.SIMULTANEOUS_TRAINING: All outputs are trained within the same epoch with the same inputs
				* Both are in O(m*n), where m is the number of mini batches and n the number of outputs
				* DefaultTrainer.RANDOM_PICK_TRAINING: Will pick one of the outputs at random for each example

			:param bool reset: Should the trainer be reset before starting the run
			:param dict moreHyperParameters: If provided, the fields in this dictionary will be included into the log .csv file
		"""
		def setHPs(layer, thing, dct) :
			try :
				thingObj = getattr(l, thing)
			except AttributeError :
				return

			if thingObj is not None :
				if type(thingObj) is types.ListType :
					for obj in thingObj :
						if len(obj.hyperParameters) == 0 :
							dct["%s_%s_%s" % (l.name, thing, obj.name)] = 1
						else :
							for hp in obj.hyperParameters :
								dct["%s_%s_%s_%s" % (l.name, thing, obj.name, hp)] = getattr(obj, hp)
				else :
					if len(thingObj.hyperParameters) == 0 :
						dct["%s_%s" % (l.name, thingObj.name)] = 1
					else :
						for hp in thingObj.hyperParameters :
							dct["%s_%s" % (l.name, hp)] = getattr(thingObj, hp)

		def _trainTest(aMap, modelFct, trainingOrder, miniBatchSize, inputLayers, outputLayers) :
			scores = {}
			layerList = inputLayers
			if miniBatchSize == DefaultTrainer.ALL_SET :
				for output in outputLayers :
					layerList.append(output)
					kwargs = dict( aMap.getAll(layerList = layerList) )
					res = modelFct(output, **kwargs)
					scores[output.name] = res[0]
					layerList.pop(-1)
			else :
				if trainingOrder == DefaultTrainer.SEQUENTIAL_TRAINING :
					for output in outputLayers :
						for i in xrange(0, len(aMap), miniBatchSize) :
							layerList.append(output)
							batchData = aMap.getBatch(i, miniBatchSize, layerList = layerList)
							res = modelFct(output, **batchData)
							try :
								scores[output.name].append(res[0])
							except KeyError:
								scores[output.name] = [res[0]]
							layerList.pop(-1)

				elif trainingOrder == DefaultTrainer.SIMULTANEOUS_TRAINING :
					for i in xrange(0, len(aMap), miniBatchSize) :
						batchData = aMap.getBatch(i, miniBatchSize, layerList = layerList)
						for output in outputLayers :
							layerList.append(output)
							res = modelFct(output, **batchData)
							try :
								scores[output.name].append(res[0])
							except KeyError:
								scores[output.name] = [res[0]]
							layerList.pop(-1)
				
				elif trainingOrder == DefaultTrainer.RANDOM_PICK_TRAINING :
					outputOrder = list(numpy.random.randint(0, len(outputLayers), len(aMap)/miniBatchSize +1))
					for i in xrange(0, len(aMap), miniBatchSize):
						output = outputLayers[outputOrder.pop()]
						layerList.append(output)
						batchData = aMap.getBatch(i, miniBatchSize, layerList = layerList)
						res = modelFct(output, **batchData)
						
						try :
							scores[output.name].append(res[0])
						except KeyError:
							scores[output.name] = [res[0]]
						layerList.pop(-1)
				else :
					raise ValueError("Unknown training order: %s" % trainingOrder)

			for outputName in scores :
				scores[outputName] = numpy.mean(scores[outputName])
			if len(scores) > 1 :
				scores["average"] = numpy.mean(scores.values())
			
			return scores

		if trainingOrder not in self.trainingOrdersHR:
			raise ValueError("Unknown training order: %s" % trainingOrder)

		legend = ["name", "epoch", "runtime(min)", "training_order"]
		legend.extend(moreHyperParameters.keys())
		hyperParameters = OrderedDict()
		for l in model.layers.itervalues() :
			hyperParameters["%s_size" % l.name] = len(l)
			try :
				hyperParameters["activation"] = l.activation.__name__
			except AttributeError :
				pass
			setHPs(l, "learningScenario", hyperParameters)
			setHPs(l, "decorators", hyperParameters)
			setHPs(l, "activation", hyperParameters)
			if l.type == MNET.TYPE_OUTPUT_LAYER :
				setHPs(l, "costObject", hyperParameters)

		legend.extend(hyperParameters.keys())
		self.store["hyperParameters"].update(hyperParameters)
		self.store["hyperParameters"].update(moreHyperParameters)
		
		self.store["runInfos"]["name"] = name
		self.store["runInfos"]["training_order"] = self.trainingOrdersHR[trainingOrder]
		self.store["runInfos"]["pid"] = os.getpid()
	
		self.recorder = recorder
		
		startTime = time.time()
		self.store["runInfos"]["epoch"] = 0
		inputLayers = model.inputs.values()
		outputLayers = model.outputs.values()

		for mapName in self.maps :
			self.store["setSizes"][mapName] = self.maps[mapName].getMinFullLength()
			self.store["scores"][mapName] = {}
			for o in outputLayers :
				self.store["scores"][mapName][o.name] = "NA"

		while True :
			for mapName in ["train", "test", "validation"] :
				try :
					aMap = self.maps[mapName]
					if len(aMap) > 0 :
						scores = {}
						aMap.commit()
						if mapName == "train" :
							modelFct = model.train
						else :
							modelFct = model.test
						
						scores = _trainTest(
							aMap,
							modelFct,
							trainingOrder,
							self.miniBatchSizes[mapName],
							inputLayers,
							outputLayers
						)
						for k, v in scores.iteritems() :
							self.store["scores"][mapName][k] = v
				except KeyError :
					pass
			
			runtime = (time.time() - startTime)/60
			self.store["runInfos"].update( (
				("runtime_min", runtime),
			) )
	
			self.recorder.commit(self.store, model)
			for crit in self.stopCriteria :
				if crit.stop(self) :
					raise MSTOP.EndOfTraining(crit)

			for l in model.layers.itervalues() :
				try :
					l.learningScenario.update(self.store)
				except AttributeError :
					pass

			self.store["runInfos"]["epoch"] += 1
dataset/ETHPy150Open tariqdaouda/Mariana/Mariana/training/trainers.py/DefaultTrainer.run/original