Numpy形状不包括子阵列

时间:2017-04-01 10:59:51

标签: python arrays numpy

我使用的库(keras)依赖于具有numpy数组的特定形状。我从未遇到过以下问题:numpy是不是提出了正确的形状?

这是我输出我的ndarray时输出的内容

array([ array([[-0.038548  ,  0.54251999, -0.21843   , ..., -0.38580999,
        -0.029534  ,  0.14425001],
       [-0.084961  ,  0.50199997,  0.0023823 , ..., -0.037066  ,
         0.10436   ,  0.17904   ],
       [ 0.27204001, -0.06203   , -0.1884    , ..., -0.088243  ,
         0.30318001,  0.087747  ],
       ..., 
       [ 0.089187  ,  0.25792   ,  0.26282001, ..., -0.23406   ,
        -0.086024  , -0.50603998],
       [-0.89548999,  0.38773   ,  0.64984   , ..., -0.24102999,
        -0.29991001,  0.2174    ],
       [-0.086864  ,  0.19160999,  0.10915   , ..., -0.47512001,
         0.047597  , -0.12785   ]], dtype=float32),
       array([[-0.038548  ,  0.54251999, -0.21843   , ..., -0.38580999,
        -0.029534  ,  0.14425001],
       [-0.084961  ,  0.50199997,  0.0023823 , ..., -0.037066  ,
         0.10436   ,  0.17904   ],
       [ 0.27204001, -0.06203   , -0.1884    , ..., -0.088243  ,
         0.30318001,  0.087747  ],
       ..., 
       [-0.27142   ,  0.047374  , -0.17278001, ...,  0.25861999,
         0.06769   ,  0.10761   ],
       [-0.33340001,  0.45183   ,  0.40684   , ...,  0.025225  ,
        -0.10559   , -0.058053  ],
       [-0.086864  ,  0.19160999,  0.10915   , ..., -0.47512001,
         0.047597  , -0.12785   ]], dtype=float32),
       array([[-0.23205   ,  0.47468001, -0.38264   , ..., -0.072927  ,
        -0.32218999, -0.065715  ],
       [-0.23857   ,  0.35457   , -0.30219001, ..., -0.023289  ,
        -0.29661   , -0.11824   ],
       [ 0.18732999,  0.40595001, -0.51174003, ...,  0.197     ,
        -0.48326999,  0.089523  ],
       ..., 
       [ 0.043798  ,  0.024779  , -0.20937   , ...,  0.010196  ,
         0.37641999, -0.01946   ],
       [ 0.37004   ,  0.089479  ,  0.53771001, ..., -0.17144001,
        -0.41093001,  0.97061002],
       [-0.086864  ,  0.19160999,  0.10915   , ..., -0.47512001,
         0.047597  , -0.12785   ]], dtype=float32),
       ...,
       array([[ -3.85480002e-02,   5.42519987e-01,  -2.18429998e-01,
         -1.88549995e-01,   7.29999989e-02,   1.31799996e-01,
         -1.04020000e-01,   1.72309995e-01,  -5.15870005e-02,
          2.86459994e+00,  -2.51309991e-01,  -1.91459998e-01,
          7.99869969e-02,   7.28920028e-02,  -1.32090002e-01,
         -2.29709998e-01,  -1.72680005e-01,   8.35070014e-01,
         -3.84869993e-01,  -3.24919999e-01,   4.66800004e-01,
         -1.56780005e-01,   1.07069999e-01,  -1.24789998e-01,
         -1.60300002e-01,  -5.21539990e-03,   1.51660005e-02,
          1.65079996e-01,   9.80250016e-02,  -9.18980017e-02,
          2.45520001e-04,   4.42539990e-01,   1.60459995e-01,
          1.22149996e-01,   1.25939995e-01,   3.19990009e-01,
          2.20449999e-01,   1.68699995e-01,  -3.89270008e-01,
         -1.73470005e-01,  -1.31579995e-01,   7.98169971e-02,
         -5.80530018e-02,  -7.22350031e-02,   2.80330002e-01,
          6.10799994e-03,  -3.92890006e-01,   6.17439975e-04,
         -3.33629996e-02,   7.58850016e-03,  -9.36639979e-02,
          1.89319998e-01,  -2.25419998e-01,  -1.80910006e-02,
          2.95459986e-01,  -1.51629999e-01,  -1.55939996e-01,
         -2.19390005e-01,   8.83169994e-02,  -6.54719993e-02,
         -6.29500002e-02,  -1.99890003e-01,  -4.94540017e-03,
          2.95740008e-01,   2.73330003e-01,  -3.62129986e-01,
         -4.05099988e-02,   2.20449999e-01,   8.47209990e-02,
          6.27639983e-03,   1.69139996e-01,  -2.00430006e-01,
          5.16470015e-01,  -1.19050004e-01,   7.86669999e-02,
          2.68339992e-01,   6.69509992e-02,  -2.51179993e-01,
         -2.41449997e-01,   4.81339991e-01,   1.54479995e-01,
          1.15379997e-01,  -9.82709974e-02,  -6.84430003e-02,
          1.66710004e-01,  -4.16940004e-01,  -2.25419998e-01,
         -8.74610007e-01,   3.08230013e-01,   8.99629965e-02,
         -3.68919998e-01,  -1.73769996e-01,  -4.17360008e-01,
          2.62569994e-01,   3.59600008e-01,   1.33239999e-01,
          1.28410002e-02,  -3.85809988e-01,  -2.95340009e-02,
          1.44250005e-01],
       [ -8.49609971e-02,   5.01999974e-01,   2.38230010e-03,
         -1.67549998e-01,   3.07209998e-01,  -2.37619996e-01,
          1.60689995e-01,  -3.67859989e-01,  -5.83470017e-02,
          2.49900007e+00,  -2.36469996e-03,   1.07319998e-02,
         -3.04219991e-01,   8.45789984e-02,  -4.02989984e-02,
         -4.15619999e-01,  -2.44939998e-02,   1.46910000e+00,
         -5.29320017e-02,  -7.44130015e-02,  -3.92439991e-01,
         -3.25349987e-01,  -2.23330006e-01,   5.68229984e-03,
          3.56750011e-01,   1.94450006e-01,   5.67619987e-02,
         -4.55019996e-02,  -2.81049997e-01,  -5.88960014e-02,
         -9.86260027e-02,   9.21770036e-02,   3.31719995e-01,
         -3.99670005e-02,  -1.17660001e-01,   4.83729988e-02,
         -6.22409992e-02,  -1.04130000e-01,   9.92630026e-04,
         -4.89250004e-01,   3.47860008e-01,   3.27239990e-01,
          1.38820007e-01,  -1.99169993e-01,   1.29950002e-01,
          6.05489984e-02,  -2.37140000e-01,  -5.12950003e-01,
         -3.73959988e-01,   1.29020005e-01,   5.57969995e-02,
          3.34439993e-01,  -1.80250004e-01,  -3.47400010e-02,
          2.83230007e-01,  -9.53010023e-02,   2.11429998e-01,
         -7.61490017e-02,   1.50690004e-01,  -1.74410000e-01,
         -7.47680012e-03,  -7.82869980e-02,  -1.27509996e-01,
          2.25449994e-01,   3.51010002e-02,  -6.10149980e-01,
         -2.68119991e-01,   6.16319999e-02,  -3.05029988e-01,
         -1.34049997e-01,  -4.42710012e-01,  -1.77200004e-01,
          1.76630005e-01,  -3.12099993e-01,  -2.57220000e-01,
         -2.48579998e-02,   7.25039989e-02,  -7.97590017e-02,
         -1.92139998e-01,   5.96019983e-01,   1.28800005e-01,
         -7.46290013e-02,  -1.58120006e-01,   3.63940001e-01,
          2.30550006e-01,  -4.21750009e-01,  -9.06509981e-02,
         -3.00850004e-01,   1.79399997e-01,  -2.97859997e-01,
         -1.06420003e-01,   4.72389996e-01,  -1.38370007e-01,
         -1.01609997e-01,   8.01339969e-02,   4.07150015e-02,
         -3.69760007e-01,  -3.70660014e-02,   1.04359999e-01,
          1.79040000e-01],
       [  5.40710017e-02,   1.11100003e-01,  -1.45569995e-01,
         -2.42940001e-02,   3.81099999e-01,  -1.43889993e-01,
         -1.79979995e-01,  -3.10790002e-01,  -7.96900038e-03,
          2.65380001e+00,  -1.27719998e-01,   2.38850005e-02,
          7.12840036e-02,  -1.42639995e-01,   1.09389998e-01,
         -1.06670000e-01,  -3.81780006e-02,   1.18529999e+00,
          5.25589995e-02,  -1.71810001e-01,  -1.86289996e-01,
         -1.65330004e-02,  -8.40080008e-02,   1.45420000e-01,
          1.60589993e-01,  -6.91630021e-02,  -7.68119991e-02,
         -2.06579998e-01,   1.60249993e-01,   2.14049995e-01,
          5.92090003e-02,   4.78909999e-01,   8.33740011e-02,
          1.99939996e-01,   9.62250009e-02,  -1.00330003e-01,
          4.25769985e-02,  -9.35870036e-02,  -1.33890003e-01,
         -3.27039987e-01,   2.36499999e-02,   3.40640008e-01,
         -7.59759992e-02,  -1.01499997e-01,   1.24310002e-01,
         -5.59540018e-02,  -2.52840012e-01,  -1.85199995e-02,
          4.69119996e-02,  -8.47740024e-02,  -1.58840001e-01,
          2.37509996e-01,   7.61089996e-02,   7.17530027e-02,
          3.14049982e-02,   3.26559991e-02,   1.12709999e-01,
          2.78389990e-01,   3.52329999e-01,  -1.08439997e-01,
          7.01830015e-02,  -4.68910001e-02,  -1.88250005e-01,
          4.05180007e-01,   2.11799994e-01,  -1.43759996e-01,
         -4.80750017e-03,   1.38769999e-01,  -9.15210024e-02,
          2.51940012e-01,   1.79979995e-01,  -1.58999994e-01,
          1.47530004e-01,   1.18660003e-01,  -1.54469997e-01,
          1.09690003e-01,   5.79660013e-02,  -2.58619994e-01,
         -2.37639993e-02,   1.90640002e-01,  -3.43649983e-02,
          9.08799991e-02,  -2.90160000e-01,  -1.30030006e-01,
          2.86660008e-02,  -2.06230000e-01,  -2.85860002e-01,
         -2.29340002e-01,   1.53819993e-01,  -2.03730002e-01,
         -2.53500015e-01,   2.07029998e-01,  -8.60000029e-02,
         -8.44089985e-02,  -1.29040003e-01,   5.94369993e-02,
          8.51750001e-02,  -4.17740010e-02,   8.60700011e-02,
          7.82589987e-02],
       [ -2.91300006e-02,  -1.52989998e-01,   7.37699986e-01,
          1.23810001e-01,   7.53529966e-02,  -5.48210025e-01,
         -2.86799997e-01,  -4.00489986e-01,  -2.24610008e-02,
          1.09679997e+00,  -5.50310016e-01,  -4.02750000e-02,
          7.86580026e-01,  -3.43159996e-02,   2.01429993e-01,
         -3.19319993e-01,  -7.49930024e-01,   1.06040001e+00,
          3.85280013e-01,  -1.10100001e-01,   1.25440001e-01,
          3.97709996e-01,  -4.50349987e-01,  -1.37869999e-01,
          3.46359998e-01,  -2.17920005e-01,  -2.21599996e-01,
         -2.67529994e-01,  -7.48199999e-01,  -6.40890002e-02,
          1.69840008e-02,  -5.38230002e-01,   9.31750014e-02,
          4.50679988e-01,  -1.69719994e-01,  -1.70690000e-01,
          4.03360009e-01,  -4.86820012e-01,   2.00289994e-01,
          9.72639993e-02,  -2.96240002e-01,   8.76160026e-01,
          1.53449997e-02,  -6.04390025e-01,   5.52349985e-01,
         -1.20439999e-01,   2.56650001e-01,  -1.10550001e-01,
         -3.71060014e-01,   9.64860022e-02,   1.56389996e-01,
          6.02020025e-01,   4.12550010e-02,  -6.96389973e-02,
          1.25190005e-01,   9.21360031e-02,   1.84919998e-01,
         -7.63119981e-02,   7.02779964e-02,   4.12399992e-02,
          1.41660003e-02,  -2.79309992e-02,  -7.89560005e-02,
         -1.38319999e-01,  -3.62630010e-01,  -1.73889995e-02,
          1.62430003e-01,   3.83130014e-01,   2.36460000e-01,
          3.69349986e-01,  -6.75029993e-01,   3.32300007e-01,
         -4.22430009e-01,  -3.35220009e-01,   1.50879994e-01,
          2.00020000e-01,   5.75739980e-01,  -4.21869993e-01,
          1.37989998e-01,   3.77519995e-01,   8.12970027e-02,
          4.30990010e-01,   4.08219993e-01,   8.87599960e-03,
          2.73759991e-01,  -7.77720008e-03,   6.57100022e-01,
          6.44659996e-01,  -3.80160004e-01,  -2.27239996e-01,
          2.48699993e-01,  -2.06330001e-01,   1.25920000e-02,
         -1.82589993e-01,   3.50809991e-01,  -4.61959988e-01,
          5.15730008e-02,  -1.64570004e-01,  -3.00960004e-01,
          1.01379998e-01],
       [ -8.68640020e-02,   1.91609994e-01,   1.09150000e-01,
         -3.43210012e-01,   2.03679994e-01,  -2.47769997e-01,
          4.60460007e-01,  -3.65700006e-01,  -1.98039994e-01,
          1.73790002e+00,  -4.35070008e-01,   9.61349979e-02,
          1.56010002e-01,   2.39030004e-01,  -4.19310004e-01,
         -9.51310024e-02,   4.43420000e-02,   1.23920000e+00,
          1.11570004e-02,  -2.25219995e-01,   3.84110004e-01,
         -1.16060004e-01,  -3.90359983e-02,   3.61060016e-02,
         -5.26760006e-04,  -1.21540003e-01,  -5.68839982e-02,
          4.14249986e-01,   3.82479995e-01,   2.35900000e-01,
         -8.55500028e-02,   8.51199999e-02,  -3.79760005e-02,
         -1.61090001e-01,   4.62740004e-01,   4.56809998e-01,
          1.50989994e-01,   1.15510002e-01,  -5.93560003e-03,
         -1.49599999e-01,   1.15900002e-01,  -1.14139996e-01,
         -1.92619994e-01,  -2.57660002e-02,   1.68489993e-01,
          4.73800004e-02,  -4.74830002e-01,  -1.60710007e-01,
         -9.62430015e-02,   1.81920007e-01,   1.49540007e-01,
          1.21299997e-01,   9.35969991e-04,  -5.73629975e-01,
         -1.78800002e-01,  -1.44850001e-01,   1.11579999e-01,
         -1.83860004e-01,   3.40299994e-01,   2.17950001e-01,
         -2.64899999e-01,  -1.16650000e-01,   6.43589973e-01,
          9.53160040e-03,   5.43700010e-02,  -2.70080000e-01,
         -4.25550014e-01,   1.87640004e-02,  -3.04060012e-01,
         -3.53909992e-02,   1.68899998e-01,  -9.61219966e-02,
          4.85760003e-01,   2.26359993e-01,   8.67540017e-02,
          3.25210005e-01,   1.01999998e-01,  -2.13860005e-01,
          1.63530007e-01,   5.70400000e-01,  -4.88339990e-01,
         -2.96689998e-02,  -1.25320002e-01,   1.57839999e-01,
         -1.63489997e-01,   1.07620001e-01,   6.45250022e-01,
         -8.36459994e-01,   1.35000005e-01,   2.16319993e-01,
         -3.08219999e-01,  -1.56729996e-01,   2.70789992e-02,
         -4.64430004e-02,  -4.03910019e-02,  -3.12559992e-01,
         -4.49640006e-01,  -4.75120008e-01,   4.75969985e-02,
         -1.27849996e-01]], dtype=float32),
       array([[-0.038548  ,  0.54251999, -0.21843   , ..., -0.38580999,
        -0.029534  ,  0.14425001],
       [-0.084961  ,  0.50199997,  0.0023823 , ..., -0.037066  ,
         0.10436   ,  0.17904   ],
       [ 0.27204001, -0.06203   , -0.1884    , ..., -0.088243  ,
         0.30318001,  0.087747  ],
       ..., 
       [-0.43731001, -0.14038999,  0.42151001, ..., -0.005359  ,
        -0.25985   ,  0.46535999],
       [-0.31110999, -0.044779  ,  0.0067328 , ...,  0.30699   ,
        -0.036171  ,  0.072974  ],
       [-0.086864  ,  0.19160999,  0.10915   , ..., -0.47512001,
         0.047597  , -0.12785   ]], dtype=float32),
       array([[ -3.85480002e-02,   5.42519987e-01,  -2.18429998e-01,
         -1.88549995e-01,   7.29999989e-02,   1.31799996e-01,
         -1.04020000e-01,   1.72309995e-01,  -5.15870005e-02,
          2.86459994e+00,  -2.51309991e-01,  -1.91459998e-01,
          7.99869969e-02,   7.28920028e-02,  -1.32090002e-01,
         -2.29709998e-01,  -1.72680005e-01,   8.35070014e-01,
         -3.84869993e-01,  -3.24919999e-01,   4.66800004e-01,
         -1.56780005e-01,   1.07069999e-01,  -1.24789998e-01,
         -1.60300002e-01,  -5.21539990e-03,   1.51660005e-02,
          1.65079996e-01,   9.80250016e-02,  -9.18980017e-02,
          2.45520001e-04,   4.42539990e-01,   1.60459995e-01,
          1.22149996e-01,   1.25939995e-01,   3.19990009e-01,
          2.20449999e-01,   1.68699995e-01,  -3.89270008e-01,
         -1.73470005e-01,  -1.31579995e-01,   7.98169971e-02,
         -5.80530018e-02,  -7.22350031e-02,   2.80330002e-01,
          6.10799994e-03,  -3.92890006e-01,   6.17439975e-04,
         -3.33629996e-02,   7.58850016e-03,  -9.36639979e-02,
          1.89319998e-01,  -2.25419998e-01,  -1.80910006e-02,
          2.95459986e-01,  -1.51629999e-01,  -1.55939996e-01,
         -2.19390005e-01,   8.83169994e-02,  -6.54719993e-02,
         -6.29500002e-02,  -1.99890003e-01,  -4.94540017e-03,
          2.95740008e-01,   2.73330003e-01,  -3.62129986e-01,
         -4.05099988e-02,   2.20449999e-01,   8.47209990e-02,
          6.27639983e-03,   1.69139996e-01,  -2.00430006e-01,
          5.16470015e-01,  -1.19050004e-01,   7.86669999e-02,
          2.68339992e-01,   6.69509992e-02,  -2.51179993e-01,
         -2.41449997e-01,   4.81339991e-01,   1.54479995e-01,
          1.15379997e-01,  -9.82709974e-02,  -6.84430003e-02,
          1.66710004e-01,  -4.16940004e-01,  -2.25419998e-01,
         -8.74610007e-01,   3.08230013e-01,   8.99629965e-02,
         -3.68919998e-01,  -1.73769996e-01,  -4.17360008e-01,
          2.62569994e-01,   3.59600008e-01,   1.33239999e-01,
          1.28410002e-02,  -3.85809988e-01,  -2.95340009e-02,
          1.44250005e-01],
       [ -8.49609971e-02,   5.01999974e-01,   2.38230010e-03,
         -1.67549998e-01,   3.07209998e-01,  -2.37619996e-01,
          1.60689995e-01,  -3.67859989e-01,  -5.83470017e-02,
          2.49900007e+00,  -2.36469996e-03,   1.07319998e-02,
         -3.04219991e-01,   8.45789984e-02,  -4.02989984e-02,
         -4.15619999e-01,  -2.44939998e-02,   1.46910000e+00,
         -5.29320017e-02,  -7.44130015e-02,  -3.92439991e-01,
         -3.25349987e-01,  -2.23330006e-01,   5.68229984e-03,
          3.56750011e-01,   1.94450006e-01,   5.67619987e-02,
         -4.55019996e-02,  -2.81049997e-01,  -5.88960014e-02,
         -9.86260027e-02,   9.21770036e-02,   3.31719995e-01,
         -3.99670005e-02,  -1.17660001e-01,   4.83729988e-02,
         -6.22409992e-02,  -1.04130000e-01,   9.92630026e-04,
         -4.89250004e-01,   3.47860008e-01,   3.27239990e-01,
          1.38820007e-01,  -1.99169993e-01,   1.29950002e-01,
          6.05489984e-02,  -2.37140000e-01,  -5.12950003e-01,
         -3.73959988e-01,   1.29020005e-01,   5.57969995e-02,
          3.34439993e-01,  -1.80250004e-01,  -3.47400010e-02,
          2.83230007e-01,  -9.53010023e-02,   2.11429998e-01,
         -7.61490017e-02,   1.50690004e-01,  -1.74410000e-01,
         -7.47680012e-03,  -7.82869980e-02,  -1.27509996e-01,
          2.25449994e-01,   3.51010002e-02,  -6.10149980e-01,
         -2.68119991e-01,   6.16319999e-02,  -3.05029988e-01,
         -1.34049997e-01,  -4.42710012e-01,  -1.77200004e-01,
          1.76630005e-01,  -3.12099993e-01,  -2.57220000e-01,
         -2.48579998e-02,   7.25039989e-02,  -7.97590017e-02,
         -1.92139998e-01,   5.96019983e-01,   1.28800005e-01,
         -7.46290013e-02,  -1.58120006e-01,   3.63940001e-01,
          2.30550006e-01,  -4.21750009e-01,  -9.06509981e-02,
         -3.00850004e-01,   1.79399997e-01,  -2.97859997e-01,
         -1.06420003e-01,   4.72389996e-01,  -1.38370007e-01,
         -1.01609997e-01,   8.01339969e-02,   4.07150015e-02,
         -3.69760007e-01,  -3.70660014e-02,   1.04359999e-01,
          1.79040000e-01],
       [ -1.84169993e-01,   5.51149994e-02,  -3.69529992e-01,
         -2.08949998e-01,   2.56720006e-01,   3.01420003e-01,
          1.62990004e-01,  -1.64370000e-01,  -7.02679977e-02,
          2.16380000e+00,  -2.65960008e-01,  -5.39130010e-02,
          4.81840014e-01,  -4.23640013e-02,  -3.80939990e-01,
          5.30319996e-02,   6.45349994e-02,   7.16679990e-01,
         -4.60260004e-01,  -5.72770014e-02,   7.41859972e-02,
          1.25790000e-01,  -1.88989997e-01,   1.86289998e-03,
         -2.29739994e-01,  -7.91509971e-02,  -6.16800003e-02,
         -2.95690000e-01,   3.95119995e-01,  -2.78979987e-01,
          1.79690003e-01,   3.21170002e-01,  -1.27489999e-01,
          4.81799990e-02,   2.32800007e-01,  -2.68130004e-01,
         -7.70540014e-02,   1.46990001e-01,  -2.71149993e-01,
          9.77350026e-02,  -1.76330000e-01,   2.92490005e-01,
         -2.01900005e-01,  -5.04230009e-03,   8.96809995e-02,
          2.62979995e-02,  -4.05790001e-01,  -2.38460004e-01,
         -8.90780017e-02,   6.78009987e-02,  -3.48470002e-01,
          1.95350006e-01,  -1.40560001e-01,   3.56579982e-02,
          5.83989993e-02,   8.71259999e-03,  -2.65359998e-01,
         -3.17880005e-01,  -7.53000006e-03,  -4.76210006e-02,
         -4.53200005e-02,  -5.04060015e-02,  -1.52730003e-01,
          1.53449997e-01,   1.06519997e-01,  -3.12390000e-01,
         -7.27680027e-02,   1.78140000e-01,   6.71949983e-03,
          1.67579994e-01,   1.00979999e-01,  -1.71670001e-02,
          3.08860004e-01,   1.38119996e-01,  -1.64940000e-01,
          1.90549999e-01,   4.05309983e-02,  -7.69170001e-02,
          7.96949957e-03,   7.93910027e-02,   5.87599985e-02,
         -2.83049997e-02,  -4.39249985e-02,  -3.18120003e-01,
          1.58710003e-01,  -3.04500014e-01,   1.12360001e-01,
         -1.07989997e-01,   1.23530000e-01,   1.59029998e-02,
         -2.62550004e-02,   9.91180018e-02,   3.85789983e-02,
          2.64290005e-01,   3.73979986e-01,  -5.87330014e-02,
          2.76419997e-01,  -1.05070002e-01,  -3.59629989e-02,
         -2.80809999e-01],
       [  3.19240004e-01,   6.31600022e-02,  -2.78580010e-01,
          2.61200011e-01,   7.92480037e-02,  -2.14619994e-01,
         -1.04950003e-01,   1.54949993e-01,  -3.35300006e-02,
          2.48340011e+00,  -5.09039998e-01,   8.74899998e-02,
          2.14259997e-01,   2.21509993e-01,  -2.52339989e-01,
         -9.75439996e-02,  -1.92699999e-01,   1.36059999e+00,
         -1.15920000e-01,  -1.03830002e-01,   2.19290003e-01,
          1.19970001e-01,  -1.10629998e-01,   1.42120004e-01,
         -1.66429996e-01,   2.18150005e-01,   4.20860015e-03,
         -7.00120032e-02,  -2.35320002e-01,  -2.65179992e-01,
          3.12479995e-02,   1.66690007e-01,  -8.97770002e-02,
          2.00590000e-01,   3.16139996e-01,  -5.58300018e-01,
          7.57350028e-02,   2.76349992e-01,   1.27409995e-01,
         -1.81850001e-01,  -1.27220005e-01,   2.46859994e-02,
         -7.72330016e-02,  -4.89980012e-01,   2.03549992e-02,
          3.91640002e-03,   1.21500000e-01,   8.97229984e-02,
         -7.89749995e-02,   8.14429969e-02,  -9.90869999e-02,
         -5.56209981e-02,   1.07369997e-01,  -4.40419978e-03,
          4.84959990e-01,   1.17169999e-01,  -1.73289999e-02,
          1.08999997e-01,  -3.55580002e-01,   5.10840006e-02,
          1.57140002e-01,   1.79609999e-01,  -2.97109991e-01,
          3.36450003e-02,  -2.57920008e-02,  -1.39309997e-02,
         -2.30000004e-01,  -4.03059982e-02,   2.22819999e-01,
         -1.35439998e-02,   1.15540000e-02,   3.91099989e-01,
          2.65329987e-01,  -3.10119987e-01,   4.05389994e-01,
         -4.29750010e-02,   2.08110008e-02,  -3.30330014e-01,
          1.95730001e-01,  -3.79579999e-02,   1.02739997e-01,
         -1.35809998e-03,  -4.45050001e-01,   7.78860003e-02,
          8.51100013e-02,  -2.02849999e-01,  -1.94810003e-01,
          5.69330007e-02,   5.31050026e-01,   3.41540016e-02,
         -5.69959998e-01,  -1.84689999e-01,   9.34029967e-02,
          2.80440003e-01,  -2.33490005e-01,   1.09379999e-01,
         -1.42879998e-02,  -2.73999989e-01,   3.41960005e-02,
         -9.84790027e-02],
       [  3.56700011e-02,   1.85599998e-01,  -3.05519998e-01,
         -2.51199991e-01,  -2.24189993e-04,  -7.31739998e-02,
          1.32200003e-01,   1.63519997e-02,  -3.41459997e-02,
          2.77419996e+00,  -6.77910000e-02,  -6.82319999e-02,
          4.20379996e-01,  -1.62430003e-01,  -3.19739997e-01,
         -3.38930003e-02,  -3.80869992e-02,   9.30549979e-01,
         -5.36260009e-01,   9.52339992e-02,  -5.37200011e-02,
         -2.39480004e-01,   1.52759999e-01,  -1.71739999e-02,
         -1.57989994e-01,   4.44849990e-02,  -3.49970013e-01,
         -2.36240000e-01,   2.76169986e-01,   3.48140001e-02,
         -4.43699993e-02,   2.15990007e-01,  -4.60020006e-02,
          1.22599997e-01,  -1.30390003e-02,   6.79529980e-02,
          4.99430001e-02,  -9.86519977e-02,  -2.87310004e-01,
         -1.95649996e-01,  -2.56339997e-01,   7.76060000e-02,
          1.04130000e-01,   1.21679999e-01,  -5.15320003e-02,
          7.22220019e-02,  -3.85670006e-01,  -1.68909997e-01,
          2.52389997e-01,   1.22180000e-01,  -4.29439992e-01,
         -1.22089997e-01,   6.01550005e-02,  -5.72599992e-02,
          4.16130006e-01,  -5.42609990e-02,  -2.48830006e-01,
         -1.29290000e-01,   1.78519997e-03,   4.42010015e-02,
         -7.49820024e-02,  -1.15110002e-01,  -1.44140005e-01,
          6.01159990e-01,   9.13949981e-02,   2.77630001e-01,
          2.75260001e-01,   6.13510013e-02,   2.76419997e-01,
          1.41230002e-01,   3.17680001e-01,   4.43419993e-01,
          4.27650005e-01,   1.03189997e-01,   3.38169992e-01,
          7.12070009e-03,   1.35120004e-01,  -2.19019994e-01,
         -1.14979997e-01,   3.67590010e-01,  -1.15110002e-01,
          1.01620004e-01,  -4.61019993e-01,  -2.34840006e-01,
          8.17179978e-02,  -3.45560014e-01,  -2.66669989e-01,
         -2.97380000e-01,   5.34730017e-01,  -1.03560001e-01,
          2.99919993e-02,  -1.99819997e-01,  -1.88350007e-02,
          3.15519989e-01,   3.74920011e-01,   2.29069993e-01,
          3.27549994e-01,   1.89150006e-01,  -1.23930000e-01,
          2.20180005e-02],
       .....
       [ -8.68640020e-02,   1.91609994e-01,   1.09150000e-01,
         -3.43210012e-01,   2.03679994e-01,  -2.47769997e-01,
          4.60460007e-01,  -3.65700006e-01,  -1.98039994e-01,
          1.73790002e+00,  -4.35070008e-01,   9.61349979e-02,
          1.56010002e-01,   2.39030004e-01,  -4.19310004e-01,
         -9.51310024e-02,   4.43420000e-02,   1.23920000e+00,
          1.11570004e-02,  -2.25219995e-01,   3.84110004e-01,
         -1.16060004e-01,  -3.90359983e-02,   3.61060016e-02,
         -5.26760006e-04,  -1.21540003e-01,  -5.68839982e-02,
          4.14249986e-01,   3.82479995e-01,   2.35900000e-01,
         -8.55500028e-02,   8.51199999e-02,  -3.79760005e-02,
         -1.61090001e-01,   4.62740004e-01,   4.56809998e-01,
          1.50989994e-01,   1.15510002e-01,  -5.93560003e-03,
         -1.49599999e-01,   1.15900002e-01,  -1.14139996e-01,
         -1.92619994e-01,  -2.57660002e-02,   1.68489993e-01,
          4.73800004e-02,  -4.74830002e-01,  -1.60710007e-01,
         -9.62430015e-02,   1.81920007e-01,   1.49540007e-01,
          1.21299997e-01,   9.35969991e-04,  -5.73629975e-01,
         -1.78800002e-01,  -1.44850001e-01,   1.11579999e-01,
         -1.83860004e-01,   3.40299994e-01,   2.17950001e-01,
         -2.64899999e-01,  -1.16650000e-01,   6.43589973e-01,
          9.53160040e-03,   5.43700010e-02,  -2.70080000e-01,
         -4.25550014e-01,   1.87640004e-02,  -3.04060012e-01,
         -3.53909992e-02,   1.68899998e-01,  -9.61219966e-02,
          4.85760003e-01,   2.26359993e-01,   8.67540017e-02,
          3.25210005e-01,   1.01999998e-01,  -2.13860005e-01,
          1.63530007e-01,   5.70400000e-01,  -4.88339990e-01,
         -2.96689998e-02,  -1.25320002e-01,   1.57839999e-01,
         -1.63489997e-01,   1.07620001e-01,   6.45250022e-01,
         -8.36459994e-01,   1.35000005e-01,   2.16319993e-01,
         -3.08219999e-01,  -1.56729996e-01,   2.70789992e-02,
         -4.64430004e-02,  -4.03910019e-02,  -3.12559992e-01,
         -4.49640006e-01,  -4.75120008e-01,   4.75969985e-02,
         -1.27849996e-01]], dtype=float32)], dtype=object)

基本上,它是一个数组列表的数组(传递给矩阵的pandas系列的行)。形状输出为:

(404290,)

为什么不能检测到我想要一个三维数组呢?

编辑:改变了一些东西,因为我是个白痴,但在这里有同样的问题。

Edit2:这就是我如何创建数组

train['question1_vector'] = train['question1_nlp'].apply(lambda x: np.array([k.vector[:100] for k in x]))

基本上,我会从每个句子的句子中提取所有单词向量(最多100个窗口)。

然后我打电话给

train['question1_vector'].values

尝试获取值。

形状应该像

(404290, len_of_sentence, 100)

1 个答案:

答案 0 :(得分:0)

我们假设你有这样的数据:

a = pd.Series(np.arange(1,3))
b = a.apply(lambda n: n * np.arange(3*4).reshape(4,-1))

b.values现在是:

[ array([[ 0,  1,  2],
       [ 3,  4,  5],
       [ 6,  7,  8],
       [ 9, 10, 11]])
 array([[ 0,  2,  4],
       [ 6,  8, 10],
       [12, 14, 16],
       [18, 20, 22]])]

你想"堆叠"这两个2D阵列可以制作单个3D阵列。例如,11应该在22的顶部,并且与那些相邻,10应该在20之上。

使用np.stack(b, 0)

[ array([[ 0,  1,  2],
       [ 3,  4,  5],
       [ 6,  7,  8],
       [ 9, 10, 11]])
 array([[ 0,  2,  4],
       [ 6,  8, 10],
       [12, 14, 16],
       [18, 20, 22]])]