Why is python only outputting 6 numbers seperated by '…', when the expectation is output of 10,000 numbers?
本问题已经有最佳答案,请猛点这里访问。
在全部的问题:(一)numpy Generate阵列(10000个随机数(称为X)和可变的create a储方程Y=5公尺?3 + 15 </P >
1 2 3 4 5 6 7 8 9 10 | 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)) |
[ 4528679冰的输出4547733 119675…………………2215797 1247 1703543 ]。 什么是理性的诠释,包括完整的10000个随机数在阵列?和什么是"……"signify吗? </P >
这只是对数组的麻木总结,所以不会有1000个数字打印到终端。您可以通过使用
1 2 3 | threshold : int, optional Total number of array elements which trigger summarization rather than full repr (default 1000). |
演示:
1 2 3 4 5 6 7 8 9 10 11 12 | >>> 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] |