Open FayeXXX opened 1 year ago
Hi @FayeXXX, @hzhwcmhf, I also encounter this error when running
cd styletransformer
python run.py --name STyelp0 --dataid ../data/yelp --clsrestore model/CLSyelp0_best.model
Does anyone have a fix ? (solved, I changed list to " ".join(list))
@thangld201 I am not sure where is the problem... Is the output correct after modifying this line?
@hzhwcmhf There are two parts that I had to change: +) Line 350-351 to:
show_str.append(f"sent{domain}:" + " ".join(result["sgen"][i]))
show_str.append(f"gen{domain}:" + " ".join(result["gen"][i]))
+) Line 397-403 to:
with open(f"{output_dir}/{self.now_batch}.neg2pos.txt", 'w') as f:
for sent in result0["gen"]:
f.write(' '.join(sent)+ "\n")
with open(f"{output_dir}/{self.now_batch}.pos2neg.txt", 'w') as f:
for sent in result1["gen"]:
f.write(' '.join(sent)+ "\n")
The reasons being result["gen"][i]
,result["sgen"][i]
and sent
are all list of words (e.g. ["I","have","seen","this","cake"] instead of "I have seen this cake"), so they need to be formatted as string before writing to files like this.
There is a bug in styletransformer/seq2seq.py line 350, which is : "{TypeError}can only concatenate str (not "list") to str" I think the result["gen"][i] should be the sentence instead of token list