Exemplo n.º 1
0
def get_dataset(size, partition, label_category=None, skip=1):
	"""
	:param size: 0:mini, 1:small, 2:medium, 3:large
	:param label_category: 0:moving, 1:position, 2:in/outdoor
	"""
	train_x, train_y = load_data.load_prepared_data(load_data.load_sample_expId(size, partition), skip=skip)
	if label_category is not None:
		train_y = numpy.asarray(train_y[:,label_category], dtype='int32')
	else:
		train_y = numpy.asarray(train_y, dtype='int32')
	return [train_x, train_y]
Exemplo n.º 2
0
	def eval_exps(self, exp_ids):
		preparedset = load_prepared_data(exp_ids)
		prepared_x = preparedset[0]
		prepared_y = numpy.asarray(preparedset[1][:,0], 'int32')

		mv_logreg_error = 1-self.mv_logreg.score(prepared_x, prepared_y)

		# dataset = load_data(exp_ids, window=self.window, sliding_step=self.sliding_step)
		# if dataset is None:
		# 	return 0, 0, 0, 0
		# sharedset = shared_dataset(dataset, self.convnet.static_sensor)
		# convnet_inst_num = dataset[1].shape[0]
		dataset = cc_preprocessor.load_data(exp_ids, window=self.window, sliding_step=self.sliding_step)
		if dataset.start_idx < 1:
			return 0, 0, 0, 0
		sharedset = cc_multimodal_conv.shared_dataset(dataset)
		convnet_inst_num = dataset.start_idx

		"""
		shared_x = theano.shared(prepared_x, borrow=True)
		shared_y = theano.shared(prepared_y, borrow=True)
		sharedset = [shared_x, shared_y]
		"""	

		if self.mv_rf is None:
			convnet_scores = self.convnet.score(sharedset)
			print convnet_scores
		else:
			repr_x, repr_y = self.convnet.input_to_feature(sharedset, layer=self.layer)
			print repr_x.shape
			convnet_scores = self.mv_rf.score(repr_x, repr_y[:,0])

		convnet_errors = 1-convnet_scores
		logreg_inst_num = len(preparedset[1])

		return logreg_inst_num, mv_logreg_error, convnet_inst_num, convnet_errors