为什么python只输出以';分隔的6个数字';,当期望输出10000个数字时?

为什么python只输出以';分隔的6个数字';,当期望输出10000个数字时?,python,numpy,tensorflow,Python,Numpy,Tensorflow,完整的问题:生成一个包含10000个随机数(称为x)的NumPy数组,并创建一个存储公式y=5x^2的变量−3x+15 import numpy as np data = np.random.randint(1000, size=10000) x = tf.constant(data, name='x') y = tf.Variable(5 * (x**2) - (3 * x) + 15) model = tf.global_variables_initializer() with tf.

完整的问题:生成一个包含10000个随机数(称为x)的NumPy数组,并创建一个存储公式y=5x^2的变量−3x+15

import numpy as np 
data = np.random.randint(1000, size=10000)
x = tf.constant(data, name='x')
y = tf.Variable(5 * (x**2) - (3 * x) + 15)

model = tf.global_variables_initializer()

with tf.Session() as session:
    session.run(model)
    print(session.run(y))
输出为[45286794547733119675…221579712471703543]。
数组中不包含完整的10000个随机数的原因是什么?那么“…”代表什么呢

这只是简单地总结一下你的数组,所以你不会在终端上打印出1000个数字。通过使用
np的
threshold
参数,您可以控制启动的阈值。set\u printoptions

threshold : int, optional
    Total number of array elements which trigger summarization
    rather than full repr (default 1000).
演示:

>>> import numpy as np
>>> a = np.arange(100)
>>> np.set_printoptions(threshold=5)
>>> print(a)
[ 0  1  2 ... 97 98 99]
>>> np.set_printoptions(threshold=500)
>>> print(a)
[ 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
 96 97 98 99]