{"id":50464,"date":"2025-08-10T08:38:54","date_gmt":"2025-08-10T00:38:54","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/50464.html"},"modified":"2025-08-10T08:38:54","modified_gmt":"2025-08-10T00:38:54","slug":"%e8%81%8a%e5%a4%a9%e6%9c%ba%e5%99%a8%e4%ba%ba%ef%bc%9a%e5%9f%ba%e4%ba%8e-encoder-decoder-%e6%9e%b6%e6%9e%84%e7%9a%84%e7%94%9f%e6%88%90%e5%bc%8f%e8%81%8a%e5%a4%a9%e6%9c%ba%e5%99%a8%e4%ba%ba","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/50464.html","title":{"rendered":"\u804a\u5929\u673a\u5668\u4eba\uff1a\u57fa\u4e8e Encoder-Decoder \u67b6\u6784\u7684\u751f\u6210\u5f0f\u804a\u5929\u673a\u5668\u4eba"},"content":{"rendered":"<h3>\u9879\u76ee\u6982\u8ff0<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5927\u5bb6\u597d&#xff01;\u4f5c\u4e3a\u4e00\u540d\u548c\u5927\u5bb6\u4e00\u6837\u5728\u7f16\u7a0b\u8def\u4e0a\u6162\u6162\u6478\u7d22\u7684\u5f00\u53d1\u8005&#xff0c;\u6211\u6df1\u77e5\u4ece\u96f6\u5f00\u59cb\u642d\u5efa\u4e00\u4e2a\u804a\u5929\u673a\u5668\u4eba\u65f6\u7684\u8ff7\u832b\u4e0e\u6311\u6218\u3002\u4e0a\u9762\u8fd9\u4e9b\u4ee3\u7801&#xff0c;\u662f\u6211\u4e00\u70b9\u70b9\u8c03\u8bd5\u3001\u4fee\u6539\u3001\u5b8c\u5584\u51fa\u6765\u7684\u6210\u679c \u2014\u2014 \u5b83\u53ef\u80fd\u4e0d\u591f\u5b8c\u7f8e&#xff0c;\u4e5f\u6ca1\u6709\u7528\u5230\u6700\u524d\u6cbf\u7684\u6280\u672f&#xff0c;\u4f46\u6bcf\u4e00\u884c\u90fd\u51dd\u7ed3\u7740\u5b9e\u8df5\u4e2d\u7684\u601d\u8003\u3002\u4eca\u5929\u628a\u5b83\u5206\u4eab\u51fa\u6765&#xff0c;\u5c31\u662f\u5e0c\u671b\u80fd\u5e2e\u66f4\u591a\u65b0\u624b\u5c11\u8d70\u5f2f\u8def&#xff0c;\u5feb\u901f\u62e5\u6709\u4e00\u4e2a\u5c5e\u4e8e\u81ea\u5df1\u7684\u804a\u5929\u673a\u5668\u4eba\u3002\u672c\u6587\u6240\u9009\u7528\u6570\u636e\u96c6\u662fxiaohuangji50w_nofenci.conv&#xff0c;\u53ef\u524d\u5f80https:\/\/github.com\/candlewill\/Dialog_Corpus\u8fdb\u884c\u4e0b\u8f7d\u3002<\/p>\n<h3>\u6838\u5fc3\u529f\u80fd\u89e3\u6790<\/h3>\n<h4>1. \u6570\u636e\u5904\u7406\u6a21\u5757<\/h4>\n<p>\u6570\u636e\u5904\u7406\u662f\u804a\u5929\u673a\u5668\u4eba\u5b9e\u73b0\u7684\u57fa\u7840&#xff0c;\u4e0b\u9762\u5206\u522b\u7528\u4e24\u4e2a\u90e8\u5206\u4ee3\u7801\u8fdb\u884c\u6570\u636e\u5904\u7406&#xff1a;<\/p>\n<ul>\n<li>\u5bf9\u8bdd\u6570\u636e\u8bfb\u53d6&#xff1a;read_dialog_file\u51fd\u6570\u8d1f\u8d23\u4ece\u7279\u5b9a\u683c\u5f0f\u7684\u6587\u4ef6\u4e2d\u8bfb\u53d6\u5bf9\u8bdd\u6570\u636e&#xff0c;\u8bc6\u522b\u7528\u6237&#xff08;user&#xff09;\u548c\u673a\u5668&#xff08;machine&#xff09;\u7684\u5bf9\u8bdd\u8f6e\u6b21&#xff0c;\u5e76\u4ee5\u7ed3\u6784\u5316\u65b9\u5f0f\u5b58\u50a8<\/li>\n<\/ul>\n<p>def read_dialog_file(file_path):<br \/>\n    dialogs &#061; []<br \/>\n    current_dialog &#061; []<br \/>\n    with open(file_path, &#039;r&#039;, encoding&#061;&#039;utf-8&#039;) as file:<br \/>\n        for line in file:<br \/>\n            line &#061; line.strip()<br \/>\n            if not line:<br \/>\n                continue<br \/>\n            prefix &#061; line[0]<br \/>\n            content &#061; line[2:]<br \/>\n            if prefix &#061;&#061; &#039;E&#039;:  # \u5bf9\u8bdd\u7ed3\u675f\u6807\u8bb0<br \/>\n                if current_dialog:<br \/>\n                    dialogs.append(current_dialog)<br \/>\n                    current_dialog &#061; []<br \/>\n            elif prefix &#061;&#061; &#039;M&#039;:  # \u5bf9\u8bdd\u5185\u5bb9\u6807\u8bb0<br \/>\n                if not current_dialog:<br \/>\n                    current_dialog.append((&#039;user&#039;, content))<br \/>\n                else:<br \/>\n                    current_dialog.append((&#039;machine&#039;, content))<br \/>\n    if current_dialog:<br \/>\n        dialogs.append(current_dialog)<br \/>\n    return dialogs<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"314\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810003852-6897ea1c888ef.png\" width=\"2329\" \/><\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8bcd\u6c47\u8868\u6784\u5efa&#xff1a;build_vocab\u51fd\u6570\u4ece\u5bf9\u8bdd\u6570\u636e\u4e2d\u63d0\u53d6\u6240\u6709\u51fa\u73b0\u7684\u5b57\u7b26&#xff0c;\u6784\u5efa\u8bcd\u6c47\u8868\u5e76\u4e3a\u6bcf\u4e2a\u5b57\u7b26\u5206\u914d\u552f\u4e00\u7d22\u5f15&#xff0c;\u540c\u65f6\u52a0\u5165\u7279\u6b8a\u6807\u8bb0&lt;pad&gt;&#xff08;\u586b\u5145&#xff09;\u3001&lt;sos&gt;&#xff08;\u5e8f\u5217\u5f00\u59cb&#xff09;\u548c&lt;eos&gt;&#xff08;\u5e8f\u5217\u7ed3\u675f&#xff09;<\/p>\n<p>def read_dialog_file(file_path):<br \/>\n    dialogs &#061; []<br \/>\n    current_dialog &#061; []<\/p>\n<p>    with open(file_path, &#039;r&#039;, encoding&#061;&#039;utf-8&#039;) as file:<br \/>\n        for line in file:<br \/>\n            line &#061; line.strip()<br \/>\n            if not line:<br \/>\n                continue<\/p>\n<p>            # \u5206\u5272\u6bcf\u884c\u7684\u524d\u7f00\u548c\u5185\u5bb9<br \/>\n            prefix &#061; line[0]<br \/>\n            content &#061; line[2:]<\/p>\n<p>            if prefix &#061;&#061; &#039;E&#039;:<br \/>\n                # \u5982\u679c\u5f53\u524d\u5bf9\u8bdd\u4e0d\u4e3a\u7a7a&#xff0c;\u4fdd\u5b58\u5e76\u91cd\u7f6e<br \/>\n                if current_dialog:<br \/>\n                    dialogs.append(current_dialog)<br \/>\n                    current_dialog &#061; []<br \/>\n            elif prefix &#061;&#061; &#039;M&#039;:<br \/>\n                if not current_dialog:<br \/>\n                    current_dialog.append((&#039;user&#039;, content))<br \/>\n                else:<br \/>\n                    current_dialog.append((&#039;machine&#039;, content))<\/p>\n<p>    # \u4fdd\u5b58\u6700\u540e\u4e00\u4e2a\u5bf9\u8bdd<br \/>\n    if current_dialog:<br \/>\n        dialogs.append(current_dialog)<\/p>\n<p>    return dialogs<\/p>\n<p>def preprocess_dialogs(dialogs):<br \/>\n    preprocessed_dialogs &#061; []<br \/>\n    for dialog in dialogs:<br \/>\n        preprocessed_dialog &#061; []<br \/>\n        for turn in dialog:<br \/>\n            # \u53bb\u9664\u659c\u6760\u5e76\u5408\u5e76\u5206\u8bcd\u540e\u7684\u8bcd<br \/>\n            text &#061; turn[1].replace(&#039;\/&#039;, &#039;&#039;)<br \/>\n            preprocessed_dialog.append((turn[0], text))<br \/>\n        preprocessed_dialogs.append(preprocessed_dialog)<br \/>\n    return preprocessed_dialogs<\/p>\n<p>def build_vocab(dialogs):<br \/>\n    vocab &#061; set()<br \/>\n    for dialog in dialogs:<br \/>\n        for turn in dialog:<br \/>\n            for char in turn[1]:<br \/>\n                vocab.add(char)<br \/>\n    return sorted(vocab)<\/p>\n<p>def save_vocab(vocab, file_path):<br \/>\n    with open(file_path, &#039;w&#039;, encoding&#061;&#039;utf-8&#039;) as file:<br \/>\n        for word in vocab:<br \/>\n            file.write(word &#043; &#039;\\\\n&#039;)<\/p>\n<p># \u8bfb\u53d6\u6587\u4ef6<br \/>\nfile_path &#061; &#039;..\/data\/xiaohuangji50w_nofenci.conv&#039;  # \u66ff\u6362\u4e3a\u4f60\u7684\u6587\u4ef6\u8def\u5f84<br \/>\ndialogs &#061; read_dialog_file(file_path)<\/p>\n<p># \u9884\u5904\u7406\u5bf9\u8bdd<br \/>\npreprocessed_dialogs &#061; preprocess_dialogs(dialogs)<\/p>\n<p># \u6784\u5efa\u8bcd\u6c47\u8868<br \/>\nvocab &#061; build_vocab(preprocessed_dialogs)<\/p>\n<p># \u4fdd\u5b58\u8bcd\u6c47\u8868<br \/>\nvocab_file_path &#061; &#039;..\/data\/xhj_vocab.txt&#039;  # \u66ff\u6362\u4e3a\u4f60\u5e0c\u671b\u4fdd\u5b58\u7684\u8bcd\u6c47\u8868\u6587\u4ef6\u8def\u5f84<br \/>\nsave_vocab(vocab, vocab_file_path)<\/p>\n<p>print(f&#034;\u8bcd\u6c47\u8868\u5df2\u4fdd\u5b58\u5230 {vocab_file_path}&#034;) <\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u6587\u672c\u4e0e\u5411\u91cf\u8f6c\u6362&#xff1a;convert\u51fd\u6570\u5b9e\u73b0\u6587\u672c\u4e0e\u6574\u6570\u5411\u91cf\u4e4b\u95f4\u7684\u53cc\u5411\u8f6c\u6362&#xff0c;\u662f\u81ea\u7136\u8bed\u8a00\u4e0e\u6a21\u578b\u8f93\u5165\u8f93\u51fa\u4e4b\u95f4\u7684\u6865\u6881\u3002\u5728\u4e4b\u540e\u4ee3\u7801\u4e2d\u4f1a\u7528\u5230\u3002<\/p>\n<p># \u5b57\u7b26\u5411\u91cf\u7684\u8f6c\u6362<br \/>\ndef convert(char_list, mode, vocab):<br \/>\n    con &#061; []<br \/>\n    if mode &#061;&#061; &#034;word2vec&#034;:<br \/>\n        conver &#061; dict((x, y) for x, y in vocab.items())<br \/>\n        if isinstance(char_list, str):<br \/>\n            char_list &#061; list(char_list)<br \/>\n        con &#061; [vocab[&#034;&lt;sos&gt;&#034;]] &#043; [conver.get(char, vocab[&#034;&lt;pad&gt;&#034;]) for char in char_list] &#043; [vocab[&#034;&lt;eos&gt;&#034;]]<br \/>\n    elif mode &#061;&#061; &#034;vec2word&#034;:<br \/>\n        conver &#061; dict((y, x) for x, y in vocab.items())<br \/>\n        for char in char_list:<br \/>\n            con.append(conver[char])<br \/>\n    return con <\/p>\n<h4>2. \u6a21\u578b\u67b6\u6784<\/h4>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u5b9e\u73b0\u804a\u5929\u673a\u5668\u4eba\u7684\u6838\u5fc3\u6a21\u578b&#xff0c;\u91c7\u7528\u4e86\u5e26\u6ce8\u610f\u529b\u673a\u5236\u7684 Encoder-Decoder \u67b6\u6784&#xff1a;<\/p>\n<ul>\n<li>\u7f16\u7801\u5668&#xff08;Encoder&#xff09;&#xff1a; \u63a5\u6536\u8f93\u5165\u5e8f\u5217&#xff08;\u7528\u6237\u8bdd\u8bed&#xff09;&#xff0c;\u901a\u8fc7\u5d4c\u5165\u5c42\u5c06\u8bcd\u7d22\u5f15\u8f6c\u6362\u4e3a\u8bcd\u5411\u91cf&#xff0c;\u518d\u7ecf\u53cc\u5411 GRU \u5904\u7406&#xff0c;\u8f93\u51fa\u6240\u6709\u65f6\u95f4\u6b65\u7684\u9690\u85cf\u72b6\u6001\u548c\u6700\u7ec8\u7684\u4e0a\u4e0b\u6587\u5411\u91cf<\/li>\n<\/ul>\n<p>class Encoder(nn.Module):<br \/>\n    def __init__(self, input_dim, emb_dim, enc_hid_dim, dec_hid_dim, dropout):<br \/>\n        super().__init__()<br \/>\n        self.embedding &#061; nn.Embedding(input_dim, emb_dim)<br \/>\n        self.rnn &#061; nn.GRU(emb_dim, enc_hid_dim, bidirectional&#061;True, num_layers&#061;2)<br \/>\n        self.fc &#061; nn.Linear(enc_hid_dim * 2, dec_hid_dim)<br \/>\n        self.dropout &#061; nn.Dropout(dropout)<\/p>\n<p>    def forward(self, src):<br \/>\n        embedded &#061; self.dropout(self.embedding(src))<br \/>\n        outputs, hidden &#061; self.rnn(embedded)<br \/>\n        # \u878d\u5408\u53cc\u5411GRU\u7684\u9690\u85cf\u72b6\u6001<br \/>\n        hidden &#061; torch.tanh(self.fc(torch.cat((hidden[-2, :, :], hidden[-1, :, :]), dim&#061;1)))<br \/>\n        return outputs, hidden<\/p>\n<ul>\n<li>\u6ce8\u610f\u529b\u673a\u5236&#xff08;Attention&#xff09;&#xff1a; \u89e3\u51b3\u4f20\u7edf Encoder-Decoder \u67b6\u6784\u4e2d\u4e0a\u4e0b\u6587\u5411\u91cf\u96be\u4ee5\u5904\u7406\u957f\u5e8f\u5217\u7684\u95ee\u9898&#xff0c;\u4f7f\u89e3\u7801\u5668\u5728\u751f\u6210\u6bcf\u4e2a\u8bcd\u65f6\u80fd\u5173\u6ce8\u8f93\u5165\u5e8f\u5217\u7684\u4e0d\u540c\u90e8\u5206<\/li>\n<\/ul>\n<p>class Attention(nn.Module):<br \/>\n    def __init__(self, enc_hid_dim, dec_hid_dim):<br \/>\n        super().__init__()<br \/>\n        self.attn &#061; nn.Linear((enc_hid_dim * 2) &#043; dec_hid_dim, dec_hid_dim)<br \/>\n        self.v &#061; nn.Parameter(torch.rand(dec_hid_dim))<\/p>\n<p>    def forward(self, hidden, encoder_outputs):<br \/>\n        # \u8ba1\u7b97\u6ce8\u610f\u529b\u6743\u91cd\u5e76\u8fd4\u56de\u6ce8\u610f\u529b\u5206\u5e03<br \/>\n        batch_size &#061; encoder_outputs.shape[1]<br \/>\n        src_len &#061; encoder_outputs.shape[0]<br \/>\n        hidden &#061; hidden.unsqueeze(1).repeat(1, src_len, 1)<br \/>\n        encoder_outputs &#061; encoder_outputs.permute(1, 0, 2)<br \/>\n        energy &#061; torch.tanh(self.attn(torch.cat((hidden, encoder_outputs), dim&#061;2)))<br \/>\n        energy &#061; energy.permute(0, 2, 1)<br \/>\n        v &#061; self.v.repeat(batch_size, 1).unsqueeze(1)<br \/>\n        attention &#061; torch.bmm(v, energy).squeeze(1)<br \/>\n        return F.softmax(attention, dim&#061;1)<\/p>\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"700\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810003852-6897ea1cedc01.png\" width=\"1059\" \/><\/p>\n<ul>\n<li>\n<p>\u89e3\u7801\u5668&#xff08;Decoder&#xff09;&#xff1a; \u4ee5\u7f16\u7801\u5668\u8f93\u51fa\u548c\u4e0a\u4e00\u65f6\u95f4\u6b65\u7684\u8f93\u51fa\u4e3a\u8f93\u5165&#xff0c;\u901a\u8fc7 GRU \u548c\u6ce8\u610f\u529b\u673a\u5236\u751f\u6210\u5f53\u524d\u65f6\u95f4\u6b65\u7684\u8f93\u51fa<\/p>\n<\/li>\n<li>\n<p>Seq2Seq \u6a21\u578b&#xff1a; \u6574\u5408\u7f16\u7801\u5668\u548c\u89e3\u7801\u5668&#xff0c;\u5b9e\u73b0\u7aef\u5230\u7aef\u7684\u5e8f\u5217\u8f6c\u6362\u529f\u80fd&#xff0c;\u652f\u6301\u6559\u5e08\u5f3a\u5236&#xff08;teacher forcing&#xff09;\u673a\u5236\u52a0\u901f\u8bad\u7ec3<\/p>\n<\/li>\n<\/ul>\n<p>class Seq2Seq(nn.Module):<br \/>\n    def __init__(self, encoder, decoder, device&#061;&#034;CPU&#034;):<br \/>\n        super().__init__()<br \/>\n        self.encoder &#061; encoder<br \/>\n        self.decoder &#061; decoder<br \/>\n        self.device &#061; device<\/p>\n<p>    def forward(self, src, trg, teacher_forcing_ratio&#061;0.5,max_length&#061;30):<br \/>\n        batch_size &#061; src.shape[1]<br \/>\n        trg_len &#061; trg.shape[0]<br \/>\n        trg_vocab_size &#061; self.decoder.output_dim<br \/>\n        outputs &#061; torch.zeros(trg_len, batch_size, trg_vocab_size).to(self.device)<br \/>\n        encoder_outputs, hidden &#061; self.encoder(src)<br \/>\n        input &#061; trg[0, :]<br \/>\n        for t in range(1, trg_len):<br \/>\n            output, hidden &#061; self.decoder(input, hidden, encoder_outputs) # output:torch.Size([batch_size, vocab_size])<br \/>\n            outputs[t] &#061; output<br \/>\n            teacher_force &#061; random.random() &lt; teacher_forcing_ratio<br \/>\n            top1 &#061; output.argmax(1)<br \/>\n            input &#061; trg[t] if teacher_force else top1<br \/>\n            if all(top1.item() &#061;&#061; 2 for top1 in top1):<br \/>\n                break<br \/>\n        return outputs <\/p>\n<h4>3. \u6a21\u578b\u8bad\u7ec3<\/h4>\n<p>\u5b9e\u73b0\u6a21\u578b\u7684\u8bad\u7ec3\u6d41\u7a0b&#xff1a;<\/p>\n<\/p>\n<ul>\n<li>\u6570\u636e\u52a0\u8f7d&#xff1a;GetDATA\u51fd\u6570\u6309\u6279\u6b21\u52a0\u8f7d\u5e76\u9884\u5904\u7406\u6570\u636e&#xff0c;\u5c06\u6587\u672c\u8f6c\u6362\u4e3a\u6a21\u578b\u53ef\u63a5\u53d7\u7684\u5f20\u91cf\u5f62\u5f0f<\/li>\n<li>\u8bad\u7ec3\u5faa\u73af&#xff1a;train_model\u51fd\u6570\u5b9a\u4e49\u4e86\u5b8c\u6574\u7684\u8bad\u7ec3\u8fc7\u7a0b&#xff0c;\u5305\u62ec\u524d\u5411\u4f20\u64ad\u3001\u635f\u5931\u8ba1\u7b97\u3001\u53cd\u5411\u4f20\u64ad\u548c\u53c2\u6570\u66f4\u65b0<\/li>\n<li>\u4f18\u5316\u7b56\u7565&#xff1a;\u4f7f\u7528 Adam \u4f18\u5316\u5668\u548c\u5b66\u4e60\u7387\u8c03\u5ea6\u5668&#xff0c;\u91c7\u7528\u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570&#xff0c;\u901a\u8fc7\u4fdd\u5b58\u9a8c\u8bc1\u96c6\u8868\u73b0\u6700\u597d\u7684\u6a21\u578b\u6765\u9632\u6b62\u8fc7\u62df\u5408<\/li>\n<\/ul>\n<p>def train_model(model, batch_size, vocab, dialogs, optimizer, scheduler, criterion, device, epochs&#061;10, teacher_forcing_ratio&#061;0.5):<br \/>\n    best_loss &#061; float(&#039;inf&#039;)<br \/>\n    for epoch in range(epochs):<br \/>\n        model.train()<br \/>\n        total_train_loss &#061; 0<br \/>\n        for batch in tqdm(range(int(train_sample \/ batch_size))):<br \/>\n            src, trg &#061; GetDATA(batch_size, vocab, dialogs, count&#061;batch)<br \/>\n            src &#061; src.transpose(0, 1).to(device)<br \/>\n            trg &#061; trg.transpose(0, 1).to(device)<br \/>\n            optimizer.zero_grad()<br \/>\n            output &#061; model(src, trg, teacher_forcing_ratio)<br \/>\n            loss &#061; criterion(output[1:].reshape(-1, output.shape[-1]), trg[1:].reshape(-1))<br \/>\n            loss.backward()<br \/>\n            optimizer.step()<br \/>\n            total_train_loss &#043;&#061; loss.item()<br \/>\n        # \u4fdd\u5b58\u6700\u4f73\u6a21\u578b<br \/>\n        if avg_train_loss &lt; best_loss:<br \/>\n            best_loss &#061; avg_train_loss<br \/>\n            torch.save(model.state_dict(), &#039;best_model.pth&#039;)<\/p>\n<h4>4. \u6a21\u578b\u63a8\u7406<\/h4>\n<p>ED\u4ee3\u7801\u6d41\u7a0b.py\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528\u8bad\u7ec3\u597d\u7684\u6a21\u578b\u8fdb\u884c\u5bf9\u8bdd\u751f\u6210&#xff1a;<\/p>\n<\/p>\n<ul>\n<li>\u52a0\u8f7d\u8bad\u7ec3\u597d\u7684\u6a21\u578b\u53c2\u6570<\/li>\n<li>\u5c06\u7528\u6237\u8f93\u5165\u8f6c\u6362\u4e3a\u6a21\u578b\u53ef\u63a5\u53d7\u7684\u5411\u91cf\u5f62\u5f0f<\/li>\n<li>\u5229\u7528\u89e3\u7801\u5668\u9010\u6b65\u751f\u6210\u56de\u590d&#xff0c;\u76f4\u5230\u751f\u6210&lt;eos&gt;\u6807\u8bb0\u6216\u8fbe\u5230\u6700\u5927\u957f\u5ea6<\/li>\n<li>\u5c06\u751f\u6210\u7684\u5411\u91cf\u8f6c\u6362\u56de\u6587\u672c\u5f62\u5f0f&#xff0c;\u5f97\u5230\u6700\u7ec8\u56de\u590d<\/li>\n<\/ul>\n<p># \u6a21\u578b\u63a8\u7406\u8fc7\u7a0b<br \/>\nbatch_size &#061; src.shape[1]<br \/>\ntrg &#061; torch.zeros((1, batch_size), dtype&#061;torch.long).fill_(vocab[&#034;&lt;sos&gt;&#034;]).to(device)<br \/>\nsrc &#061; src.to(device)<\/p>\n<p>outputs &#061; []<br \/>\nmax_length &#061; 50  # \u6700\u5927\u751f\u6210\u957f\u5ea6<br \/>\nwith torch.no_grad():<br \/>\n    encoder_outputs, hidden &#061; model.encoder(src)<br \/>\n    for t in range(1, max_length):<br \/>\n        output, hidden &#061; model.decoder(trg[-1], hidden, encoder_outputs)<br \/>\n        top1 &#061; output.argmax(1)  # \u8d2a\u5a6a\u89e3\u7801<br \/>\n        outputs.append(top1)<br \/>\n        trg &#061; torch.cat((trg, top1.unsqueeze(0)), dim&#061;0)<br \/>\n        # \u5982\u679c\u6240\u6709\u5e8f\u5217\u90fd\u751f\u6210\u4e86&lt;eos&gt;\u6807\u8bb0&#xff0c;\u5219\u505c\u6b62\u751f\u6210<br \/>\n        if all(top1.item() &#061;&#061; vocab[&#034;&lt;eos&gt;&#034;] for top1 in top1):<br \/>\n            break<\/p>\n<h3>\u6700\u540e\u6548\u679c\u5c55\u793a&#xff1a;<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"253\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810003853-6897ea1d4d769.png\" width=\"210\" \/><\/p>\n<p>&#xff08;\u56e0\u4e3a\u6211\u81ea\u5df1\u4f7f\u7528\u7684\u7b14\u8bb0\u672c\u7535\u8111\u7528CPU\u8bad\u7ec3\u51fa\u6765\u7684&#xff0c;\u53ea\u4f7f\u7528\u4e86\u524d12800\u6761\u6570\u636e\u96c6&#xff0c;\u6240\u4ee5\u6548\u679c\u53ea\u80fd\u8bf4\u8fd8\u884c&#8230;&#8230;&#xff09;<\/p>\n<h3>\u529f\u80fd\u6269\u5c55\u4e0e\u4f18\u5316\u601d\u8def<\/h3>\n<p>\u4e0b\u9762\u63d0\u4f9b\u4e00\u4e9b\u53ef\u6269\u5c55\u7684\u529f\u80fd\u601d\u8def&#xff1a;<\/p>\n<li>\u5bf9\u8bdd\u5386\u53f2\u8bb0\u5fc6&#xff1a;\u901a\u8fc7GetDATA_with_history\u51fd\u6570\u53ef\u4ee5\u5c06\u591a\u8f6e\u5bf9\u8bdd\u5386\u53f2\u4f5c\u4e3a\u4e0a\u4e0b\u6587\u8f93\u5165&#xff0c;\u589e\u5f3a\u6a21\u578b\u7684\u4e0a\u4e0b\u6587\u7406\u89e3\u80fd\u529b<\/li>\n<li>\u591a\u6837\u5316\u56de\u590d\u751f\u6210&#xff1a;\u901a\u8fc7\u6e29\u5ea6\u53c2\u6570&#xff08;Temperature&#xff09;\u63a7\u5236\u8f93\u51fa\u6982\u7387\u5206\u5e03\u7684\u968f\u673a\u6027&#xff0c;\u7ed3\u5408\u968f\u673a\u91c7\u6837\u66ff\u4ee3\u8d2a\u5a6a\u9009\u62e9&#xff0c;\u751f\u6210\u66f4\u591a\u6837\u5316\u7684\u56de\u590d<\/li>\n<li>\u56de\u590d\u8d28\u91cf\u63a7\u5236&#xff1a;\u901a\u8fc7\u53bb\u91cd\u3001\u8fc7\u6ee4\u65e0\u6548\u56de\u590d\u7b49\u7b56\u7565\u63d0\u9ad8\u751f\u6210\u56de\u590d\u7684\u8d28\u91cf<\/li>\n<h3>\u5199\u5728\u6700\u540e<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u6280\u672f\u7684\u8fdb\u6b65\u4ece\u6765\u4e0d\u662f\u4e00\u8e74\u800c\u5c31\u7684&#xff0c;\u6211\u73b0\u5728\u56de\u5934\u770b\u6700\u521d\u7684\u7248\u672c&#xff0c;\u4e5f\u4f1a\u89c9\u5f97\u7b28\u62d9\u3002\u4f46\u6b63\u662f\u8fd9\u4e9b\u4e0d\u5b8c\u7f8e\u7684\u5c1d\u8bd5&#xff0c;\u8ba9\u6211\u6162\u6162\u7406\u89e3\u4e86\u804a\u5929\u673a\u5668\u4eba\u7684\u5de5\u4f5c\u539f\u7406\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5982\u679c\u4f60\u5728\u8fd0\u884c\u4ee3\u7801\u65f6\u9047\u5230\u62a5\u9519&#xff0c;\u522b\u7740\u6025 \u2014\u2014 \u8fd9\u592a\u6b63\u5e38\u4e86&#xff01;\u770b\u770b\u9519\u8bef\u63d0\u793a\u6307\u5411\u54ea\u4e00\u884c&#xff0c;\u60f3\u60f3\u8fd9\u4e00\u6b65\u662f\u5728\u505a\u4ec0\u4e48&#xff08;\u6bd4\u5982\u6570\u636e\u683c\u5f0f\u4e0d\u5bf9&#xff1f;\u6a21\u578b\u53c2\u6570\u4e0d\u5339\u914d&#xff1f;&#xff09;&#xff0c;\u8bd5\u7740\u6539\u6539\u770b\u3002\u89e3\u51b3\u95ee\u9898\u7684\u8fc7\u7a0b&#xff0c;\u5c31\u662f\u8fdb\u6b65\u6700\u5feb\u7684\u65f6\u5019\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5e0c\u671b\u8fd9\u4efd\u4ee3\u7801\u80fd\u6210\u4e3a\u4f60\u63a2\u7d22\u81ea\u7136\u8bed\u8a00\u5904\u7406\u7684\u8d77\u70b9\u3002\u5982\u679c\u5b83\u80fd\u5e2e\u4f60\u5c11\u8d70\u4e00\u4e9b\u5f2f\u8def&#xff0c;\u6216\u8005\u8ba9\u4f60\u611f\u53d7\u5230\u642d\u5efa\u673a\u5668\u4eba\u7684\u4e50\u8da3&#xff0c;\u90a3\u6211\u5c31\u5f88\u5f00\u5fc3\u4e86\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u6700\u540e\u60f3\u8bf4&#xff1a;\u7f16\u7a0b\u7684\u4e50\u8da3\u4e0d\u5728\u4e8e\u5199\u51fa\u5b8c\u7f8e\u7684\u4ee3\u7801&#xff0c;\u800c\u5728\u4e8e\u4eb2\u624b\u521b\u9020\u51fa\u80fd\u5de5\u4f5c\u7684\u4e1c\u897f\u3002\u5f00\u59cb\u52a8\u624b\u5427&#xff0c;\u4f60\u7684\u7b2c\u4e00\u4e2a\u804a\u5929\u673a\u5668\u4eba&#xff0c;\u53ef\u80fd\u6bd4\u4f60\u60f3\u8c61\u7684\u79bb\u4f60\u66f4\u8fd1&#xff01;<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb807\u6b21\uff0c\u70b9\u8d5e21\u6b21\uff0c\u6536\u85cf15\u6b21\u3002\u5927\u5bb6\u597d\uff01\u4f5c\u4e3a\u4e00\u540d\u548c\u5927\u5bb6\u4e00\u6837\u5728\u7f16\u7a0b\u8def\u4e0a\u6162\u6162\u6478\u7d22\u7684\u5f00\u53d1\u8005\uff0c\u6211\u6df1\u77e5\u4ece\u96f6\u5f00\u59cb\u642d\u5efa\u4e00\u4e2a\u804a\u5929\u673a\u5668\u4eba\u65f6\u7684\u8ff7\u832b\u4e0e\u6311\u6218\u3002\u4e0a\u9762\u8fd9\u4e9b\u4ee3\u7801\uff0c\u662f\u6211\u4e00\u70b9\u70b9\u8c03\u8bd5\u3001\u4fee\u6539\u3001\u5b8c\u5584\u51fa\u6765\u7684\u6210\u679c \u2014\u2014 \u5b83\u53ef\u80fd\u4e0d\u591f\u5b8c\u7f8e\uff0c\u4e5f\u6ca1\u6709\u7528\u5230\u6700\u524d\u6cbf\u7684\u6280\u672f\uff0c\u4f46\u6bcf\u4e00\u884c\u90fd\u51dd\u7ed3\u7740\u5b9e\u8df5\u4e2d\u7684\u601d\u8003\u3002\u4eca\u5929\u628a\u5b83\u5206\u4eab\u51fa\u6765\uff0c\u5c31\u662f\u5e0c\u671b\u80fd\u5e2e\u66f4\u591a\u65b0\u624b\u5c11\u8d70\u5f2f\u8def\uff0c\u5feb\u901f\u62e5\u6709\u4e00\u4e2a\u5c5e\u4e8e\u81ea\u5df1\u7684\u804a\u5929\u673a\u5668\u4eba\u3002\u672c\u6587\u6240\u9009\u7528\u6570\u636e\u96c6\u662fxiaohuangji50w_nofenci.conv\uff0c\u53ef\u524d\u5f80\u8fdb\u884c\u4e0b\u8f7d\u3002<\/p>\n","protected":false},"author":2,"featured_media":50461,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[384],"topic":[],"class_list":["post-50464","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-384"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u804a\u5929\u673a\u5668\u4eba\uff1a\u57fa\u4e8e Encoder-Decoder \u67b6\u6784\u7684\u751f\u6210\u5f0f\u804a\u5929\u673a\u5668\u4eba - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/50464.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u804a\u5929\u673a\u5668\u4eba\uff1a\u57fa\u4e8e Encoder-Decoder \u67b6\u6784\u7684\u751f\u6210\u5f0f\u804a\u5929\u673a\u5668\u4eba - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb807\u6b21\uff0c\u70b9\u8d5e21\u6b21\uff0c\u6536\u85cf15\u6b21\u3002\u5927\u5bb6\u597d\uff01\u4f5c\u4e3a\u4e00\u540d\u548c\u5927\u5bb6\u4e00\u6837\u5728\u7f16\u7a0b\u8def\u4e0a\u6162\u6162\u6478\u7d22\u7684\u5f00\u53d1\u8005\uff0c\u6211\u6df1\u77e5\u4ece\u96f6\u5f00\u59cb\u642d\u5efa\u4e00\u4e2a\u804a\u5929\u673a\u5668\u4eba\u65f6\u7684\u8ff7\u832b\u4e0e\u6311\u6218\u3002\u4e0a\u9762\u8fd9\u4e9b\u4ee3\u7801\uff0c\u662f\u6211\u4e00\u70b9\u70b9\u8c03\u8bd5\u3001\u4fee\u6539\u3001\u5b8c\u5584\u51fa\u6765\u7684\u6210\u679c \u2014\u2014 \u5b83\u53ef\u80fd\u4e0d\u591f\u5b8c\u7f8e\uff0c\u4e5f\u6ca1\u6709\u7528\u5230\u6700\u524d\u6cbf\u7684\u6280\u672f\uff0c\u4f46\u6bcf\u4e00\u884c\u90fd\u51dd\u7ed3\u7740\u5b9e\u8df5\u4e2d\u7684\u601d\u8003\u3002\u4eca\u5929\u628a\u5b83\u5206\u4eab\u51fa\u6765\uff0c\u5c31\u662f\u5e0c\u671b\u80fd\u5e2e\u66f4\u591a\u65b0\u624b\u5c11\u8d70\u5f2f\u8def\uff0c\u5feb\u901f\u62e5\u6709\u4e00\u4e2a\u5c5e\u4e8e\u81ea\u5df1\u7684\u804a\u5929\u673a\u5668\u4eba\u3002\u672c\u6587\u6240\u9009\u7528\u6570\u636e\u96c6\u662fxiaohuangji50w_nofenci.conv\uff0c\u53ef\u524d\u5f80\u8fdb\u884c\u4e0b\u8f7d\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/50464.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-10T00:38:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810003852-6897ea1c888ef.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/50464.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/50464.html\",\"name\":\"\u804a\u5929\u673a\u5668\u4eba\uff1a\u57fa\u4e8e Encoder-Decoder \u67b6\u6784\u7684\u751f\u6210\u5f0f\u804a\u5929\u673a\u5668\u4eba - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-10T00:38:54+00:00\",\"dateModified\":\"2025-08-10T00:38:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/50464.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/50464.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/50464.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u804a\u5929\u673a\u5668\u4eba\uff1a\u57fa\u4e8e Encoder-Decoder \u67b6\u6784\u7684\u751f\u6210\u5f0f\u804a\u5929\u673a\u5668\u4eba\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u804a\u5929\u673a\u5668\u4eba\uff1a\u57fa\u4e8e Encoder-Decoder \u67b6\u6784\u7684\u751f\u6210\u5f0f\u804a\u5929\u673a\u5668\u4eba - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/50464.html","og_locale":"zh_CN","og_type":"article","og_title":"\u804a\u5929\u673a\u5668\u4eba\uff1a\u57fa\u4e8e Encoder-Decoder \u67b6\u6784\u7684\u751f\u6210\u5f0f\u804a\u5929\u673a\u5668\u4eba - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb807\u6b21\uff0c\u70b9\u8d5e21\u6b21\uff0c\u6536\u85cf15\u6b21\u3002\u5927\u5bb6\u597d\uff01\u4f5c\u4e3a\u4e00\u540d\u548c\u5927\u5bb6\u4e00\u6837\u5728\u7f16\u7a0b\u8def\u4e0a\u6162\u6162\u6478\u7d22\u7684\u5f00\u53d1\u8005\uff0c\u6211\u6df1\u77e5\u4ece\u96f6\u5f00\u59cb\u642d\u5efa\u4e00\u4e2a\u804a\u5929\u673a\u5668\u4eba\u65f6\u7684\u8ff7\u832b\u4e0e\u6311\u6218\u3002\u4e0a\u9762\u8fd9\u4e9b\u4ee3\u7801\uff0c\u662f\u6211\u4e00\u70b9\u70b9\u8c03\u8bd5\u3001\u4fee\u6539\u3001\u5b8c\u5584\u51fa\u6765\u7684\u6210\u679c \u2014\u2014 \u5b83\u53ef\u80fd\u4e0d\u591f\u5b8c\u7f8e\uff0c\u4e5f\u6ca1\u6709\u7528\u5230\u6700\u524d\u6cbf\u7684\u6280\u672f\uff0c\u4f46\u6bcf\u4e00\u884c\u90fd\u51dd\u7ed3\u7740\u5b9e\u8df5\u4e2d\u7684\u601d\u8003\u3002\u4eca\u5929\u628a\u5b83\u5206\u4eab\u51fa\u6765\uff0c\u5c31\u662f\u5e0c\u671b\u80fd\u5e2e\u66f4\u591a\u65b0\u624b\u5c11\u8d70\u5f2f\u8def\uff0c\u5feb\u901f\u62e5\u6709\u4e00\u4e2a\u5c5e\u4e8e\u81ea\u5df1\u7684\u804a\u5929\u673a\u5668\u4eba\u3002\u672c\u6587\u6240\u9009\u7528\u6570\u636e\u96c6\u662fxiaohuangji50w_nofenci.conv\uff0c\u53ef\u524d\u5f80\u8fdb\u884c\u4e0b\u8f7d\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/50464.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-10T00:38:54+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810003852-6897ea1c888ef.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/50464.html","url":"https:\/\/www.wsisp.com\/helps\/50464.html","name":"\u804a\u5929\u673a\u5668\u4eba\uff1a\u57fa\u4e8e Encoder-Decoder \u67b6\u6784\u7684\u751f\u6210\u5f0f\u804a\u5929\u673a\u5668\u4eba - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-10T00:38:54+00:00","dateModified":"2025-08-10T00:38:54+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/50464.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/50464.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/50464.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u804a\u5929\u673a\u5668\u4eba\uff1a\u57fa\u4e8e Encoder-Decoder \u67b6\u6784\u7684\u751f\u6210\u5f0f\u804a\u5929\u673a\u5668\u4eba"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/50464","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=50464"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/50464\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/50461"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=50464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=50464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=50464"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=50464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}