예제 #1
0
def multiplyData(y,node,edge):
	y_ = []
	node_ = []
	edge_ = []
	N = len(node)
	for l, n , e in zip(y,node,edge):
		samples = sampleSubSequences(n.shape[0],extra_samples,min_length_sequence)
		for s in samples:
			if copy_start_state:			
				ll = [0]
				if s[0] > 0:
					ll = ll + range(s[0],s[1])
				else:
					ll = range(s[0],s[1])
				y_.append(l[ll])
				node_.append(n[ll,:])
				edge_.append(e[ll,:])
			else:
				y_.append(l[s[0]:s[1]])
				node_.append(n[s[0]:s[1],:])
				edge_.append(e[s[0]:s[1],:])
			N += 1
	y = y + y_
	edge = edge + edge_
	node = node + node_
	return N,y,node,edge
예제 #2
0
def multiplyData(features,sample_ratio):
	N = 0	
	for action in actions:
		new_samples = []
		for f in features[action]:
			N += 1
			samples = sampleSubSequences(f.shape[0],int(sample_ratio[action]*extra_samples),min_length_sequence)
			for s in samples:
				N += 1
				if copy_start_state:			
					ll = [0]
					if s[0] > 0:
						ll = ll + range(s[0],s[1])
					else:
						ll = range(s[0],s[1])
					new_samples.append(f[ll,:])
				else:
					new_samples.append(f[s[0]:s[1],:])
		features[action] = features[action] + new_samples
		print '{0} {1}'.format(action,len(features[action]))
	return N,features
예제 #3
0
def multiplyData(features,sample_ratio):
	N = 0	
	for action in actions:
		new_samples = []
		for f in features[action]:
			N += 1
			samples = sampleSubSequences(f.shape[0],int(sample_ratio[action]*extra_samples),min_length_sequence)
			for s in samples:
				N += 1
				if copy_start_state:			
					ll = [0]
					if s[0] > 0:
						ll = ll + range(s[0],s[1])
					else:
						ll = range(s[0],s[1])
					new_samples.append(f[ll,:])
				else:
					new_samples.append(f[s[0]:s[1],:])
		features[action] = features[action] + new_samples
		print '{0} {1}'.format(action,len(features[action]))
	return N,features
예제 #4
0
def multiplyData(y,node,edge,edge_intra,y_object,node_object,edge_object,edge_intra_object,edge_intra_object_human):
	
	y_ = []
	y_anticipation_ = []
	node_ = []
	edge_ = []
	edge_intra_ = []
	
	y_object_ = []
	y_object_anticipation_ = []
	node_object_ = []
	edge_object_ = []
	edge_intra_object_ = []
	edge_intra_object_human_ = []

	N = len(node)

	for l in y:
		y_anticipation_.append(appendToArray(l[1:],11))


	for l, n , e, ei, yo, no, eo, eio, eioh in zip(y,node,edge,edge_intra,y_object,node_object,edge_object,edge_intra_object,edge_intra_object_human):
		samples = sampleSubSequences(n.shape[0],extra_samples,min_length_sequence)
		for yo_, no_, eo_, eio_, eioh_ in zip(yo, no, eo, eio, eioh):
			y_object_.append(yo_)
			y_object_anticipation_.append(appendToArray(yo_[1:],13))
			node_object_.append(no_)
			edge_object_.append(eo_)
			edge_intra_object_.append(eio_)
			edge_intra_object_human_.append(eioh_)
		for s in samples:
			if copy_start_state:			
				ll = [0]
				if s[0] > 0:
					ll = ll + range(s[0],s[1])
				else:
					ll = range(s[0],s[1])
				y_.append(l[ll])
				node_.append(n[ll,:])
				edge_.append(e[ll,:])
				edge_intra_.append(ei[ll,:])
				new_list = [(x+1) for x in ll]		
				y_anticipation_.append(appendToArray(l,11,new_list))

				for yo_, no_, eo_, eio_, eioh_ in zip(yo, no, eo, eio, eioh):
					y_object_.append(yo_[ll])
					node_object_.append(no_[ll,:])
					edge_object_.append(eo_[ll,:])
					edge_intra_object_.append(eio_[ll,:])
					edge_intra_object_human_.append(eioh_[ll,:])
					y_object_anticipation_.append(appendToArray(yo_,13,new_list))
			else:
				y_.append(l[s[0]:s[1]])
				node_.append(n[s[0]:s[1],:])
				edge_.append(e[s[0]:s[1],:])
				edge_intra_.append(ei[s[0]:s[1],:])
				new_list = range(s[0]+1,s[1]+1)
				y_anticipation_.append(appendToArray(l,11,new_list))
				for yo_, no_, eo_, eio_, eioh_ in zip(yo, no, eo, eio, eioh):
					y_object_.append(yo_[s[0]:s[1]])
					node_object_.append(no_[s[0]:s[1],:])
					edge_object_.append(eo_[s[0]:s[1],:])
					edge_intra_object_.append(eio_[s[0]:s[1],:])
					edge_intra_object_human_.append(eioh_[s[0]:s[1],:])
					y_object_anticipation_.append(appendToArray(yo_,13,new_list))
			N += 1
	y = y + y_
	edge = edge + edge_
	node = node + node_
	edge_intra = edge_intra + edge_intra_
	y_anticipation = y_anticipation_

	y_object = y_object_
	y_object_anticipation = y_object_anticipation_
	edge_object = edge_object_
	node_object = node_object_
	edge_intra_object = edge_intra_object_
	edge_intra_object_human = edge_intra_object_human_

	return N,y,node,edge,edge_intra,y_object,node_object,edge_object,edge_intra_object,edge_intra_object_human,y_anticipation,y_object_anticipation
예제 #5
0
def multiplyData(y, node, edge, edge_intra, y_object, node_object, edge_object,
                 edge_intra_object, edge_intra_object_human):

    y_ = []
    y_anticipation_ = []
    node_ = []
    edge_ = []
    edge_intra_ = []

    y_object_ = []
    y_object_anticipation_ = []
    node_object_ = []
    edge_object_ = []
    edge_intra_object_ = []
    edge_intra_object_human_ = []

    N = len(node)

    for l in y:
        y_anticipation_.append(appendToArray(l[1:], 11))

    for l, n, e, ei, yo, no, eo, eio, eioh in zip(y, node, edge, edge_intra,
                                                  y_object, node_object,
                                                  edge_object,
                                                  edge_intra_object,
                                                  edge_intra_object_human):
        samples = sampleSubSequences(n.shape[0], extra_samples,
                                     min_length_sequence)
        for yo_, no_, eo_, eio_, eioh_ in zip(yo, no, eo, eio, eioh):
            y_object_.append(yo_)
            y_object_anticipation_.append(appendToArray(yo_[1:], 13))
            node_object_.append(no_)
            edge_object_.append(eo_)
            edge_intra_object_.append(eio_)
            edge_intra_object_human_.append(eioh_)
        for s in samples:
            if copy_start_state:
                ll = [0]
                if s[0] > 0:
                    ll = ll + range(s[0], s[1])
                else:
                    ll = range(s[0], s[1])
                y_.append(l[ll])
                node_.append(n[ll, :])
                edge_.append(e[ll, :])
                edge_intra_.append(ei[ll, :])
                new_list = [(x + 1) for x in ll]
                y_anticipation_.append(appendToArray(l, 11, new_list))

                for yo_, no_, eo_, eio_, eioh_ in zip(yo, no, eo, eio, eioh):
                    y_object_.append(yo_[ll])
                    node_object_.append(no_[ll, :])
                    edge_object_.append(eo_[ll, :])
                    edge_intra_object_.append(eio_[ll, :])
                    edge_intra_object_human_.append(eioh_[ll, :])
                    y_object_anticipation_.append(
                        appendToArray(yo_, 13, new_list))
            else:
                y_.append(l[s[0]:s[1]])
                node_.append(n[s[0]:s[1], :])
                edge_.append(e[s[0]:s[1], :])
                edge_intra_.append(ei[s[0]:s[1], :])
                new_list = range(s[0] + 1, s[1] + 1)
                y_anticipation_.append(appendToArray(l, 11, new_list))
                for yo_, no_, eo_, eio_, eioh_ in zip(yo, no, eo, eio, eioh):
                    y_object_.append(yo_[s[0]:s[1]])
                    node_object_.append(no_[s[0]:s[1], :])
                    edge_object_.append(eo_[s[0]:s[1], :])
                    edge_intra_object_.append(eio_[s[0]:s[1], :])
                    edge_intra_object_human_.append(eioh_[s[0]:s[1], :])
                    y_object_anticipation_.append(
                        appendToArray(yo_, 13, new_list))
            N += 1
    y = y + y_
    edge = edge + edge_
    node = node + node_
    edge_intra = edge_intra + edge_intra_
    y_anticipation = y_anticipation_

    y_object = y_object_
    y_object_anticipation = y_object_anticipation_
    edge_object = edge_object_
    node_object = node_object_
    edge_intra_object = edge_intra_object_
    edge_intra_object_human = edge_intra_object_human_

    return N, y, node, edge, edge_intra, y_object, node_object, edge_object, edge_intra_object, edge_intra_object_human, y_anticipation, y_object_anticipation