<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 加載和準備 PTB 數據集 首先導入模塊并加載數據如下:: ```py from datasetslib.ptb import PTBSimple ptb = PTBSimple() # downloads data, converts words to ids, converts files to a list of ids ptb.load_data() print('Train :',ptb.part['train'][0:5]) print('Test: ',ptb.part['test'][0:5]) print('Valid: ',ptb.part['valid'][0:5]) print('Vocabulary Length = ',ptb.vocab_len) ``` 每個數據集的前五個元素以及詞匯長度打印如下: ```py Train : [9970, 9971, 9972, 9974, 9975] Test: [102, 14, 24, 32, 752] Valid: [1132, 93, 358, 5, 329] Vocabulary Length = 10000 ``` 我們將上下文窗口設置為兩個單詞并獲得 CBOW 對: ```py ptb.skip_window=2 ptb.reset_index_in_epoch() # in CBOW input is the context word and output is the target word y_batch, x_batch = ptb.next_batch_cbow() print('The CBOW pairs : context,target') for i in range(5 * ptb.skip_window): print('(', [ptb.id2word[x_i] for x_i in x_batch[i]], ',', y_batch[i], ptb.id2word[y_batch[i]], ')') ``` 輸出是: ```py The CBOW pairs : context,target ( ['aer', 'banknote', 'calloway', 'centrust'] , 9972 berlitz ) ( ['banknote', 'berlitz', 'centrust', 'cluett'] , 9974 calloway ) ( ['berlitz', 'calloway', 'cluett', 'fromstein'] , 9975 centrust ) ( ['calloway', 'centrust', 'fromstein', 'gitano'] , 9976 cluett ) ( ['centrust', 'cluett', 'gitano', 'guterman'] , 9980 fromstein ) ( ['cluett', 'fromstein', 'guterman', 'hydro-quebec'] , 9981 gitano ) ( ['fromstein', 'gitano', 'hydro-quebec', 'ipo'] , 9982 guterman ) ( ['gitano', 'guterman', 'ipo', 'kia'] , 9983 hydro-quebec ) ( ['guterman', 'hydro-quebec', 'kia', 'memotec'] , 9984 ipo ) ( ['hydro-quebec', 'ipo', 'memotec', 'mlx'] , 9986 kia ) ``` 現在讓我們看看 skip-gram 對: ```py ptb.skip_window=2 ptb.reset_index_in_epoch() # in skip-gram input is the target word and output is the context word x_batch, y_batch = ptb.next_batch() print('The skip-gram pairs : target,context') for i in range(5 * ptb.skip_window): print('(',x_batch[i], ptb.id2word[x_batch[i]], ',', y_batch[i], ptb.id2word[y_batch[i]],')') ``` 輸出為: ```py The skip-gram pairs : target,context ( 9972 berlitz , 9970 aer ) ( 9972 berlitz , 9971 banknote ) ( 9972 berlitz , 9974 calloway ) ( 9972 berlitz , 9975 centrust ) ( 9974 calloway , 9971 banknote ) ( 9974 calloway , 9972 berlitz ) ( 9974 calloway , 9975 centrust ) ( 9974 calloway , 9976 cluett ) ( 9975 centrust , 9972 berlitz ) ( 9975 centrust , 9974 calloway ) ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看