在 Latex 中插入一个大词嵌入向量

在 Latex 中插入一个大词嵌入向量

我正在使用 gensim 来获取标记“cow”的词嵌入向量。

from gensim.models.word2vec import Word2Vec
import gensim.downloader as api

corpus = api.load('text8')
model = Word2Vec(corpus)


print(model['cow'])

打印结果如下:

[-1.2547063   1.1942102   0.17151938  0.5987412  -0.49579155 -1.2060282
 -0.1634423  -0.16817395 -0.01932111  0.89791673 -0.6204074  -0.6942175
  0.5526197   0.7512524   1.0385613   0.63329834 -0.36372072  0.13436835
  1.5774019   0.6611982   0.03756079 -0.55493605  0.01850715  0.7029431
 -0.31836367 -1.4836626   0.61409605 -0.34402883  0.01940718  0.04913517
  0.22122279 -0.9317553  -0.05954444  0.47895068  0.5322139   0.5262284
 -0.18197684 -0.5717366  -0.9348576   1.8352545  -1.163346    0.06449085
 -0.12519367 -0.17958975 -0.02057225 -0.71246105 -0.9612495   0.0209828
  2.0363474   0.34898216 -0.08456944  0.24616042 -0.47641563 -0.05189624
 -0.51321644  1.1948055  -0.18322913  1.8176553  -0.7698356  -0.05641554
 -0.97348034 -0.11560358 -0.43876162  1.1535367   0.46992347  0.3269939
 -0.114779    0.13100009 -0.30459177 -1.0905075  -0.5375251   0.05887824
  0.58892184 -1.3707904   1.0063274  -0.5675427   0.62443995 -1.1964613
  0.80283827 -0.20880152  0.4350883  -0.5720035   0.29524413 -0.48592576
  0.08546621  0.02609405 -0.0226634   0.03425831 -1.0997567   0.8341457
 -0.7338353   0.92001337  0.23941106 -0.8202021  -0.27842462  0.6777595
  0.6380239  -0.67553854 -0.17544152 -0.8047661 ]

现在我想将这个非常大的向量插入到我的论文中。我尝试了以下方法:

\usepackage{amsmath}
\begin{align}
    y &= \begin{bmatrix}
           1 \\
           2 \\
           3 \\
           4 \\
           1 \\
           2 \\
           3 \\
           4 \\
           1 \\
           2 \\
           3 \\
           4 \\
           1 \\
           2 \\
           3 \\
           4 \\
           1 \\
           2 \\
           3 \\
           4 \\
         \end{bmatrix}
\end{align}

我会得到这个结果

我的向量

这很不方便,因为这个向量会跨越几页:D 现在我想知道是否有可能在乳胶中实现与使用 python 打印相同的结果?

答案1

您在评论中澄清了这一点,但由于我已经这样做了,因此其中之一:

在此处输入图片描述

\documentclass{article}

\usepackage{amsmath}
\advance\textheight4cm
\begin{document}

\begin{verbatim}
[-1.2547063   1.1942102   0.17151938  0.5987412  -0.49579155 -1.2060282
 -0.1634423  -0.16817395 -0.01932111  0.89791673 -0.6204074  -0.6942175
  0.5526197   0.7512524   1.0385613   0.63329834 -0.36372072  0.13436835
  1.5774019   0.6611982   0.03756079 -0.55493605  0.01850715  0.7029431
 -0.31836367 -1.4836626   0.61409605 -0.34402883  0.01940718  0.04913517
  0.22122279 -0.9317553  -0.05954444  0.47895068  0.5322139   0.5262284
 -0.18197684 -0.5717366  -0.9348576   1.8352545  -1.163346    0.06449085
 -0.12519367 -0.17958975 -0.02057225 -0.71246105 -0.9612495   0.0209828
  2.0363474   0.34898216 -0.08456944  0.24616042 -0.47641563 -0.05189624
 -0.51321644  1.1948055  -0.18322913  1.8176553  -0.7698356  -0.05641554
 -0.97348034 -0.11560358 -0.43876162  1.1535367   0.46992347  0.3269939
 -0.114779    0.13100009 -0.30459177 -1.0905075  -0.5375251   0.05887824
  0.58892184 -1.3707904   1.0063274  -0.5675427   0.62443995 -1.1964613
  0.80283827 -0.20880152  0.4350883  -0.5720035   0.29524413 -0.48592576
  0.08546621  0.02609405 -0.0226634   0.03425831 -1.0997567   0.8341457
 -0.7338353   0.92001337  0.23941106 -0.8202021  -0.27842462  0.6777595
  0.6380239  -0.67553854 -0.17544152 -0.8047661 ]
\end{verbatim}


$\def\,{\linebreak[0]\ }
[-1.2547063\, 1.1942102\, 0.17151938\, 0.5987412\, -0.49579155\, -1.2060282\,
 -0.1634423\, -0.16817395\, -0.01932111\, 0.89791673\, -0.6204074\, -0.6942175\,
 0.5526197\, 0.7512524\, 1.0385613\, 0.63329834\, -0.36372072\, 0.13436835\,
 1.5774019\, 0.6611982\, 0.03756079\, -0.55493605\, 0.01850715\, 0.7029431\,
 -0.31836367\, -1.4836626\, 0.61409605\, -0.34402883\, 0.01940718\, 0.04913517\,
 0.22122279\, -0.9317553\, -0.05954444\, 0.47895068\, 0.5322139\, 0.5262284\,
 -0.18197684\, -0.5717366\, -0.9348576\, 1.8352545\, -1.163346\, 0.06449085\,
 -0.12519367\, -0.17958975\, -0.02057225\, -0.71246105\, -0.9612495\, 0.0209828\,
 2.0363474\, 0.34898216\, -0.08456944\, 0.24616042\, -0.47641563\, -0.05189624\,
 -0.51321644\, 1.1948055\, -0.18322913\, 1.8176553\, -0.7698356\, -0.05641554\,
 -0.97348034\, -0.11560358\, -0.43876162\, 1.1535367\, 0.46992347\, 0.3269939\,
 -0.114779\, 0.13100009\, -0.30459177\, -1.0905075\, -0.5375251\, 0.05887824\,
 0.58892184\, -1.3707904\, 1.0063274\, -0.5675427\, 0.62443995\, -1.1964613\,
 0.80283827\, -0.20880152\, 0.4350883\, -0.5720035\, 0.29524413\, -0.48592576\,
 0.08546621\, 0.02609405\, -0.0226634\, 0.03425831\, -1.0997567\, 0.8341457\,
 -0.7338353\, 0.92001337\, 0.23941106\, -0.8202021\, -0.27842462\, 0.6777595\,
 0.6380239\, -0.67553854\, -0.17544152\, -0.8047661 ]$


\[
\begin{bmatrix}
 -1.2547063 & 1.1942102 & 0.17151938 & 0.5987412 & -0.49579155 & -1.2060282 \\
 -0.1634423 & -0.16817395 & -0.01932111 & 0.89791673 & -0.6204074 & -0.6942175 \\
  0.5526197 & 0.7512524 & 1.0385613 & 0.63329834 & -0.36372072 & 0.13436835 \\
  1.5774019 & 0.6611982 & 0.03756079 & -0.55493605 & 0.01850715 & 0.7029431  \\
 -0.31836367 & -1.4836626 & 0.61409605 & -0.34402883 & 0.01940718 & 0.04913517 \\
  0.22122279 & -0.9317553 & -0.05954444 & 0.47895068 & 0.5322139 & 0.5262284 \\
 -0.18197684 & -0.5717366 & -0.9348576 & 1.8352545 & -1.163346 & 0.06449085 \\
 -0.12519367 & -0.17958975 & -0.02057225 & -0.71246105 & -0.9612495 & 0.0209828 \\
  2.0363474 & 0.34898216 & -0.08456944 & 0.24616042 & -0.47641563 & -0.05189624 \\
 -0.51321644 & 1.1948055 & -0.18322913 & 1.8176553 & -0.7698356 & -0.05641554 \\
 -0.97348034 & -0.11560358 & -0.43876162 & 1.1535367 & 0.46992347 & 0.3269939 \\
 -0.114779 & 0.13100009 & -0.30459177 & -1.0905075 & -0.5375251 & 0.05887824 \\
  0.58892184 & -1.3707904 & 1.0063274 & -0.5675427 & 0.62443995 & -1.1964613 \\
  0.80283827 & -0.20880152 & 0.4350883 & -0.5720035 & 0.29524413 & -0.48592576 \\
  0.08546621 & 0.02609405 & -0.0226634 & 0.03425831 & -1.0997567 & 0.8341457 \\
 -0.7338353 & 0.92001337 & 0.23941106 & -0.8202021 & -0.27842462 & 0.6777595 \\
  0.6380239 & -0.67553854 & -0.17544152 & -0.8047661
\end{bmatrix}
\]
\end{document}

相关内容