seq2seq LSTM编码器解码器预测错误的输出

时间:2019-10-17 13:11:45

标签: python-3.x tensorflow keras

我正在尝试实施从序列到序列的培训以构建会话代理。我有以下表示形式的数据集,

*TEXT - User's utterance
-Text - System's utterance

因此,我尝试将用户的话语作为输入序列,将系统的话语作为目标序列来训练我的网络。代码段如下,

for lines in range(0,num_samples):
    line = next(dataset)
    if '*' in line:
        _,text = line.split('* ')
        input_text = text.splitlines()
        input_texts.append(input_text)
        for char in text:
            if char not in input_intent_sv:
                input_intent_sv.add(char)
    elif ' - ' in line:
        special, text = line.split(' - ',1)
        target_text = f"-{text}"
        target_texts.append(target_text)      

        for char in text:
            if char not in target_intent_sv:
                target_intent_sv.add(char)
for sublist in input_texts:
    for item in sublist:
        flatten_input_texts.append(item)
for sublist in target_texts:
    for item in sublist:
        flatten_target_texts.append(item)

在解码的同时,我以这种方式创建了目标序列,因此将开始和结束序列字符分别更改为“-”和“ \ n”。

模型经过训练,但可以预测出如下错误,

-
Input sentence: ['Restaurant-Inform{"Price": "cheap", "Area": "north"}']
Decoded sentence: Restaurant-Inform{"Phone": "01223 356666", "Name": "the nicin", "Addr": "1220 01223 356666", "Name": "the nicin", "Addr": "122   ilg street chity centre", "Name": "the nicing ose", "Area": "centre", "Name": "t
-
Input sentence: ['Restaurant-Request{"Food": "?", "Addr": "?"}']
Decoded sentence: Restaurant-Inform{"Phone": "01223 356666", "Name": "the nicin", "Addr": "1220 01223 356666", "Name": "the nicin", "Addr": "122   ilg street chity centre", "Name": "the nicing ose", "Area": "centre", "Name": "t
-
Input sentence: ['general-thank']
Decoded sentence: Restaurant-Inform{"Phone": "01223 356666", "Name": "the nicin", "Addr": "1220 01223 356666", "Name": "the nicin", "Addr": "122   ilg street chity centre", "Name": "the nicing ose", "Area": "centre", "Name": "t
-
Input sentence: ['general-greet']
Decoded sentence: Restaurant-Inform{"Phone": "01223 356666", "Name": "the nicin", "Addr": "1220 01223 356666", "Name": "the nicin", "Addr": "122   ilg street chity centre", "Name": "the nicing ose", "Area": "centre", "Name": "t
-
Input sentence: ['Restaurant-Inform{"Food": "portuguese"}']
Decoded sentence: Restaurant-Inform{"Phone": "01223 356666", "Name": "the nicin", "Addr": "1220 01223 356666", "Name": "the nicin", "Addr": "122   ilg street chity centre", "Name": "the nicing ose", "Area": "centre", "Name": "t
-

但是预期的输出是这样的

Input sentence: general-greet
decoded sentence: greet
Input sentence: Restaurant-Inform{"Name": "pizza hut city centre"}
Decoded sentence:general-reqmore
Decoded sentence:Restaurant-Inform{"Food": "italian", "Price": "cheap", "Area": "centre", "Addr": "regent street city centre", "Post": "cb21ab", "Phone": "01223323737"}
Input sentence: Restaurant-Inform{"Time": "19:45", "Day": "thursday", "People": "2"}
Decoded sentence:general-welcome
Decoded sentence:Booking-Book{"People": "2", "Day": "thursday", "Time": "19:45", "Ref": "f3k2pqzz"}
Input sentence: general-thank
Decoded sentence:general-welcome
Decoded sentence:general-reqmore
Input sequence: general-thank
Decoded sentence:general-bye
Decoded sentence:general-welcome

我试图以以下方式更改数据,但它也会预测相同的错误输出,

* general-greet
 - greet
* Restaurant-Inform{"Name": "pizza hut city centre"}
 - Restaurant-Inform{"Food": "italian", "Price": "cheap", "Area": "centre", "Addr": "regent street city centre", "Post": "cb21ab", "Phone": "01223323737"}
* Restaurant-Inform{"Time": "19:45", "Day": "thursday", "People": "2"}
 - Booking-Book{"People": "2", "Day": "thursday", "Time": "19:45", "Ref": "f3k2pqzz"}
* general-thank
 - general-welcome
* general-thank
 - general-bye

我可以获取解决此问题的帮助吗?

0 个答案:

没有答案