malllabiisc / RESIDE

EMNLP 2018: RESIDE: Improving Distantly-Supervised Neural Relation Extraction using Side Information

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem about running pcnnatt

yangluojun opened this issue · comments

Traceback (most recent call last):
File "/home/luoyang/reside/pcnnatt.py", line 347, in
model.fit(sess)
File "/home/luoyang/reside/base.py", line 479, in fit
train_loss, train_acc = self.run_epoch(sess, self.data['train'], epoch)
File "/home/luoyang/reside/base.py", line 369, in run_epoch
for step, batch in enumerate(self.getBatches(data, shuffle)):
File "/home/luoyang/reside/pcnnatt.py", line 54, in getBatches
batch['PartPos'] += get_sent_part(bag['Pos1'], bag['Pos2'], bag['X'])
File "/home/luoyang/reside/pcnnatt.py", line 38, in get_sent_part
if pos1 == pos2 or pos1 <= 0 or pos2 >= len(sent) - 1:
TypeError: '<=' not supported between instances of 'list' and 'int'

The same error occured when running pcnnatt and cnnatt.

Please look at this response:
#9 (comment)

def get_sent_part(sub_pos, obj_pos, sents):

		assert len(sub_pos) == len(obj_pos)
		part_pos = []
		for i in range(len(sub_pos)):
			sent = sents[i]
			pos1, pos2 = sub_pos[i], obj_pos[i]
			pos1, pos2 = min(pos1, pos2), max(pos1, pos2)
			**if pos1 == pos2 or len(pos1) <= 0 or len(pos2) >= len(sent)-1:**
				pos1 = np.ceil(len(sent) / 4)
				pos2 = pos1 + len(sent) // 2

			part_pos.append([pos1, pos2])

		return part_pos

I hope this can help you!