Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python np.split()和tf.nn.softmax的输出_Python_Arrays_Numpy_Tensorflow - Fatal编程技术网

Python np.split()和tf.nn.softmax的输出

Python np.split()和tf.nn.softmax的输出,python,arrays,numpy,tensorflow,Python,Arrays,Numpy,Tensorflow,我用Tensorflow做词性标注。我通过以下方式获得softmax层的输出(它使用tf.nn.softmax): pos_tags_confidences = sess.run( self.pos_tags_softmax_op, feed_dict=self.feed_dict(batch, is_test=True) ) POS标签有一个形状(580,21),看起来如下: [[ 2.84045556e-04 1.08584835e-07

我用Tensorflow做词性标注。我通过以下方式获得softmax层的输出(它使用tf.nn.softmax):

pos_tags_confidences = sess.run(
        self.pos_tags_softmax_op,
        feed_dict=self.feed_dict(batch, is_test=True)
    )
POS标签有一个形状(580,21),看起来如下:

[[  2.84045556e-04   1.08584835e-07   5.98690785e-05 ...,   
    7.19540509e-18
    9.11230517e-18   1.95343427e-21]
[  9.98795390e-01   4.86789819e-12   1.50688564e-07 ...,   
   8.64652642e-23
2.89635869e-14   1.35281987e-18]
[  1.54589606e-03   1.40889606e
我想在前面的数组中使用np.split(),并将其拆分为[550,30]

问题是我得到了以下结果:

  • 形状为(550,21)的数组
  • 空数组
  • 另一个具有形状的阵列(550,21)
而不是:

  • 形状为(550,21)的数组
  • 形状为(30,21)的数组
可能出了什么问题?请注意,我在我的项目的其他地方使用了相同的代码,效果很好

pos_tags_confidences = pos_tags_confidences.squeeze()
assert pos_tags_confidences.shape==(580, 21) 
split_arrays = np.split(pos_tags_confidences, [550], axis=0)